Monday, February 16, 2015

Program Writer Class – Call Chain Removal

To write words into the program, a standard back insert iterator (back inserter) was passed to the encode functions (one in the token class and the others in the table virtual encode functions).  The virtual table encode functions also need to add entries to a dictionary in a program unit, so a pointer to the program unit was also passed.  Since the token encode calls a virtual table encode function, it is also passed a program unit pointer.

In the case of the program reader class (originally implemented because both an iterator and an end iterator needed to be carried together) there was already a container that could carry the program unit pointer to the operand text and remove functions.  Therefore, a Program Writer class was implemented to carry a back inserter and a program unit pointer.

To program writer class was given a couple of member functions including a write code function for inserting a program word with the code and sub-code, and a generate and write operand function for inserting a program word with an operand after the operand is obtained by adding a reference to a dictionary entry.

The back inserter and program unit pointer arguments to the encode functions were changed to a reference to a program writer instance, and these functions were modified to use it.  The generate and write operand function calls a new program model generate operand from dictionary function.  To create a program writer instance, the create program writer function was added to the program model class.

To be more consistent with the naming of the generate and write operand function name, the program reader get string for operand and remove reference to operand functions were renamed to read operand and get string and read operand and remove reference respectively.

[branch table commit 37a64d99c7]