In the get operand routine, if the token is a constant and the data type requested is a specific data type (double, integer or string), the token can be assigned one of the constant codes. For the any, none or number data types, it is not yet known what type the constant needs to be, so the code set assignment code will be delayed until it is known.
This will generally take place when the find code routine is called as the type of constant needed will be determined by the operator being processed. A constant token will be assigned before returning unless an error detected (wrong data type or a double constant that cannot be converted to an integer).
For most functions, constant arguments the will be assigned a code by the get operand routine since the arguments are for a specific data type. A few functions have multiple forms for double and integer arguments (ABS, SGN and STR$). For these functions, a constant argument is assigned a code since no code has not been assigned yet. Integer constants containing a decimal or an exponent (the double sub-code is set) are first changed to the double data type.
Previously, at the end of the get expression routine, the data type of a constant was forced to the expected data type passed. This would be another place a constant token needs to be assigned a code, however, it turned out that this code was never executed because the type of constants had already been determined and assigned a code by the end of this routine, so this code was removed.
To validate that constants are being assigned a code by the end of translation, the token text routine was modified to output a question mark in front of a constant token if no code has been assigned. When the with index flag argument is set (during encoder test output), constant tokens output the code and operand (the string of the constant) instead of just the constant since these tokens will be encoded as two program words (the constant instruction and its index). Also, constant token codes are no longer assigned a code in the output assign codes routine called at the end of translation.
To make the constant output work correctly for both translator and encoder test output, the token type in the table entries for the three constant codes were changed from the internal function with no parentheses type to the constant type. This will make constant tokens go through the constant case in the token text routine. This is inconsequential since the token type disappears once the tokens are encoded.
[commit fa0916f67b]
Saturday, September 21, 2013
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.)