Add ExternDecl and ExternType for extern classes. (#3893)

This expands `extern` handling for most cases.
This commit is contained in:
Jon Ross-Perkins
2024-04-22 15:04:16 +00:00
committed by GitHub
parent 459c41ab3c
commit 5694dd152e
18 changed files with 332 additions and 308 deletions
+10
View File
@@ -206,6 +206,7 @@ static auto GetTypePrecedence(InstKind kind) -> int {
case BindSymbolicName::Kind:
case Builtin::Kind:
case ClassType::Kind:
case ExternType::Kind:
case FacetTypeAccess::Kind:
case FloatType::Kind:
case ImportRefLoaded::Kind:
@@ -246,6 +247,7 @@ static auto GetTypePrecedence(InstKind kind) -> int {
case ClassInit::Kind:
case Converted::Kind:
case Deref::Kind:
case ExternDecl::Kind:
case FieldDecl::Kind:
case FloatLiteral::Kind:
case FunctionDecl::Kind:
@@ -379,6 +381,11 @@ static auto StringifyTypeExprImpl(const SemIR::File& outer_sem_ir,
}
break;
}
case CARBON_KIND(ExternType inst): {
out << "extern ";
push_inst_id(sem_ir.types().GetInstId(inst.non_extern_type_id));
break;
}
case CARBON_KIND(FacetTypeAccess inst): {
// Print `T as type` as simply `T`.
push_inst_id(inst.facet_id);
@@ -521,6 +528,7 @@ static auto StringifyTypeExprImpl(const SemIR::File& outer_sem_ir,
case ClassInit::Kind:
case Converted::Kind:
case Deref::Kind:
case ExternDecl::Kind:
case FieldDecl::Kind:
case FloatLiteral::Kind:
case FunctionDecl::Kind:
@@ -640,6 +648,8 @@ auto GetExprCategory(const File& file, InstId inst_id) -> ExprCategory {
case ClassDecl::Kind:
case ClassType::Kind:
case ConstType::Kind:
case ExternDecl::Kind:
case ExternType::Kind:
case FacetTypeAccess::Kind:
case FloatLiteral::Kind:
case FloatType::Kind: