mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
77 lines
1.3 KiB
C
77 lines
1.3 KiB
C
// #target: macos-x64
|
|
|
|
module foo;
|
|
import std::io;
|
|
|
|
fault Foo
|
|
{
|
|
X
|
|
}
|
|
|
|
define Bar = distinct int;
|
|
|
|
enum MyEnum
|
|
{
|
|
A,
|
|
B
|
|
}
|
|
|
|
fn void Foo.hello(Foo *f)
|
|
{
|
|
io::println("Hello from Foo");
|
|
}
|
|
|
|
fn void Bar.hello(Bar *b)
|
|
{
|
|
io::println("Hello from Bar");
|
|
}
|
|
|
|
fn void MyEnum.hello(MyEnum *myenum)
|
|
{
|
|
io::println("Hello from MyEnum");
|
|
}
|
|
fn int main()
|
|
{
|
|
Foo f;
|
|
Bar b;
|
|
MyEnum a = MyEnum.A;
|
|
f.hello();
|
|
b.hello();
|
|
a.hello();
|
|
return 0;
|
|
}
|
|
|
|
/* #expect: foo.ll
|
|
|
|
define void @foo_Foo_hello(i64* %0) #0 {
|
|
entry:
|
|
%1 = call i32 @std_io_println(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i32 0, i32 0)) #1
|
|
ret void
|
|
}
|
|
|
|
define void @foo_Bar_hello(i32* %0) #0 {
|
|
entry:
|
|
%1 = call i32 @std_io_println(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i32 0, i32 0)) #1
|
|
ret void
|
|
}
|
|
|
|
define void @foo_MyEnum_hello(i32* %0) #0 {
|
|
entry:
|
|
%1 = call i32 @std_io_println(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i32 0, i32 0)) #1
|
|
ret void
|
|
}
|
|
|
|
define i32 @main() #0 {
|
|
entry:
|
|
%f = alloca i64, align 8
|
|
%b = alloca i32, align 4
|
|
%a = alloca i32, align 4
|
|
store i64 0, i64* %f, align 8
|
|
store i32 0, i32* %b, align 4
|
|
store i32 0, i32* %a, align 4
|
|
call void @foo_Foo_hello(i64* %f)
|
|
call void @foo_Bar_hello(i32* %b)
|
|
call void @foo_MyEnum_hello(i32* %a)
|
|
ret i32 0
|
|
}
|