aboutsummaryrefslogtreecommitdiff
path: root/symbol.c
diff options
context:
space:
mode:
authorTom Smeding <tom.smeding@gmail.com>2018-01-03 23:10:59 +0100
committerTom Smeding <tom.smeding@gmail.com>2018-01-03 23:10:59 +0100
commit9911f9a73c7dc46069199e52f2bc54082d10366c (patch)
tree914cd4fc2367207271c1c53c7f11a96ed9bbc9b7 /symbol.c
Initial
Diffstat (limited to 'symbol.c')
-rw-r--r--symbol.c23
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;
+}