During the design of the INPUT statement translation, some code reorganization was needed, specifically in the Translator find code routine, which processes the done stack top item (that was last added to the RPN output list) to check its data type to see if it matches the expected operand data type of the operator or internal function being processed, and if not looks to see if there is an associated code with that expected data type. If no associated code is found, then checks to see if the data type of the operand can be converted (a hidden convert code is added to the output if it can), or else determines the appropriate error. Upon success, the done stack top item is dropped.
The find code routine had evolved into a somewhat complicated function. It is also used to take a base code (for example PrintDbl, and will also be used for InputAssignType) and change it to an associated code for the data type of the operand on top of the done stack. The functionality of looking up an associated code from a base code for a given data type will also be needed in the Encoder (to be implemented soon now), for example, taking the VarDbl code (that pushes a double variable value to the evaluation stack during run-time), and changing it as needed to VarInt or VarStr for the data type of a token with no parentheses.
Since the future Encoder class should not need to call a Translator class function for this, and since this is really the functionality of the Table class (all the associated code and data type information is in the Table), the part of the find code routine that does this was moved into a new find code routine in the Table class. Some unused code was discovered (part of it even containing a bug, but was causing a problem since the code was not used), which was removed when the code was moved.
The Translator find code routine was renamed to the process done stack top routine to more appropriately describe its functionality. The convert code have need table was also moved from the translator to the table source file. As a result, a new Table convert code access function was needed, that takes a token and data type and returns the convert code needed (including a null code for no convert code or invalid if conversion is not possible). Some comments were also added documenting code that needs to be removed when the old translator routines are finally removed.
[commit b5fa514ca9]
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.)