mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-26 22:31:05 +00:00
Start work on simple names in symbol tables
I don't remember what the goal was (stopped working on it eight months ago), but some possibilities include: - better handling of nil (have trouble with assigning into struts) - automatic forward declarations ala C# and jai (I was watching vids about jai at the time) - something for pascal - simply that the default symbol type should not be var (in which case, goal accomplished)
This commit is contained in:
parent
7e31704ebe
commit
4ef4a7e955
5 changed files with 8 additions and 0 deletions
|
@ -48,6 +48,7 @@ typedef enum vis_e {
|
|||
} vis_t;
|
||||
|
||||
typedef enum {
|
||||
sy_name, ///< just a name (referent tbd)
|
||||
sy_var, ///< symbol refers to a variable
|
||||
sy_const, ///< symbol refers to a constant
|
||||
sy_type, ///< symbol refers to a type
|
||||
|
|
|
@ -87,6 +87,8 @@ check_valid_lvalue (expr_t *expr)
|
|||
switch (expr->type) {
|
||||
case ex_symbol:
|
||||
switch (expr->e.symbol->sy_type) {
|
||||
case sy_name:
|
||||
break;
|
||||
case sy_var:
|
||||
return 0;
|
||||
case sy_const:
|
||||
|
|
|
@ -650,6 +650,7 @@ struct_decl
|
|||
$<spec>0.type = type_default;
|
||||
$1->type = append_type ($1->type, $<spec>0.type);
|
||||
$1->type = find_type ($1->type);
|
||||
$1->sy_type = sy_var;
|
||||
symtab_addsymbol (current_symtab, $1);
|
||||
}
|
||||
| var_decl
|
||||
|
@ -658,6 +659,7 @@ struct_decl
|
|||
$<spec>0.type = type_default;
|
||||
$1->type = append_type ($1->type, $<spec>0.type);
|
||||
$1->type = find_type ($1->type);
|
||||
$1->sy_type = sy_var;
|
||||
symtab_addsymbol (current_symtab, $1);
|
||||
}
|
||||
| var_decl ':' expr %prec COMMA {}
|
||||
|
|
|
@ -246,6 +246,7 @@ make_structure (const char *name, int su, struct_def_t *defs, type_t *type)
|
|||
strct = new_symtab (0, stab_struct);
|
||||
while (defs->name) {
|
||||
field = new_symbol_type (defs->name, defs->type);
|
||||
field->sy_type = sy_var;
|
||||
if (!symtab_addsymbol (strct, field))
|
||||
internal_error (0, "duplicate symbol: %s", defs->name);
|
||||
defs++;
|
||||
|
|
|
@ -52,6 +52,7 @@ static symtab_t *symtabs_freelist;
|
|||
static symbol_t *symbols_freelist;
|
||||
|
||||
static const char *sy_type_names[] = {
|
||||
"sy_name",
|
||||
"sy_var",
|
||||
"sy_const",
|
||||
"sy_type",
|
||||
|
@ -234,5 +235,6 @@ make_symbol (const char *name, type_t *type, defspace_t *space,
|
|||
sym->s.def = new_def (name, type, space, storage);
|
||||
reloc_attach_relocs (relocs, &sym->s.def->relocs);
|
||||
}
|
||||
sym->sy_type = sy_var;
|
||||
return sym;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue