mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
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:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user