Add new_symbol_type to ease creation of typed symbols.

This is inteded for code generation functions that need to create
variables and structures.
This commit is contained in:
Bill Currie 2011-01-17 12:04:41 +09:00
parent ffea505678
commit 537b930ba6
2 changed files with 20 additions and 0 deletions

View file

@ -71,6 +71,17 @@ typedef struct symtab_s {
*/
symbol_t *new_symbol (const char *name);
/** Create a new, typed, named symbol.
Only the symbol name and type fields will be filled in. \a name will
be copied using save_string().
\param name The name of the symbol.
\param type The type of the symbol.
\return The new symbol.
*/
symbol_t *new_symbol_type (const char *name, struct type_s *type);
/** Create a new, empty symbol table.
The symbol tables support scoping via their \c parent pointer. This

View file

@ -22,6 +22,15 @@ new_symbol (const char *name)
return symbol;
}
symbol_t *
new_symbol_type (const char *name, type_t *type)
{
symbol_t *symbol;
symbol = new_symbol (name);
symbol->type = type;
return symbol;
}
static const char *
sym_getkey (void *k, void *unused)
{