mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 20:11:17 +00:00
77 lines
1.1 KiB
C
77 lines
1.1 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(ptr %0) #0 {
|
|
entry:
|
|
%1 = call i32 @std_io_println(ptr @.str) #1
|
|
ret void
|
|
}
|
|
|
|
define void @foo_Bar_hello(ptr %0) #0 {
|
|
entry:
|
|
%1 = call i32 @std_io_println(ptr @.str.1) #1
|
|
ret void
|
|
}
|
|
|
|
define void @foo_MyEnum_hello(ptr %0) #0 {
|
|
entry:
|
|
%1 = call i32 @std_io_println(ptr @.str.2) #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, ptr %f, align 8
|
|
store i32 0, ptr %b, align 4
|
|
store i32 0, ptr %a, align 4
|
|
call void @foo_Foo_hello(ptr %f)
|
|
call void @foo_Bar_hello(ptr %b)
|
|
call void @foo_MyEnum_hello(ptr %a)
|
|
ret i32 0
|
|
}
|