Exemplo n.º 1
0
 @Override
 public void execute() {
   if (table.exists(name)) stack.push(table.get(name));
   else {
     Errors.error("Variable does not exist.", table);
   }
 }
Exemplo n.º 2
0
 /**
  * Run a "compiled" program by executing in order each instruction contained therein. Report on
  * the final size of the stack (should normally be empty) and the contents of the symbol table.
  *
  * @param program a list of Machine instructions
  */
 public static void execute(List<Instruction> program) {
   reset();
   System.out.println("Executing compiled code...");
   for (Instruction instr : program) {
     instr.execute();
   }
   System.out.println(
       "Machine: execution ended with " + stack.size() + " items left on the stack.");
   System.out.println();
   table.dump();
 }
Exemplo n.º 3
0
 /** Run the microsteps for the STORE instruction. */
 @Override
 public void execute() {
   table.put(this.name, stack.pop());
 }