mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-02 22:02:51 +01:00
Switch types to a SemanticsTypeId. (#2854)
This switches types to using SemanticsTypeId instead of SemanticsNodeId, and lowering pre-builds its list of types. The empty tuple type is special-cased because we don't want to emit it unless it's in-use, but as the implicit return for functions, it's frequently used. Callables use invalid to indicate the implicit return, and that seems undesirable to change due to the size increase.
This commit is contained in:
@@ -28,7 +28,7 @@ auto SemanticsHandleStructFieldDesignator(SemanticsContext& context,
|
||||
auto SemanticsHandleStructFieldType(SemanticsContext& context,
|
||||
ParseTree::Node parse_node) -> bool {
|
||||
auto [type_node, type_id] = context.node_stack().PopForParseNodeAndNodeId();
|
||||
SemanticsNodeId cast_type_id = context.ExpressionAsType(type_node, type_id);
|
||||
SemanticsTypeId cast_type_id = context.ExpressionAsType(type_node, type_id);
|
||||
|
||||
auto [name_node, name_id] = context.node_stack().PopForParseNodeAndNameId(
|
||||
ParseNodeKind::DesignatedName);
|
||||
@@ -80,9 +80,7 @@ auto SemanticsHandleStructLiteral(SemanticsContext& context,
|
||||
auto refs = context.semantics().GetNodeBlock(refs_id);
|
||||
auto type_id =
|
||||
context.CanonicalizeType(context.AddNode(SemanticsNode::StructType::Make(
|
||||
parse_node,
|
||||
context.CanonicalizeType(SemanticsNodeId::BuiltinTypeType),
|
||||
type_block_id)));
|
||||
parse_node, SemanticsTypeId::TypeType, type_block_id)));
|
||||
|
||||
auto value_id = context.AddNode(
|
||||
SemanticsNode::StructValue::Make(parse_node, type_id, refs_id));
|
||||
@@ -117,8 +115,7 @@ auto SemanticsHandleStructTypeLiteral(SemanticsContext& context,
|
||||
<< "{} is handled by StructLiteral.";
|
||||
|
||||
auto type_id = context.AddNode(SemanticsNode::StructType::Make(
|
||||
parse_node, context.CanonicalizeType(SemanticsNodeId::BuiltinTypeType),
|
||||
refs_id));
|
||||
parse_node, SemanticsTypeId::TypeType, refs_id));
|
||||
context.node_stack().Push(parse_node, type_id);
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user