Wednesday, October 30, 2013

Program – Line Change Detection

The translated RPN lists for program lines is currently being saved in the line information list.  This was only temporary until the RPN lists could be encoded into program code and stored.  This mechanism was left in place since it is still being used for line change detection.  As described in the last post, RPN lists will still be compared to detect line changes except that the program code will be decoded into an RPN list.

However, the form of the decoded RPN list will be slightly different then a translated RPN list.  The method of RPN list comparison was to compare each RPN item, where the token, the attached token count, and if non-zero, each attached token was compared.  For the token comparison, the token type, the data type for constants, the code for commands and operators except the REM command and operator, the code for internal functions, the string for other token types, the reference flag, and the sub-code.

The tokens in a decoded RPN list will only have the code, sub-code (only program sub-codes), and a string (for all types).  Therefore, only these members of the token are compared.  For the RPN items, it is unnecessary to compare the attached tokens since these only refer to other tokens in the list, and the token comparisons are sufficient to catch differences, so only the attached token count needs to be compared.  In fact, a decoded RPN list will not have attached tokens, only the count, since these will not be necessary for recreation.

Token comparison boils down to comparing the code, sub-code masked by the program only sub-codes, and the string.  There is one other issue when comparing the strings that would cause the previous comparison to incorrect detect a change.  A non-case sensitive comparison must be used except for the REM, REM operator and string constant codes.

Where testing these changes in the GUI, a token (memory) leak was discovered, which occurred when the line did not change.  The program was due to the RPN list of the line to replace was not used in this case, but was not deleted.  This was corrected in additional to updating the RPN item and tokens comparison routines.

[commit 16c85dfe79]