mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Add typed nodes to SemIR. (#3280)
Replace `SemIR::Node::GetAsFoo` and `SemIR::Node::Foo::Make` with `SemIR::Foo` class that represents a particular kind of node, with named fields. Rename `SemIR::IntegerLiteral` and `SemIR::RealLiteral` to `IntegerValue` / `RealValue` to better reflect their purpose and avoid a name collision with the corresponding `SemIR` node kinds. Remove `NodeKind::Invalid` and the `SemIR::Node` default constructor entirely, as they were not used for anything.
This commit is contained in:
@@ -35,14 +35,14 @@ auto HandleArrayExpression(Context& context, Parse::Node parse_node) -> bool {
|
||||
.PopAndDiscardSoloParseNode<Parse::NodeKind::ArrayExpressionSemi>();
|
||||
auto element_type_node_id = context.node_stack().PopExpression();
|
||||
auto bound_node = context.semantics_ir().GetNode(bound_node_id);
|
||||
if (bound_node.kind() == SemIR::NodeKind::IntegerLiteral) {
|
||||
auto bound_value = context.semantics_ir().GetIntegerLiteral(
|
||||
bound_node.GetAsIntegerLiteral());
|
||||
if (auto literal = bound_node.TryAs<SemIR::IntegerLiteral>()) {
|
||||
const auto& bound_value =
|
||||
context.semantics_ir().GetInteger(literal->integer_id);
|
||||
// TODO: Produce an error if the array type is too large.
|
||||
if (bound_value.getActiveBits() <= 64) {
|
||||
context.AddNodeAndPush(
|
||||
parse_node,
|
||||
SemIR::Node::ArrayType::Make(
|
||||
SemIR::ArrayType(
|
||||
parse_node, SemIR::TypeId::TypeType, bound_node_id,
|
||||
ExpressionAsType(context, parse_node, element_type_node_id)));
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user