|
C Configuration Space and Tuning Library (CCS)
|
An expression in CCS is a combination of constants, variables (parameters), and operators. More...

Go to the source code of this file.
Data Structures | |
| struct | ccs_user_defined_expression_vector_s |
| A structure that define the callbacks the user must provide to create a user defined expression. More... | |
Typedefs | |
| typedef enum ccs_expression_type_e | ccs_expression_type_t |
| A commodity type to represent an expression type. | |
| typedef enum ccs_associativity_type_e | ccs_associativity_type_t |
| A commodity type to represent an associativity. | |
| typedef enum ccs_terminal_type_e | ccs_terminal_type_t |
| A commodity type to represend CCS terminal types. | |
| typedef struct ccs_user_defined_expression_vector_s | ccs_user_defined_expression_vector_t |
| a commodity type to represent a user defined expression callback vector. | |
Functions | |
| ccs_result_t | ccs_create_expression (ccs_expression_type_t type, size_t num_nodes, ccs_datum_t *nodes, ccs_expression_t *expression_ret) |
| Create a new expression. | |
| ccs_result_t | ccs_create_binary_expression (ccs_expression_type_t type, ccs_datum_t node_left, ccs_datum_t node_right, ccs_expression_t *expression_ret) |
| Create a new binary expression. | |
| ccs_result_t | ccs_create_unary_expression (ccs_expression_type_t type, ccs_datum_t node, ccs_expression_t *expression_ret) |
| Create a new unary expression. | |
| ccs_result_t | ccs_create_literal (ccs_datum_t value, ccs_expression_t *expression_ret) |
| Create a new literal expression. | |
| ccs_result_t | ccs_create_variable (ccs_parameter_t parameter, ccs_expression_t *expression_ret) |
| Create a new variable expression. | |
| ccs_result_t | ccs_create_user_defined_expression (const char *name, size_t num_nodes, ccs_datum_t *nodes, ccs_user_defined_expression_vector_t *vector, void *expression_data, ccs_expression_t *expression_ret) |
| Create a new user defined expression. | |
| ccs_result_t | ccs_expression_get_type (ccs_expression_t expression, ccs_expression_type_t *type_ret) |
| Get the type of an expression. | |
| ccs_result_t | ccs_expression_get_nodes (ccs_expression_t expression, size_t num_nodes, ccs_expression_t *nodes, size_t *num_nodes_ret) |
| Get the child nodes of an expression. | |
| ccs_result_t | ccs_literal_get_value (ccs_expression_t expression, ccs_datum_t *value_ret) |
| Get the value of a literal expression. | |
| ccs_result_t | ccs_variable_get_parameter (ccs_expression_t expression, ccs_parameter_t *parameter_ret) |
| Get the parameter of a variable expression. | |
| ccs_result_t | ccs_user_defined_expression_get_name (ccs_expression_t expression, const char **name_ret) |
| Get the name of a user defined expression. | |
| ccs_result_t | ccs_user_defined_expression_get_expression_data (ccs_expression_t expression, void **expression_data_ret) |
| Get the user defined expression internal data pointer. | |
| ccs_result_t | ccs_expression_eval (ccs_expression_t expression, size_t num_bindings, ccs_binding_t *bindings, ccs_datum_t *result_ret) |
| Get the value of an expression, in a given list of bindings. | |
| ccs_result_t | ccs_expression_list_eval_node (ccs_expression_t expression, size_t num_bindings, ccs_binding_t *bindings, size_t index, ccs_datum_t *result_ret) |
| Evaluate the entry of a list at a given index, in a given context, provided a list of values for the context parameters. | |
| ccs_result_t | ccs_expression_get_parameters (ccs_expression_t expression, size_t num_parameters, ccs_parameter_t *parameters, size_t *num_parameters_ret) |
| Get the parameters used in an expression. | |
| ccs_result_t | ccs_expression_check_contexts (ccs_expression_t expression, size_t num_contexts, ccs_context_t *contexts) |
| Validate that an expression can be evaluated in the given context. | |
Variables | |
| const int | ccs_expression_precedence [] |
| An array of precedence of operators as defined by CCS grammar: | |
| const ccs_associativity_type_t | ccs_expression_associativity [] |
| An array of associativity of operators as defined by CCS grammar: | |
| const char * | ccs_expression_symbols [] |
| An array of suggested symbols (NULL terminated strings) for CCS operators. | |
| const int | ccs_expression_arity [] |
| An array of arity of CCS operators. | |
| const int | ccs_terminal_precedence [] |
| An array of integers defining terminal precedence in order to disambiguate NONE, TRUE and FALSE from identifiers: | |
| const char * | ccs_terminal_regexp [] |
| An array of regexp that define terminals: | |
| const char * | ccs_terminal_symbols [] |
| An array of symbols (NULL terminated strings) for terminals that define them: | |
An expression in CCS is a combination of constants, variables (parameters), and operators.
Expressions are usually evaluated in the context of a binding where parameters are associated values. For convinience CCS suggests a grammar that can be used to create an expression parser.
Associativity of CCS operators:
Supported expression types.
| enum ccs_terminal_type_e |
The different terminal types of ccs expressions.
| Enumerator | |
|---|---|
| CCS_TERMINAL_TYPE_NONE | The CCS_NONE_VAL value. |
| CCS_TERMINAL_TYPE_TRUE | The CCS_TRUE_VAL value. |
| CCS_TERMINAL_TYPE_FALSE | The CCS_FALSE_VAL value. |
| CCS_TERMINAL_TYPE_STRING | A CCS_DATA_TYPE_STRING value. |
| CCS_TERMINAL_TYPE_IDENTIFIER | An identifer (name of a parameter) |
| CCS_TERMINAL_TYPE_INTEGER | A CCS_DATA_TYPE_INT value. |
| CCS_TERMINAL_TYPE_FLOAT | A CCS_DATA_TYPE_FLOAT value. |
| CCS_TERMINAL_TYPE_MAX | Guard. |
| CCS_TERMINAL_FORCE_32BIT | Try forcing 32 bits value for bindings. |
|
extern |
Create a new binary expression.
Convenience wrapper around ccs_create_expression for binary operators.
| [in] | type | the type of the expression |
| [in] | node_left | left child node |
| [in] | node_right | right child node |
| [out] | expression_ret | a pointer to the variable that will hold the newly created expression |
type is not a valid CCS expression type; or if type arity is not 2; or if node_left or node_right are of type CCS_DATA_TYPE_OBJECT but are neither a CCS_OBJECT_TYPE_PARAMETER nor a CCS_OBJECT_TYPE_EXPRESSION; or if node_left or node_right are not of type CCS_DATA_TYPE_OBJECT, CCS_DATA_TYPE_NONE, CCS_DATA_TYPE_INT, CCS_DATA_TYPE_FLOAT, CCS_DATA_TYPE_BOOL, or CCS_DATA_TYPE_STRING; or if expression_ret is NULL node_left or node_right are of type CCS_DATA_TYPE_OBJECT but the object is not a valid CCS object
|
extern |
Create a new expression.
| [in] | type | the type of the expression |
| [in] | num_nodes | the number of the expression children nodes. Must be compatible with the arity of the expression |
| [in] | nodes | an array of num_nodes expressions |
| [out] | expression_ret | a pointer to the variable that will hold the newly created expression |
type is not a valid CCS expression type; or if num_nodes is not compatible with the arity of type; or if one the nodes given is of type CCS_DATA_TYPE_OBJECT but is neither a CCS_OBJECT_TYPE_PARAMETER nor a CCS_OBJECT_TYPE_EXPRESSION; or if one the nodes given node is not a type CCS_DATA_TYPE_OBJECT, CCS_DATA_TYPE_NONE, CCS_DATA_TYPE_INT, CCS_DATA_TYPE_FLOAT, CCS_DATA_TYPE_BOOL, or CCS_DATA_TYPE_STRING; or if expression_ret is NULL
|
extern |
Create a new literal expression.
| [in] | value | the value of the literal |
| [out] | expression_ret | a pointer to the variable that will hold the newly created expression. If value is of type CCS_DATA_TYPE_STRING, the string value is memoized |
value is not of type CCS_DATA_TYPE_NONE, CCS_DATA_TYPE_INT, CCS_DATA_TYPE_FLOAT, CCS_DATA_TYPE_BOOL, or CCS_DATA_TYPE_STRING; or if expression_ret is NULL
|
extern |
Create a new unary expression.
Convenience wrapper around ccs_create_expression for unary expressions.
| [in] | type | the type of the expression |
| [in] | node | child node |
| [out] | expression_ret | a pointer to the variable that will hold the newly created expression |
type is not a valid CCS expression type; or if type arity is not 1; or if node is of type CCS_DATA_TYPE_OBJECT but is neither a CCS_OBJECT_TYPE_PARAMETER nor a CCS_OBJECT_TYPE_EXPRESSION; or if node is not of type CCS_DATA_TYPE_OBJECT, CCS_DATA_TYPE_NONE, CCS_DATA_TYPE_INT, CCS_DATA_TYPE_FLOAT, CCS_DATA_TYPE_BOOL, or CCS_DATA_TYPE_STRING; or if expression_ret is NULL node is of type CCS_DATA_TYPE_OBJECT but the object is not a valid CCS object
|
extern |
Create a new user defined expression.
| [in] | name | the name of the expression |
| [in] | num_nodes | the number of the expression children nodes. Must be compatible with the arity of the expression |
| [in] | nodes | an array of num_nodes expressions |
| [in] | vector | the vector of callbacks implementing the expression interface |
| [in] | expression_data | a pointer to the expression internal data structures. Can be NULL |
| [out] | expression_ret | a pointer to the variable that will hold the newly created expression |
name is NULL; or if one the nodes given is of type CCS_DATA_TYPE_OBJECT but is neither a CCS_OBJECT_TYPE_PARAMETER nor a CCS_OBJECT_TYPE_EXPRESSION; or if one the nodes given node is not a type CCS_DATA_TYPE_OBJECT, CCS_DATA_TYPE_NONE, CCS_DATA_TYPE_INT, CCS_DATA_TYPE_FLOAT, CCS_DATA_TYPE_BOOL, or CCS_DATA_TYPE_STRING; or if expression_ret is NULL; or if vector is NULL; or if any non optional interface pointer is NULL
|
extern |
Create a new variable expression.
| [in] | parameter | parameter to use as a variable |
| [out] | expression_ret | a pointer to the variable that will hold the newly created expression |
expression_ret is NULL parameter is not a valid CCS parameter
|
extern |
Validate that an expression can be evaluated in the given context.
| [in] | expression | |
| [in] | num_contexts | the number of contexts in contexts |
| [in] | contexts | an array of num_contexts contexts |
expression is not a valid CCS expression; or if one of the provided contexts in contexts is not a valid CCS context contexts is NULL contexts
|
extern |
Get the value of an expression, in a given list of bindings.
| [in] | expression | |
| [in] | num_bindings | the number of bindings in bindings |
| [in] | bindings | an array of num_bindings bindings |
| [out] | result_ret | a pointer to a variable that will contain the result of the evaluation of the expression. Result can be ccs_inactive when the result depend on an inactive parameter |
expression is not a valid CCS variable expression; of if one of the provided bindings is not a valid CCS binding; or if no binding is provided and expression must evaluate a variable result_ret is NULL; or if num_bindings is greater than 0 and bindings is NULL; or if an illegal arithmetic or comparison operation would have occurred; or if a non boolean value is used in a boolean operation
|
extern |
Get the child nodes of an expression.
| [in] | expression | |
| [in] | num_nodes | the size of the nodes array |
| [out] | nodes | an array of size num_nodes to hold the returned values or NULL. If the array is too big, extra values are set NULL |
| [out] | num_nodes_ret | a pointer to a variable that will contain the number of nodes that are or would be returned. Can be NULL |
expression is not a valid CCS expression nodes is NULL and num_nodes is greater than 0; or if nodes is NULL and num_nodes_ret is NULL; or if num_values is less than the number of values that would be returned
|
extern |
Get the parameters used in an expression.
| [in] | expression | |
| [in] | num_parameters | the size of the parameters array |
| [in] | parameters | an array of size num_parameters to hold the returned values, or NULL. If the array is too big, extra values are set to NULL |
| [out] | num_parameters_ret | a pointer to a variable that will contain the number of parameters that are or would be returned. Can be NULL |
expression is not a valid CCS expression parameters is NULL and num_parameters is greater than 0; or if parameters is NULL and num_parameters_ret is NULL; or if num_parameters is less than the number of parameters that would be returned
|
extern |
Get the type of an expression.
| [in] | expression | |
| [out] | type_ret | a pointer to the variable that will contain the type of the expression |
type_ret is NULL expression is not a valid CCS expression
|
extern |
Evaluate the entry of a list at a given index, in a given context, provided a list of values for the context parameters.
| [in] | expression | |
| [in] | num_bindings | the number of bindings in bindings |
| [in] | bindings | an array of num_bindings bindings |
| [in] | index | index of the child node to evaluate |
| [out] | result_ret | a pointer to a variable that will contain the result of the evaluation of the expression. Result can be ccs_inactive when the result depend on an inactive parameter |
expression is not a valid CCS variable expression; of if one of the provided bindings is not a valid CCS binding; or if no binding is provided and expression must evaluate a variable expression is not a CCS_EXPRESSION_TYPE_LIST index is greater than the number of child nodes in the list result_ret is NULL; or if num_bindings is greater than 0 and bindings is NULL; or if an illegal arithmetic or comparison operation would have occurred; or if a non boolean value is used in a boolean operation
|
extern |
Get the value of a literal expression.
| [in] | expression | |
| [out] | value_ret | a pointer to a variable that will contain the value of the literal |
expression is not a valid CCS expression expression is not a CCS_EXPRESSION_TYPE_LITERAL value_ret is NULL
|
extern |
Get the user defined expression internal data pointer.
| [in] | expression | |
| [out] | expression_data_ret |
expression is not a valid CCS expression expression is not a user defined expression expression_data_ret is NULL
|
extern |
Get the name of a user defined expression.
| [in] | expression | |
| [out] | name_ret | a pointer to the variable that will contain a pointer to the name of the expression |
name_ret is NULL expression is not a valid CCS expression expression is not a user defined expression
|
extern |
Get the parameter of a variable expression.
| [in] | expression | |
| [out] | parameter_ret | a pointer to a variable that will contain the parameter |
expression is not a valid CCS expression expression is not a CCS_EXPRESSION_TYPE_VARIABLE parameter_ret is NULL
|
extern |
An array of arity of CCS operators.
|
extern |
An array of associativity of operators as defined by CCS grammar:
|
extern |
An array of precedence of operators as defined by CCS grammar:
Those are similar to C's precedence
|
extern |
An array of suggested symbols (NULL terminated strings) for CCS operators.
|
extern |
An array of integers defining terminal precedence in order to disambiguate NONE, TRUE and FALSE from identifiers:
|
extern |
An array of regexp that define terminals:
|
extern |
An array of symbols (NULL terminated strings) for terminals that define them: