-
Notifications
You must be signed in to change notification settings - Fork 0
/
CodeWriter.h
40 lines (35 loc) · 875 Bytes
/
CodeWriter.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
#ifndef _CODEWRITER_
#define _CODEWRITER_
#include <iostream>
#include <string>
#include <fstream>
#include "Parser.h"
using namespace std;
class CodeWriter
{
public:
CodeWriter(string filename);
CodeWriter();
~CodeWriter();
void setFileName(string filename);
void WArithmetic(string command);
void WPushPop(VMcommand PushOrPop, string segment, int index);
void WInit(void);
void WLabel(string label);
void WGoto(string label);
void WIf(string label);
void WCall(string functionName, int numArgs);
void WReturn(void);
void WFunction(string functionName, int numLocals);
void PopToGeneralPurposeRegister(int regNum);
void PushInPushOrPop(string loc, int i);
void PopInPushOrPop(string loc, int i);
void setOutputFileName(string outname);
private:
string FileName;
string FunctionName;
ofstream outf;
int labelno;
int line;
};
#endif