mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
true and false support, and lowering for bool type. (#2896)
This commit is contained in:
@@ -68,6 +68,23 @@ struct SemanticsCrossReferenceIRId : public IndexBase {
|
||||
}
|
||||
};
|
||||
|
||||
// A boolean value.
|
||||
struct SemanticsBoolValue : public IndexBase {
|
||||
using IndexBase::IndexBase;
|
||||
auto Print(llvm::raw_ostream& out) const -> void {
|
||||
switch (index) {
|
||||
case 0:
|
||||
out << "false";
|
||||
break;
|
||||
case 1:
|
||||
out << "true";
|
||||
break;
|
||||
default:
|
||||
CARBON_FATAL() << "Invalid bool value " << index;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// The ID of an integer literal.
|
||||
struct SemanticsIntegerLiteralId : public IndexBase {
|
||||
using IndexBase::IndexBase;
|
||||
@@ -264,6 +281,9 @@ class SemanticsNode {
|
||||
|
||||
using BlockArg = Factory<SemanticsNodeKind::BlockArg>;
|
||||
|
||||
using BoolLiteral =
|
||||
Factory<SemanticsNodeKind::BoolLiteral, SemanticsBoolValue /*value*/>;
|
||||
|
||||
using Branch = FactoryNoType<SemanticsNodeKind::Branch,
|
||||
SemanticsNodeBlockId /*target_id*/>;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user