mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-04 19:41:05 +01:00
Initial support for binding patterns in SemIR (#4221)
Introduces the `BindingPattern` and `SymbolicBindingPattern` insts, and a separate stack of pattern blocks that they are emitted into. The intent is to generate the corresponding pattern-matching insts (like `BindName`) from them in a separate pass, but that is deferred to future PRs. See [here](https://docs.google.com/document/d/1U_vQH17V893J9aF1LJXUnFYBNSs2MjKl4bJPaWCB2zo/edit?usp=sharing&resourcekey=0-w0xGYZ0An31Kpz-wvzSXwQ) for the design this is based on, but note that during review we have chosen to deviate from that design by putting the patterns in separate blocks, and omitting the "forward references" from a `BindingPattern` to its corresponding `BindName`. This in turn necessitates having separate inst kinds for symbolic and non-symbolic binding patterns. --------- Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
This commit is contained in:
co-authored by
Jon Ross-Perkins
parent
87678cc374
commit
dc32aa2690
@@ -35,6 +35,8 @@ auto HandleParseNode(Context& context, Parse::FunctionIntroducerId node_id)
|
||||
context.decl_name_stack().PushScopeAndStartName();
|
||||
// The function is potentially generic.
|
||||
StartGenericDecl(context);
|
||||
// Start a new pattern block for the signature.
|
||||
context.pattern_block_stack().Push();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -213,8 +215,6 @@ static auto BuildFunctionDecl(Context& context,
|
||||
Parse::AnyFunctionDeclId node_id,
|
||||
bool is_definition)
|
||||
-> std::pair<SemIR::FunctionId, SemIR::InstId> {
|
||||
auto decl_block_id = context.inst_block_stack().Pop();
|
||||
|
||||
auto return_storage_id = SemIR::InstId::Invalid;
|
||||
if (auto [return_node, maybe_return_storage_id] =
|
||||
context.node_stack().PopWithNodeIdIf<Parse::NodeKind::ReturnType>();
|
||||
@@ -260,6 +260,7 @@ static auto BuildFunctionDecl(Context& context,
|
||||
}
|
||||
|
||||
// Add the function declaration.
|
||||
auto decl_block_id = context.inst_block_stack().Pop();
|
||||
auto function_decl = SemIR::FunctionDecl{
|
||||
SemIR::TypeId::Invalid, SemIR::FunctionId::Invalid, decl_block_id};
|
||||
auto decl_id =
|
||||
|
||||
Reference in New Issue
Block a user