OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
genericopcodes.hpp
Go to the documentation of this file.
1 #ifndef INTERPRETER_GENERICOPCODES_H_INCLUDED
2 #define INTERPRETER_GENERICOPCODES_H_INCLUDED
3 
4 #include "opcodes.hpp"
5 #include "runtime.hpp"
6 
7 namespace Interpreter
8 {
9  class OpPushInt : public Opcode1
10  {
11  public:
12 
13  virtual void execute (Runtime& runtime, unsigned int arg0)
14  {
15  runtime.push (static_cast<Type_Integer> (arg0));
16  }
17  };
18 
19  class OpIntToFloat : public Opcode0
20  {
21  public:
22 
23  virtual void execute (Runtime& runtime)
24  {
25  Type_Integer data = runtime[0].mInteger;
26  Type_Float floatValue = static_cast<Type_Float> (data);
27  runtime[0].mFloat = floatValue;
28  }
29  };
30 
31  class OpFloatToInt : public Opcode0
32  {
33  public:
34 
35  virtual void execute (Runtime& runtime)
36  {
37  Type_Float data = runtime[0].mFloat;
38  Type_Integer integerValue = static_cast<Type_Integer> (data);
39  runtime[0].mInteger = integerValue;
40  }
41  };
42 
43  class OpNegateInt : public Opcode0
44  {
45  public:
46 
47  virtual void execute (Runtime& runtime)
48  {
49  Type_Integer data = runtime[0].mInteger;
50  data = -data;
51  runtime[0].mInteger = data;
52  }
53  };
54 
55  class OpNegateFloat : public Opcode0
56  {
57  public:
58 
59  virtual void execute (Runtime& runtime)
60  {
61  Type_Float data = runtime[0].mFloat;
62  data = -data;
63  runtime[0].mFloat = data;
64  }
65  };
66 
67  class OpIntToFloat1 : public Opcode0
68  {
69  public:
70 
71  virtual void execute (Runtime& runtime)
72  {
73  Type_Integer data = runtime[1].mInteger;
74  Type_Float floatValue = static_cast<Type_Float> (data);
75  runtime[1].mFloat = floatValue;
76  }
77  };
78 
79  class OpFloatToInt1 : public Opcode0
80  {
81  public:
82 
83  virtual void execute (Runtime& runtime)
84  {
85  Type_Float data = runtime[1].mFloat;
86  Type_Integer integerValue = static_cast<Type_Integer> (data);
87  runtime[1].mInteger = integerValue;
88  }
89  };
90 }
91 
92 #endif
93 
Definition: genericopcodes.hpp:43
virtual void execute(Runtime &runtime)
Definition: genericopcodes.hpp:35
void push(const Data &data)
push data on stack
Definition: runtime.cpp:75
Runtime data and engine interface.
Definition: runtime.hpp:15
opcode for 0 arguments
Definition: opcodes.hpp:9
virtual void execute(Runtime &runtime)
Definition: genericopcodes.hpp:47
virtual void execute(Runtime &runtime)
Definition: genericopcodes.hpp:59
virtual void execute(Runtime &runtime)
Definition: genericopcodes.hpp:23
virtual void execute(Runtime &runtime, unsigned int arg0)
Definition: genericopcodes.hpp:13
Definition: genericopcodes.hpp:19
Definition: genericopcodes.hpp:79
virtual void execute(Runtime &runtime)
Definition: genericopcodes.hpp:71
Definition: genericopcodes.hpp:9
float Type_Float
Definition: types.hpp:16
virtual void execute(Runtime &runtime)
Definition: genericopcodes.hpp:83
opcode for 1 argument
Definition: opcodes.hpp:19
Definition: genericopcodes.hpp:67
Definition: genericopcodes.hpp:55
Definition: genericopcodes.hpp:31