gotoOpCode method Null safety

  1. @protected
void gotoOpCode(
  1. int wanted
)

Implementation

@protected
void gotoOpCode(int wanted) {
  // We might be at the label, so we start at 0.  Also, remember that
  // line 0 has the phantom return instruction, so we have to
  // iterate over lines+1 "lines".
  if (lines != 0) {
    for (int i = 0; i <= lines; i++) {
      int line = (currentLine + i) % lines;
      if (line == 0) {
        line = lines;
      }
      if (opcodeAt(line) == wanted) {
        currentLine = line;
        return;
      }
    }
  }
  throw CalculatorError(4);
}