Saturday, January 10, 2015

Table – Functions Returning Codes

There were several table (and token) functions that returned a code enumerator (which was really an index).  These functions were changed to return a table entry pointer.  In the short term this means in some cases calling the temporary code access function to get the index of the entry (the code is still stored in a token).

The functions modified included the find code and token convert code functions.  Several new table entry alternate functions replaced equivalent table set token code functions.  Click Continue... for details of the changes.  Replacing of the use of code enumerators with table entry pointers has been started, which is necessary before the code and type enumerations is replaced with the code type enumeration.

[branch table commit 3df697fa40]

The find code function previously found an appropriate alternate code for the data type of an operand token for a specific operand number and set the token to that alternate code (which could be the code already in the token if the data type already matched).  The token would be set to the alternate if one was found, or a hidden conversion code was returned needed to convert the operand to the data type.  This function was modified to return the table entry pointer of the conversion code (or the default null pointer for no conversion).

The find code function previously used the set token code function to look for and set a token to an alternate code for a specified operand data type and operand number.  This was the only caller to this function.  The set token code function was replaced with a table entry alternate function taking operand index and data type arguments.  If the data type already matches the table entry, then the entry pointer is returned.  Otherwise it searches the alternates and returns an alternate entry if one with a matching data type if found.  If there are no alternates or none are found then a default (null) entry pointer is returned.

The token convert code function previously returned a hidden conversion code necessary for the desired data type (or the default code enumerator if no conversion is needed).  This function was modified to return the table entry pointer of the conversion code entry (or the default null entry pointer).  The hidden conversion code enumerator is passed to the table entry function to obtain its table entry pointer.

There was another set token code function that looked for and set a token to an alternate code for a specified code and return data type, which was used by several of the token constructors and the convert constant function.  This function was replaced with the static entry function taking  code and data type arguments.  The code argument of the new function will eventually be changed to a code type enumerator.  This function simply calls the alternate function for the data type of the table entry for the code.  The token constructors and convert constant function were updated to use this new function (and the token constructors were moved back to the header file since there was no function body left).

The former set token code function along with several of the token constructors and command translate functions used the set token function to set the code, type and data type of the token.  With the type and data type removed from the token, this function was left only setting the code of the token.  This function was replaced with setting the token code directly.

The alternate code function was also returning a code (the alternate for a particular operand index).  Calls to this function were replaced with calls to the recently added table entry alternate function.  Similarly, the alternate code count function for returning the number of alternate codes for an operand index was replaced with the new table entry alternate count function.  There were several calls to the alternate code function wrapped inside of a set token or token set code call.  These were replaced with a new token set first alternate function taking an operand index.

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.)