-
Notifications
You must be signed in to change notification settings - Fork 0
/
generator.h
43 lines (33 loc) · 963 Bytes
/
generator.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
#ifndef GENERATOR_H
#define GENERATOR_H
#include <iostream>
#include "treenode.h"
#include "analyzer.h"
class Generator
{
public:
Generator(Analyzer & analyzer, std::ostream & os = std::cout);
void genCode();
private:
void genCode(TreeNode * t);
void genStmtSeq(TreeNode * t);
void genStmt(TreeNode * t);
void genExpr(TreeNode * t);
size_t skipLocation(size_t size);
void backupLocation(size_t loc);
void restoreLocation();
void increaseLocation();
void genRO(const char *op, int r, int s, int t);
void genRM(const char * op, int r, int d, int s);
void genRMAbs(const char *op, int r, int a);
Analyzer & analyzer_;
std::ostream & os_;
size_t current_location_;
size_t highest_location_;
/* tmpOffset is the memory offset for temps
* It is decremented each time a temp is
* stored, and incremeted when loaded again
*/
size_t tmp_offset_;
};
#endif // GENERATOR_H