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:
josh11b
2024-02-01 22:23:21 +00:00
committed by GitHub
co-authored by Jon Ross-Perkins
parent efde1497c4
commit 03bf22e55e
11 changed files with 88 additions and 56 deletions
+11 -7
View File
@@ -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()