-
Notifications
You must be signed in to change notification settings - Fork 0
/
stack.h
60 lines (50 loc) · 1.54 KB
/
stack.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
#ifndef __stack_h__
#define __stack_h__
#define MAXPRINTS 50
#include "ast.h"
typedef enum {LDC, ADI, SBI, DIVOP, MPI, MODULE, EQUJ, NEQc, LESc, LEQc, GETc, GEQc, BEQZ, LOD, STO, GRT, UJP, LABEL, EQU, NEQ, LDA, IOR, ANDOP, WRI, SCANF} IKind;
struct _Instr{
enum {
E_NAME,
E_INT2,
E_FLOAT2
} type;
IKind kind;
union {
char* name;
float argf;
int argi;
} arg;
};
struct _Instr_List{
struct _Instr* instruction;
struct _Instr_List* next;
};
typedef struct _Instr_List Instr_List;
typedef struct _Instr Instr;
char** printfString;
char*** variablesPrint;
unsigned int LABEL_COUNT;
unsigned int printCounts;
unsigned int variablesPerPrint;
int mipsLabel;
Instr* mkInstr(IKind kind, int n);
Instr* mkInstr2(IKind kind, char* name);
Instr* mkInstr3(IKind kind, float n);
Instr* head(Instr_List* l);
Instr_List* compileDeclaration(char* name);
Instr_List* tail(Instr_List* l);
Instr_List* append(Instr_List* l1, Instr_List* l2);
Instr_List* mkList(Instr* code, Instr_List* l2);
Instr_List* compileExpression(Expr* expr);
Instr_List* compileAssignment(char* name, Expr* expression);
Instr_List* compileCmd(Command* cmd);
Instr_List* compile(CommandList* list);
Instr_List* compileDeclarationList(DeclarationList* decl_list);
Instr_List* compileAssignmentList(AsgList* asg_list);
Instr_List* compileVarList(varList* list);
Instr_List* compileWhile(WHILEexpression* while_expr);
Instr_List* compileIf(IFexpression* if_expr);
void printInstr(Instr* instr);
void printListIntrs(Instr_List* list);
#endif