Update calling convention

Previously, the stack would look like this when calling a function:

TOP
| arg2     |
| arg1     |
| function |
BOTTOM

This order is now reversed, with the function coming first and then the
args:

TOP
| function |
| arg2     |
| arg1     |
BOTTOM

This is a little more friendly to the stack-based machine. It is
slightly less intuitive as far as order of operations goes, but having a
function's arguments depend on the state of the function itself is a
little suspect and easy to work around if you truly need that.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2023-04-07 00:36:16 -07:00
parent 4cec6f0765
commit fcef6c053d
3 changed files with 7 additions and 7 deletions

View File

@@ -25,8 +25,8 @@ pub enum Inst {
/// Pops the top item off of the stack, discarding it.
Pop,
/// Pops the top N function arguments off the stack, and attempt to call the
/// next stack item.
/// Pops the top item off of the stack to call, and then pops off the
/// following N arguments.
Call(usize),
/// Exits the current function stack frame and returns control to the