mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Initialize vptrs to point to vtables (#5244)
Adds a mapping to keep track of vtable LLVM IR decls/defs for use. Adds the vtable_id to the vtable_ptr initialize instruction for lookup. Adds emission of vtable declarations for use outside the file that defines the vtable. (this isn't done lazily, it's done for any imported class - it could be done lazily & maybe eventually has to be lazy to handle generics)
This commit is contained in:
@@ -324,12 +324,8 @@ auto HandleInst(FunctionContext& context, SemIR::InstId inst_id,
|
||||
}
|
||||
|
||||
auto HandleInst(FunctionContext& context, SemIR::InstId inst_id,
|
||||
SemIR::VtablePtr /*inst*/) -> void {
|
||||
// TODO: Initialize the virtual pointer to actually point to a virtual
|
||||
// function table.
|
||||
context.SetLocal(inst_id,
|
||||
llvm::ConstantPointerNull::get(
|
||||
llvm::PointerType::get(context.llvm_context(), 0)));
|
||||
SemIR::VtablePtr inst) -> void {
|
||||
context.SetLocal(inst_id, context.GetValue(inst.vtable_id));
|
||||
}
|
||||
|
||||
} // namespace Carbon::Lower
|
||||
|
||||
Reference in New Issue
Block a user