mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Parse tree for impl that is better for check stage (#3678)
Use two different nodes for "<type> followed by `as`" and "<type> omitted before `as`, use `self`", so it is easier to determine which case. Later the second case will push the type id for `self` onto the node stack, making the two paths more similar. --------- Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
This commit is contained in:
co-authored by
Jon Ross-Perkins
parent
efde1497c4
commit
03bf22e55e
@@ -32,20 +32,24 @@ auto HandleImplForall(Context& context, Parse::ImplForallId parse_node)
|
||||
return true;
|
||||
}
|
||||
|
||||
auto HandleImplAs(Context& /*context*/, Parse::ImplAsId /*parse_node*/)
|
||||
auto HandleTypeImplAs(Context& context, Parse::TypeImplAsId parse_node)
|
||||
-> bool {
|
||||
auto self_id = context.node_stack().PopExpr();
|
||||
context.node_stack().Push(parse_node, self_id);
|
||||
return true;
|
||||
}
|
||||
|
||||
auto HandleDefaultSelfImplAs(Context& /*context*/,
|
||||
Parse::DefaultSelfImplAsId /*parse_node*/)
|
||||
-> bool {
|
||||
// TODO: Determine self_id and push it onto node stack.
|
||||
return true;
|
||||
}
|
||||
|
||||
static auto BuildImplDecl(Context& context, Parse::AnyImplDeclId /*parse_node*/)
|
||||
-> SemIR::InstId {
|
||||
auto interface_id = context.node_stack().PopExpr();
|
||||
auto self_id = SemIR::InstId::Invalid;
|
||||
if (!context.node_stack().PeekIs<Parse::NodeKind::ImplForall>() &&
|
||||
!context.node_stack().PeekIs<Parse::NodeKind::ImplIntroducer>()) {
|
||||
self_id = context.node_stack().PopExpr();
|
||||
}
|
||||
|
||||
auto self_id = context.node_stack().PopIf<Parse::NodeKind::TypeImplAs>();
|
||||
auto params_id = context.node_stack().PopIf<Parse::NodeKind::ImplForall>();
|
||||
auto decl_block_id = context.inst_block_stack().Pop();
|
||||
context.node_stack()
|
||||
|
||||
Reference in New Issue
Block a user