mirror of
https://github.com/anoma/juvix.git
synced 2024-11-30 05:42:26 +03:00
ed15e57d8a
* Closes #2578 * Implements JuvixReg parser and pretty printer. * Adds the `juvix dev reg read file.jvr` command. * Adds the `reg` target to the `compile` commands. * Adds tests for the JuvixReg parser.
39 lines
727 B
Plaintext
39 lines
727 B
Plaintext
|
|
function g(integer → integer, integer) : integer;
|
|
function f(integer) : integer;
|
|
function main() : *;
|
|
|
|
function g(integer → integer, integer) : integer {
|
|
tmp[0] = arg[1];
|
|
tmp[1] = 0;
|
|
tmp[0] = eq tmp[1] tmp[0];
|
|
br tmp[0] {
|
|
true: {
|
|
tmp[0] = 0;
|
|
ret tmp[0];
|
|
};
|
|
false: {
|
|
tmp[0] = 1;
|
|
tmp[1] = arg[1];
|
|
tmp[0] = sub tmp[1] tmp[0];
|
|
tmp[1] = arg[0];
|
|
tcall tmp[1] (tmp[0]);
|
|
};
|
|
};
|
|
}
|
|
|
|
function f(integer) : integer {
|
|
prealloc 2, live: (arg[0]);
|
|
tmp[0] = arg[0];
|
|
tmp[1] = calloc f ();
|
|
tmp[0] = call g (tmp[1], tmp[0]), live: (arg[0]);
|
|
tmp[1] = arg[0];
|
|
tmp[0] = add tmp[1] tmp[0];
|
|
ret tmp[0];
|
|
}
|
|
|
|
function main() : * {
|
|
tmp[0] = 10;
|
|
tcall f (tmp[0]);
|
|
}
|