To avoid needing to add/remove 1 in multiple places at runtime (for example when loading locals), it would be nice to store the called function in the cb_frame instead of on the stack. To do so means that the function should be at the top of the stack when evaluating OP_CALL, which requires reordering the code emitted by the compiler. The way to do this that comes to mind is buffering the bytecode from nud and appending it after compiling the arguments.
See the branch function-last for a WIP implementation.
To avoid needing to add/remove 1 in multiple places at runtime (for example when loading locals), it would be nice to store the called function in the
cb_frameinstead of on the stack. To do so means that the function should be at the top of the stack when evaluatingOP_CALL, which requires reordering the code emitted by the compiler. The way to do this that comes to mind is buffering the bytecode fromnudand appending it after compiling the arguments.See the branch
function-lastfor a WIP implementation.