src/parser/impcomp/ExecLoop.h

00001 #ifndef EXECLOOP_H_
00002 #define EXECLOOP_H_
00003 
00004 #include <vector>
00005 #include "OpSeq.h"
00006 #include "engine/VariableTableInstance.h"
00007 #include "engine/TemplateTable.h"
00008 #include "engine/Variable.h"
00009 #include "engine/System.h"
00010 
00011 
00012 
00013 typedef std::vector<uint>::iterator SeqData;
00014 typedef std::vector<uint>::iterator SeqDataIter;
00015 
00016 
00017 namespace green
00018 {
00019 
00020 class ExecException
00021 {
00022 public:
00023         char* message;
00024 
00025 public:
00026         ExecException(char* inStr)
00027                 {
00028                 message = inStr;
00029                 }
00030 
00031         char* toString()
00032                 {
00033                 return message;
00034                 }
00035 };
00036 
00037 
00038 class ExecLoop
00039         {
00040         private:
00041                 class LocalVars
00042                         {
00043                         private:
00044                                 std::vector<Variable::Value> data;
00045                                 uint stackPointer;
00046 
00047                         public:
00048                                 LocalVars();
00049 
00050                                 void setVar(uint offset,Variable::Value value);
00051                                 Variable::Value getVar(uint offset);
00052 
00053                                 void allocate(uint size);
00054                                 void clear();
00055                         };
00056 
00057 
00058                 struct TablePile
00059                         {
00060                         LocalVars localTable;
00061                         VariableTableInstancePtr varTables[OpSeq::BIN_ENUM_COUNT];
00062                         ArgListPtr argTable;
00063                         };
00064 
00065 
00066                 static Variable::Value callFunc(SystemPtr sysPtr,int entityKey,int funcId,ArgListPtr argTable);
00067                 
00068                 static void setVarValI(SeqDataIter& opCur,int intVal,TablePile& tablPile);
00069                 static void setVarValF(SeqDataIter& opCur,float floatVal,TablePile& tablPile);
00070                 static Variable::Value getVarVal(SeqDataIter& opCur,TablePile& tablPile);
00071 
00072                 static void doIntBinaryOp(SeqDataIter& opCur,TablePile& tablPile);
00073                 static void doFloatBinaryOp(SeqDataIter& opCur,TablePile& tablPile);
00074                 static void doUnaryOp(SeqDataIter& opCur,TablePile& tablPile);
00075                 static void doGotoOp(SeqData opData,SeqDataIter& opCur,TablePile& tablPile);
00076                 static void doGotoIfOp(int ifN,SeqData opData,SeqDataIter& opCur,TablePile& tablPile);
00077                 static void doDeclareOp(int ifPop,SeqDataIter& opCur,TablePile& tablPile);
00078                 static void doFuncOp(SystemPtr sysPtr,int entityKey,SeqDataIter& opCur,TablePile& tablPile);
00079 
00080                 static void doRun(SystemPtr sysPtr,int entityKey,SeqData& opSeq,SeqDataIter& opCur,
00081                                   int opSeqLength,TablePile& tablPile);
00082 
00083 
00084         public:
00085                 //ExecLoop();
00086 
00087                 static void runBody(SystemPtr sysPtr,int entityKey,OpSeq& opSeqContainer,
00088                                     VariableTableInstancePtr entityCur,
00089                                     VariableTableInstancePtr entityStart,
00090                                     VariableTableInstancePtr entityOld,
00091                                     VariableTableInstancePtr behavior);
00092                 void runInit(SystemPtr sysPtr,int entityKey,OpSeq& opSeqContainer,
00093                      VariableTableInstancePtr object,ArgListPtr args);
00094 
00095         };
00096 
00097 }
00098 
00099 #endif

Generated on Fri Apr 27 10:27:38 2007 for Green Engine by  doxygen 1.5.1