more --id support

This commit is contained in:
Bill Currie 2001-08-07 16:50:22 +00:00
parent 6a59ac6c51
commit b341529fce
2 changed files with 24 additions and 17 deletions

View file

@ -80,6 +80,12 @@ get_type (expr_t *e)
return e->e.expr.type->type;
case ex_def:
return e->e.def->type->type;
case ex_integer:
if (options.version == PROG_ID_VERSION) {
e->type = ex_float;
e->e.float_val = e->e.integer_val;
}
// fall through
case ex_string:
case ex_float:
case ex_vector:
@ -88,7 +94,6 @@ get_type (expr_t *e)
case ex_func:
case ex_pointer:
case ex_quaternion:
case ex_integer:
return qc_types[e->type];
}
return ev_type_count;

View file

@ -141,24 +141,25 @@ typedef struct {
const char *name;
int value;
type_t *type;
int version;
} keyword_t;
static keyword_t keywords[] = {
{"void", TYPE, &type_void },
{"float", TYPE, &type_float },
{"string", TYPE, &type_string },
{"vector", TYPE, &type_vector },
{"entity", TYPE, &type_entity },
{"quaternion", TYPE, &type_quaternion},
{"integer", TYPE, &type_integer },
{"function", TYPE, &type_function },
{"local", LOCAL, 0 },
{"return", RETURN, 0 },
{"while", WHILE, 0 },
{"do", DO, 0 },
{"if", IF, 0 },
{"else", ELSE, 0 },
{"for", FOR, 0 },
{"void", TYPE, &type_void, PROG_ID_VERSION},
{"float", TYPE, &type_float, PROG_ID_VERSION},
{"string", TYPE, &type_string, PROG_ID_VERSION},
{"vector", TYPE, &type_vector, PROG_ID_VERSION},
{"entity", TYPE, &type_entity, PROG_ID_VERSION},
{"quaternion", TYPE, &type_quaternion, PROG_VERSION},
{"integer", TYPE, &type_integer, PROG_VERSION},
{"function", TYPE, &type_function, PROG_VERSION},
{"local", LOCAL, 0, PROG_ID_VERSION},
{"return", RETURN, 0, PROG_ID_VERSION},
{"while", WHILE, 0, PROG_ID_VERSION},
{"do", DO, 0, PROG_ID_VERSION},
{"if", IF, 0, PROG_ID_VERSION},
{"else", ELSE, 0, PROG_ID_VERSION},
{"for", FOR, 0, PROG_ID_VERSION},
};
static const char *
@ -178,7 +179,8 @@ type_or_name (char *token)
int i;
keyword_tab = Hash_NewTable (1021, keyword_get_key, 0, 0);
for (i = 0; i < sizeof (keywords) / sizeof (keywords[0]); i++)
Hash_Add (keyword_tab, &keywords[i]);
if (keywords[i].version <= options.version)
Hash_Add (keyword_tab, &keywords[i]);
initialized = 1;
}
keyword = Hash_Find (keyword_tab, token);