aboutsummaryrefslogtreecommitdiff
path: root/symbol.c
blob: 2f4adb78f0f3cf5ce34d086a7e91c3b7b14e77f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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;
}