rcl15 property Null safety
final
Implementation
static final NormalArgOperation rcl15 = NormalArgOperationWithBeforeCalc(
maxOneByteOpcodes: 47,
beforeCalculate: (Resting s) {
// For the matrix operations, this is deferred to key release. It is
// not run if the operation is cancelled.
s.liftStackIfEnabled();
return StackLift.neutral;
// But stack lift is still set after the calculation completes,
// as with normal operations.
},
arg: ArgAlternates(synonyms: {
..._matrixSynonymsPlusRandom,
Operations15.sin: Operations15.dim
}, children: [
RegisterReadArg(maxDigit: 19, noParenI: true, f: (m, v) => m.x = v),
KeyArg(
key: Operations15.ranNum,
child: ArgDone(((m) {
m.xF = (m as Model15).rand.lastValue;
}))),
// g A..E
KeysArg(
keys: _letterLabelsGShifted,
generator: (i) => DeferredRclArg(
matrixNumber: i,
noStackLift: true,
pressed: (m, matrix) {
final int row = m.yF.truncate().abs() - 1;
final int col = m.xF.truncate().abs() - 1;
_showMatrix(m, matrix, row, col);
},
released: (m, matrix) {
final int row = m.yF.truncate().abs() - 1;
final int col = m.xF.truncate().abs() - 1;
m.popStack();
m.x = matrix.get(row, col);
})),
KeyArg(
key: Operations15.sigmaPlus,
child: StackLiftingArgDone((m) {
m.x = m.memory.registers[5]; // Don't set lastX
m.pushStack();
m.x = m.memory.registers[3];
},
needsStackLiftIfEnabled: (m) =>
(m as Model15).memory.numRegisters >= 6)),
KeyArg(
key: Operations15.dim,
child:
ArgAlternates(synonyms: _letterAndRegisterISynonyms, children: [
KeysArg(
keys: _letterLabels,
generator: (i) => ArgDone((m) {
final mat = (m as Model15).matrices[i];
m.xF = mat.rows.toDouble();
m.pushStack();
m.xF = mat.columns.toDouble();
})),
KeyArg(
key: Operations15.I15,
child: ArgDone((m) {
final int? miv = m.memory.registers.index.asMatrix;
if (miv == null) {
throw CalculatorError(11);
}
final mat = (m as Model15).matrices[miv];
m.xF = mat.rows.toDouble();
m.pushStack();
m.xF = mat.columns.toDouble();
})),
KeyArg(
key: Operations15.parenI15,
child: ArgDone((m) => m.xF =
((m as Model15).memory.numRegisters - 1).toDouble()))
])),
KeyArg(
key: Operations15.resultOp,
child: ArgDone(
(m) => m.x = Value.fromMatrix((m as Model15).resultMatrix))),
KeyArg(
// RCL MATRIX A..E. These are one-byte opcodes.
key: Operations15.matrix,
child: KeysArg(
synonyms: _matrixSynonyms,
keys: _letterLabels,
generator: (i) => ArgDone((m) => m.x = Value.fromMatrix(i)))),
UserArg(
userMode: false,
child:
ArgAlternates(synonyms: _letterAndRegisterISynonyms, children: [
KeysArg(
keys: _letterLabels,
generator: (i) => DeferredRclArg(
matrixNumber: i,
pressed: _showMatrixR0R1,
released: (m, matrix) =>
_recallFromMatrix(m, matrix, false))),
KeyArg(
key: Operations15.parenI15,
child: RclIndirectArg(
matPressed: _showMatrixR0R1,
matReleased: (m, matrix) =>
_recallFromMatrix(m, matrix, false))),
])),
UserArg(
userMode: true,
child:
ArgAlternates(synonyms: _letterAndRegisterISynonyms, children: [
KeysArg(
keys: _letterLabels,
generator: (i) => DeferredRclArg(
matrixNumber: i,
pressed: _showMatrixR0R1,
released: (m, matrix) =>
_recallFromMatrix(m, matrix, true))),
KeyArg(
key: Operations15.parenI15,
child: RclIndirectArg(
matPressed: _showMatrixR0R1,
matReleased: (m, matrix) =>
_recallFromMatrix(m, matrix, true))),
])),
KeyArg(
key: Operations15.plus,
child: RegisterReadOpArg(
maxDigit: 19, f: (double r, double x) => r + x)),
KeyArg(
key: Operations15.minus,
child: RegisterReadOpArg(
maxDigit: 19, f: (double r, double x) => r - x)),
KeyArg(
key: Operations15.mult,
child: RegisterReadOpArg(
maxDigit: 19, f: (double r, double x) => r * x)),
KeyArg(
key: Operations15.div,
child: RegisterReadOpArg(
maxDigit: 19, f: (double r, double x) => r / x)),
KeyArg(
key: Operations15.cosInverse, // That's g (i)
child: RclIndirectArg(
noStackLift: true,
matPressed: (m, matrix) {
final int row = m.yF.truncate().abs() - 1;
final int col = m.xF.truncate().abs() - 1;
_showMatrix(m, matrix, row, col);
},
matReleased: (m, matrix) {
final int row = m.yF.truncate().abs() - 1;
final int col = m.xF.truncate().abs() - 1;
m.popStack();
m.x = matrix.get(row, col);
})),
]),
name: 'RCL');