/** jump */
 public void jump(JumpInstruction currentInstruction) {
   if (program.checkExistLabel(currentInstruction.getLabel()))
     setCurrentInstructionIndex(program.getLabelIndex(currentInstruction.getLabel()));
   else {
     halt();
     System.out.println(
         "Error. Line: "
             + (currentInstructionIndex + 1)
             + " Invalid label: "
             + currentInstruction.getName()
             + " "
             + currentInstruction.getLabel());
   }
 }
 /** jgtz */
 public void jgtz(JumpInstruction currentInstruction) {
   if (memoryRegister.getAccumulator() > 0) {
     if (program.checkExistLabel(currentInstruction.getLabel()))
       setCurrentInstructionIndex(program.getLabelIndex(currentInstruction.getLabel()));
     else {
       halt();
       System.out.println(
           "Error. Line: "
               + (currentInstructionIndex + 1)
               + " Invalid label: "
               + currentInstruction.getName()
               + " "
               + currentInstruction.getLabel());
     }
   } else currentInstructionIndex++;
 }
Beispiel #3
0
 @Override
 public void visit(JumpInstruction insn) {
   Statement stmt = generateJumpStatement(insn.getTarget());
   if (stmt != null) {
     statements.add(stmt);
   }
 }