operator [] method Null safety

ProgramInstruction<OT> operator [](
  1. int line
)

line counts from 1, with a phantom return at line 0

Implementation

ProgramInstruction<OT> operator [](final int line) {
  final int opCode = opcodeAt(line);
  final OT op = _operationTable[opCode]!;
  // "!" throws an exception on an illegal opCode, which is what we want.
  final ArgDone arg = _argValues[opCode]!;
  return memory.model.newProgramInstruction(op, arg);
  // We're storing the instructions as nybbles and creating
  // ProgramInstruction instances as needed, but not to save memory.
  // Rather, it's the easiest way of implementing it, given that we
  // want to store the program in a form that is faithful to the
  // original 16C, that preserves the memory management constraints.
  // The extra time we spend converting back and forth is, of course,
  // irrelevant.
}