Data Structures | |
struct | symbol_s |
struct | symtab_s |
Typedefs | |
typedef struct symbol_s | symbol_t |
typedef struct symtab_s | symtab_t |
typedef enum vis_e | vis_t |
Enumerations | |
enum | stab_type_e { stab_global, stab_local, stab_struct, stab_union, stab_enum } |
enum | sy_type_e { sy_var, sy_const, sy_type, sy_expr, sy_func, sy_class } |
enum | vis_e { vis_public, vis_protected, vis_private } |
Functions | |
symbol_t * | copy_symbol (symbol_t *symbol) |
Make a copy of a symbol. More... | |
symbol_t * | make_symbol (const char *name, struct type_s *type, struct defspace_s *space, enum storage_class_e storage) |
Create a global symbol and allocate space for a variable. More... | |
symbol_t * | new_symbol (const char *name) |
Create a new, empty named symbol. More... | |
symbol_t * | new_symbol_type (const char *name, struct type_s *type) |
Create a new, typed, named symbol. More... | |
symtab_t * | new_symtab (symtab_t *parent, stab_type_e type) |
Create a new, empty symbol table. More... | |
symbol_t * | symtab_addsymbol (symtab_t *symtab, symbol_t *symbol) |
Add a symbol to the symbol table. More... | |
symtab_t * | symtab_flat_copy (symtab_t *symtab, symtab_t *parent) |
Create a new single symbol table from the given symbol table chain. More... | |
symbol_t * | symtab_lookup (symtab_t *symtab, const char *name) |
Lookup a name in the symbol table. More... | |
symbol_t * | symtab_removesymbol (symtab_t *symtab, symbol_t *symbol) |
Remove a symbol from the symbol table. More... | |
const char * | symtype_str (sy_type_e type) |
enum stab_type_e |
enum sy_type_e |
enum vis_e |
Make a copy of a symbol.
The new symbol will not be associated with any table.
symbol | The symbol to be copied. |
symbol_t* make_symbol | ( | const char * | name, |
struct type_s * | type, | ||
struct defspace_s * | space, | ||
enum storage_class_e | storage | ||
) |
Create a global symbol and allocate space for a variable.
If the symbol already exists, it must be of the correct type. If it is external, it will be converted to the given storage class and allocatged space from the given defspace, otherwise it will be returned.
If the symbol is new, it will be allocated space from the given defspace with the given storage class.
name | The name of the symbol. |
type | The type of the symbol. |
space | The defspace from which space will be allocated for the symbol. Ignored for sc_extern, must not be null for others. |
storage | The storage class for the symbol. Only sc_extern, sc_global, and sc_static are valid. |
Create a new, empty named symbol.
Only the symbol name field will be filled in. name will be copied using save_string().
name | The name of the symbol. |
Create a new, typed, named symbol.
Only the symbol name and type fields will be filled in. name will be copied using save_string().
name | The name of the symbol. |
type | The type of the symbol. |
symtab_t* new_symtab | ( | symtab_t * | parent, |
stab_type_e | type | ||
) |
Create a new, empty symbol table.
The symbol tables support scoping via their parent
pointer. This supports both code block scoping and ivar inheritance.
parent | Pointer to parent scope symbol table. |
type | The type of symbol table. Currently governs expected size. |
Add a symbol to the symbol table.
If there is already a symbol with the same name in the symbol table, the symbol will not be added to the table, and the symbol that was found in the table witll be returned.
symtab | The symol table to which the symbol will be added. |
symbol | The symbol to be added to the symbol table. |
Create a new single symbol table from the given symbol table chain.
Create a new symbol table and add all of the symbols from the given symbol table chain to the new symbol table. However, in order to preserve scoping rules, duplicate names in ancestor tables will not be added to the new table.
The new symbol table will be "local".
The intended use is for creating the ivar scope for methods.
symtab | The symbol table chain to be copied. |
parent | The parent symbol table of the new symbol table, or null. |
Lookup a name in the symbol table.
The entire symbol table chain (symtab_t::parent) starting at symtab will be checked for name.
symtab | The symbol table to search for name. If name is not in the symbol table, the tables's parent, if it exists, will be checked, and then its parent, until the end of the chain. |
name | The name to look up in the symbol table chain. |
Remove a symbol from the symbol table.
symtab | The symol table from which the symbol will be removed. |
symbol | The symbol to be removed from the symbol table. |