OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
localopcodes.hpp
Go to the documentation of this file.
1 #ifndef INTERPRETER_LOCALOPCODES_H_INCLUDED
2 #define INTERPRETER_LOCALOPCODES_H_INCLUDED
3 
4 #include "opcodes.hpp"
5 #include "runtime.hpp"
6 #include "context.hpp"
7 
8 namespace Interpreter
9 {
10  class OpStoreLocalShort : public Opcode0
11  {
12  public:
13 
14  virtual void execute (Runtime& runtime)
15  {
16  Type_Integer data = runtime[0].mInteger;
17  int index = runtime[1].mInteger;
18 
19  runtime.getContext().setLocalShort (index, data);
20 
21  runtime.pop();
22  runtime.pop();
23  }
24  };
25 
26  class OpStoreLocalLong : public Opcode0
27  {
28  public:
29 
30  virtual void execute (Runtime& runtime)
31  {
32  Type_Integer data = runtime[0].mInteger;
33  int index = runtime[1].mInteger;
34 
35  runtime.getContext().setLocalLong (index, data);
36 
37  runtime.pop();
38  runtime.pop();
39  }
40  };
41 
42  class OpStoreLocalFloat : public Opcode0
43  {
44  public:
45 
46  virtual void execute (Runtime& runtime)
47  {
48  Type_Float data = runtime[0].mFloat;
49  int index = runtime[1].mInteger;
50 
51  runtime.getContext().setLocalFloat (index, data);
52 
53  runtime.pop();
54  runtime.pop();
55  }
56  };
57 
58  class OpFetchIntLiteral : public Opcode0
59  {
60  public:
61 
62  virtual void execute (Runtime& runtime)
63  {
64  Type_Integer intValue = runtime.getIntegerLiteral (runtime[0].mInteger);
65  runtime[0].mInteger = intValue;
66  }
67  };
68 
70  {
71  public:
72 
73  virtual void execute (Runtime& runtime)
74  {
75  Type_Float floatValue = runtime.getFloatLiteral (runtime[0].mInteger);
76  runtime[0].mFloat = floatValue;
77  }
78  };
79 
80  class OpFetchLocalShort : public Opcode0
81  {
82  public:
83 
84  virtual void execute (Runtime& runtime)
85  {
86  int index = runtime[0].mInteger;
87  int value = runtime.getContext().getLocalShort (index);
88  runtime[0].mInteger = value;
89  }
90  };
91 
92  class OpFetchLocalLong : public Opcode0
93  {
94  public:
95 
96  virtual void execute (Runtime& runtime)
97  {
98  int index = runtime[0].mInteger;
99  int value = runtime.getContext().getLocalLong (index);
100  runtime[0].mInteger = value;
101  }
102  };
103 
104  class OpFetchLocalFloat : public Opcode0
105  {
106  public:
107 
108  virtual void execute (Runtime& runtime)
109  {
110  int index = runtime[0].mInteger;
111  float value = runtime.getContext().getLocalFloat (index);
112  runtime[0].mFloat = value;
113  }
114  };
115 
117  {
118  public:
119 
120  virtual void execute (Runtime& runtime)
121  {
122  Type_Integer data = runtime[0].mInteger;
123  int index = runtime[1].mInteger;
124 
125  std::string name = runtime.getStringLiteral (index);
126 
127  runtime.getContext().setGlobalShort (name, data);
128 
129  runtime.pop();
130  runtime.pop();
131  }
132  };
133 
134  class OpStoreGlobalLong : public Opcode0
135  {
136  public:
137 
138  virtual void execute (Runtime& runtime)
139  {
140  Type_Integer data = runtime[0].mInteger;
141  int index = runtime[1].mInteger;
142 
143  std::string name = runtime.getStringLiteral (index);
144 
145  runtime.getContext().setGlobalLong (name, data);
146 
147  runtime.pop();
148  runtime.pop();
149  }
150  };
151 
153  {
154  public:
155 
156  virtual void execute (Runtime& runtime)
157  {
158  Type_Float data = runtime[0].mFloat;
159  int index = runtime[1].mInteger;
160 
161  std::string name = runtime.getStringLiteral (index);
162 
163  runtime.getContext().setGlobalFloat (name, data);
164 
165  runtime.pop();
166  runtime.pop();
167  }
168  };
169 
171  {
172  public:
173 
174  virtual void execute (Runtime& runtime)
175  {
176  int index = runtime[0].mInteger;
177  std::string name = runtime.getStringLiteral (index);
178  Type_Integer value = runtime.getContext().getGlobalShort (name);
179  runtime[0].mInteger = value;
180  }
181  };
182 
183  class OpFetchGlobalLong : public Opcode0
184  {
185  public:
186 
187  virtual void execute (Runtime& runtime)
188  {
189  int index = runtime[0].mInteger;
190  std::string name = runtime.getStringLiteral (index);
191  Type_Integer value = runtime.getContext().getGlobalLong (name);
192  runtime[0].mInteger = value;
193  }
194  };
195 
197  {
198  public:
199 
200  virtual void execute (Runtime& runtime)
201  {
202  int index = runtime[0].mInteger;
203  std::string name = runtime.getStringLiteral (index);
204  Type_Float value = runtime.getContext().getGlobalFloat (name);
205  runtime[0].mFloat = value;
206  }
207  };
208 
210  {
211  bool mGlobal;
212 
213  public:
214 
215  OpStoreMemberShort (bool global) : mGlobal (global) {}
216 
217  virtual void execute (Runtime& runtime)
218  {
219  Type_Integer data = runtime[0].mInteger;
220  Type_Integer index = runtime[1].mInteger;
221  std::string id = runtime.getStringLiteral (index);
222  index = runtime[2].mInteger;
223  std::string variable = runtime.getStringLiteral (index);
224 
225  runtime.getContext().setMemberShort (id, variable, data, mGlobal);
226 
227  runtime.pop();
228  runtime.pop();
229  runtime.pop();
230  }
231  };
232 
233  class OpStoreMemberLong : public Opcode0
234  {
235  bool mGlobal;
236 
237  public:
238 
239  OpStoreMemberLong (bool global) : mGlobal (global) {}
240 
241  virtual void execute (Runtime& runtime)
242  {
243  Type_Integer data = runtime[0].mInteger;
244  Type_Integer index = runtime[1].mInteger;
245  std::string id = runtime.getStringLiteral (index);
246  index = runtime[2].mInteger;
247  std::string variable = runtime.getStringLiteral (index);
248 
249  runtime.getContext().setMemberLong (id, variable, data, mGlobal);
250 
251  runtime.pop();
252  runtime.pop();
253  runtime.pop();
254  }
255  };
256 
258  {
259  bool mGlobal;
260 
261  public:
262 
263  OpStoreMemberFloat (bool global) : mGlobal (global) {}
264 
265  virtual void execute (Runtime& runtime)
266  {
267  Type_Float data = runtime[0].mFloat;
268  Type_Integer index = runtime[1].mInteger;
269  std::string id = runtime.getStringLiteral (index);
270  index = runtime[2].mInteger;
271  std::string variable = runtime.getStringLiteral (index);
272 
273  runtime.getContext().setMemberFloat (id, variable, data, mGlobal);
274 
275  runtime.pop();
276  runtime.pop();
277  runtime.pop();
278  }
279  };
280 
282  {
283  bool mGlobal;
284 
285  public:
286 
287  OpFetchMemberShort (bool global) : mGlobal (global) {}
288 
289  virtual void execute (Runtime& runtime)
290  {
291  Type_Integer index = runtime[0].mInteger;
292  std::string id = runtime.getStringLiteral (index);
293  index = runtime[1].mInteger;
294  std::string variable = runtime.getStringLiteral (index);
295  runtime.pop();
296 
297  int value = runtime.getContext().getMemberShort (id, variable, mGlobal);
298  runtime[0].mInteger = value;
299  }
300  };
301 
302  class OpFetchMemberLong : public Opcode0
303  {
304  bool mGlobal;
305 
306  public:
307 
308  OpFetchMemberLong (bool global) : mGlobal (global) {}
309 
310  virtual void execute (Runtime& runtime)
311  {
312  Type_Integer index = runtime[0].mInteger;
313  std::string id = runtime.getStringLiteral (index);
314  index = runtime[1].mInteger;
315  std::string variable = runtime.getStringLiteral (index);
316  runtime.pop();
317 
318  int value = runtime.getContext().getMemberLong (id, variable, mGlobal);
319  runtime[0].mInteger = value;
320  }
321  };
322 
324  {
325  bool mGlobal;
326 
327  public:
328 
329  OpFetchMemberFloat (bool global) : mGlobal (global) {}
330 
331  virtual void execute (Runtime& runtime)
332  {
333  Type_Integer index = runtime[0].mInteger;
334  std::string id = runtime.getStringLiteral (index);
335  index = runtime[1].mInteger;
336  std::string variable = runtime.getStringLiteral (index);
337  runtime.pop();
338 
339  float value = runtime.getContext().getMemberFloat (id, variable, mGlobal);
340  runtime[0].mFloat = value;
341  }
342  };
343 }
344 
345 #endif
virtual void execute(Runtime &runtime)
Definition: localopcodes.hpp:174
virtual void setMemberShort(const std::string &id, const std::string &name, int value, bool global)=0
Definition: localopcodes.hpp:58
virtual void execute(Runtime &runtime)
Definition: localopcodes.hpp:84
Definition: localopcodes.hpp:116
bool mGlobal
Definition: localopcodes.hpp:211
Definition: localopcodes.hpp:69
Definition: localopcodes.hpp:26
virtual void execute(Runtime &runtime)
Definition: localopcodes.hpp:241
virtual float getLocalFloat(int index) const =0
void pop()
pop stack
Definition: runtime.cpp:94
OpStoreMemberLong(bool global)
Definition: localopcodes.hpp:239
bool mGlobal
Definition: localopcodes.hpp:325
virtual void execute(Runtime &runtime)
Definition: localopcodes.hpp:310
Definition: localopcodes.hpp:10
virtual void execute(Runtime &runtime)
Definition: localopcodes.hpp:73
Definition: localopcodes.hpp:233
std::string getStringLiteral(int index) const
Definition: runtime.cpp:34
Runtime data and engine interface.
Definition: runtime.hpp:15
virtual void setGlobalFloat(const std::string &name, float value)=0
virtual void execute(Runtime &runtime)
Definition: localopcodes.hpp:265
opcode for 0 arguments
Definition: opcodes.hpp:9
virtual void setMemberFloat(const std::string &id, const std::string &name, float value, bool global)=0
virtual void execute(Runtime &runtime)
Definition: localopcodes.hpp:46
virtual int getLocalLong(int index) const =0
virtual void setMemberLong(const std::string &id, const std::string &name, int value, bool global)=0
bool mGlobal
Definition: localopcodes.hpp:235
OpStoreMemberShort(bool global)
Definition: localopcodes.hpp:215
virtual int getMemberShort(const std::string &id, const std::string &name, bool global) const =0
virtual int getMemberLong(const std::string &id, const std::string &name, bool global) const =0
float getFloatLiteral(int index) const
Definition: runtime.cpp:25
virtual float getMemberFloat(const std::string &id, const std::string &name, bool global) const =0
virtual void execute(Runtime &runtime)
Definition: localopcodes.hpp:30
Definition: localopcodes.hpp:92
Definition: localopcodes.hpp:323
Definition: localopcodes.hpp:257
virtual void execute(Runtime &runtime)
Definition: localopcodes.hpp:156
Definition: localopcodes.hpp:170
virtual void execute(Runtime &runtime)
Definition: localopcodes.hpp:289
virtual int getGlobalLong(const std::string &name) const =0
OpFetchMemberShort(bool global)
Definition: localopcodes.hpp:287
Definition: localopcodes.hpp:152
virtual void setLocalFloat(int index, float value)=0
virtual void execute(Runtime &runtime)
Definition: localopcodes.hpp:331
virtual float getGlobalFloat(const std::string &name) const =0
virtual int getGlobalShort(const std::string &name) const =0
Definition: localopcodes.hpp:302
virtual void setLocalLong(int index, int value)=0
virtual void setGlobalLong(const std::string &name, int value)=0
Definition: localopcodes.hpp:104
Definition: localopcodes.hpp:209
virtual void execute(Runtime &runtime)
Definition: localopcodes.hpp:138
Definition: localopcodes.hpp:42
virtual int getLocalShort(int index) const =0
virtual void execute(Runtime &runtime)
Definition: localopcodes.hpp:108
virtual void setGlobalShort(const std::string &name, int value)=0
Definition: localopcodes.hpp:281
int getIntegerLiteral(int index) const
Definition: runtime.cpp:16
Definition: localopcodes.hpp:80
Context & getContext()
Definition: runtime.cpp:110
virtual void execute(Runtime &runtime)
Definition: localopcodes.hpp:14
virtual void execute(Runtime &runtime)
Definition: localopcodes.hpp:200
virtual void execute(Runtime &runtime)
Definition: localopcodes.hpp:187
float Type_Float
Definition: types.hpp:16
virtual void setLocalShort(int index, int value)=0
OpFetchMemberLong(bool global)
Definition: localopcodes.hpp:308
Definition: localopcodes.hpp:183
Definition: localopcodes.hpp:196
bool mGlobal
Definition: localopcodes.hpp:283
bool mGlobal
Definition: localopcodes.hpp:304
virtual void execute(Runtime &runtime)
Definition: localopcodes.hpp:120
Definition: localopcodes.hpp:134
OpStoreMemberFloat(bool global)
Definition: localopcodes.hpp:263
virtual void execute(Runtime &runtime)
Definition: localopcodes.hpp:62
bool mGlobal
Definition: localopcodes.hpp:259
virtual void execute(Runtime &runtime)
Definition: localopcodes.hpp:96
OpFetchMemberFloat(bool global)
Definition: localopcodes.hpp:329
const char * name
Definition: crashcatcher.cpp:59
virtual void execute(Runtime &runtime)
Definition: localopcodes.hpp:217