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.
37 lines
815 B
Plaintext
37 lines
815 B
Plaintext
|
|
function multiply(integer, integer) : integer;
|
|
function plus(integer, integer) : integer;
|
|
function calculate(integer, integer, integer) : integer;
|
|
function main() : *;
|
|
|
|
function multiply(integer, integer) : integer {
|
|
tmp[0] = arg[0];
|
|
tmp[1] = arg[1];
|
|
tmp[0] = mul tmp[1] tmp[0];
|
|
ret tmp[0];
|
|
}
|
|
|
|
function plus(integer, integer) : integer {
|
|
tmp[0] = arg[0];
|
|
tmp[1] = arg[1];
|
|
tmp[0] = add tmp[1] tmp[0];
|
|
ret tmp[0];
|
|
}
|
|
|
|
function calculate(integer, integer, integer) : integer {
|
|
tmp[0] = arg[0];
|
|
tmp[1] = arg[1];
|
|
tmp[2] = arg[2];
|
|
tmp[1] = call multiply (tmp[2], tmp[1]), live: (tmp[0], arg[0], arg[1], arg[2]);
|
|
tcall plus (tmp[1], tmp[0]);
|
|
}
|
|
|
|
function main() : * {
|
|
prealloc 4;
|
|
tmp[0] = 2;
|
|
tmp[1] = 3;
|
|
tmp[2] = 5;
|
|
tmp[1] = calloc calculate (tmp[2], tmp[1]);
|
|
tcall tmp[1] (tmp[0]);
|
|
}
|