mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 06:41:06 +01:00
true and false support, and lowering for bool type. (#2896)
This commit is contained in:
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user