How Does the VMEmulator Call Methods from Class Files
When we run 'Main'(for any of the programs from Chapter 11) in the VMEmulator, how does the VMEmulator 'see' the VM commands of the called methods belonging to other files?
Example(from Square - Main):
function Main.main 1
call SquareGame.new 0 pop local 0
push local 0
call SquareGame.run 1 pop temp 0
push local 0
call SquareGame.dispose 1 pop temp 0
push constant 0
--> How does the VMEmulator know what to do when it see's 'Call SquareGame.new 0', 'call SquareGame.run 1', or 'call SquareGame.dispose 1'?
Is there an explanation for this in somewhere in the lectures or textbook that I missed? If not, could someone give me a brief explanation of this or point me towards a good explanation of this that already exists out there on the Internet?
Re: How Does the VMEmulator Call Methods from Class Files
Are you asking about how the VMEmulator works internally? If so, it works by loading all the .vm files from a given folder (it will load any missing OS files from its installation folder). It then knows all the declared classes, functions, methods, etc. and starts executing from Main.main.
I don't think there is any documentation about it, but the VMEmulator along with most* of the other tools are open source and are available from the site. But note, that the code is a quite messy and at least I find it quite hard to refactor and improve. And I've tried several times during the last few years.
* All except the assembler and Jack compiler for obvious reasons.