From 537b930ba63c49d3e6715b072eb63066f51c7ea4 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Mon, 17 Jan 2011 12:04:41 +0900 Subject: [PATCH] Add new_symbol_type to ease creation of typed symbols. This is inteded for code generation functions that need to create variables and structures. --- tools/qfcc/include/symtab.h | 11 +++++++++++ tools/qfcc/source/symtab.c | 9 +++++++++ 2 files changed, 20 insertions(+) diff --git a/tools/qfcc/include/symtab.h b/tools/qfcc/include/symtab.h index 134bcf1a1..33aff8e52 100644 --- a/tools/qfcc/include/symtab.h +++ b/tools/qfcc/include/symtab.h @@ -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 diff --git a/tools/qfcc/source/symtab.c b/tools/qfcc/source/symtab.c index d4eb3a715..145874fee 100644 --- a/tools/qfcc/source/symtab.c +++ b/tools/qfcc/source/symtab.c @@ -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) {