-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbyte_code_cmd.h
171 lines (149 loc) · 3.91 KB
/
byte_code_cmd.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#pragma once
#include <sstream>
#include "type.h"
#include "stack.h"
#include "iostream"
class TByteCodeCMD {
public:
virtual ~TByteCodeCMD(){}
virtual void UpdateStack(TStack& Stack){}
public:
static const std::map<std::string, ExprType*(*)(std::vector< std::shared_ptr<ExprType> >&) > stdFuncMap;
};
class TByteCodeCMDAllocInt: public TByteCodeCMD {
public:
TByteCodeCMDAllocInt(int val);
void UpdateStack(TStack& Stack);
private:
int value;
};
class TByteCodeCMDAllocDouble: public TByteCodeCMD {
public:
TByteCodeCMDAllocDouble(double val);
void UpdateStack(TStack& Stack);
private:
double value;
};
class TByteCodeCMDAllocChar: public TByteCodeCMD {
public:
TByteCodeCMDAllocChar(char val);
void UpdateStack(TStack& Stack);
private:
char value;
};
class TByteCodeCMDAllocString: public TByteCodeCMD {
public:
TByteCodeCMDAllocString(std::string val);
void UpdateStack(TStack& Stack);
private:
std::string value;
};
class TByteCodeCMDAllocSymbol: public TByteCodeCMD {
public:
TByteCodeCMDAllocSymbol(std::string val);
void UpdateStack(TStack& Stack);
private:
std::string value;
};
class TByteCodeCMDAllocBool: public TByteCodeCMD {
public:
TByteCodeCMDAllocBool(bool val);
void UpdateStack(TStack& Stack);
private:
bool value;
};
class TByteCodeCMDPush: public TByteCodeCMD {
public:
TByteCodeCMDPush(size_t valNum);
void UpdateStack(TStack& Stack);
private:
size_t valueNumber;
};
class TByteCodeCMDPushIdent: public TByteCodeCMD {
public:
TByteCodeCMDPushIdent(std::string val);
void UpdateStack(TStack& Stack);
private:
std::string value;
};
class TByteCodeCMDIfElse: public TByteCodeCMD {
public:
TByteCodeCMDIfElse(size_t& IT);
void UpdateStack(TStack& Stack);
private:
size_t& it;
};
class TByteCodeCMDLambda: public TByteCodeCMD {
public:
TByteCodeCMDLambda(std::vector<std::string> agrs, Enviroment& defParent);
void UpdateStack(TStack& Stack);
private:
std::vector<std::string> args;
std::shared_ptr<Enviroment> define = std::shared_ptr<Enviroment>(new Enviroment());
};
class TByteCodeCMDBegin: public TByteCodeCMD {
public:
TByteCodeCMDBegin(size_t size);
void UpdateStack(TStack& Stack);
private:
size_t sizeArgs;
};
class TByteCodeCMDDefine: public TByteCodeCMD {
public:
TByteCodeCMDDefine(std::string name, std::vector<std::string> identName,
Enviroment& defParent,
std::vector<std::shared_ptr<TByteCodeCMD>>& cmd, size_t& IT);
void UpdateStack(TStack& Stack);
public:
Enviroment* GetEnviroment();
private:
std::shared_ptr<Enviroment> define = std::shared_ptr<Enviroment>(new Enviroment());
std::vector<std::string> Args;
std::string funcName;
std::vector<std::shared_ptr<TByteCodeCMD>>& command;
size_t& it;
};
class TByteCodeCMDCall: public TByteCodeCMD {
public:
TByteCodeCMDCall(std::string callee, size_t i, size_t& IT, std::vector<std::shared_ptr<TByteCodeCMD>>& Command);
void UpdateStack(TStack& Stack);
private:
std::string name;
size_t size;
size_t& it;
std::vector<std::shared_ptr<TByteCodeCMD>>& command;
};
class TByteCodeCMDTailCall: public TByteCodeCMD {
public:
TByteCodeCMDTailCall(std::string callee, size_t p, size_t i, size_t& IT);
void UpdateStack(TStack& Stack);
private:
std::string name;
size_t pos;
size_t size;
size_t& it;
};
class TByteCodeCMDJump: public TByteCodeCMD {
public:
TByteCodeCMDJump(size_t& It): it(It) {
}
void UpdateStack(TStack& Stack) {
it = currentPos;
}
void SetCurrentPos(size_t pos);
private:
size_t& it;
size_t currentPos;
};
class TByteCodeCMDJumpEndDefine: public TByteCodeCMD {
public:
TByteCodeCMDJumpEndDefine(size_t& It): it(It) {
}
void UpdateStack(TStack& Stack) {
it = currentPos;
}
void SetCurrentPos(size_t pos);
private:
size_t& it;
size_t currentPos;
};