controller library Null safety

The main controller for the application. The controller receives Operation instances from the view in response to button presses, and manipulates the Model.

The Operations are split out into a separate library, so that they are prevented from accessing private parts of the controller. Similarly, the concrete ControllerState types are put in a separate Dart library. Operations and states are fairly complex, reflecting the sophisticated design of the original HP-16C. Keeping them encapsulated from the controller's internals helps make the code easier to follow.

See ControllerState for a detailed description of the controller's state machine. See Operation for a description of the operation type hierarchy.


Classes

BranchingArgOperation
A BranchingOperation that takes an argument, namely B? (bit test)
BranchingOperation
A program branching operation. These operations only function when running a program. They represent a condition. If that condition is true, the next instruction executes normally; otherwise, it is skipped.
Controller
The main controller for the application. This abstract class is implemented by a RealController for normal calculator, and by RunningController, which manages a running calculator program.
KeyboardController
LetterLabel
One of the 15C's letter keys, from A to E.
LimitedOperation
Operations that do something when the key is pressed, even when the calculator is in program entry state. They're called "limited," because the set of handleXXX() calls is limited to those supported by ProgramEntry.
NoArgOperation
NonProgrammableOperation
NormalArgOperation
An Operation that takes an argument. For example, the RCL and STO operations take an argument, giving the register to store to or recall from.
NormalArgOperationWithBeforeCalc
NormalOperation
A "normal" calculator operation that doesn't take any keyboard arguments. Generally, they perform some kind of calculation, or otherwise manipulate the model.
NormalOperationOrLetter
A NormalOperation that doubles as a letter (A-F) on the 15C, as the argument to LBL, GTO or GSB. The letters on the 16C are unshifted, so this doesn't come up there.
NormalOperationShiftedArg
A NormalOperation that is shifted (by fShift or gShift), and that is used as an argument.
NumberEntry
One of the number keys, from 0 to f.
Operation
An operation, triggered by a key on the calculator keyboard, or executed as part of a program.
RealController
A controller for normal calculator operation. When a program is running, the real controller continues to exist, for when the program stops.
RunningController
A controller for when a program is running.
RunProgramOperation
SelfTests
Some built-in regression tests. There aren't just an excuse to flash "running" when a user triggers the 16C's self test fonction. It's also a way of easily running some of the tests involving integer and floating point behavior in different browsers. This might be a bit of a pain point for Dart, since the numeric types behave differently given JavaScript's deficiencies in ths regard.
ShiftOperation
StackLift
A declarative description of an Operation's effect on stack lift, when its calculation has been performed. This covers the most common effects that operations can have on stack lift. See Page 99, "Operations Affecting Stack Lift" in Appendix B of the 16C's manual.
StackLiftEnabledUser
A type that can be used by states to access the library-private RealController _stackLiftEnabled flag. This provides enhanced encapsulation, by explicitly marking states that do this.
StackLiftingNormalOperation
A NormalOperation that might lift this stack, if enabled