Make it easy to print symbol types.

This commit is contained in:
Bill Currie 2012-12-05 19:45:16 +09:00
parent 2904c619c1
commit 3bb8b1b9d2
2 changed files with 19 additions and 0 deletions

View file

@ -94,6 +94,8 @@ typedef struct symtab_s {
struct defspace_s *space; ///< storage for vars in scope symtabs
} symtab_t;
const char *symtype_str (sy_type_e type);
/** Create a new, empty named symbol.
Only the symbol name field will be filled in. \a name will be copied

View file

@ -50,6 +50,23 @@
static symtab_t *free_symtabs;
static symbol_t *free_symbols;
static const char *sy_type_names[] = {
"sy_var",
"sy_const",
"sy_type",
"sy_expr",
"sy_func",
"sy_class",
};
const char *
symtype_str (sy_type_e type)
{
if (type < 0 || type > sy_class)
return "<invalid sy_type>";
return sy_type_names[type];
}
symbol_t *
new_symbol (const char *name)
{