Initial scaffolding for building a witness table for an impl. (#3743)

Add an instruction to hold the witness table, along with a corresponding
type to keep things simpler. Add `check/impl.{h,cpp}` to house the new
logic. No checking of impls against interfaces is performed yet.

---------

Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
This commit is contained in:
Richard Smith
2024-03-07 23:10:14 +00:00
committed by GitHub
co-authored by Jon Ross-Perkins
parent 2424ea16ea
commit abf23ae7fe
27 changed files with 216 additions and 29 deletions
+7 -3
View File
@@ -5,6 +5,7 @@
#include "toolchain/check/context.h"
#include "toolchain/check/convert.h"
#include "toolchain/check/decl_name_stack.h"
#include "toolchain/check/impl.h"
#include "toolchain/check/modifiers.h"
#include "toolchain/parse/typed_nodes.h"
#include "toolchain/sem_ir/ids.h"
@@ -270,11 +271,14 @@ auto HandleImplDefinition(Context& context,
Parse::ImplDefinitionId /*parse_node*/) -> bool {
auto impl_id =
context.node_stack().Pop<Parse::NodeKind::ImplDefinitionStart>();
if (!context.impls().Get(impl_id).is_defined()) {
context.impls().Get(impl_id).witness_id =
BuildImplWitness(context, impl_id);
}
context.inst_block_stack().Pop();
context.decl_name_stack().PopScope();
// The impl is now fully defined.
context.impls().Get(impl_id).defined = true;
return true;
}