-
Notifications
You must be signed in to change notification settings - Fork 7
/
InnerCodeGenerator.hpp
45 lines (37 loc) · 962 Bytes
/
InnerCodeGenerator.hpp
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
//
// InnerCodeGenerator.hpp
// C_Compiler
//
// Created by egoist on 2019/5/26.
// Copyright © 2019 egoist. All rights reserved.
//
#ifndef InnerCodeGenerator_hpp
#define InnerCodeGenerator_hpp
#include "ast.hpp"
#include "block.hpp"
#include "Optimizer.hpp"
#include "Codegen.hpp"
#include <string>
using namespace std;
class ICG{
private:
vector<string> codeList;
public:
int tempNum = 0;
int varNum = 0;
int labelNum = 0;
int arrayNum = 0;
ICG();
void addCode(string code);
void printCode();
string createCode(string );
string createCodeforParam(VarNode);
string createCodeforRet(VarNode);
string createCodeforAssign(VarNode, VarNode);
string createCodeforVar(string, string, VarNode, VarNode);
string createCodeforArugument(VarNode);
string getLabelname();
string getNodename(VarNode node);
string getArrNodename(ArrayNode);
};
#endif /* InnerCodeGenerator_hpp */