diff options
Diffstat (limited to 'symbol.c')
-rw-r--r-- | symbol.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/symbol.c b/symbol.c new file mode 100644 index 0000000..2f4adb7 --- /dev/null +++ b/symbol.c @@ -0,0 +1,23 @@ +#include <stdlib.h> +#include "symbol.h" + + +struct symbol* symbol_make_var(char *name, struct type *rtype) { + struct symbol *sym = malloc(sizeof(struct symbol)); + sym->name = name; + sym->stype = ST_VAR; + sym->rtype = rtype; + sym->numparams = 0; + sym->params = NULL; + return sym; +} + +struct symbol* symbol_make_func(char *name, struct type *rtype, int numparams) { + struct symbol *sym = malloc(sizeof(struct symbol)); + sym->name = name; + sym->stype = ST_FUNC; + sym->rtype = rtype; + sym->numparams = numparams; + sym->params = malloc(numparams * sizeof(struct pair_tn)); + return sym; +} |