-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvmachine.h
67 lines (54 loc) · 1.95 KB
/
vmachine.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
////////////////////////////////////////////////////////////////////////////////
// DScript Scripting Language
// Copyright (C) 2003 Bryan "daerid" Ross
//
// Permission to copy, use, modify, sell and distribute this software is
// granted provided this copyright notice appears in all copies. This
// software is provided "as is" without express or implied warranty, and
// with no claim as to its suitability for any purpose.
////////////////////////////////////////////////////////////////////////////////
#ifndef __DSCRIPT_VMACHINE_H__
#define __DSCRIPT_VMACHINE_H__
////////////////////////////////////////////////////////////////////////////////
// Standard Library Includes
#include <stack>
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// DScript Includes
#include "instruction.h"
#include "value.h"
#include "functions.h"
////////////////////////////////////////////////////////////////////////////////
namespace dscript
{
/// The virtual machine. This object takes care of the actual execution
/// of the bytecode contained in a codeblock
class vmachine
{
public:
void execute(
instr_iter begin,
instr_iter end,
instr_iter instr,
class context& ctx
);
friend class context;
private:
// the stack frames
std::stack<dictionary_t> m_callstack;
// the runtime stack
std::stack<value> m_runtime_stack;
dictionary_t globals;
// the return register
value m_return_val;
// the function call param stack
std::vector<value> m_param_stack;
// string table
string_table strings;
// double table
float_table floats;
// the function table
func_table functions;
};
}
#endif//__DSCRIPT_VMACHINE_H__