00001
00032 #ifndef LL_LSCRIPT_BYTEFORMAT_H
00033 #define LL_LSCRIPT_BYTEFORMAT_H
00034
00035
00036
00037 #include "stdtypes.h"
00038
00039 const S32 LSL2_VERSION_NUMBER = 0x0200;
00040 const S32 LSL2_VERSION1_END_NUMBER = 0x0101;
00041 const S32 LSL2_VERSION2_START_NUMBER = 0x0200;
00042
00043 const S32 LSL2_MAJOR_VERSION_ONE = 1;
00044 const S32 LSL2_MAJOR_VERSION_TWO = 2;
00045 const S32 LSL2_CURRENT_MAJOR_VERSION = LSL2_MAJOR_VERSION_TWO;
00046
00047 const S32 TOP_OF_MEMORY = 16384;
00048
00049 typedef enum e_lscript_registers
00050 {
00051 LREG_INVALID,
00052 LREG_IP,
00053 LREG_VN,
00054 LREG_BP,
00055 LREG_SP,
00056 LREG_HR,
00057 LREG_HP,
00058 LREG_CS,
00059 LREG_NS,
00060 LREG_CE,
00061 LREG_IE,
00062 LREG_ER,
00063 LREG_FR,
00064 LREG_SLR,
00065 LREG_GVR,
00066 LREG_GFR,
00067 LREG_SR,
00068 LREG_TM,
00069 LREG_PR,
00070 LREG_ESR,
00071 LREG_NCE,
00072 LREG_NIE,
00073 LREG_NER,
00074 LREG_EOF
00075 } LSCRIPTRegisters;
00076
00077 const S32 gLSCRIPTRegisterAddresses[LREG_EOF] =
00078 {
00079 0,
00080 4,
00081 8,
00082 12,
00083 16,
00084 20,
00085 24,
00086 28,
00087 32,
00088 36,
00089 40,
00090 44,
00091 48,
00092 52,
00093 56,
00094 60,
00095 72,
00096 0,
00097 64,
00098 68,
00099 76,
00100 84,
00101 92,
00102 };
00103
00104 const char * const gLSCRIPTRegisterNames[LREG_EOF] =
00105 {
00106 "INVALID",
00107 "IP",
00108 "VN",
00109 "BP",
00110 "SP",
00111 "HR",
00112 "HP",
00113 "CS",
00114 "NS",
00115 "CE",
00116 "IE",
00117 "ER",
00118 "FR",
00119 "SLR",
00120 "GVR",
00121 "GFR",
00122 "SR",
00123 "TM",
00124 "PR",
00125 "ESR",
00126 "NCE",
00127 "NIE",
00128 "NER",
00129 };
00130
00131 typedef enum e_lscript_op_codes
00132 {
00133 LOPC_INVALID,
00134 LOPC_NOOP,
00135 LOPC_POP,
00136 LOPC_POPS,
00137 LOPC_POPL,
00138 LOPC_POPV,
00139 LOPC_POPQ,
00140 LOPC_POPARG,
00141 LOPC_POPIP,
00142 LOPC_POPBP,
00143 LOPC_POPSP,
00144 LOPC_POPSLR,
00145 LOPC_DUP,
00146 LOPC_DUPS,
00147 LOPC_DUPL,
00148 LOPC_DUPV,
00149 LOPC_DUPQ,
00150 LOPC_STORE,
00151 LOPC_STORES,
00152 LOPC_STOREL,
00153 LOPC_STOREV,
00154 LOPC_STOREQ,
00155 LOPC_STOREG,
00156 LOPC_STOREGS,
00157 LOPC_STOREGL,
00158 LOPC_STOREGV,
00159 LOPC_STOREGQ,
00160 LOPC_LOADP,
00161 LOPC_LOADSP,
00162 LOPC_LOADLP,
00163 LOPC_LOADVP,
00164 LOPC_LOADQP,
00165 LOPC_LOADGP,
00166 LOPC_LOADGLP,
00167 LOPC_LOADGSP,
00168 LOPC_LOADGVP,
00169 LOPC_LOADGQP,
00170 LOPC_PUSH,
00171 LOPC_PUSHS,
00172 LOPC_PUSHL,
00173 LOPC_PUSHV,
00174 LOPC_PUSHQ,
00175 LOPC_PUSHG,
00176 LOPC_PUSHGS,
00177 LOPC_PUSHGL,
00178 LOPC_PUSHGV,
00179 LOPC_PUSHGQ,
00180 LOPC_PUSHIP,
00181 LOPC_PUSHBP,
00182 LOPC_PUSHSP,
00183 LOPC_PUSHARGB,
00184 LOPC_PUSHARGI,
00185 LOPC_PUSHARGF,
00186 LOPC_PUSHARGS,
00187 LOPC_PUSHARGV,
00188 LOPC_PUSHARGQ,
00189 LOPC_PUSHE,
00190 LOPC_PUSHEV,
00191 LOPC_PUSHEQ,
00192 LOPC_PUSHARGE,
00193 LOPC_ADD,
00194 LOPC_SUB,
00195 LOPC_MUL,
00196 LOPC_DIV,
00197 LOPC_MOD,
00198 LOPC_EQ,
00199 LOPC_NEQ,
00200 LOPC_LEQ,
00201 LOPC_GEQ,
00202 LOPC_LESS,
00203 LOPC_GREATER,
00204 LOPC_BITAND,
00205 LOPC_BITOR,
00206 LOPC_BITXOR,
00207 LOPC_BOOLAND,
00208 LOPC_BOOLOR,
00209 LOPC_NEG,
00210 LOPC_BITNOT,
00211 LOPC_BOOLNOT,
00212 LOPC_JUMP,
00213 LOPC_JUMPIF,
00214 LOPC_JUMPNIF,
00215 LOPC_STATE,
00216 LOPC_CALL,
00217 LOPC_RETURN,
00218 LOPC_CAST,
00219 LOPC_STACKTOS,
00220 LOPC_STACKTOL,
00221 LOPC_PRINT,
00222 LOPC_CALLLIB,
00223 LOPC_CALLLIB_TWO_BYTE,
00224 LOPC_SHL,
00225 LOPC_SHR,
00226 LOPC_EOF
00227 } LSCRIPTOpCodesEnum;
00228
00229 const U8 LSCRIPTOpCodes[LOPC_EOF] =
00230 {
00231 0x00,
00232 0x00,
00233 0x01,
00234 0x02,
00235 0x03,
00236 0x04,
00237 0x05,
00238 0x06,
00239 0x07,
00240 0x08,
00241 0x09,
00242 0x0a,
00243 0x20,
00244 0x21,
00245 0x22,
00246 0x23,
00247 0x24,
00248 0x30,
00249 0x31,
00250 0x32,
00251 0x33,
00252 0x34,
00253 0x35,
00254 0x36,
00255 0x37,
00256 0x38,
00257 0x39,
00258 0x3a,
00259 0x3b,
00260 0x3c,
00261 0x3d,
00262 0x3e,
00263 0x3f,
00264 0x40,
00265 0x41,
00266 0x42,
00267 0x43,
00268 0x50,
00269 0x51,
00270 0x52,
00271 0x53,
00272 0x54,
00273 0x55,
00274 0x56,
00275 0x57,
00276 0x58,
00277 0x59,
00278 0x5a,
00279 0x5b,
00280 0x5c,
00281 0x5d,
00282 0x5e,
00283 0x5f,
00284 0x60,
00285 0x61,
00286 0x62,
00287 0x63,
00288 0x64,
00289 0x65,
00290 0x66,
00291 0x70,
00292 0x71,
00293 0x72,
00294 0x73,
00295 0x74,
00296 0x75,
00297 0x76,
00298 0x77,
00299 0x78,
00300 0x79,
00301 0x7a,
00302 0x7b,
00303 0x7c,
00304 0x7d,
00305 0x7e,
00306 0x7f,
00307 0x80,
00308 0x81,
00309 0x82,
00310 0x90,
00311 0x91,
00312 0x92,
00313 0x93,
00314 0x94,
00315 0x95,
00316 0xa0,
00317 0xb0,
00318 0xb1,
00319 0xc0,
00320 0xd0,
00321 0xd1,
00322 0xe0,
00323 0xe1
00324 };
00325
00326 typedef enum e_lscript_state_event_type
00327 {
00328 LSTT_NULL,
00329 LSTT_STATE_ENTRY,
00330 LSTT_STATE_EXIT,
00331 LSTT_TOUCH_START,
00332 LSTT_TOUCH,
00333 LSTT_TOUCH_END,
00334 LSTT_COLLISION_START,
00335 LSTT_COLLISION,
00336 LSTT_COLLISION_END,
00337 LSTT_LAND_COLLISION_START,
00338 LSTT_LAND_COLLISION,
00339 LSTT_LAND_COLLISION_END,
00340 LSTT_TIMER,
00341 LSTT_CHAT,
00342 LSTT_REZ,
00343 LSTT_SENSOR,
00344 LSTT_NO_SENSOR,
00345 LSTT_CONTROL,
00346 LSTT_MONEY,
00347 LSTT_EMAIL,
00348 LSTT_AT_TARGET,
00349 LSTT_NOT_AT_TARGET,
00350 LSTT_AT_ROT_TARGET,
00351 LSTT_NOT_AT_ROT_TARGET,
00352 LSTT_RTPERMISSIONS,
00353 LSTT_INVENTORY,
00354 LSTT_ATTACH,
00355 LSTT_DATASERVER,
00356 LSTT_LINK_MESSAGE,
00357 LSTT_MOVING_START,
00358 LSTT_MOVING_END,
00359 LSTT_OBJECT_REZ,
00360 LSTT_REMOTE_DATA,
00361 LSTT_HTTP_RESPONSE,
00362 LSTT_EOF,
00363
00364 LSTT_STATE_BEGIN = LSTT_STATE_ENTRY,
00365 LSTT_STATE_END = LSTT_EOF
00366 } LSCRIPTStateEventType;
00367
00368 const U64 LSCRIPTStateBitField[LSTT_EOF] =
00369 {
00370 0x0000000000000000,
00371 0x0000000000000001,
00372 0x0000000000000002,
00373 0x0000000000000004,
00374 0x0000000000000008,
00375 0x0000000000000010,
00376 0x0000000000000020,
00377 0x0000000000000040,
00378 0x0000000000000080,
00379 0x0000000000000100,
00380 0x0000000000000200,
00381 0x0000000000000400,
00382 0x0000000000000800,
00383 0x0000000000001000,
00384 0x0000000000002000,
00385 0x0000000000004000,
00386 0x0000000000008000,
00387 0x0000000000010000,
00388 0x0000000000020000,
00389 0x0000000000040000,
00390 0x0000000000080000,
00391 0x0000000000100000,
00392 0x0000000000200000,
00393 0x0000000000400000,
00394 0x0000000000800000,
00395 0x0000000001000000,
00396 0x0000000002000000,
00397 0x0000000004000000,
00398 0x0000000008000000,
00399 0x0000000010000000,
00400 0x0000000020000000,
00401 0x0000000040000000,
00402 0x0000000080000000,
00403 0x0000000100000000LL
00404 };
00405
00406 inline S32 get_event_handler_jump_position(U64 bit_field, LSCRIPTStateEventType type)
00407 {
00408 S32 count = 0, position = LSTT_STATE_ENTRY;
00409 while (position < type)
00410 {
00411 if (bit_field & 0x1)
00412 {
00413 count++;
00414 }
00415 bit_field >>= 1;
00416 position++;
00417 }
00418 return count;
00419 }
00420
00421 inline S32 get_number_of_event_handlers(U64 bit_field)
00422 {
00423 S32 count = 0, position = 0;
00424 while (position < LSTT_EOF)
00425 {
00426 if (bit_field & 0x1)
00427 {
00428 count++;
00429 }
00430 bit_field >>= 1;
00431 position++;
00432 }
00433 return count;
00434 }
00435
00436 typedef enum e_lscript_types
00437 {
00438 LST_NULL,
00439 LST_INTEGER,
00440 LST_FLOATINGPOINT,
00441 LST_STRING,
00442 LST_KEY,
00443 LST_VECTOR,
00444 LST_QUATERNION,
00445 LST_LIST,
00446 LST_UNDEFINED,
00447 LST_EOF
00448 } LSCRIPTType;
00449
00450 const U8 LSCRIPTTypeByte[LST_EOF] =
00451 {
00452 LST_NULL,
00453 LST_INTEGER,
00454 LST_FLOATINGPOINT,
00455 LST_STRING,
00456 LST_KEY,
00457 LST_VECTOR,
00458 LST_QUATERNION,
00459 LST_LIST,
00460 LST_NULL,
00461 };
00462
00463 const U8 LSCRIPTTypeHi4Bits[LST_EOF] =
00464 {
00465 LST_NULL,
00466 LST_INTEGER << 4,
00467 LST_FLOATINGPOINT << 4,
00468 LST_STRING << 4,
00469 LST_KEY << 4,
00470 LST_VECTOR << 4,
00471 LST_QUATERNION << 4,
00472 LST_LIST << 4,
00473 };
00474
00475 const char * const LSCRIPTTypeNames[LST_EOF] =
00476 {
00477 "VOID",
00478 "integer",
00479 "float",
00480 "string",
00481 "key",
00482 "vector",
00483 "quaternion",
00484 "list",
00485 "invalid"
00486 };
00487
00488 const S32 LSCRIPTDataSize[LST_EOF] =
00489 {
00490 0,
00491 4,
00492 4,
00493 4,
00494 4,
00495 12,
00496 16,
00497 4,
00498 0
00499 };
00500
00501
00502 typedef enum e_lscript_runtime_faults
00503 {
00504 LSRF_INVALID,
00505 LSRF_MATH,
00506 LSRF_STACK_HEAP_COLLISION,
00507 LSRF_BOUND_CHECK_ERROR,
00508 LSRF_HEAP_ERROR,
00509 LSRF_VERSION_MISMATCH,
00510 LSRF_MISSING_INVENTORY,
00511 LSRF_SANDBOX,
00512 LSRF_CHAT_OVERRUN,
00513 LSRF_TOO_MANY_LISTENS,
00514 LSRF_NESTING_LISTS,
00515 LSRF_EOF
00516 } LSCRIPTRunTimeFaults;
00517
00518 extern char* LSCRIPTRunTimeFaultStrings[LSRF_EOF];
00519
00520 const S32 LSCRIPTRunTimeFaultBits[LSRF_EOF] =
00521 {
00522 0,
00523 1,
00524 2,
00525 3,
00526 4,
00527 5,
00528 6,
00529 7,
00530 8,
00531 9,
00532 10,
00533 };
00534
00535 typedef enum e_lscript_runtime_permissions
00536 {
00537 SCRIPT_PERMISSION_DEBIT,
00538 SCRIPT_PERMISSION_TAKE_CONTROLS,
00539 SCRIPT_PERMISSION_REMAP_CONTROLS,
00540 SCRIPT_PERMISSION_TRIGGER_ANIMATION,
00541 SCRIPT_PERMISSION_ATTACH,
00542 SCRIPT_PERMISSION_RELEASE_OWNERSHIP,
00543 SCRIPT_PERMISSION_CHANGE_LINKS,
00544 SCRIPT_PERMISSION_CHANGE_JOINTS,
00545 SCRIPT_PERMISSION_CHANGE_PERMISSIONS,
00546 SCRIPT_PERMISSION_TRACK_CAMERA,
00547 SCRIPT_PERMISSION_CONTROL_CAMERA,
00548 SCRIPT_PERMISSION_EOF
00549 } LSCRIPTRunTimePermissions;
00550
00551 const U32 LSCRIPTRunTimePermissionBits[SCRIPT_PERMISSION_EOF] =
00552 {
00553 (0x1 << 1),
00554 (0x1 << 2),
00555 (0x1 << 3),
00556 (0x1 << 4),
00557 (0x1 << 5),
00558 (0x1 << 6),
00559 (0x1 << 7),
00560 (0x1 << 8),
00561 (0x1 << 9),
00562 (0x1 << 10),
00563 (0x1 << 11),
00564 };
00565
00566 #endif
00567