OSDN Git Service

全体の環境を表すenvironmentの追加。
[simplecms/utakata.git] / vm.h
1 #ifndef __VM_H__
2 #define __VM_H__
3
4 #include "smart_ptr.h"
5 #include <vector>
6
7 namespace vm {
8
9     class vcpu;
10     class IOperand;
11
12     struct COperandRunner {
13         COperandRunner(smart_ptr<vcpu> cpu) : cpu_(cpu) {}
14         ~COperandRunner() {}
15         
16         template<class T>
17         int operator()(T& p) {
18             return (*p)(*cpu_);
19         }
20
21     private:
22
23         smart_ptr<vcpu> cpu_;
24     };
25     
26     class UKVirtualMachine
27     {
28     public:
29         UKVirtualMachine();
30         virtual ~UKVirtualMachine();
31
32         /**
33            オペランドの配列を受け取り、配列に基づいたデータを実行する
34         */
35         int run(std::vector<smart_ptr<IOperand> >& ops);
36
37     private:
38
39         smart_ptr<vcpu> cpu_;
40     };
41 };
42
43 #endif
44
45