mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Add ExternDecl and ExternType for extern classes. (#3893)
This expands `extern` handling for most cases.
This commit is contained in:
@@ -409,6 +409,9 @@ class ImportRefResolver {
|
||||
case CARBON_KIND(SemIR::ConstType inst): {
|
||||
return TryResolveTypedInst(inst);
|
||||
}
|
||||
case CARBON_KIND(SemIR::ExternDecl inst): {
|
||||
return TryResolveTypedInst(inst);
|
||||
}
|
||||
case CARBON_KIND(SemIR::FieldDecl inst): {
|
||||
return TryResolveTypedInst(inst, inst_id);
|
||||
}
|
||||
@@ -669,6 +672,19 @@ class ImportRefResolver {
|
||||
SemIR::ConstType{SemIR::TypeId::TypeType, inner_type_id})};
|
||||
}
|
||||
|
||||
auto TryResolveTypedInst(SemIR::ExternDecl inst) -> ResolveResult {
|
||||
auto initial_work = work_stack_.size();
|
||||
CARBON_CHECK(inst.type_id == SemIR::TypeId::TypeType);
|
||||
auto decl_const_id = GetLocalConstantId(inst.decl_id);
|
||||
if (HasNewWork(initial_work)) {
|
||||
return ResolveResult::Retry();
|
||||
}
|
||||
auto extern_id = context_.AddInstInNoBlock(SemIR::LocIdAndInst::Untyped(
|
||||
AddImportIRInst(inst.decl_id),
|
||||
SemIR::ExternDecl{SemIR::TypeId::TypeType, decl_const_id.inst_id()}));
|
||||
return {context_.constant_values().Get(extern_id)};
|
||||
}
|
||||
|
||||
auto TryResolveTypedInst(SemIR::FieldDecl inst, SemIR::InstId import_inst_id)
|
||||
-> ResolveResult {
|
||||
auto initial_work = work_stack_.size();
|
||||
|
||||
Reference in New Issue
Block a user