Assign a constant to ClassDecl/InterfaceDecl for name references. (#3722)

By adding a constant to ClassDecl/InterfaceDecl, we're able to remove
name reference special-casing. Use TryEvalInst on the Decl to generate
the Type. For ClassDecl, then use the generated constant for
self_type_id.
This commit is contained in:
Jon Ross-Perkins
2024-02-24 00:00:18 +00:00
committed by GitHub
parent 8e8eeb3243
commit 364ea5d3f2
109 changed files with 420 additions and 429 deletions
@@ -28,13 +28,13 @@ var p: Incomplete* = &a[0];
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace {.Incomplete = %Incomplete.decl, .a = %a, .p = %p} [template]
// CHECK:STDOUT: %Incomplete.decl = class_decl @Incomplete, ()
// CHECK:STDOUT: %Incomplete.ref.loc15: type = name_ref Incomplete, constants.%Incomplete [template = constants.%Incomplete]
// CHECK:STDOUT: %Incomplete.decl = class_decl @Incomplete, () [template = constants.%Incomplete]
// CHECK:STDOUT: %Incomplete.ref.loc15: type = name_ref Incomplete, %Incomplete.decl [template = constants.%Incomplete]
// CHECK:STDOUT: %.loc15_21: i32 = int_literal 1 [template = constants.%.1]
// CHECK:STDOUT: %.loc15_22: type = array_type %.loc15_21, Incomplete [template = constants.%.2]
// CHECK:STDOUT: %a.var: ref <error> = var a
// CHECK:STDOUT: %a: ref <error> = bind_name a, %a.var
// CHECK:STDOUT: %Incomplete.ref.loc17: type = name_ref Incomplete, constants.%Incomplete [template = constants.%Incomplete]
// CHECK:STDOUT: %Incomplete.ref.loc17: type = name_ref Incomplete, %Incomplete.decl [template = constants.%Incomplete]
// CHECK:STDOUT: %.loc17: type = ptr_type Incomplete [template = constants.%.3]
// CHECK:STDOUT: %p.var: ref Incomplete* = var p
// CHECK:STDOUT: %p: ref Incomplete* = bind_name p, %p.var