00001
00002
00003
00004
00005
00006 #ifndef __BS_CORE_H__
00007 #define __BS_CORE_H__
00008
00009 #include <vector>
00010 #include <map>
00011 #include "bsPrerequisites.h"
00012 #include "bsDeepMemoryPool.h"
00013
00014 namespace BS_NMSP
00015 {
00016 struct EmitTypeControl;
00017
00024 struct UserTypeBase
00025 {
00027 EmitTypeControl* _et_;
00028 };
00029
00033 struct MemberVariableDeclaration
00034 {
00036 String name;
00038 bstype value;
00039 };
00040
00041 typedef std::multimap<String, MemberVariableDeclaration> MemberVariableDeclarationMap;
00042
00049 enum ScriptStatus
00050 {
00051 ScriptSuspended,
00052 ScriptOK
00053 };
00054
00059 struct ScriptState
00060 {
00062 uint16 curInstruction;
00063
00065 uint16 stackHead;
00066
00068 bstype stack[BS_SCRIPT_STACK_SIZE];
00069
00071 bstype suspendTime;
00072
00075 bstype* locals;
00076
00077 public:
00078
00081 ScriptState();
00082 };
00083
00086 struct _BSAPI ScriptRecord
00087 {
00089 bstype* members;
00090
00091
00092
00094 int numMembers;
00095
00097 int curState;
00098
00100 ScriptState scriptState;
00101
00102 public:
00103
00106 explicit ScriptRecord(int numLocals);
00107
00110 ~ScriptRecord();
00111 };
00112
00113
00117 #ifdef BS_Z_DIMENSION
00118 typedef UserTypeBase* (BS_CALLCONV *EmitFunction) (bstype, bstype, bstype, bstype, const bstype*, void*);
00119 #else
00120 typedef UserTypeBase* (BS_CALLCONV *EmitFunction) (bstype, bstype, bstype, const bstype*, void*);
00121 #endif
00122
00126 typedef void (BS_CALLCONV *DieFunction) (UserTypeBase*, void*);
00127
00131 typedef void (BS_CALLCONV *SetFunction) (UserTypeBase*, bstype);
00132
00136 typedef bstype (BS_CALLCONV *GetFunction) (UserTypeBase*);
00137
00141 typedef void (BS_CALLCONV *AffectorFunction) (UserTypeBase*, float, const bstype*);
00142
00146 typedef int (BS_CALLCONV *NativeFunction)(ScriptState&);
00147
00151 typedef float (BS_CALLCONV *JittedFunction)();
00152
00153 class ScriptMachine;
00157 typedef JittedFunction (BS_CALLCONV *JitterHookFunction)(const unsigned int*, size_t, const char*, ScriptMachine* bsMachine);
00158
00163 class _BSAPI CodeRecord
00164 {
00165
00166 std::vector<String> mVariables;
00167
00168 String mName;
00169
00170 public:
00171
00175 uint32* byteCode;
00176
00180 size_t byteCodeSize;
00181
00185 JittedFunction jitFunction;
00186
00187 public:
00188
00192 explicit CodeRecord(const String& name);
00193
00196 ~CodeRecord();
00197
00202 const String& getName() const;
00203
00208 void addVariable(const String& name);
00209
00215 const String& getVariable(int index) const;
00216
00221 int getVariableIndex(const String& name) const;
00222
00227 int getNumVariables() const;
00228 };
00229
00230
00235 enum
00236 {
00237 Member_X,
00238 Member_Y,
00239 #ifdef BS_Z_DIMENSION
00240 Member_Z,
00241 #endif
00242 Member_Angle,
00243 NUM_SPECIAL_MEMBERS
00244 };
00245
00251 enum
00252 {
00253 Property_X,
00254 Property_Y,
00255 #ifdef BS_Z_DIMENSION
00256 Property_Z,
00257 #endif
00258 Property_Angle,
00259 NUM_SPECIAL_PROPERTIES
00260 };
00261
00262 }
00263
00264 #endif