quakeforge/tools/qfcc/include/expr.h

119 lines
2.5 KiB
C
Raw Normal View History

typedef enum {
ex_label,
ex_block,
ex_expr, // binary expression
ex_uexpr, // unary expression
ex_def,
ex_temp, // temporary variable
ex_nil, // umm, nil, null. nuff said
ex_name,
ex_string,
ex_float,
ex_vector,
ex_entity,
ex_field,
ex_func,
ex_pointer,
ex_quaternion,
ex_integer,
ex_uinteger,
ex_short,
} expr_type;
typedef struct {
statref_t *refs;
dstatement_t *statement;
const char *name;
2001-08-11 21:46:02 +00:00
} elabel_t;
typedef struct {
struct expr_s *head;
struct expr_s **tail;
struct expr_s *result;
int is_call;
} block_t;
typedef struct {
struct expr_s *expr;
def_t *def;
type_t *type;
int users;
} temp_t;
typedef struct expr_s {
struct expr_s *next;
expr_type type;
int line;
string_t file;
2001-06-28 15:20:31 +00:00
int paren;
union {
2001-08-11 21:46:02 +00:00
elabel_t label;
block_t block;
struct {
int op;
type_t *type;
struct expr_s *e1;
struct expr_s *e2;
} expr;
def_t *def;
temp_t temp;
const char *string_val;
float float_val;
float vector_val[3];
int entity_val;
int field_val;
int func_val;
int pointer_val;
float quaternion_val[4];
Initial integer type support. qfcc /is/ partially broken when it comes to integer constants and float function args/return values. pr_comp.h: o add the integer opcodes to pr_opcode_e pr_edict.c: o add "quaternion" and "integer" to type_name[] o support quatnernion and integers types when printing values o support the integer opcodes when bounds checking pr_exec.c o enable the integer opcodes pr_opcode: o add the integer opcodes to the opcode table o logical operators all result in an integer rather than a value expr.h: o rename int_val to integer_val qfcc.h: o kill another magic number expr.c: o move the opcode to string conversion out of type_mismatch and into get_op_string o rename int_val to integer_val o general integer type support. o generate an internal comipiler error for null opcodes rather than segging. pr_imm.c: o rename int_val to integer_val o support integer constants, converting to float when needed. pr_lex.c: o magic number death and support quaternions and integers in type_size[] qc-lex.l o rename int_val to integer_val o support quaternion and integer type keywords qc-parse.y: o rename int_val to integer_val o use binary_expr instead of new_binary_expr for local initialized variables builtins.c: o rename int_val to integer_val o fix most (all?) of the INT related FIXMEs defs.qc: o use integer instead of float where it makes sense main.c: o read_result is now integer rather than float main.qc: o float -> integer where appropriate o new test for int const to float arg
2001-07-23 01:31:22 +00:00
int integer_val;
unsigned int uinteger_val;
short short_val;
} e;
} expr_t;
extern etype_t qc_types[];
extern struct type_s *types[];
extern expr_type expr_types[];
type_t *get_type (expr_t *e);
etype_t extract_type (expr_t *e);
expr_t *new_expr (void);
const char *new_label_name (void);
2001-06-26 02:46:02 +00:00
expr_t *new_label_expr (void);
expr_t *new_block_expr (void);
2001-06-26 02:46:02 +00:00
expr_t *new_binary_expr (int op, expr_t *e1, expr_t *e2);
expr_t *new_unary_expr (int op, expr_t *e1);
expr_t *new_temp_def_expr (type_t *type);
expr_t *new_bind_expr (expr_t *e1, expr_t *e2);
void inc_users (expr_t *e);
expr_t *append_expr (expr_t *block, expr_t *e);
void print_expr (expr_t *e);
void convert_int (expr_t *e);
expr_t *test_expr (expr_t *e, int test);
expr_t *binary_expr (int op, expr_t *e1, expr_t *e2);
expr_t *asx_expr (int op, expr_t *e1, expr_t *e2);
expr_t *unary_expr (int op, expr_t *e);
expr_t *function_expr (expr_t *e1, expr_t *e2);
2001-07-23 02:27:46 +00:00
expr_t *return_expr (function_t *f, expr_t *e);
expr_t *conditional_expr (expr_t *cond, expr_t *e1, expr_t *e2);
expr_t *incop_expr (int op, expr_t *e, int postop);
expr_t *array_expr (expr_t *array, expr_t *index);
def_t *emit_statement (int line, opcode_t *op, def_t *var_a, def_t *var_b, def_t *var_c);
void emit_expr (expr_t *e);
2001-06-28 21:26:40 +00:00
expr_t *error (expr_t *e, const char *fmt, ...) __attribute__((format(printf, 2,3)));
void warning (expr_t *e, const char *fmt, ...) __attribute__((format(printf, 2,3)));
const char *get_op_string (int op);
extern int lineno_base;