-
Notifications
You must be signed in to change notification settings - Fork 0
/
intercode.h
40 lines (31 loc) · 845 Bytes
/
intercode.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
#include "globals.h"
#include "symtab.h"
#include "util.h"
#ifndef _INTERCODE_H_
#define _INTERCODE_H_
#define nlabel_size 3
#define ntemp_size 3
//MIGHT NEED CHANGING WHEN ADDING INSTRUCTIONS
typedef enum { opADD, opSUB, opMULT, opDIV, opMOD, opLT, opLTE, opGT, opGTE, opAND, opOR, opASSIGN, opALLOC, opIMMED, opLOAD, opSTORE, opVEC, opGOTO, opIF, opRET, opFUN, opEND, opPARAM, opCALL, opARG, opLAB, opHLT} OpKind;
typedef enum { Empty, IntConst, String } AddrKind;
typedef struct {
AddrKind kind;
union {
int val;
struct {
char * name;
char * scope;
} var;
} contents;
} Address;
typedef struct {
OpKind op;
Address addr1, addr2, addr3;
} Quad;
typedef struct QuadListRec {
int location;
Quad quad;
struct QuadListRec * next;
} * QuadList;
QuadList GenInterCode(TreeNode *syntaxTree);
#endif