function Bob
Henoktes722 wrote
class Main {
function void main() {
var int x, y;
do Output.printInt(1 + (2 * 3));
return;
}
}
I'm having a hard time to complete the project. Here writeFunction called first and writes, "function Main.main 2". But we can't get the number of local variables the function have, since we are on subroutineDeclaration. So to actually get the number of local variables we need to call compileSubroutineBody then compileVarDec. So I can't get how to design the project to get the desired value.
So when you generate the VM code
function main 2
consider if it is required that all parts of this line have to be generated before you call subroutineDeclaration.
Perhaps part of it can and then the rest can be the first thing that is output by subroutineDeclaration.