From 9911f9a73c7dc46069199e52f2bc54082d10366c Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Wed, 3 Jan 2018 23:10:59 +0100 Subject: Initial --- symbol.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 symbol.c (limited to 'symbol.c') 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 +#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; +} -- cgit v1.2.3-70-g09d2