|
I'm looking for a way to make sure that every call in class1 to a subroutine in class2 uses the correct number of arguments.
As the Jack compiler is meant to compile each .jack file independently, I can't just check class2's file.
I could try detecting it in the resulting vm code, but I don't know of an easy way to find out the number of arguments that a vm function uses.
One solution I came up with is to compile each jack subroutine to a vm function whose identifier includes the number of arguments eg: function int foo(int i, int j) -> function file.foo2 ...
This way, using the incorrect number of arguments will result in a call to an undefined function in the vm translator.
However, this isn't compatible with the jack OS vm files.
Is there a better way?
|