-
Notifications
You must be signed in to change notification settings - Fork 1
/
symbol.c
38 lines (30 loc) · 916 Bytes
/
symbol.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include "nocc.h"
VariableSymbol *variable_symbol_new(const char *filename, int line,
const char *identifier, Type *type) {
VariableSymbol *p;
assert(filename != NULL);
assert(identifier != NULL);
assert(type != NULL);
p = malloc(sizeof(*p));
p->kind = symbol_variable;
p->filename = str_dup(filename);
p->line = line;
p->identifier = str_dup(identifier);
p->type = type;
p->generated_location = NULL;
return p;
}
Symbol *type_symbol_new(const char *filename, int line, const char *identifier,
Type *type) {
Symbol *p;
assert(filename != NULL);
assert(identifier != NULL);
assert(type != NULL);
p = malloc(sizeof(*p));
p->kind = symbol_type;
p->filename = str_dup(filename);
p->line = line;
p->identifier = str_dup(identifier);
p->type = type;
return p;
}