OpenMW
components/interpreter/genericopcodes.hpp
Go to the documentation of this file.
00001 #ifndef INTERPRETER_GENERICOPCODES_H_INCLUDED
00002 #define INTERPRETER_GENERICOPCODES_H_INCLUDED
00003 
00004 #include "opcodes.hpp"
00005 #include "runtime.hpp"
00006 
00007 namespace Interpreter
00008 {
00009     class OpPushInt : public Opcode1
00010     {
00011         public:
00012         
00013             virtual void execute (Runtime& runtime, unsigned int arg0)
00014             {
00015                 runtime.push (static_cast<Type_Integer> (arg0));
00016             }        
00017     };
00018     
00019     class OpIntToFloat : public Opcode0
00020     {
00021         public:
00022         
00023             virtual void execute (Runtime& runtime)
00024             {
00025                 Type_Integer data = runtime[0].mInteger;
00026                 Type_Float floatValue = static_cast<Type_Float> (data);
00027                 runtime[0].mFloat = floatValue;
00028             }           
00029     };
00030     
00031     class OpFloatToInt : public Opcode0
00032     {
00033         public:
00034         
00035             virtual void execute (Runtime& runtime)
00036             {
00037                 Type_Float data = runtime[0].mFloat;
00038                 Type_Integer integerValue = static_cast<Type_Integer> (data);
00039                 runtime[0].mInteger = integerValue;
00040             }           
00041     };    
00042     
00043     class OpNegateInt : public Opcode0
00044     {
00045         public:
00046         
00047             virtual void execute (Runtime& runtime)
00048             {
00049                 Type_Integer data = runtime[0].mInteger;
00050                 data = -data;
00051                 runtime[0].mInteger = data;
00052             }           
00053     };    
00054     
00055     class OpNegateFloat : public Opcode0
00056     {
00057         public:
00058         
00059             virtual void execute (Runtime& runtime)
00060             {
00061                 Type_Float data = runtime[0].mFloat;
00062                 data = -data;
00063                 runtime[0].mFloat = data;
00064             }           
00065     };
00066     
00067     class OpIntToFloat1 : public Opcode0
00068     {
00069         public:
00070         
00071             virtual void execute (Runtime& runtime)
00072             {
00073                 Type_Integer data = runtime[1].mInteger;
00074                 Type_Float floatValue = static_cast<Type_Float> (data);
00075                 runtime[1].mFloat = floatValue;
00076             }           
00077     };
00078     
00079     class OpFloatToInt1 : public Opcode0
00080     {
00081         public:
00082         
00083             virtual void execute (Runtime& runtime)
00084             {
00085                 Type_Float data = runtime[1].mFloat;
00086                 Type_Integer integerValue = static_cast<Type_Integer> (data);
00087                 runtime[1].mInteger = integerValue;
00088             }           
00089     };            
00090 }
00091 
00092 #endif
00093