-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgen.h
61 lines (45 loc) · 1.01 KB
/
gen.h
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
#include<stdarg.h>
typedef enum { typeCon, typeScon, typeOp, typeVar } Types;
typedef enum { vFunc, vInt, vChar, vNull, vPointer } Vtype;
typedef struct {
union {
long long int val;
char *strVal;
};
} conType;
typedef struct {
char *name;
int type;
int symoff;
void *extra;
} varType;
typedef struct {
int op;
int nops;
char *flabel;
void **operands;
} operType;
struct Node {
Types type;
int reg; /* register where this is mapped */
int sfof; /* stack frame offset */
int hits;
int dirty;
union {
conType con;
varType var;
operType oper;
};
};
struct Node *create_scon(char *str);
struct Node *create_con(long long int val);
struct Node *sym_lookup(char *name);
void insert_symtab(struct Node *n);
char *new_cstr(char *str);
struct Node *create_var(char *name, int type, void*);
struct Node *create_oper(int type, int nops, ...);
void display_tree(struct Node* root);
void add_child(struct Node *parent, struct Node *child);