mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-16 09:18:12 +00:00
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.
36 lines
1.1 KiB
Plaintext
36 lines
1.1 KiB
Plaintext
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
// Exceptions. See /LICENSE for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
// AUTOUPDATE
|
|
|
|
fn Echo(a: i32) -> i32 {
|
|
return a;
|
|
}
|
|
|
|
fn Main() {
|
|
var b: i32 = Echo(1);
|
|
}
|
|
|
|
// CHECK:STDOUT: file "i32.carbon" {
|
|
// CHECK:STDOUT: %Echo: <function> = fn_decl @Echo
|
|
// CHECK:STDOUT: %Main: <function> = fn_decl @Main
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @Echo(%a: i32) -> i32 {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: %a.ref: i32 = name_reference "a", %a
|
|
// CHECK:STDOUT: return %a.ref
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @Main() {
|
|
// CHECK:STDOUT: !entry:
|
|
// 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.var, %.loc12_20
|
|
// CHECK:STDOUT: return
|
|
// CHECK:STDOUT: }
|