QuakeForge  0.7.2.210-815cf
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Expressions

Modules

 Constant values.
 

Data Structures

struct  ex_block_t
 
struct  ex_bool_t
 
struct  ex_expr_s
 Binary and unary expressions. More...
 
struct  ex_func_s
 
struct  ex_label_s
 
struct  ex_labelref_t
 
struct  ex_list_t
 
struct  ex_pointer_s
 Pointer constant expression. More...
 
struct  ex_state_t
 State expression used for think function state-machines. More...
 
struct  ex_temp_t
 
struct  ex_value_s
 
struct  ex_vector_t
 
struct  expr_s
 

Macros

#define POINTER_VAL(p)   (((p).def ? (p).def->offset : 0) + (p).val)
 

Typedefs

typedef struct ex_expr_s ex_expr_t
 Binary and unary expressions. More...
 
typedef struct ex_func_s ex_func_t
 
typedef struct ex_label_s ex_label_t
 
typedef struct ex_pointer_s ex_pointer_t
 Pointer constant expression. More...
 
typedef struct ex_value_s ex_value_t
 
typedef struct expr_s expr_t
 

Enumerations

enum  expr_type {
  ex_error, ex_state, ex_bool, ex_label,
  ex_labelref, ex_block, ex_expr, ex_uexpr,
  ex_symbol, ex_temp, ex_vector, ex_nil,
  ex_value
}
 Type of the exression node in an expression tree. More...
 

Functions

expr_taddress_expr (expr_t *e1, expr_t *e2, struct type_s *t)
 
expr_tappend_expr (expr_t *block, expr_t *e)
 
expr_tarray_expr (expr_t *array, expr_t *index)
 
expr_tassign_expr (expr_t *e1, expr_t *e2)
 
expr_tasx_expr (int op, expr_t *e1, expr_t *e2)
 
void backpatch (ex_list_t *list, expr_t *label)
 
expr_tbinary_expr (int op, expr_t *e1, expr_t *e2)
 
expr_tbool_expr (int op, expr_t *label, expr_t *e1, expr_t *e2)
 
expr_tbranch_expr (int op, expr_t *test, expr_t *label)
 
expr_tbuild_do_while_statement (expr_t *statement, int not, expr_t *test, expr_t *break_label, expr_t *continue_label)
 
expr_tbuild_for_statement (expr_t *init, expr_t *test, expr_t *next, expr_t *statement, expr_t *break_label, expr_t *continue_label)
 
expr_tbuild_function_call (expr_t *fexpr, struct type_s *ftype, expr_t *params)
 
expr_tbuild_if_statement (int not, expr_t *test, expr_t *s1, expr_t *els, expr_t *s2)
 
expr_tbuild_state_expr (expr_t *e)
 
expr_tbuild_while_statement (int not, expr_t *test, expr_t *statement, expr_t *break_label, expr_t *continue_label)
 
expr_tcast_error (expr_t *e, struct type_s *t1, struct type_s *t2)
 
expr_tcast_expr (struct type_s *t, expr_t *e)
 
expr_tconditional_expr (expr_t *cond, expr_t *e1, expr_t *e2)
 
expr_tconstant_expr (expr_t *e)
 Return a value expression representing the constant stored in e. More...
 
expr_tconvert_bool (expr_t *e, int block)
 
expr_tconvert_from_bool (expr_t *e, struct type_s *type)
 
void convert_int (expr_t *e)
 
void convert_name (expr_t *e)
 Convert a name to an expression of the appropriate type. More...
 
void convert_nil (expr_t *e, struct type_s *t)
 
void convert_short (expr_t *e)
 
void convert_short_int (expr_t *e)
 
expr_tconvert_vector (expr_t *e)
 
expr_tcopy_expr (expr_t *e)
 Create a deep copy of an expression tree. More...
 
void dump_dot_expr (void *e, const char *filename)
 
expr_tencode_expr (struct type_s *type)
 
float expr_float (expr_t *e)
 
int expr_integer (expr_t *e)
 
const float * expr_quaternion (expr_t *e)
 
short expr_short (expr_t *e)
 
const char * expr_string (expr_t *e)
 
unsigned expr_uinteger (expr_t *e)
 
const float * expr_vector (expr_t *e)
 
etype_t extract_type (expr_t *e)
 Get the basic type code of the expression result. More...
 
expr_tfield_expr (expr_t *e1, expr_t *e2)
 
expr_tfold_constants (expr_t *e)
 
expr_tfunction_expr (expr_t *e1, expr_t *e2)
 
const char * get_op_string (int op)
 
struct type_sget_type (expr_t *e)
 Get the type descriptor of the expression result. More...
 
expr_tgoto_expr (expr_t *label)
 
int has_function_call (expr_t *e)
 
expr_tincop_expr (int op, expr_t *e, int postop)
 
int is_compare (int op)
 Check if the op-code is a comparison. More...
 
int is_constant (expr_t *e)
 Check of the expression refers to a constant value. More...
 
int is_float_val (expr_t *e)
 
int is_integer_val (expr_t *e)
 
int is_logic (int op)
 Check if the op-code is a logic operator. More...
 
int is_math_op (int op)
 Check if the op-code is a math operator. More...
 
int is_quaternion_val (expr_t *e)
 
int is_short_val (expr_t *e)
 
int is_string_val (expr_t *e)
 
int is_vector_val (expr_t *e)
 
expr_tmessage_expr (expr_t *receiver, struct keywordarg_s *message)
 
expr_tnew_alias_expr (struct type_s *type, expr_t *expr)
 
expr_tnew_binary_expr (int op, expr_t *e1, expr_t *e2)
 Create a new binary expression node node. More...
 
expr_tnew_block_expr (void)
 Create a new statement block expression node. More...
 
expr_tnew_bool_expr (ex_list_t *true_list, ex_list_t *false_list, expr_t *e)
 
expr_tnew_entity_expr (int entity_val)
 Create a new entity constant expression node. More...
 
expr_tnew_expr (void)
 Create a new expression node. More...
 
expr_tnew_field_expr (int field_val, struct type_s *type, struct def_s *def)
 Create a new field constant expression node. More...
 
expr_tnew_float_expr (float float_val)
 Create a new float constant expression node. More...
 
expr_tnew_func_expr (int func_val, struct type_s *type)
 Create a new function constant expression node. More...
 
expr_tnew_integer_expr (int integer_val)
 Create a new integer constant expression node. More...
 
expr_tnew_label_expr (void)
 Create a new label expression node. More...
 
const char * new_label_name (void)
 Create a new label name. More...
 
expr_tnew_label_ref (ex_label_t *label)
 Create a new label reference expression node. More...
 
expr_tnew_move_expr (expr_t *e1, expr_t *e2, struct type_s *type, int indirect)
 Create an expression representing a block copy. More...
 
expr_tnew_name_expr (const char *name)
 Create a new symbol expression node from a name. More...
 
expr_tnew_nil_expr (void)
 Create a new nil expression node. More...
 
expr_tnew_param_expr (struct type_s *type, int num)
 Create an expression of the correct type that references the specified parameter slot. More...
 
expr_tnew_pointer_expr (int val, struct type_s *type, struct def_s *def)
 Create a new pointer constant expression node. More...
 
expr_tnew_quaternion_expr (const float *quaternion_val)
 Create a new quaternion constant expression node. More...
 
expr_tnew_ret_expr (struct type_s *type)
 Create an expression of the correct type that references the return slot. More...
 
expr_tnew_self_expr (void)
 Create a reference to the global .self entity variable. More...
 
expr_tnew_short_expr (short short_val)
 Create a new short constant expression node. More...
 
expr_tnew_state_expr (expr_t *frame, expr_t *think, expr_t *step)
 Create a new state expression node. More...
 
expr_tnew_string_expr (const char *string_val)
 Create a new string constant expression node. More...
 
expr_tnew_symbol_expr (struct symbol_s *symbol)
 Create a new symbol reference (non-temporary variable) expression node. More...
 
expr_tnew_temp_def_expr (struct type_s *type)
 Create a new temporary variable expression node. More...
 
expr_tnew_this_expr (void)
 Create a reference to the .this entity field. More...
 
expr_tnew_uinteger_expr (unsigned uinteger_val)
 Create a new integer constant expression node. More...
 
expr_tnew_unary_expr (int op, expr_t *e1)
 Create a new unary expression node node. More...
 
expr_tnew_value_expr (ex_value_t *value)
 Create a new value expression node. More...
 
expr_tnew_vector_expr (const float *vector_val)
 Create a new vector constant expression node. More...
 
expr_tnew_vector_list (expr_t *e)
 
expr_tparam_mismatch (expr_t *e, int param, const char *fn, struct type_s *t1, struct type_s *t2)
 
expr_tpointer_expr (expr_t *pointer)
 
void print_expr (expr_t *e)
 
expr_tprotocol_expr (const char *protocol)
 
expr_treturn_expr (struct function_s *f, expr_t *e)
 
expr_treverse_expr_list (expr_t *e)
 
expr_tselector_expr (struct keywordarg_s *selector)
 
expr_tsizeof_expr (expr_t *expr, struct type_s *type)
 
expr_tsuper_expr (struct class_type_s *class_type)
 
expr_ttest_error (expr_t *e, struct type_s *t)
 
expr_ttest_expr (expr_t *e)
 
expr_tthink_expr (struct symbol_s *think_sym)
 
expr_ttype_mismatch (expr_t *e1, expr_t *e2, int op)
 Report a type mismatch error. More...
 
expr_tunary_expr (int op, expr_t *e)
 

Variables

struct type_sev_types []
 
expr_tlocal_expr
 

Detailed Description

Macro Definition Documentation

#define POINTER_VAL (   p)    (((p).def ? (p).def->offset : 0) + (p).val)

Typedef Documentation

typedef struct ex_expr_s ex_expr_t

Binary and unary expressions.

This is used for both binary and unary expressions. Unary expressions do not use e2. The opcode is generally the parser token for the expression, though special codes are used for non-math expressions.

typedef struct ex_func_s ex_func_t
typedef struct ex_label_s ex_label_t
typedef struct ex_pointer_s ex_pointer_t

Pointer constant expression.

Represent a pointer to an absolute address in data space.

typedef struct ex_value_s ex_value_t
typedef struct expr_s expr_t

Enumeration Type Documentation

enum expr_type

Type of the exression node in an expression tree.

Enumerator
ex_error 

error expression. used to signal an error

ex_state 

state expression (ex_state_t)

ex_bool 

short circuit boolean logic expression (ex_bool_t)

ex_label 

goto/branch label (ex_label_t)

ex_labelref 

label reference (ex_labelref_t)

ex_block 

statement block expression (ex_block_t)

ex_expr 

binary expression (ex_expr_t)

ex_uexpr 

unary expression (ex_expr_t)

ex_symbol 

non-temporary variable (symbol_t)

ex_temp 

temporary variable (ex_temp_t)

ex_vector 

"vector" expression (ex_vector_t)

ex_nil 

umm, nil, null. nuff said (0 of any type)

ex_value 

constant value (ex_value_t)

Function Documentation

expr_t* address_expr ( expr_t e1,
expr_t e2,
struct type_s t 
)
expr_t* append_expr ( expr_t block,
expr_t e 
)
expr_t* array_expr ( expr_t array,
expr_t index 
)
expr_t* assign_expr ( expr_t e1,
expr_t e2 
)
expr_t* asx_expr ( int  op,
expr_t e1,
expr_t e2 
)
void backpatch ( ex_list_t list,
expr_t label 
)
expr_t* binary_expr ( int  op,
expr_t e1,
expr_t e2 
)
expr_t* bool_expr ( int  op,
expr_t label,
expr_t e1,
expr_t e2 
)
expr_t* branch_expr ( int  op,
expr_t test,
expr_t label 
)
expr_t* build_do_while_statement ( expr_t statement,
int  not,
expr_t test,
expr_t break_label,
expr_t continue_label 
)
expr_t* build_for_statement ( expr_t init,
expr_t test,
expr_t next,
expr_t statement,
expr_t break_label,
expr_t continue_label 
)
expr_t* build_function_call ( expr_t fexpr,
struct type_s ftype,
expr_t params 
)
expr_t* build_if_statement ( int  not,
expr_t test,
expr_t s1,
expr_t els,
expr_t s2 
)
expr_t* build_state_expr ( expr_t e)
expr_t* build_while_statement ( int  not,
expr_t test,
expr_t statement,
expr_t break_label,
expr_t continue_label 
)
expr_t* cast_error ( expr_t e,
struct type_s t1,
struct type_s t2 
)
expr_t* cast_expr ( struct type_s t,
expr_t e 
)
expr_t* conditional_expr ( expr_t cond,
expr_t e1,
expr_t e2 
)
expr_t* constant_expr ( expr_t e)

Return a value expression representing the constant stored in e.

If e does not represent a constant, or e is already a value or nil expression, then e is returned rather than a new expression.

Parameters
eThe expression from which to extract the value.
Returns
A new expression holding the value of e or itself.
expr_t* convert_bool ( expr_t e,
int  block 
)
expr_t* convert_from_bool ( expr_t e,
struct type_s type 
)
void convert_int ( expr_t e)
void convert_name ( expr_t e)

Convert a name to an expression of the appropriate type.

Converts the expression in-place. If the exprssion is not a name expression (ex_name), no converision takes place.

Parameters
eThe expression to convert.
void convert_nil ( expr_t e,
struct type_s t 
)
void convert_short ( expr_t e)
void convert_short_int ( expr_t e)
expr_t* convert_vector ( expr_t e)
expr_t* copy_expr ( expr_t e)

Create a deep copy of an expression tree.

Parameters
eThe root of the expression tree to copy.
Returns
A new expression tree giving the same expression.

Create a fresh label

void dump_dot_expr ( void *  e,
const char *  filename 
)
expr_t* encode_expr ( struct type_s type)
float expr_float ( expr_t e)
int expr_integer ( expr_t e)
const float* expr_quaternion ( expr_t e)
short expr_short ( expr_t e)
const char* expr_string ( expr_t e)
unsigned expr_uinteger ( expr_t e)
const float* expr_vector ( expr_t e)
etype_t extract_type ( expr_t e)

Get the basic type code of the expression result.

Parameters
eThe expression from which to get the result type.
Returns
Pointer to the type description, or ev_type_count if get_type() returns null.
expr_t* field_expr ( expr_t e1,
expr_t e2 
)
expr_t* fold_constants ( expr_t e)
expr_t* function_expr ( expr_t e1,
expr_t e2 
)
const char* get_op_string ( int  op)
struct type_s* get_type ( expr_t e)

Get the type descriptor of the expression result.

Parameters
eThe expression from which to get the result type.
Returns
Pointer to the type description, or null if the expression type (expr_t::type) is inappropriate.
expr_t* goto_expr ( expr_t label)
int has_function_call ( expr_t e)
expr_t* incop_expr ( int  op,
expr_t e,
int  postop 
)
int is_compare ( int  op)

Check if the op-code is a comparison.

Parameters
opThe op-code to check.
Returns
True if the op-code is a comparison operator.
int is_constant ( expr_t e)

Check of the expression refers to a constant value.

Parameters
eThe expression to check.
Returns
True if the expression is constant.
int is_float_val ( expr_t e)
int is_integer_val ( expr_t e)
int is_logic ( int  op)

Check if the op-code is a logic operator.

Parameters
opThe op-code to check.
Returns
True if the op-code is a logic operator.
int is_math_op ( int  op)

Check if the op-code is a math operator.

Parameters
opThe op-code to check.
Returns
True if the op-code is a math operator.
int is_quaternion_val ( expr_t e)
int is_short_val ( expr_t e)
int is_string_val ( expr_t e)
int is_vector_val ( expr_t e)
expr_t* message_expr ( expr_t receiver,
struct keywordarg_s message 
)
expr_t* new_alias_expr ( struct type_s type,
expr_t expr 
)
expr_t* new_binary_expr ( int  op,
expr_t e1,
expr_t e2 
)

Create a new binary expression node node.

If either e1 or e2 are error expressions, then that expression will be returned instead of a new binary expression.

Parameters
opThe op-ccode of the binary expression.
e1The left side of the binary expression.
e2The right side of the binary expression.
Returns
The new binary expression node (ex_expr_t) if neither e1 nor e2 are error expressions, otherwise the expression that is an error expression.
expr_t* new_block_expr ( void  )

Create a new statement block expression node.

The returned block expression is empty. Use append_expr() to add expressions to the block expression.

Returns
The new block expression (ex_block_t) node.
expr_t* new_bool_expr ( ex_list_t true_list,
ex_list_t false_list,
expr_t e 
)
expr_t* new_entity_expr ( int  entity_val)

Create a new entity constant expression node.

Parameters
entity_valThe entity constant being represented.
Returns
The new entity constant expression node (expr_t::e::entity_val).
expr_t* new_expr ( void  )

Create a new expression node.

Sets the source file and line number information. The expression node is otherwise raw. This function is generally not used directly.

Returns
The new expression node.
expr_t* new_field_expr ( int  field_val,
struct type_s type,
struct def_s def 
)

Create a new field constant expression node.

Parameters
field_valXXX
typeThe type of the field.
def
Returns
The new field constant expression node (expr_t::e::field_val).
expr_t* new_float_expr ( float  float_val)

Create a new float constant expression node.

Parameters
float_valThe float constant being represented.
Returns
The new float constant expression node (expr_t::e::float_val).
expr_t* new_func_expr ( int  func_val,
struct type_s type 
)

Create a new function constant expression node.

Parameters
func_valThe function constant being represented.
typeThe type of the function
Returns
The new function constant expression node (expr_t::e::func_val).
expr_t* new_integer_expr ( int  integer_val)

Create a new integer constant expression node.

Parameters
integer_valThe integer constant being represented.
Returns
The new integer constant expression node (expr_t::e::integer_val).
expr_t* new_label_expr ( void  )

Create a new label expression node.

The label name is set using new_label_name().

Returns
The new label expression (ex_label_t) node.
const char* new_label_name ( void  )

Create a new label name.

The label name is guaranteed to to the compilation. It is made up of the name of the current function plus an incrementing number. The number is not reset between functions.

Returns
The string representing the label name.
expr_t* new_label_ref ( ex_label_t label)

Create a new label reference expression node.

Used for taking the address of a label (eg. jump tables). The label's used field is incremented.

Returns
The new label reference expression (ex_labelref_t) node.
expr_t* new_move_expr ( expr_t e1,
expr_t e2,
struct type_s type,
int  indirect 
)

Create an expression representing a block copy.

This is used for structure assignments.

Parameters
e1Destination of move.
e2Source of move.
typetype giving size of move.
indirectMove uses dereferenced pointers.
Returns
A new expression representing the move.
expr_t* new_name_expr ( const char *  name)

Create a new symbol expression node from a name.

Parameters
nameThe name for the symbol.
Returns
The new symbol expression.
expr_t* new_nil_expr ( void  )

Create a new nil expression node.

nil represents 0 of any type.

Returns
The new nil expression node.
expr_t* new_param_expr ( struct type_s type,
int  num 
)

Create an expression of the correct type that references the specified parameter slot.

Parameters
typeThe type of the reference to the parameter slot.
numThe index of the parameter (0-7).
Returns
A new expression referencing the parameter slot.
expr_t* new_pointer_expr ( int  val,
struct type_s type,
struct def_s def 
)

Create a new pointer constant expression node.

Parameters
valThe pointer constant (address) being represented. XXX
typeThe type of the referenced value.
def
Returns
The new pointer constant expression node (expr_t::e::pointer_val).
expr_t* new_quaternion_expr ( const float *  quaternion_val)

Create a new quaternion constant expression node.

Parameters
quaternion_valThe quaternion constant being represented.
Returns
The new quaternion constant expression node (expr_t::e::quaternion_val).
expr_t* new_ret_expr ( struct type_s type)

Create an expression of the correct type that references the return slot.

Parameters
typeThe type of the reference to the return slot.
Returns
A new expression referencing the return slot.
expr_t* new_self_expr ( void  )

Create a reference to the global .self entity variable.

This is used for @self.

Returns
A new expression referencing the .self def.
expr_t* new_short_expr ( short  short_val)

Create a new short constant expression node.

Parameters
short_valThe short constant being represented.
Returns
The new short constant expression node (expr_t::e::short_val).
expr_t* new_state_expr ( expr_t frame,
expr_t think,
expr_t step 
)

Create a new state expression node.

The label name is set using new_label_name(), and the label is linked into the global list of labels for later resolution.

Parameters
frameThe expression giving the frame number.
thinkThe expression giving the think function.
stepThe expression giving the time step value, or null if no time-step is specified (standard form).
Returns
The new state expression (ex_state_t) node.
expr_t* new_string_expr ( const char *  string_val)

Create a new string constant expression node.

Parameters
string_valThe string constant being represented.
Returns
The new string constant expression node (expr_t::e::string_val).
expr_t* new_symbol_expr ( struct symbol_s symbol)

Create a new symbol reference (non-temporary variable) expression node.

Returns
The new symbol reference expression node (symbol_t).
expr_t* new_temp_def_expr ( struct type_s type)

Create a new temporary variable expression node.

Does not allocate a new temporary variable. The ex_temp_t::users field will be 0.

Parameters
typeThe type of the temporary variable.
Returns
The new temporary variable expression node (ex_temp_t).
expr_t* new_this_expr ( void  )

Create a reference to the .this entity field.

This is used for @this.

Returns
A new expression referencing the .this def.
expr_t* new_uinteger_expr ( unsigned  uinteger_val)

Create a new integer constant expression node.

Parameters
uinteger_valThe integer constant being represented.
Returns
The new integer constant expression node (expr_t::e::integer_val).
expr_t* new_unary_expr ( int  op,
expr_t e1 
)

Create a new unary expression node node.

If e1 is an error expression, then it will be returned instead of a new binary expression.

Parameters
opThe op-code of the unary expression.
e1The "right" side of the expression.
Returns
The new unary expression node (ex_expr_t) if e1 is not an error expression, otherwise e1.
expr_t* new_value_expr ( ex_value_t value)

Create a new value expression node.

Parameters
valueThe value to put in the expression node.
Returns
The new value expression.
expr_t* new_vector_expr ( const float *  vector_val)

Create a new vector constant expression node.

Parameters
vector_valThe vector constant being represented.
Returns
The new vector constant expression node (expr_t::e::vector_val).
expr_t* new_vector_list ( expr_t e)
expr_t* param_mismatch ( expr_t e,
int  param,
const char *  fn,
struct type_s t1,
struct type_s t2 
)
expr_t* pointer_expr ( expr_t pointer)
void print_expr ( expr_t e)
expr_t* protocol_expr ( const char *  protocol)
expr_t* return_expr ( struct function_s f,
expr_t e 
)
expr_t* reverse_expr_list ( expr_t e)
expr_t* selector_expr ( struct keywordarg_s selector)
expr_t* sizeof_expr ( expr_t expr,
struct type_s type 
)
expr_t* super_expr ( struct class_type_s class_type)
expr_t* test_error ( expr_t e,
struct type_s t 
)
expr_t* test_expr ( expr_t e)
expr_t* think_expr ( struct symbol_s think_sym)
expr_t* type_mismatch ( expr_t e1,
expr_t e2,
int  op 
)

Report a type mismatch error.

e1 is used for reporting the file and line number of the error.

Parameters
e1Left side expression. Used for reporting the type.
e2Right side expression. Used for reporting the type.
opThe opcode of the expression.
Returns
e1 with its type set to ex_error.
expr_t* unary_expr ( int  op,
expr_t e 
)

Variable Documentation

struct type_s* ev_types[]
expr_t* local_expr