handleOpBeforeCalculate method Null safety
- Model<
ProgramOperation> m, - void opBeforeCalculate(
override
For many of the RCL operations on matrices, we need to take over stack lift, so we do the deferral on beforeCalculate rather than calc.
Implementation
@override
void handleOpBeforeCalculate(Model m, void Function() opBeforeCalculate) {
final Value iv = m.memory.registers.index;
final int? miv = iv.asMatrix;
if (miv == null) {
opBeforeCalculate(); // noStackLift only relevant if I is a matrix
final int reg = iv.asDouble.floor().abs();
m.resultX = m.memory.registers[reg]; // Index exception becomes Error 3
} else {
final matrix = (m as Model15).matrices[miv];
matPressed(m, matrix);
m.deferToButtonUp = DeferredFunction(m, () {
if (!noStackLift) {
opBeforeCalculate();
}
matReleased(m, matrix);
}).run;
}
}