mirror of
https://github.com/anoma/juvix.git
synced 2024-12-12 14:28:08 +03:00
76548e464a
* Replaces the `pusht` and `popt` instructions with block-based `save` and `tsave`. This encodes the structure of temporary stack manipulation syntactically, making it impossible to manipulate it in unexpected ways. Also simplifies compilation to Nock. * Adds optional names for temporaries and function arguments.
37 lines
526 B
Plaintext
37 lines
526 B
Plaintext
-- temporary stack
|
|
|
|
function main() {
|
|
push 1;
|
|
tsave {
|
|
push 2;
|
|
save {
|
|
push tmp[1];
|
|
};
|
|
push tmp[0];
|
|
add;
|
|
tsave {
|
|
push tmp[1];
|
|
push tmp[1];
|
|
mul;
|
|
tsave {
|
|
push tmp[2];
|
|
push 2;
|
|
add;
|
|
tsave {
|
|
push tmp[2];
|
|
push tmp[3];
|
|
add;
|
|
tsave {
|
|
push tmp[2];
|
|
push tmp[3];
|
|
push tmp[4];
|
|
add;
|
|
add;
|
|
ret;
|
|
};
|
|
};
|
|
};
|
|
};
|
|
};
|
|
}
|