This repository has been archived by the owner on Dec 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
ilist.h
100 lines (82 loc) · 1.75 KB
/
ilist.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
#ifndef ILIST_H
#define ILIST_H
#include "scanner.h"
#include "str.h"
/***** Specific calls for creating instructions ********/
#define FUNC -2 // + createframe
#define SCOPE -1 // + createframe pushframe
#define LABEL 0
#define DEFVAR_TF 1
#define DEFVAR_LF 2
#define CREATEFRAME 3
#define CALL 4
#define RETURN 5
#define PUSHS 6
#define POPS 7
#define CLEARS 8
#define ADDS 9
#define SUBS 10
#define MULS 11
#define DIVS 12
#define LTS 13
#define GTS 14
#define EQS 15
#define LTEQS 16
#define GTEQS 17
#define JUMPIFEQS 18
#define JUMPIFENQS 19
#define JUMP 20
#define PUSHFRAME 21
#define READ 22
#define WRITE 23
#define MOVE_LF_LF 24
#define MOVE_LF_TF 25
#define MOVE_TF_LF 26
#define WHILE 27
#define LOOP 28
#define IF 29
#define ELSE 30
#define ENDIF 31
#define RETVAL_OUT 32
#define RETVAL_IN 33
#define MOVE 34
#define RETVAL_POP 35
#define NOTS 36
#define INT2FLOAT 37
#define FLOAT2R2EINT 38
#define RETVAL_INT2FLOAT_IN 39
#define RETVAL_FLOAT2R2EINT_IN 40
#define RETVAL_INT2FLOAT_OUT 41
#define RETVAL_FLOAT2R2EINT_OUT 42
#define INT2FLOATS 43
#define FLOAT2R2EINTS 44
#define CONCAT 45
#define LT 46
#define GT 47
#define EQ 48
#define NOTEQ 49
#define LTEQ 50
#define GTEQ 51
#define FLOAT2INTS 52
#define INSTNUMBER 1000
#define INSTSIZE 300
#define INST (Instr->instrList[Instr->used_lines])
typedef struct I_output
{
unsigned alloc_lines;
unsigned used_lines;
char *instrList[];
} I_output;
typedef enum
{
con_IF,
con_WHILE,
con_NONE
} I_context;
extern struct I_output *Instr; //global list of instructions
int add_instruction(int instType, token_t *op1, string *op2, token_t *op3);
int instr_init(); //call from main
void print_all(); //call from main
void inst_free(); //call at the end of program
void addInstComment(char *comment);
#endif