Add a Field node for fields in a class. (#3332)

This replaces the use of `VarStorage` in this case.

Add an `UnboundFieldType` type as the type of a field, in cases where
it's referenced without an accompanying object.

Add a `BindName` node to describe the name binding performed for both
variables and fields so that we can handle them more uniformly.
This commit is contained in:
Richard Smith
2023-10-25 18:49:36 +00:00
committed by GitHub
parent 74c3c665fa
commit 7f2f4bec4f
107 changed files with 792 additions and 450 deletions
@@ -20,9 +20,10 @@ fn Run() {
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Run() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %x: ref i32 = var "x"
// CHECK:STDOUT: %x.var: ref i32 = var "x"
// CHECK:STDOUT: %x: ref i32 = bind_name "x", %x.var
// CHECK:STDOUT: %.1: type = ptr_type String
// CHECK:STDOUT: %.loc14: String = string_literal "hello"
// CHECK:STDOUT: assign %x, <error>
// CHECK:STDOUT: assign %x.var, <error>
// CHECK:STDOUT: return
// CHECK:STDOUT: }
@@ -26,9 +26,10 @@ fn Run() {
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Run() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %x: ref i32 = var "x"
// CHECK:STDOUT: %x.var: ref i32 = var "x"
// CHECK:STDOUT: %x: ref i32 = bind_name "x", %x.var
// CHECK:STDOUT: %Foo.ref: <function> = name_reference "Foo", file.%Foo
// CHECK:STDOUT: %.loc13: init f64 = call %Foo.ref()
// CHECK:STDOUT: assign %x, <error>
// CHECK:STDOUT: assign %x.var, <error>
// CHECK:STDOUT: return
// CHECK:STDOUT: }
+3 -2
View File
@@ -25,10 +25,11 @@ fn Main() {
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Main() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %b: ref i32 = var "b"
// CHECK:STDOUT: %b.var: ref i32 = var "b"
// CHECK:STDOUT: %b: ref i32 = bind_name "b", %b.var
// CHECK:STDOUT: %Echo.ref: <function> = name_reference "Echo", file.%Echo
// CHECK:STDOUT: %.loc12_21: i32 = int_literal 1
// CHECK:STDOUT: %.loc12_20: init i32 = call %Echo.ref(%.loc12_21)
// CHECK:STDOUT: assign %b, %.loc12_20
// CHECK:STDOUT: assign %b.var, %.loc12_20
// CHECK:STDOUT: return
// CHECK:STDOUT: }
@@ -25,9 +25,10 @@ fn Main() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %.loc11_11.1: type = tuple_type ()
// CHECK:STDOUT: %.loc11_11.2: () = tuple_literal ()
// CHECK:STDOUT: %b: ref () = var "b"
// CHECK:STDOUT: %b.var: ref () = var "b"
// CHECK:STDOUT: %b: ref () = bind_name "b", %b.var
// CHECK:STDOUT: %MakeImplicitEmptyTuple.ref: <function> = name_reference "MakeImplicitEmptyTuple", file.%MakeImplicitEmptyTuple
// CHECK:STDOUT: %.loc11_37: init () = call %MakeImplicitEmptyTuple.ref()
// CHECK:STDOUT: assign %b, %.loc11_37
// CHECK:STDOUT: assign %b.var, %.loc11_37
// CHECK:STDOUT: return
// CHECK:STDOUT: }