-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgen_3adres.h
100 lines (89 loc) · 1.93 KB
/
gen_3adres.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/**
* @file gen_3adres.h
* @author Jan Brudný ([email protected])
* @author Antonín Jarolím ([email protected])
* @brief definice datových typů pro práci s tříadresným kódem
* Implementation IFJ22 compiler
*/
#ifndef IFJ22_3ADRES_H
#define IFJ22_3ADRES_H
#include "common.h"
#include "symtable.h"
typedef enum i3InstructionType {
I_NOOP,
I_ADDS,
I_SUBS,
I_MULS,
I_DIVS,
I_IDIVS,
I_CONCAT,
I_CONCATS,//SPECIAL
I_EQ,
I_NEQ,
I_LT,
I_GT,
I_LEQ,
I_GEQ,
I_AND,
I_OR,
I_NOT,
I_MOVE,
I_MOVE_PARAM,
I_MOVE_RETURN,
I_POPFRAME,
I_PUSHFRAME,
I_CREATEFRAME,
I_INT2FLOAT,
I_READ,
I_WRITE,
I_STRLEN,
I_LABEL,
I_JUMP,
I_JUMP_IF_TRUE,
I_JUMP_IF_FALSE,
I_JUMPS_NEQ,
I_JUMPS_EQ,
I_LTS,// lesser
I_LT_OR_EQ,
I_GTS,// greater
I_GT_OR_EQ,
I_EQS,// equal
I_CALL,
I_RETURN,
I_DEFVAR,
I_PUSHS,
I_POPS,
I_INT2FLOATS,
I_FLOAT2INTS,
I_INT2CHARS,
I_STRI2INTS
} i3InstructionType_t;
/**
* @brief three-address instruction
*
*/
typedef struct i3Instruction {
i3InstructionType_t type;
symbol_t dest;
symbol_t arg1;
symbol_t arg2;
bool checkedType;
} i3Instruction_t;
/**
* @brief list of three-address instructions
*
*/
typedef struct i3InstructionArray {
char *functionName;
i3Instruction_t *instructions;
size_t size;
size_t capacity;
} i3InstructionArray_t;
typedef i3InstructionArray_t i3Table_t[MAX_HTSIZE];
void pushToArray(i3InstructionArray_t *array, i3Instruction_t instruction);
void initializeInstructionArray(int maxCapacity, i3InstructionArray_t *array, char *functionName);
void initializeProgram(i3Table_t *program);
char *copyString(char *toCopy);
void insertInstruction(i3InstructionArray_t *array, i3Instruction_t toInsert, size_t pos);
dynStr_t *functionParamInternalName(size_t number);
#endif//IFJ22_3ADRES_H