mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
39 lines
1.0 KiB
Plaintext
39 lines
1.0 KiB
Plaintext
// #target: macos-x64
|
|
module test;
|
|
import std::collections::list;
|
|
macro @test_list(a)
|
|
{
|
|
var $Type = $typeof(a);
|
|
$if $defined(a[0]) &&& $Type.typeid == List{$typeof(a[0])}.typeid:
|
|
return 1;
|
|
$else
|
|
return 0;
|
|
$endif
|
|
}
|
|
|
|
fn int main(String[] args)
|
|
{
|
|
DString str = dstring::new(mem, "test");
|
|
return @test_list(str);
|
|
}
|
|
|
|
/* #expect: test.ll
|
|
|
|
define i32 @test.main(ptr %0, i64 %1) #0 {
|
|
entry:
|
|
%args = alloca %"char[][]", align 8
|
|
%str = alloca ptr, align 8
|
|
%a = alloca ptr, align 8
|
|
store ptr %0, ptr %args, align 8
|
|
%ptradd = getelementptr inbounds i8, ptr %args, i64 8
|
|
store i64 %1, ptr %ptradd, align 8
|
|
%2 = call ptr @llvm.threadlocal.address.p0(ptr @std.core.mem.allocator.thread_allocator)
|
|
%lo = load i64, ptr %2, align 8
|
|
%ptradd1 = getelementptr inbounds i8, ptr %2, i64 8
|
|
%hi = load ptr, ptr %ptradd1, align 8
|
|
%3 = call ptr @std.core.dstring.new(i64 %lo, ptr %hi, ptr @.str, i64 4)
|
|
store ptr %3, ptr %str, align 8
|
|
%4 = load ptr, ptr %str, align 8
|
|
store ptr %4, ptr %a, align 8
|
|
ret i32 0
|
|
} |