itoshkov / nand2tetris-emu

Nand2Tetris Software Suite - hardware simulator and CPU and VM emulators
http://www.nand2tetris.org
GNU General Public License v2.0
90 stars 29 forks source link

VMEmulator built-in classes not useable from command line #2

Closed markarmb closed 9 years ago

markarmb commented 9 years ago

When running a .tst script from the command line, built-in classes cannot by used. The "No implementation was found..." message does not appear.

I propose that an environment variable be used to control this behavior when running without GUI. This would allow, for example:

export VMEBUILTIN=yes
VMEmulator whatever.tst

(Environment variable is preferred over a command line option so that the user doesn't need to edit the VMEmulator sh/bat.)

This is not a trivial fix, however. The built-in class runner appears to be tied to the GUI thread. From the CPU class's constructor:

   if (program.getGUI() != null) {
        builtInFunctionsRunner =
            new BuiltInFunctionsRunner(this, builtInDir);
    }
itoshkov commented 9 years ago

Fixed with commit 6f28006.

I've changed the variable name to N2T_VM_USE_BUILTINS. See the commit comment for possible values and how they affect the behavriour.