Saturday, October 12, 2013

Encoder Class – Removal

The next step is to implement the code to insert the encoded lines into the program (currently the translated RPN lists are stored).  Part of this process that is already implemented is to increment the use counts for dictionary items when a line is inserted into the program.  The encoder handled this part.  Related to this is when a line is removed from the program - the use counts need to be decremented for dictionary items that were on the line (deleting a dictionary item when it is no longer used).

This remove line process appeared to be mirror to the encode (add) line process and therefore the question arose whether the encoder class should also contain a remove routine.  Looking at the current encoder class, it currently contained the single encode routine and no member variables (except for a reference to the table instance).  It also required a pointer to the current program unit, which is only used to pass to the encode functions for each code with an operand.  A reference to the encoder was not passed to the encode function since the encoder class did not contain anything that was needed.

So the conclusion was made that the encoder class was not really necessary and that the encode routine should be in the program model (which contains all the dictionaries needed for encoding) along with the remove routine that will be implemented.  Therefore, the encoder class was removed and the encode routine was moved to the program model class.

[commit 85827d49e8]