diff --git a/tools/qfcc/include/symtab.h b/tools/qfcc/include/symtab.h index a60b0d83a..19d1ebc93 100644 --- a/tools/qfcc/include/symtab.h +++ b/tools/qfcc/include/symtab.h @@ -32,6 +32,8 @@ #ifndef __symtab_h #define __symtab_h +#include "expr.h" + /** \defgroup qfcc_symtab Symbol Table Management \ingroup qfcc */ @@ -60,7 +62,8 @@ typedef struct symbol_s { struct type_s *type; ///< type of object to which symbol refers struct param_s *params; ///< the parameters if a function union { - int value; + int offset; + struct ex_value_s value; struct expr_s *expr; struct function_s *func; } s; diff --git a/tools/qfcc/source/expr.c b/tools/qfcc/source/expr.c index c15db77c8..e6d614e61 100644 --- a/tools/qfcc/source/expr.c +++ b/tools/qfcc/source/expr.c @@ -705,7 +705,7 @@ expr_float (expr_t *e) return e->e.value.v.float_val; if (e->type == ex_symbol && e->e.symbol->sy_type == sy_const && e->e.symbol->type->type == ev_float) - return e->e.symbol->s.value; + return e->e.symbol->s.value.v.float_val; internal_error (e, "not a float constant"); } @@ -729,9 +729,9 @@ expr_vector (expr_t *e) return vec3_origin; if (e->type == ex_value && e->e.value.type == ev_vector) return e->e.value.v.vector_val; - //if (e->type == ex_symbol && e->e.symbol->sy_type == sy_const - // && e->e.symbol->type->type == ev_vector) - // return e->e.symbol->s.value; + if (e->type == ex_symbol && e->e.symbol->sy_type == sy_const + && e->e.symbol->type->type == ev_vector) + return e->e.symbol->s.value.v.vector_val; internal_error (e, "not a vector constant"); } @@ -755,9 +755,9 @@ expr_quaternion (expr_t *e) return quat_origin; if (e->type == ex_value && e->e.value.type == ev_quat) return e->e.value.v.quaternion_val; - //if (e->type == ex_symbol && e->e.symbol->sy_type == sy_const - // && e->e.symbol->type->type == ev_quat) - // return e->e.symbol->s.value; + if (e->type == ex_symbol && e->e.symbol->sy_type == sy_const + && e->e.symbol->type->type == ev_quat) + return e->e.symbol->s.value.v.quaternion_val; internal_error (e, "not a quaternion constant"); } @@ -783,7 +783,7 @@ expr_integer (expr_t *e) return e->e.value.v.integer_val; if (e->type == ex_symbol && e->e.symbol->sy_type == sy_const && e->e.symbol->type->type == ev_integer) - return e->e.symbol->s.value; + return e->e.symbol->s.value.v.integer_val; internal_error (e, "not an integer constant"); } @@ -809,7 +809,7 @@ expr_short (expr_t *e) return e->e.value.v.short_val; if (e->type == ex_symbol && e->e.symbol->sy_type == sy_const && e->e.symbol->type->type == ev_short) - return e->e.symbol->s.value; + return e->e.symbol->s.value.v.short_val; internal_error (e, "not a short constant"); } diff --git a/tools/qfcc/source/struct.c b/tools/qfcc/source/struct.c index a8d3d85d6..e98ea22f1 100644 --- a/tools/qfcc/source/struct.c +++ b/tools/qfcc/source/struct.c @@ -114,7 +114,7 @@ build_struct (int su, symbol_t *tag, symtab_t *symtab, type_t *type) if (s->sy_type != sy_var) continue; if (su == 's') { - s->s.value = symtab->size; + s->s.offset = symtab->size; symtab->size += type_size (s->type); } else { int size = type_size (s->type); @@ -160,7 +160,7 @@ add_enum (symbol_t *enm, symbol_t *name, expr_t *val) enum_tab = enum_type->t.symtab; value = 0; if (*enum_tab->symtail) - value = ((symbol_t *)(*enum_tab->symtail))->s.value + 1; + value = ((symbol_t *)(*enum_tab->symtail))->s.value.v.integer_val + 1; if (val) { val = constant_expr (val); if (!is_constant (val)) @@ -170,7 +170,7 @@ add_enum (symbol_t *enm, symbol_t *name, expr_t *val) else value = expr_integer (val); } - name->s.value = value; + name->s.value.v.integer_val = value; symtab_addsymbol (enum_tab, name); } diff --git a/tools/qfcc/source/switch.c b/tools/qfcc/source/switch.c index 95ea1bd92..6f4f2cbc4 100644 --- a/tools/qfcc/source/switch.c +++ b/tools/qfcc/source/switch.c @@ -69,7 +69,7 @@ static uintptr_t get_value (expr_t *e) { if (e->type == ex_symbol) - return e->e.symbol->s.value; + return e->e.symbol->s.value.v.integer_val; //FIXME pointer return e->e.value.v.integer_val; } diff --git a/tools/qfcc/source/type.c b/tools/qfcc/source/type.c index a709d32f4..0efca005d 100644 --- a/tools/qfcc/source/type.c +++ b/tools/qfcc/source/type.c @@ -406,7 +406,7 @@ encode_enum (dstring_t *encoding, type_t *type, int level) dasprintf (encoding, "{%s#", name); if (level < 2) { for (e = enm->symbols; e; e = e->next) { - dasprintf (encoding, "%s=%d%s", e->name, e->s.value, + dasprintf (encoding, "%s=%d%s", e->name, e->s.value.v.integer_val, e->next ? "," : ""); } }