true and false support, and lowering for bool type. (#2896)

This commit is contained in:
Richard Smith
2023-06-13 16:43:03 -07:00
committed by GitHub
parent 8e940d9724
commit aa40e2b8a9
15 changed files with 198 additions and 5 deletions
+11
View File
@@ -224,6 +224,17 @@ auto SemanticsHandleLiteral(SemanticsContext& context,
ParseTree::Node parse_node) -> bool {
auto token = context.parse_tree().node_token(parse_node);
switch (auto token_kind = context.tokens().GetKind(token)) {
case TokenKind::False:
case TokenKind::True: {
context.AddNodeAndPush(
parse_node,
SemanticsNode::BoolLiteral::Make(
parse_node,
context.CanonicalizeType(SemanticsNodeId::BuiltinBoolType),
token_kind == TokenKind::True ? SemanticsBoolValue(1)
: SemanticsBoolValue(0)));
break;
}
case TokenKind::IntegerLiteral: {
auto id = context.semantics_ir().AddIntegerLiteral(
context.tokens().GetIntegerLiteral(token));