00001 00032 #ifndef LL_LSCRIPT_BYTECODE_H 00033 #define LL_LSCRIPT_BYTECODE_H 00034 00035 #include "lscript_byteconvert.h" 00036 #include "lscript_scope.h" 00037 00038 class LLScriptJumpTable 00039 { 00040 public: 00041 LLScriptJumpTable(); 00042 ~LLScriptJumpTable(); 00043 00044 void addLabel(char *name, S32 offset); 00045 void addJump(char *name, S32 offset); 00046 00047 LLMap<char *, S32 *> mLabelMap; 00048 LLMap<char *, S32 *> mJumpMap; 00049 }; 00050 00051 class LLScriptByteCodeChunk 00052 { 00053 public: 00054 LLScriptByteCodeChunk(BOOL b_need_jumps); 00055 ~LLScriptByteCodeChunk(); 00056 00057 void addByte(U8 byte); 00058 void addU16(U16 data); 00059 void addBytes(U8 *bytes, S32 size); 00060 void addBytes(char *bytes, S32 size); 00061 void addBytes(S32 size); 00062 void addBytesDontInc(S32 size); 00063 void addInteger(S32 value); 00064 void addFloat(F32 value); 00065 void addLabel(char *name); 00066 void addJump(char *name); 00067 void connectJumps(); 00068 00069 U8 *mCodeChunk; 00070 S32 mCurrentOffset; 00071 LLScriptJumpTable *mJumpTable; 00072 }; 00073 00074 class LLScriptScriptCodeChunk 00075 { 00076 public: 00077 LLScriptScriptCodeChunk(S32 total_size); 00078 ~LLScriptScriptCodeChunk(); 00079 00080 void build(FILE *efp, FILE *bcfp); 00081 00082 LLScriptByteCodeChunk *mRegisters; 00083 LLScriptByteCodeChunk *mGlobalVariables; 00084 LLScriptByteCodeChunk *mGlobalFunctions; 00085 LLScriptByteCodeChunk *mStates; 00086 LLScriptByteCodeChunk *mHeap; 00087 S32 mTotalSize; 00088 U8 *mCompleteCode; 00089 }; 00090 00091 extern LLScriptScriptCodeChunk *gScriptCodeChunk; 00092 00093 #endif 00094