Saturday, January 11, 2014

Program – Saving Text Of Error Lines

Now that two minor problems found during testing have been corrected, the next step in changing the program loading process is to handle lines with errors when loading the program.  This is accomplished by saving the text of the line with an error in the line information array (which also contains the offset into the program code, the code size, and error index if any of the line).

When a line has an error, the text of the line is stored in the new text variable in the line information for the line.  This variable is cleared when a line does not have an error.  Now, when the text of a line is requested (by the edit box when processing a program change signal), if the line has an error, this text is returned instead of recreating the code for the line (since there is no code for the line).

When a line is changed or inserted and the line has an error, a program change signal is no longer emitted.  Only the edit box changes and it already has the text of lines inserted with an error.  However, when a line is appended, a program change signal is always emitted regardless of whether it has an error (lines will only be appended during loading and the edit box will need the text for all lines including those with errors).

The program changed slot of the edit box class was modified to no longer check for lines with errors (by checking if the line text string was null) because the program unit attached no longer sends signals for lines with errors (if the change originated from the edit box).

[commit 4a110b2735]

Dictionary – Remove Correction

A minor problem was discovered with the dictionary class, which can be demonstrated by entering the single statement "a=0" into an empty program and then introducing an error on the line (for example, "a=0b") and entering the line.  Once the error is removed, the line is recreated incorrectly as " = 0" (note the space where the "a" should be).

When the statement is first entered, the "a" variable gets entered into the dictionary as "A" (because variable names are case insensitive).  When the error is introduced, the statement is dereferenced (both the variable "a" and the constant "0" should be removed from the dictionaries).  However, when the attempt to remove "a" from the hash in the dictionary, it does not match the "A" that was put into the hash originally.  The dictionary item is removed (from the key list).  When the "a" is added back, the dictionary sees that it is already in the hash because it was not correctly removed and returns it index and the name doesn't get added back to the key list, which still has an empty name for the index.

This problem was corrected by adding a case sensitivity argument to the remove functions of the dictionary and info dictionary classes with a default of case insensitive (same as for the add functions).  For dictionaries that use the case sensitive option (remark and string constant), they must also use it when removing dictionary entries.  The remove function converts the obtained key from the key list for the index specified to upper case for a case insensitive dictionary so that the hash is properly removed.

[commit d7dec3ca11]