Beispiel #1
0
  /**
   * Load a new program into the machine and reset it
   *
   * @param instructions The program to load into the machine
   */
  public void loadInstructions(List<Instruction> instructions) {
    this.instructions = instructions;

    if (instructions != null) {
      int i = 0;
      for (Instruction op : instructions) {
        if (op.name.equals("label")) labels.put((String) op.arg.getValue(), i);
        i++;
      }
    } else instructions = new ArrayList<Instruction>();

    for (StackMachineListener l : listeners) l.programChanged(instructions);
    reset();
  }