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_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. More... | |
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. 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_t * | convert_vector (expr_t *e) |
expr_t * | copy_expr (expr_t *e) |
Create a deep copy of an expression tree. More... | |
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. More... | |
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. More... | |
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. 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_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. More... | |
expr_t * | new_block_expr (void) |
Create a new statement block expression node. More... | |
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. More... | |
expr_t * | new_expr (void) |
Create a new expression node. More... | |
expr_t * | new_field_expr (int field_val, struct type_s *type, struct def_s *def) |
Create a new field constant expression node. More... | |
expr_t * | new_float_expr (float float_val) |
Create a new float constant expression node. More... | |
expr_t * | new_func_expr (int func_val, struct type_s *type) |
Create a new function constant expression node. More... | |
expr_t * | new_integer_expr (int integer_val) |
Create a new integer constant expression node. More... | |
expr_t * | new_label_expr (void) |
Create a new label expression node. More... | |
const char * | new_label_name (void) |
Create a new label name. More... | |
expr_t * | new_label_ref (ex_label_t *label) |
Create a new label reference expression node. More... | |
expr_t * | new_move_expr (expr_t *e1, expr_t *e2, struct type_s *type, int indirect) |
Create an expression representing a block copy. More... | |
expr_t * | new_name_expr (const char *name) |
Create a new symbol expression node from a name. More... | |
expr_t * | new_nil_expr (void) |
Create a new nil expression node. More... | |
expr_t * | new_param_expr (struct type_s *type, int num) |
Create an expression of the correct type that references the specified parameter slot. More... | |
expr_t * | new_pointer_expr (int val, struct type_s *type, struct def_s *def) |
Create a new pointer constant expression node. More... | |
expr_t * | new_quaternion_expr (const float *quaternion_val) |
Create a new quaternion constant expression node. More... | |
expr_t * | new_ret_expr (struct type_s *type) |
Create an expression of the correct type that references the return slot. More... | |
expr_t * | new_self_expr (void) |
Create a reference to the global .self entity variable. More... | |
expr_t * | new_short_expr (short short_val) |
Create a new short constant expression node. More... | |
expr_t * | new_state_expr (expr_t *frame, expr_t *think, expr_t *step) |
Create a new state expression node. More... | |
expr_t * | new_string_expr (const char *string_val) |
Create a new string constant expression node. More... | |
expr_t * | new_symbol_expr (struct symbol_s *symbol) |
Create a new symbol reference (non-temporary variable) expression node. More... | |
expr_t * | new_temp_def_expr (struct type_s *type) |
Create a new temporary variable expression node. More... | |
expr_t * | new_this_expr (void) |
Create a reference to the .this entity field. More... | |
expr_t * | new_uinteger_expr (unsigned uinteger_val) |
Create a new integer constant expression node. More... | |
expr_t * | new_unary_expr (int op, expr_t *e1) |
Create a new unary expression node node. More... | |
expr_t * | new_value_expr (ex_value_t *value) |
Create a new value expression node. More... | |
expr_t * | new_vector_expr (const float *vector_val) |
Create a new vector constant expression node. More... | |
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. More... | |
expr_t * | unary_expr (int op, expr_t *e) |
Variables | |
struct type_s * | ev_types [] |
expr_t * | local_expr |
#define POINTER_VAL | ( | p | ) | (((p).def ? (p).def->offset : 0) + (p).val) |
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_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 |
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) |
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_while_statement | ( | int | not, |
expr_t * | test, | ||
expr_t * | statement, | ||
expr_t * | break_label, | ||
expr_t * | continue_label | ||
) |
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.
e | The expression from which to extract the value. |
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.
e | The expression to convert. |
void convert_short | ( | expr_t * | e | ) |
void convert_short_int | ( | expr_t * | e | ) |
Create a deep copy of an expression tree.
e | The root of the expression tree to copy. |
Create a fresh label
void dump_dot_expr | ( | void * | e, |
const char * | filename | ||
) |
float expr_float | ( | expr_t * | e | ) |
short expr_short | ( | expr_t * | e | ) |
unsigned expr_uinteger | ( | expr_t * | e | ) |
Get the basic type code of the expression result.
e | The expression from which to get the result type. |
Get the type descriptor of the expression result.
e | The expression from which to get the result type. |
Check if the op-code is a comparison.
op | The op-code to check. |
Check of the expression refers to a constant value.
e | The expression to check. |
Check if the op-code is a logic operator.
op | The op-code to check. |
Check if the op-code is a math operator.
op | The op-code to check. |
expr_t* message_expr | ( | expr_t * | receiver, |
struct keywordarg_s * | message | ||
) |
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.
op | The op-ccode of the binary expression. |
e1 | The left side of the binary expression. |
e2 | The right side of the binary 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.
Create a new entity constant expression node.
entity_val | The entity constant being represented. |
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.
Create a new field constant expression node.
field_val | XXX |
type | The type of the field. |
def |
expr_t* new_float_expr | ( | float | float_val | ) |
Create a new float constant expression node.
float_val | The float constant being represented. |
Create a new function constant expression node.
func_val | The function constant being represented. |
type | The type of the function |
Create a new integer constant expression node.
integer_val | The integer constant being represented. |
expr_t* new_label_expr | ( | void | ) |
Create a new label expression node.
The label name is set using new_label_name().
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.
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.
Create an expression representing a block copy.
This is used for structure assignments.
e1 | Destination of move. |
e2 | Source of move. |
type | type giving size of move. |
indirect | Move uses dereferenced pointers. |
Create a new symbol expression node from a name.
name | The name for the symbol. |
expr_t* new_nil_expr | ( | void | ) |
Create a new nil expression node.
nil represents 0 of any type.
Create an expression of the correct type that references the specified parameter slot.
type | The type of the reference to the parameter slot. |
num | The index of the parameter (0-7). |
Create a new pointer constant expression node.
val | The pointer constant (address) being represented. XXX |
type | The type of the referenced value. |
def |
Create a new quaternion constant expression node.
quaternion_val | The quaternion constant being represented. |
Create an expression of the correct type that references the return slot.
type | The type of the reference to the return slot. |
expr_t* new_self_expr | ( | void | ) |
Create a reference to the global .self
entity variable.
This is used for @self
.
.self
def. expr_t* new_short_expr | ( | short | short_val | ) |
Create a new short constant expression node.
short_val | The short constant being represented. |
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.
frame | The expression giving the frame number. |
think | The expression giving the think function. |
step | The expression giving the time step value, or null if no time-step is specified (standard form). |
Create a new string constant expression node.
string_val | The string constant being represented. |
Create a new symbol reference (non-temporary variable) expression node.
Create a new temporary variable expression node.
Does not allocate a new temporary variable. The ex_temp_t::users field will be 0.
type | The type of the temporary variable. |
expr_t* new_this_expr | ( | void | ) |
Create a reference to the .this
entity field.
This is used for @this
.
.this
def. expr_t* new_uinteger_expr | ( | unsigned | uinteger_val | ) |
Create a new integer constant expression node.
uinteger_val | The integer constant being represented. |
Create a new unary expression node node.
If e1 is an error expression, then it will be returned instead of a new binary expression.
op | The op-code of the unary expression. |
e1 | The "right" side of the expression. |
expr_t* new_value_expr | ( | ex_value_t * | value | ) |
Create a new value expression node.
value | The value to put in the expression node. |
Create a new vector constant expression node.
vector_val | The vector constant being represented. |
expr_t* param_mismatch | ( | expr_t * | e, |
int | param, | ||
const char * | fn, | ||
struct type_s * | t1, | ||
struct type_s * | t2 | ||
) |
void print_expr | ( | expr_t * | e | ) |
expr_t* return_expr | ( | struct function_s * | f, |
expr_t * | e | ||
) |
expr_t* selector_expr | ( | struct keywordarg_s * | selector | ) |
expr_t* super_expr | ( | struct class_type_s * | class_type | ) |
Report a type mismatch error.
e1 is used for reporting the file and line number of the error.
e1 | Left side expression. Used for reporting the type. |
e2 | Right side expression. Used for reporting the type. |
op | The opcode of the expression. |
struct type_s* ev_types[] |
expr_t* local_expr |