initial commit
This commit is contained in:
commit
0b3af7375e
39 changed files with 2339 additions and 0 deletions
30
test/test_idgen.c3
Normal file
30
test/test_idgen.c3
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
import std::io;
|
||||
|
||||
alias Id = uint;
|
||||
|
||||
fn void foo_ex(Id id)
|
||||
{
|
||||
io::printfn("id = %d", id);
|
||||
}
|
||||
|
||||
|
||||
macro Id @compute_id(...)
|
||||
{
|
||||
Id id = (Id)$$LINE.hash() ^ (Id)@str_hash($$FILE);
|
||||
$for var $i = 0; $i < $vacount; $i++:
|
||||
id ^= (Id)$vaconst[$i].hash();
|
||||
$endfor
|
||||
return id;
|
||||
}
|
||||
|
||||
macro foo(...) => foo_ex(@compute_id($vasplat));
|
||||
|
||||
fn int main()
|
||||
{
|
||||
foo_ex(1234);
|
||||
foo();
|
||||
foo();
|
||||
foo();
|
||||
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue