mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-22 16:32:38 +00:00
Track the fields in a class, and generate a corresponding struct type as the object representation for the class. For now, we always use a pointer as the value representation for a class.
35 lines
875 B
Plaintext
35 lines
875 B
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
|
|
|
|
class C {
|
|
var a: i32;
|
|
var b: C*;
|
|
}
|
|
|
|
fn F(c: C) -> C {
|
|
// TODO: We should copy `c` into the return slot here.
|
|
return c;
|
|
}
|
|
|
|
fn Run() {
|
|
var c: C;
|
|
var d: C = F(c);
|
|
}
|
|
|
|
// CHECK:STDOUT: ; ModuleID = 'basic.carbon'
|
|
// CHECK:STDOUT: source_filename = "basic.carbon"
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: define void @F(ptr sret({ i32, ptr }) %return, ptr %c) {
|
|
// CHECK:STDOUT: ret void
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: define void @main() {
|
|
// CHECK:STDOUT: %c = alloca { i32, ptr }, align 8
|
|
// CHECK:STDOUT: %d = alloca { i32, ptr }, align 8
|
|
// CHECK:STDOUT: call void @F(ptr %d, ptr %c)
|
|
// CHECK:STDOUT: ret void
|
|
// CHECK:STDOUT: }
|