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 by RunningController, which manages a running calculator program.
FloatKeyArg
The description of an argument for the float mode key. It's special because stack lift is enabled when going from int mode to float mode, but it's stack neutral if staying in float mode.
GosubOperationArg
The description of an argument for GSB, which requires a special state for inputting the argument to preview the instruction that's about to be executed.
KeyboardController
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. [...]
NormalArgOperation
A NormalOperation that takes an argument. For example, the RCL and STO operations take an argument, giving the register to store to or recall from.
NormalOperation
A "normal" calculator operation. Generally, they perform some kind of calculation, or otherwise manipulate the model.
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.
OperationArg
A description of the argument for a NormalArgOperation or a BranchingArgOperation. This includes the calculation that is to be performed when the argument value is available.
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.
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. [...]
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.