Sunday, October 13, 2013

Program – Single Code Vector

The program model was modified to contain a single code vector of program words so that during execution, no handling of individual lines is needed.  Program execution will simply flow from one line to the next as if it was a single block of code.  This will allow for fast execution. The temporary line code vector that was added to the line info list was replaced with an offset into the single code vector and the code size of the line.

The code vector was previously just a QVector of the program words.  However, the QVector class does not have an existing function for inserting another vector into a vector.  Therefore, a new ProgramCode class was created based on the QVector class.  This was similar to the ProgramLine that was previously implemented and then removed.  This time, a new insert line routine was implemented to insert a vector (code for a line) into another vector (the single code for the program).

The new insert line routine does nothing if the line to insert is empty.  Otherwise the program is first resized to allow for the new line.  A hole is made for the new line if the insert point is not at the end of the program.  Finally, the code of the line is copied into the program code.

The update line routine was modified (insert operation only) to insert the code for a line that does not have an error.  The offset for the new line is determined.  If the new line will be at the end of the program, the offset is set to the current size of the program, otherwise the offset is set to the offset of the line being inserted before.  The size is set to the size of the line code, and the line is inserted into the program.

The update error routine was modified to return if the line being inserted has an error.  This is used to determine if the code for the line is to be inserted into the program.  If the line has an translator error, the line was not encoded, so there is no code to insert into the program, though information for the line is still inserted into the line info list.

The debug text routine previously just retrieved the code vector inserted into the line info list for a specified line.  Since this code vector was removed, this routine was modified to calculate the address of the line by adding the offset for the line to the base address of the program code vector.  The size is obtained from the new size added to the line info list.

[commit dd94ed0ef9]

No comments:

Post a Comment

All comments and feedback welcomed, whether positive or negative.
(Anonymous comments are allowed, but comments with URL links or unrelated comments will be removed.)