n.kinash wrote
Hi.
Jack-code:
class Main {
function void main() {
var int result;
result = 1;
return;
}
}
VM-code:
function Main.main 0
push constant 1
pop local 0
push constant 0
return
Error occurred in VM emulator: Out of segment space in Main.main.2
Its work if i change number of arguments:
function Main.main 1
push constant 1
pop local 0
push constant 0
return
Why VMemulator allocate memory for local, only if function have arguments?
The number on the
function command is the
number of local variables the function uses, not the number of arguments.
The VM Emulator, and the code your VM translator writes for the
function command, uses this number to allocate the local segment on the stack.
--Mark