mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-22 20:41:20 +00:00
[qfcc] Allow symbol tables to have procedural symbols
If a symbol is not found in the table and a callback is provided, the callback will be used to check for a valid procedural symbol before moving on to the next table in the chain. This allows for both tight scoping of the procedural symbols and caching.
This commit is contained in:
parent
dfb7862419
commit
cb9a82e74c
2 changed files with 8 additions and 1 deletions
|
@ -104,6 +104,8 @@ typedef struct symtab_s {
|
|||
symbol_t **symtail; ///< keep chain in declaration order
|
||||
struct defspace_s *space; ///< storage for vars in scope symtabs
|
||||
struct class_s *class; ///< owning class if ivar scope
|
||||
symbol_t *(*procsymbol) (const char *name, struct symtab_s *symtab);
|
||||
void *procsymbol_data;
|
||||
} symtab_t;
|
||||
|
||||
const char *symtype_str (sy_type_e type) __attribute__((const));
|
||||
|
|
|
@ -119,8 +119,13 @@ symtab_lookup (symtab_t *symtab, const char *name)
|
|||
{
|
||||
symbol_t *symbol;
|
||||
do {
|
||||
if ((symbol = Hash_Find (symtab->tab, name)))
|
||||
if ((symbol = Hash_Find (symtab->tab, name))) {
|
||||
return symbol;
|
||||
}
|
||||
if (symtab->procsymbol
|
||||
&& (symbol = symtab->procsymbol (name, symtab))) {
|
||||
return symbol;
|
||||
}
|
||||
symtab = symtab->parent;
|
||||
} while (symtab);
|
||||
return 0;
|
||||
|
|
Loading…
Reference in a new issue