mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 19:41:07 +01:00
Remove the type field from semantics nodes that don't produce values of that type. (#3049)
For `Assign` and `ReturnExpression`, this field wasn't used for anything. For `StructTypeField`, we stored the type of the field here, and now store it as an argument of the node instead. --------- Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
This commit is contained in:
co-authored by
Jon Ross-Perkins
parent
ab709b4117
commit
0c33dead70
@@ -286,7 +286,8 @@ class SemanticsNode {
|
||||
using FactoryBase<Kind, ArgTypes...>::Get;
|
||||
};
|
||||
|
||||
// Provides Get along with a Make that assumes a non-changing type.
|
||||
// Provides Get along with a Make that assumes the node doesn't produce a
|
||||
// typed value.
|
||||
template <KindTemplateEnum Kind, typename... ArgTypes>
|
||||
class FactoryNoType : public FactoryBase<Kind, ArgTypes...> {
|
||||
public:
|
||||
@@ -306,9 +307,9 @@ class SemanticsNode {
|
||||
}
|
||||
};
|
||||
|
||||
using Assign = SemanticsNode::Factory<SemanticsNodeKind::Assign,
|
||||
SemanticsNodeId /*lhs_id*/,
|
||||
SemanticsNodeId /*rhs_id*/>;
|
||||
using Assign = SemanticsNode::FactoryNoType<SemanticsNodeKind::Assign,
|
||||
SemanticsNodeId /*lhs_id*/,
|
||||
SemanticsNodeId /*rhs_id*/>;
|
||||
|
||||
using BinaryOperatorAdd =
|
||||
SemanticsNode::Factory<SemanticsNodeKind::BinaryOperatorAdd,
|
||||
@@ -387,8 +388,8 @@ class SemanticsNode {
|
||||
|
||||
using Return = FactoryNoType<SemanticsNodeKind::Return>;
|
||||
|
||||
using ReturnExpression =
|
||||
Factory<SemanticsNodeKind::ReturnExpression, SemanticsNodeId /*expr_id*/>;
|
||||
using ReturnExpression = FactoryNoType<SemanticsNodeKind::ReturnExpression,
|
||||
SemanticsNodeId /*expr_id*/>;
|
||||
|
||||
using StringLiteral = Factory<SemanticsNodeKind::StringLiteral,
|
||||
SemanticsStringId /*string_id*/>;
|
||||
@@ -400,8 +401,9 @@ class SemanticsNode {
|
||||
using StructType =
|
||||
Factory<SemanticsNodeKind::StructType, SemanticsNodeBlockId /*refs_id*/>;
|
||||
|
||||
using StructTypeField = Factory<SemanticsNodeKind::StructTypeField,
|
||||
SemanticsStringId /*name_id*/>;
|
||||
using StructTypeField =
|
||||
FactoryNoType<SemanticsNodeKind::StructTypeField,
|
||||
SemanticsStringId /*name_id*/, SemanticsTypeId /*type_id*/>;
|
||||
|
||||
using StructValue =
|
||||
Factory<SemanticsNodeKind::StructValue, SemanticsNodeBlockId /*refs_id*/>;
|
||||
@@ -431,6 +433,8 @@ class SemanticsNode {
|
||||
|
||||
auto parse_node() const -> ParseTree::Node { return parse_node_; }
|
||||
auto kind() const -> SemanticsNodeKind { return kind_; }
|
||||
|
||||
// Gets the type of the value produced by evaluating this node.
|
||||
auto type_id() const -> SemanticsTypeId { return type_id_; }
|
||||
|
||||
auto Print(llvm::raw_ostream& out) const -> void;
|
||||
|
||||
Reference in New Issue
Block a user