OpenMW
|
00001 #ifndef INTERPRETER_CONTROLOPCODES_H_INCLUDED 00002 #define INTERPRETER_CONTROLOPCODES_H_INCLUDED 00003 00004 #include <stdexcept> 00005 00006 #include "opcodes.hpp" 00007 #include "runtime.hpp" 00008 00009 namespace Interpreter 00010 { 00011 class OpReturn : public Opcode0 00012 { 00013 public: 00014 00015 virtual void execute (Runtime& runtime) 00016 { 00017 runtime.setPC (-1); 00018 } 00019 }; 00020 00021 class OpSkipZero : public Opcode0 00022 { 00023 public: 00024 00025 virtual void execute (Runtime& runtime) 00026 { 00027 Type_Integer data = runtime[0].mInteger; 00028 runtime.pop(); 00029 00030 if (data==0) 00031 runtime.setPC (runtime.getPC()+1); 00032 } 00033 }; 00034 00035 class OpSkipNonZero : public Opcode0 00036 { 00037 public: 00038 00039 virtual void execute (Runtime& runtime) 00040 { 00041 Type_Integer data = runtime[0].mInteger; 00042 runtime.pop(); 00043 00044 if (data!=0) 00045 runtime.setPC (runtime.getPC()+1); 00046 } 00047 }; 00048 00049 class OpJumpForward : public Opcode1 00050 { 00051 public: 00052 00053 virtual void execute (Runtime& runtime, unsigned int arg0) 00054 { 00055 if (arg0==0) 00056 throw std::logic_error ("infinite loop"); 00057 00058 runtime.setPC (runtime.getPC()+arg0-1); 00059 } 00060 }; 00061 00062 class OpJumpBackward : public Opcode1 00063 { 00064 public: 00065 00066 virtual void execute (Runtime& runtime, unsigned int arg0) 00067 { 00068 if (arg0==0) 00069 throw std::logic_error ("infinite loop"); 00070 00071 runtime.setPC (runtime.getPC()-arg0-1); 00072 } 00073 }; 00074 } 00075 00076 #endif