mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
$eval now also works with @foo, #foo, $Foo and $foo parameters #2114.
This commit is contained in:
@@ -2,7 +2,7 @@ import std::io;
|
||||
|
||||
fn void main()
|
||||
{
|
||||
$eval("foo()"); // #error: with $eval
|
||||
$eval("foo()"); // #error: could not be resolved to a valid
|
||||
}
|
||||
fn void foo()
|
||||
{
|
||||
|
||||
30
test/test_suite/compile_time/extended_eval.c3t
Normal file
30
test/test_suite/compile_time/extended_eval.c3t
Normal file
@@ -0,0 +1,30 @@
|
||||
// #target: macos-x64
|
||||
module test;
|
||||
macro @abc(#a)
|
||||
{
|
||||
$eval("#a") = 1;
|
||||
}
|
||||
fn void main()
|
||||
{
|
||||
int $foo = 1;
|
||||
$eval("$foo") = 2;
|
||||
$typefrom("int") x;
|
||||
var $Type = double;
|
||||
$typefrom("$Type") y;
|
||||
$eval("@abc")(x);
|
||||
x = 0;
|
||||
$eval("test::@abc")(x);
|
||||
}
|
||||
|
||||
/* #expect: test.ll
|
||||
|
||||
entry:
|
||||
%x = alloca i32, align 4
|
||||
%y = alloca double, align 8
|
||||
store i32 0, ptr %x, align 4
|
||||
store double 0.000000e+00, ptr %y, align 8
|
||||
store i32 1, ptr %x, align 4
|
||||
store i32 0, ptr %x, align 4
|
||||
store i32 1, ptr %x, align 4
|
||||
ret void
|
||||
}
|
||||
Reference in New Issue
Block a user