OpenMW
components/interpreter/localopcodes.hpp
Go to the documentation of this file.
00001 #ifndef INTERPRETER_LOCALOPCODES_H_INCLUDED
00002 #define INTERPRETER_LOCALOPCODES_H_INCLUDED
00003 
00004 #include "opcodes.hpp"
00005 #include "runtime.hpp"
00006 #include "context.hpp"
00007 
00008 namespace Interpreter
00009 {
00010     class OpStoreLocalShort : public Opcode0
00011     {
00012         public:
00013 
00014             virtual void execute (Runtime& runtime)
00015             {
00016                 Type_Integer data = runtime[0].mInteger;
00017                 int index = runtime[1].mInteger;
00018 
00019                 runtime.getContext().setLocalShort (index, data);
00020 
00021                 runtime.pop();
00022                 runtime.pop();
00023             }
00024     };
00025 
00026     class OpStoreLocalLong : public Opcode0
00027     {
00028         public:
00029 
00030             virtual void execute (Runtime& runtime)
00031             {
00032                 Type_Integer data = runtime[0].mInteger;
00033                 int index = runtime[1].mInteger;
00034 
00035                 runtime.getContext().setLocalLong (index, data);
00036 
00037                 runtime.pop();
00038                 runtime.pop();
00039             }
00040     };
00041 
00042     class OpStoreLocalFloat : public Opcode0
00043     {
00044         public:
00045 
00046             virtual void execute (Runtime& runtime)
00047             {
00048                 Type_Float data = runtime[0].mFloat;
00049                 int index = runtime[1].mInteger;
00050 
00051                 runtime.getContext().setLocalFloat (index, data);
00052 
00053                 runtime.pop();
00054                 runtime.pop();
00055             }
00056     };
00057 
00058     class OpFetchIntLiteral : public Opcode0
00059     {
00060         public:
00061 
00062             virtual void execute (Runtime& runtime)
00063             {
00064                 Type_Integer intValue = runtime.getIntegerLiteral (runtime[0].mInteger);
00065                 runtime[0].mInteger = intValue;
00066             }
00067     };
00068 
00069     class OpFetchFloatLiteral : public Opcode0
00070     {
00071         public:
00072 
00073             virtual void execute (Runtime& runtime)
00074             {
00075                 Type_Float floatValue = runtime.getFloatLiteral (runtime[0].mInteger);
00076                 runtime[0].mFloat = floatValue;
00077             }
00078     };
00079 
00080     class OpFetchLocalShort : public Opcode0
00081     {
00082         public:
00083 
00084             virtual void execute (Runtime& runtime)
00085             {
00086                 int index = runtime[0].mInteger;
00087                 int value = runtime.getContext().getLocalShort (index);
00088                 runtime[0].mInteger = value;
00089             }
00090     };
00091 
00092     class OpFetchLocalLong : public Opcode0
00093     {
00094         public:
00095 
00096             virtual void execute (Runtime& runtime)
00097             {
00098                 int index = runtime[0].mInteger;
00099                 int value = runtime.getContext().getLocalLong (index);
00100                 runtime[0].mInteger = value;
00101             }
00102     };
00103 
00104     class OpFetchLocalFloat : public Opcode0
00105     {
00106         public:
00107 
00108             virtual void execute (Runtime& runtime)
00109             {
00110                 int index = runtime[0].mInteger;
00111                 float value = runtime.getContext().getLocalFloat (index);
00112                 runtime[0].mFloat = value;
00113             }
00114     };
00115 
00116     class OpStoreGlobalShort : public Opcode0
00117     {
00118         public:
00119 
00120             virtual void execute (Runtime& runtime)
00121             {
00122                 Type_Integer data = runtime[0].mInteger;
00123                 int index = runtime[1].mInteger;
00124 
00125                 std::string name = runtime.getStringLiteral (index);
00126 
00127                 runtime.getContext().setGlobalShort (name, data);
00128 
00129                 runtime.pop();
00130                 runtime.pop();
00131             }
00132     };
00133 
00134     class OpStoreGlobalLong : public Opcode0
00135     {
00136         public:
00137 
00138             virtual void execute (Runtime& runtime)
00139             {
00140                 Type_Integer data = runtime[0].mInteger;
00141                 int index = runtime[1].mInteger;
00142 
00143                 std::string name = runtime.getStringLiteral (index);
00144 
00145                 runtime.getContext().setGlobalLong (name, data);
00146 
00147                 runtime.pop();
00148                 runtime.pop();
00149             }
00150     };
00151 
00152     class OpStoreGlobalFloat : public Opcode0
00153     {
00154         public:
00155 
00156             virtual void execute (Runtime& runtime)
00157             {
00158                 Type_Float data = runtime[0].mFloat;
00159                 int index = runtime[1].mInteger;
00160 
00161                 std::string name = runtime.getStringLiteral (index);
00162 
00163                 runtime.getContext().setGlobalFloat (name, data);
00164 
00165                 runtime.pop();
00166                 runtime.pop();
00167             }
00168     };
00169 
00170     class OpFetchGlobalShort : public Opcode0
00171     {
00172         public:
00173 
00174             virtual void execute (Runtime& runtime)
00175             {
00176                 int index = runtime[0].mInteger;
00177                 std::string name = runtime.getStringLiteral (index);
00178                 Type_Integer value = runtime.getContext().getGlobalShort (name);
00179                 runtime[0].mInteger = value;
00180             }
00181     };
00182 
00183     class OpFetchGlobalLong : public Opcode0
00184     {
00185         public:
00186 
00187             virtual void execute (Runtime& runtime)
00188             {
00189                 int index = runtime[0].mInteger;
00190                 std::string name = runtime.getStringLiteral (index);
00191                 Type_Integer value = runtime.getContext().getGlobalLong (name);
00192                 runtime[0].mInteger = value;
00193             }
00194     };
00195 
00196     class OpFetchGlobalFloat : public Opcode0
00197     {
00198         public:
00199 
00200             virtual void execute (Runtime& runtime)
00201             {
00202                 int index = runtime[0].mInteger;
00203                 std::string name = runtime.getStringLiteral (index);
00204                 Type_Float value = runtime.getContext().getGlobalFloat (name);
00205                 runtime[0].mFloat = value;
00206             }
00207     };
00208 
00209     class OpStoreMemberShort : public Opcode0
00210     {
00211         public:
00212 
00213             virtual void execute (Runtime& runtime)
00214             {
00215                 Type_Integer data = runtime[0].mInteger;
00216                 Type_Integer index = runtime[1].mInteger;
00217                 std::string id = runtime.getStringLiteral (index);
00218                 index = runtime[2].mInteger;
00219                 std::string variable = runtime.getStringLiteral (index);
00220 
00221                 runtime.getContext().setMemberShort (id, variable, data);
00222 
00223                 runtime.pop();
00224                 runtime.pop();
00225                 runtime.pop();
00226             }
00227     };
00228 
00229     class OpStoreMemberLong : public Opcode0
00230     {
00231         public:
00232 
00233             virtual void execute (Runtime& runtime)
00234             {
00235                 Type_Integer data = runtime[0].mInteger;
00236                 Type_Integer index = runtime[1].mInteger;
00237                 std::string id = runtime.getStringLiteral (index);
00238                 index = runtime[2].mInteger;
00239                 std::string variable = runtime.getStringLiteral (index);
00240 
00241                 runtime.getContext().setMemberLong (id, variable, data);
00242 
00243                 runtime.pop();
00244                 runtime.pop();
00245                 runtime.pop();
00246             }
00247     };
00248 
00249     class OpStoreMemberFloat : public Opcode0
00250     {
00251         public:
00252 
00253             virtual void execute (Runtime& runtime)
00254             {
00255                 Type_Float data = runtime[0].mFloat;
00256                 Type_Integer index = runtime[1].mInteger;
00257                 std::string id = runtime.getStringLiteral (index);
00258                 index = runtime[2].mInteger;
00259                 std::string variable = runtime.getStringLiteral (index);
00260 
00261                 runtime.getContext().setMemberFloat (id, variable, data);
00262 
00263                 runtime.pop();
00264                 runtime.pop();
00265                 runtime.pop();
00266             }
00267     };
00268 
00269     class OpFetchMemberShort : public Opcode0
00270     {
00271         public:
00272 
00273             virtual void execute (Runtime& runtime)
00274             {
00275                 Type_Integer index = runtime[0].mInteger;
00276                 std::string id = runtime.getStringLiteral (index);
00277                 index = runtime[1].mInteger;
00278                 std::string variable = runtime.getStringLiteral (index);
00279                 runtime.pop();
00280 
00281                 int value = runtime.getContext().getMemberShort (id, variable);
00282                 runtime[0].mInteger = value;
00283             }
00284     };
00285 
00286     class OpFetchMemberLong : public Opcode0
00287     {
00288         public:
00289 
00290             virtual void execute (Runtime& runtime)
00291             {
00292                 Type_Integer index = runtime[0].mInteger;
00293                 std::string id = runtime.getStringLiteral (index);
00294                 index = runtime[1].mInteger;
00295                 std::string variable = runtime.getStringLiteral (index);
00296                 runtime.pop();
00297 
00298                 int value = runtime.getContext().getMemberLong (id, variable);
00299                 runtime[0].mInteger = value;
00300             }
00301     };
00302 
00303     class OpFetchMemberFloat : public Opcode0
00304     {
00305         public:
00306 
00307             virtual void execute (Runtime& runtime)
00308             {
00309                 Type_Integer index = runtime[0].mInteger;
00310                 std::string id = runtime.getStringLiteral (index);
00311                 index = runtime[1].mInteger;
00312                 std::string variable = runtime.getStringLiteral (index);
00313                 runtime.pop();
00314 
00315                 float value = runtime.getContext().getMemberFloat (id, variable);
00316                 runtime[0].mFloat = value;
00317             }
00318     };
00319 }
00320 
00321 #endif