Next: , Up: Variables   [Index]

3.3.1 Defining Variables

The expression evaluator is introduced the variables set via a look up function and a look up context. Every time a variable identifier is picked up while parsing the expression the evaluator calls the look up function supplying it the retrieved name, its length and the look up context. If the look up function is successful in identifying the variable, the references to the variable definition and value are expected.

The look up function and the look up context are specified via the struct x1f4_e4_type, as variable_set.get and variable_set.context, respectively.

See struct x1f4_e4_type.

The C type of the look up function is:

int (*)(const char *, unsigned, const void *,
        const struct x1f4_variable_type **, void **)

When called it is passed the retrieved identifier as the first argument and its length as the second. Note the identifier is not a null terminated string and no more the specified number of character should be interpreted.

The look up function is passed the look up context as the third argument.

If the look up function fails to identify the variable it is expected to return a non null value. Otherwise, the references to the variable definition and value for which addresses have been passed as the fourth and fifth arguments are expected to be set.

The C type of the otherwise uninterpreted look up context is const void *.

Variable definitions may be used up to parsed expression destruction, thus the variable definition references must be valid for as long as the result of expression parsing is used.