-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathVM.h
69 lines (54 loc) · 1.43 KB
/
VM.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
#pragma once
#include <vector>
#include "Instruction.h"
class State;
class Stack;
class InstructionValue;
class VM
{
public:
VM(State* state);
~VM();
//friend class BaseLib;
private:
State* _state;
Stack* _stack;
Stack* _stackClosure;
InstructionValue* _curInsVal;
public:
void execute();
void execute_frame();
typedef std::vector<Instruction*> VtIns;
int runCode(InstructionValue*);
private:
void generateClosure(Instruction* ins);
void add_global_table();
void enterClosure();
void quitClosure();
void call(Instruction* ins);
void passFunParam(Instruction* ins);
void initLocalVar(Instruction* ins);
void assignOperate(Instruction* ins);
void assignVals(int, int, int type);
void assignSimple(int type);
void pushValue(Instruction* ins);
void setLoacalVar(Instruction* ins);
void getLoacalVar(Instruction* ins);
void funcionRet(Instruction* ins);
void operateNum(Instruction* ins);
void operateLogic(Instruction* ins);
Closure* getCurrentClosure();
void ifCompare(Instruction* ins);
void numericFor(Instruction* ins);
void genericFor(Instruction* ins);
void breakFor(Instruction* ins);
void enterBlock(Instruction* ins);
void quitBlock(Instruction* ins);
void generateBlock(Instruction* ins);
void runBlockCode(Value* val);
void tableDefine(Instruction* ins);
void tableAccess(Instruction* ins);
void tableArrIndex(Instruction* ins);
void negNumber(Instruction* ins);
void lenOfVale(Instruction* ins);
};