Basic support for generic bindings. (#3555)

This change adds a `BindSymbolicName` instruction for generic bindings,
paralleling the existing `BindName`. A mechanism is also added to allow
both kinds of binding to be accessed uniformly, for convenience in the
case where the two different kinds of binding are treated the same.

Generic bindings of type `type` are allowed to be used as types,
although no operations are provided for such types. For now lowering
treats these types as empty structs, which seems like a reasonable
lowering for non-monomorphized unconstrained types.
This commit is contained in:
Richard Smith
2024-01-05 03:39:45 +00:00
committed by GitHub
parent 0205645e7d
commit a6508fcf05
24 changed files with 321 additions and 33 deletions
+13
View File
@@ -134,6 +134,12 @@ class NodeStack {
return PopWithParseNode<SemIR::InstId>();
}
// Pops a pattern from the top of the stack and returns the parse_node and
// the ID.
auto PopPatternWithParseNode() -> std::pair<Parse::NodeId, SemIR::InstId> {
return PopWithParseNode<SemIR::InstId>();
}
// Pops a name from the top of the stack and returns the parse_node and
// the ID.
auto PopNameWithParseNode() -> std::pair<Parse::NodeId, SemIR::NameId> {
@@ -203,6 +209,12 @@ class NodeStack {
// Expressions map multiple Parse::NodeKinds to SemIR::InstId always.
auto PopExpr() -> SemIR::InstId { return PopExprWithParseNode().second; }
// Pops a pattern from the top of the stack and returns the ID.
// Patterns map multiple Parse::NodeKinds to SemIR::InstId always.
auto PopPattern() -> SemIR::InstId {
return PopPatternWithParseNode().second;
}
// Pops a name from the top of the stack and returns the ID.
auto PopName() -> SemIR::NameId { return PopNameWithParseNode().second; }
@@ -359,6 +371,7 @@ class NodeStack {
case Parse::NodeKind::BindingPattern:
case Parse::NodeKind::CallExpr:
case Parse::NodeKind::CallExprStart:
case Parse::NodeKind::GenericBindingPattern:
case Parse::NodeKind::IdentifierNameExpr:
case Parse::NodeKind::IfExprThen:
case Parse::NodeKind::IfExprElse: