This function took no action if the operand data type matched the expected data type of the token. If the operand was a constant, an attempt is made to change the constant to the expected data type if at the last operand and the token does not have the Use Constant As Is flag set. If there is an alternate code of the token that matches that of the operand, the token is changed to that code. Otherwise a hidden conversion code is obtained. An error is thrown if the operand cannot be converted.
Since this function is acting on a token (or possibly two tokens), it made more sense for this function to be a member of the token class. After moving it to the token class, it was renamed to the convert function. With a lot going on in this function, some refactoring was performed to improve the readability and clarity of the code:
- Added the is last operand access function to determine if an operand index is the last operand of the code in the token.
- Renamed the convert constant function to change constant. Also renamed its argument.
- Added the change constant ignore error function, which calls the change constant function and catches an error that may be throw.
- Renamed the convert code function to convert code entry. Also renamed its argument.
- Removed most of the comments as they were only restarting what appears in the code (this included the callers in the translator routines).
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.)