Upon reviewing the most recent changes made to the encode, operand text, and remove virtual table functions, I decided that some refactoring was in order to clean up how the program model is accessed from these functions and how the program line reader is utilized.
I observed that for each of the three locations that created a program line reader instance were identical. The program line reader constructor contained three arguments, the beginning of the code vector, the offset of the line within the code vector and size of the line. For code readability, the number of arguments in a function call should be as few as possible and three is a little too many.
In all three constructions, the offset and size of the line were obtained from a line info structure. This could have been one way to reduce the number of arguments by one - to pass just a reference to a line info structure. This would have meant that the program code header file where the program line reader class is located, would need access to the line info structure, which is an internal class to the program model.
The more header files included, the longer compilation takes, so this was not a desirable solution, plus there would still be two arguments. This would be an improvement, but there was an alternative to eliminate the other argument - the begin code vector iterator.
Since the program model contains the code vector, the line info structure definition and includes the program code header file containing the program line reader class definition, a new create program line reader function was added to the program model class. This function contains a single reference to a line info structure argument and creates a program line reader instance from this argument and the begin code vector iterator.
[branch table commit ba6e5ee46d]
Saturday, February 7, 2015
Subscribe to:
Post Comments (Atom)
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.)