aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/lscript/lscript_byteformat.h
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:46 -0500
committerJacek Antonelli2008-08-15 23:44:46 -0500
commit38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch)
treeadca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/lscript/lscript_byteformat.h
parentREADME.txt (diff)
downloadmeta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz
Second Life viewer sources 1.13.2.12
Diffstat (limited to '')
-rw-r--r--linden/indra/lscript/lscript_byteformat.h563
1 files changed, 563 insertions, 0 deletions
diff --git a/linden/indra/lscript/lscript_byteformat.h b/linden/indra/lscript/lscript_byteformat.h
new file mode 100644
index 0000000..a69f1fe
--- /dev/null
+++ b/linden/indra/lscript/lscript_byteformat.h
@@ -0,0 +1,563 @@
1/**
2 * @file lscript_byteformat.h
3 * @brief Shared code between compiler and assembler and LSL
4 *
5 * Copyright (c) 2002-2007, Linden Research, Inc.
6 *
7 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement
10 * ("Other License"), formally executed by you and Linden Lab. Terms of
11 * the GPL can be found in doc/GPL-license.txt in this distribution, or
12 * online at http://secondlife.com/developers/opensource/gplv2
13 *
14 * There are special exceptions to the terms and conditions of the GPL as
15 * it is applied to this Source Code. View the full text of the exception
16 * in the file doc/FLOSS-exception.txt in this software distribution, or
17 * online at http://secondlife.com/developers/opensource/flossexception
18 *
19 * By copying, modifying or distributing this software, you acknowledge
20 * that you have read and understood your obligations described above,
21 * and agree to abide by those obligations.
22 *
23 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
24 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
25 * COMPLETENESS OR PERFORMANCE.
26 */
27
28#ifndef LL_LSCRIPT_BYTEFORMAT_H
29#define LL_LSCRIPT_BYTEFORMAT_H
30
31// Data shared between compiler/assembler and lscript execution code
32
33#include "stdtypes.h"
34
35const S32 LSL2_VERSION_NUMBER = 0x0200;
36const S32 LSL2_VERSION1_END_NUMBER = 0x0101;
37const S32 LSL2_VERSION2_START_NUMBER = 0x0200;
38
39const S32 LSL2_MAJOR_VERSION_ONE = 1;
40const S32 LSL2_MAJOR_VERSION_TWO = 2;
41const S32 LSL2_CURRENT_MAJOR_VERSION = LSL2_MAJOR_VERSION_TWO;
42
43const S32 TOP_OF_MEMORY = 16384;
44
45typedef enum e_lscript_registers
46{
47 LREG_INVALID,
48 LREG_IP, // instruction pointer
49 LREG_VN, // version number
50 LREG_BP, // base pointer - what local variables are referenced from
51 LREG_SP, // stack pointer - where the top of the stack is
52 LREG_HR, // heap register - where in memory does the heap start
53 LREG_HP, // heap pointer - where is the top of the heap?
54 LREG_CS, // current state - what state are we currently in?
55 LREG_NS, // next state - what state are we currently in?
56 LREG_CE, // current events - what events are waiting to be handled?
57 LREG_IE, // in event - which event handler are we currently in?
58 LREG_ER, // event register - what events do we have active handlers for?
59 LREG_FR, // fault register - which errors are currently active?
60 LREG_SLR, // sleep register - are we sleeping?
61 LREG_GVR, // global variable register - where do global variables start
62 LREG_GFR, // global function register - where do global functions start
63 LREG_SR, // state register - where do states start
64 LREG_TM, // top of memory - where is the top of memory
65 LREG_PR, // parameter register - data passed to script from launcher
66 LREG_ESR, // energy supply register - how much energy do we have on board?
67 LREG_NCE, // 64 bit current envents - what events are waiting to be handled?
68 LREG_NIE, // 64 bit in event - which event handler are we currently in?
69 LREG_NER, // 64 bit event register - what events do we have active handlers for?
70 LREG_EOF
71} LSCRIPTRegisters;
72
73const S32 gLSCRIPTRegisterAddresses[LREG_EOF] =
74{
75 0, // LREG_INVALID
76 4, // LREG_IP
77 8, // LREG_VN
78 12, // LREG_BP
79 16, // LREG_SP
80 20, // LREG_HR
81 24, // LREG_HP
82 28, // LREG_CS
83 32, // LREG_NS
84 36, // LREG_CE
85 40, // LREG_IE
86 44, // LREG_ER
87 48, // LREG_FR
88 52, // LREG_SLR
89 56, // LREG_GVR
90 60, // LREG_GFR
91 72, // LREG_SR
92 0, // LREG_TM
93 64, // LREG_PR
94 68, // LREG_ESR
95 76, // LREG_NCE
96 84, // LREG_NIE
97 92, // LREG_NER
98};
99
100const char * const gLSCRIPTRegisterNames[LREG_EOF] =
101{
102 "INVALID", // LREG_INVALID
103 "IP", // LREG_IP
104 "VN", // LREG_VN
105 "BP", // LREG_BP
106 "SP", // LREG_SP
107 "HR", // LREG_HR
108 "HP", // LREG_HP
109 "CS", // LREG_CS
110 "NS", // LREG_NS
111 "CE", // LREG_CE
112 "IE", // LREG_IE
113 "ER", // LREG_ER
114 "FR", // LREG_FR
115 "SLR", // LREG_SLR
116 "GVR", // LREG_GVR
117 "GFR", // LREG_GFR
118 "SR", // LREG_SR
119 "TM", // LREG_TM
120 "PR", // LREG_PR
121 "ESR", // LREG_ESR
122 "NCE", // LREG_NCE
123 "NIE", // LREG_NIE
124 "NER", // LREG_NER
125};
126
127typedef enum e_lscript_op_codes
128{
129 LOPC_INVALID,
130 LOPC_NOOP,
131 LOPC_POP,
132 LOPC_POPS,
133 LOPC_POPL,
134 LOPC_POPV,
135 LOPC_POPQ,
136 LOPC_POPARG,
137 LOPC_POPIP,
138 LOPC_POPBP,
139 LOPC_POPSP,
140 LOPC_POPSLR,
141 LOPC_DUP,
142 LOPC_DUPS,
143 LOPC_DUPL,
144 LOPC_DUPV,
145 LOPC_DUPQ,
146 LOPC_STORE,
147 LOPC_STORES,
148 LOPC_STOREL,
149 LOPC_STOREV,
150 LOPC_STOREQ,
151 LOPC_STOREG,
152 LOPC_STOREGS,
153 LOPC_STOREGL,
154 LOPC_STOREGV,
155 LOPC_STOREGQ,
156 LOPC_LOADP,
157 LOPC_LOADSP,
158 LOPC_LOADLP,
159 LOPC_LOADVP,
160 LOPC_LOADQP,
161 LOPC_LOADGP,
162 LOPC_LOADGLP,
163 LOPC_LOADGSP,
164 LOPC_LOADGVP,
165 LOPC_LOADGQP,
166 LOPC_PUSH,
167 LOPC_PUSHS,
168 LOPC_PUSHL,
169 LOPC_PUSHV,
170 LOPC_PUSHQ,
171 LOPC_PUSHG,
172 LOPC_PUSHGS,
173 LOPC_PUSHGL,
174 LOPC_PUSHGV,
175 LOPC_PUSHGQ,
176 LOPC_PUSHIP,
177 LOPC_PUSHBP,
178 LOPC_PUSHSP,
179 LOPC_PUSHARGB,
180 LOPC_PUSHARGI,
181 LOPC_PUSHARGF,
182 LOPC_PUSHARGS,
183 LOPC_PUSHARGV,
184 LOPC_PUSHARGQ,
185 LOPC_PUSHE,
186 LOPC_PUSHEV,
187 LOPC_PUSHEQ,
188 LOPC_PUSHARGE,
189 LOPC_ADD,
190 LOPC_SUB,
191 LOPC_MUL,
192 LOPC_DIV,
193 LOPC_MOD,
194 LOPC_EQ,
195 LOPC_NEQ,
196 LOPC_LEQ,
197 LOPC_GEQ,
198 LOPC_LESS,
199 LOPC_GREATER,
200 LOPC_BITAND,
201 LOPC_BITOR,
202 LOPC_BITXOR,
203 LOPC_BOOLAND,
204 LOPC_BOOLOR,
205 LOPC_NEG,
206 LOPC_BITNOT,
207 LOPC_BOOLNOT,
208 LOPC_JUMP,
209 LOPC_JUMPIF,
210 LOPC_JUMPNIF,
211 LOPC_STATE,
212 LOPC_CALL,
213 LOPC_RETURN,
214 LOPC_CAST,
215 LOPC_STACKTOS,
216 LOPC_STACKTOL,
217 LOPC_PRINT,
218 LOPC_CALLLIB,
219 LOPC_CALLLIB_TWO_BYTE,
220 LOPC_SHL,
221 LOPC_SHR,
222 LOPC_EOF
223} LSCRIPTOpCodesEnum;
224
225const U8 LSCRIPTOpCodes[LOPC_EOF] =
226{
227 0x00, // LOPC_INVALID
228 0x00, // LOPC_NOOP
229 0x01, // LOPC_POP
230 0x02, // LOPC_POPS
231 0x03, // LOPC_POPL
232 0x04, // LOPC_POPV
233 0x05, // LOPC_POPQ
234 0x06, // LOPC_POPARG
235 0x07, // LOPC_POPIP
236 0x08, // LOPC_POPBP
237 0x09, // LOPC_POPSP
238 0x0a, // LOPC_POPSLR
239 0x20, // LOPC_DUP
240 0x21, // LOPC_DUPS
241 0x22, // LOPC_DUPL
242 0x23, // LOPC_DUPV
243 0x24, // LOPC_DUPQ
244 0x30, // LOPC_STORE
245 0x31, // LOPC_STORES
246 0x32, // LOPC_STOREL
247 0x33, // LOPC_STOREV
248 0x34, // LOPC_STOREQ
249 0x35, // LOPC_STOREG
250 0x36, // LOPC_STOREGS
251 0x37, // LOPC_STOREGL
252 0x38, // LOPC_STOREGV
253 0x39, // LOPC_STOREGQ
254 0x3a, // LOPC_LOADP
255 0x3b, // LOPC_LOADSP
256 0x3c, // LOPC_LOADLP
257 0x3d, // LOPC_LOADVP
258 0x3e, // LOPC_LOADQP
259 0x3f, // LOPC_LOADGP
260 0x40, // LOPC_LOADGSP
261 0x41, // LOPC_LOADGLP
262 0x42, // LOPC_LOADGVP
263 0x43, // LOPC_LOADGQP
264 0x50, // LOPC_PUSH
265 0x51, // LOPC_PUSHS
266 0x52, // LOPC_PUSHL
267 0x53, // LOPC_PUSHV
268 0x54, // LOPC_PUSHQ
269 0x55, // LOPC_PUSHG
270 0x56, // LOPC_PUSHGS
271 0x57, // LOPC_PUSHGL
272 0x58, // LOPC_PUSHGV
273 0x59, // LOPC_PUSHGQ
274 0x5a, // LOPC_PUSHIP
275 0x5b, // LOPC_PUSHBP
276 0x5c, // LOPC_PUSHSP
277 0x5d, // LOPC_PUSHARGB
278 0x5e, // LOPC_PUSHARGI
279 0x5f, // LOPC_PUSHARGF
280 0x60, // LOPC_PUSHARGS
281 0x61, // LOPC_PUSHARGV
282 0x62, // LOPC_PUSHARGQ
283 0x63, // LOPC_PUSHE
284 0x64, // LOPC_PUSHEV
285 0x65, // LOPC_PUSHEQ
286 0x66, // LOPC_PUSHARGE
287 0x70, // LOPC_ADD
288 0x71, // LOPC_SUB
289 0x72, // LOPC_MUL
290 0x73, // LOPC_DIV
291 0x74, // LOPC_MOD
292 0x75, // LOPC_EQ
293 0x76, // LOPC_NEQ
294 0x77, // LOPC_LEQ
295 0x78, // LOPC_GEQ
296 0x79, // LOPC_LESS
297 0x7a, // LOPC_GREATER
298 0x7b, // LOPC_BITAND
299 0x7c, // LOPC_BITOR
300 0x7d, // LOPC_BITXOR
301 0x7e, // LOPC_BOOLAND
302 0x7f, // LOPC_BOOLOR
303 0x80, // LOPC_NEG
304 0x81, // LOPC_BITNOT
305 0x82, // LOPC_BOOLNOT
306 0x90, // LOPC_JUMP
307 0x91, // LOPC_JUMPIF
308 0x92, // LOPC_JUMPNIF
309 0x93, // LOPC_STATE
310 0x94, // LOPC_CALL
311 0x95, // LOPC_RETURN
312 0xa0, // LOPC_CAST
313 0xb0, // LOPC_STACKTOS
314 0xb1, // LOPC_STACKTOL
315 0xc0, // LOPC_PRINT
316 0xd0, // LOPC_CALLLIB
317 0xd1, // LOPC_CALLLIB_TWO_BYTE
318 0xe0, // LOPC_SHL
319 0xe1 // LOPC_SHR
320};
321
322typedef enum e_lscript_state_event_type
323{
324 LSTT_NULL,
325 LSTT_STATE_ENTRY,
326 LSTT_STATE_EXIT,
327 LSTT_TOUCH_START,
328 LSTT_TOUCH,
329 LSTT_TOUCH_END,
330 LSTT_COLLISION_START,
331 LSTT_COLLISION,
332 LSTT_COLLISION_END,
333 LSTT_LAND_COLLISION_START,
334 LSTT_LAND_COLLISION,
335 LSTT_LAND_COLLISION_END,
336 LSTT_TIMER,
337 LSTT_CHAT,
338 LSTT_REZ,
339 LSTT_SENSOR,
340 LSTT_NO_SENSOR,
341 LSTT_CONTROL,
342 LSTT_MONEY,
343 LSTT_EMAIL,
344 LSTT_AT_TARGET,
345 LSTT_NOT_AT_TARGET,
346 LSTT_AT_ROT_TARGET,
347 LSTT_NOT_AT_ROT_TARGET,
348 LSTT_RTPERMISSIONS,
349 LSTT_INVENTORY,
350 LSTT_ATTACH,
351 LSTT_DATASERVER,
352 LSTT_LINK_MESSAGE,
353 LSTT_MOVING_START,
354 LSTT_MOVING_END,
355 LSTT_OBJECT_REZ,
356 LSTT_REMOTE_DATA,
357 LSTT_HTTP_RESPONSE,
358 LSTT_EOF,
359
360 LSTT_STATE_BEGIN = LSTT_STATE_ENTRY,
361 LSTT_STATE_END = LSTT_EOF
362} LSCRIPTStateEventType;
363
364const U64 LSCRIPTStateBitField[LSTT_EOF] =
365{
366 0x0000000000000000, // LSTT_NULL
367 0x0000000000000001, // LSTT_STATE_ENTRY
368 0x0000000000000002, // LSTT_STATE_EXIT
369 0x0000000000000004, // LSTT_TOUCH_START
370 0x0000000000000008, // LSTT_TOUCH
371 0x0000000000000010, // LSTT_TOUCH_END
372 0x0000000000000020, // LSTT_COLLISION_START
373 0x0000000000000040, // LSTT_COLLISION
374 0x0000000000000080, // LSTT_COLLISION_END
375 0x0000000000000100, // LSTT_LAND_COLLISION_START
376 0x0000000000000200, // LSTT_LAND_COLLISION
377 0x0000000000000400, // LSTT_LAND_COLLISION_END
378 0x0000000000000800, // LSTT_TIMER
379 0x0000000000001000, // LSTT_CHAT
380 0x0000000000002000, // LSTT_REZ
381 0x0000000000004000, // LSTT_SENSOR
382 0x0000000000008000, // LSTT_NO_SENSOR
383 0x0000000000010000, // LSTT_CONTROL
384 0x0000000000020000, // LSTT_MONEY
385 0x0000000000040000, // LSTT_EMAIL
386 0x0000000000080000, // LSTT_AT_TARGET
387 0x0000000000100000, // LSTT_NOT_AT_TARGET
388 0x0000000000200000, // LSTT_AT_ROT_TARGET
389 0x0000000000400000, // LSTT_NOT_AT_ROT_TARGET
390 0x0000000000800000, // LSTT_RTPERMISSIONS
391 0x0000000001000000, // LSTT_INVENTORY
392 0x0000000002000000, // LSTT_ATTACH
393 0x0000000004000000, // LSTT_DATASERVER
394 0x0000000008000000, // LSTT_LINK_MESSAGE
395 0x0000000010000000, // LSTT_MOVING_START
396 0x0000000020000000, // LSTT_MOVING_END
397 0x0000000040000000, // LSTT_OBJECT_REZ
398 0x0000000080000000, // LSTT_REMOTE_DATA
399 0x0000000100000000LL // LSTT_HTTP_RESPOSE
400};
401
402inline S32 get_event_handler_jump_position(U64 bit_field, LSCRIPTStateEventType type)
403{
404 S32 count = 0, position = LSTT_STATE_ENTRY;
405 while (position < type)
406 {
407 if (bit_field & 0x1)
408 {
409 count++;
410 }
411 bit_field >>= 1;
412 position++;
413 }
414 return count;
415}
416
417inline S32 get_number_of_event_handlers(U64 bit_field)
418{
419 S32 count = 0, position = 0;
420 while (position < LSTT_EOF)
421 {
422 if (bit_field & 0x1)
423 {
424 count++;
425 }
426 bit_field >>= 1;
427 position++;
428 }
429 return count;
430}
431
432typedef enum e_lscript_types
433{
434 LST_NULL,
435 LST_INTEGER,
436 LST_FLOATINGPOINT,
437 LST_STRING,
438 LST_KEY,
439 LST_VECTOR,
440 LST_QUATERNION,
441 LST_LIST,
442 LST_UNDEFINED,
443 LST_EOF
444} LSCRIPTType;
445
446const U8 LSCRIPTTypeByte[LST_EOF] =
447{
448 LST_NULL,
449 LST_INTEGER,
450 LST_FLOATINGPOINT,
451 LST_STRING,
452 LST_KEY,
453 LST_VECTOR,
454 LST_QUATERNION,
455 LST_LIST,
456 LST_NULL,
457};
458
459const U8 LSCRIPTTypeHi4Bits[LST_EOF] =
460{
461 LST_NULL,
462 LST_INTEGER << 4,
463 LST_FLOATINGPOINT << 4,
464 LST_STRING << 4,
465 LST_KEY << 4,
466 LST_VECTOR << 4,
467 LST_QUATERNION << 4,
468 LST_LIST << 4,
469};
470
471const char * const LSCRIPTTypeNames[LST_EOF] =
472{
473 "VOID",
474 "integer",
475 "float",
476 "string",
477 "key",
478 "vector",
479 "quaternion",
480 "list",
481 "invalid"
482};
483
484const S32 LSCRIPTDataSize[LST_EOF] =
485{
486 0, // VOID
487 4, // integer
488 4, // float
489 4, // string
490 4, // key
491 12, // vector
492 16, // quaternion
493 4, // list
494 0 // invalid
495};
496
497
498typedef enum e_lscript_runtime_faults
499{
500 LSRF_INVALID,
501 LSRF_MATH,
502 LSRF_STACK_HEAP_COLLISION,
503 LSRF_BOUND_CHECK_ERROR,
504 LSRF_HEAP_ERROR,
505 LSRF_VERSION_MISMATCH,
506 LSRF_MISSING_INVENTORY,
507 LSRF_SANDBOX,
508 LSRF_CHAT_OVERRUN,
509 LSRF_TOO_MANY_LISTENS,
510 LSRF_NESTING_LISTS,
511 LSRF_EOF
512} LSCRIPTRunTimeFaults;
513
514extern char *LSCRIPTRunTimeFaultStrings[LSRF_EOF];
515
516const S32 LSCRIPTRunTimeFaultBits[LSRF_EOF] =
517{
518 0, // LSRF_INVALID
519 1, // LSRF_MATH
520 2, // LSRF_STACK_HEAP_COLLISION
521 3, // LSREF_BOUND_CHECK_ERROR
522 4, // LSREF_HEAP_ERROR
523 5, // LSREF_VERSION_MISMATCH
524 6, // LSREF_MISSING_INVENTORY
525 7, // LSRF_SANDBOX
526 8, // LSRF_CHAT_OVERRUN
527 9, // LSRF_TOO_MANY_LISTENS
528 10, // LSRF_NESTING_LISTS
529};
530
531typedef enum e_lscript_runtime_permissions
532{
533 SCRIPT_PERMISSION_DEBIT,
534 SCRIPT_PERMISSION_TAKE_CONTROLS,
535 SCRIPT_PERMISSION_REMAP_CONTROLS,
536 SCRIPT_PERMISSION_TRIGGER_ANIMATION,
537 SCRIPT_PERMISSION_ATTACH,
538 SCRIPT_PERMISSION_RELEASE_OWNERSHIP,
539 SCRIPT_PERMISSION_CHANGE_LINKS,
540 SCRIPT_PERMISSION_CHANGE_JOINTS,
541 SCRIPT_PERMISSION_CHANGE_PERMISSIONS,
542 SCRIPT_PERMISSION_TRACK_CAMERA,
543 SCRIPT_PERMISSION_CONTROL_CAMERA,
544 SCRIPT_PERMISSION_EOF
545} LSCRIPTRunTimePermissions;
546
547const U32 LSCRIPTRunTimePermissionBits[SCRIPT_PERMISSION_EOF] =
548{
549 (0x1 << 1), // SCRIPT_PERMISSION_DEBIT,
550 (0x1 << 2), // SCRIPT_PERMISSION_TAKE_CONTROLS,
551 (0x1 << 3), // SCRIPT_PERMISSION_REMAP_CONTROLS,
552 (0x1 << 4), // SCRIPT_PERMISSION_TRIGGER_ANIMATION,
553 (0x1 << 5), // SCRIPT_PERMISSION_ATTACH,
554 (0x1 << 6), // SCRIPT_PERMISSION_RELEASE_OWNERSHIP,
555 (0x1 << 7), // SCRIPT_PERMISSION_CHANGE_LINKS,
556 (0x1 << 8), // SCRIPT_PERMISSION_CHANGE_JOINTS,
557 (0x1 << 9), // SCRIPT_PERMISSION_CHANGE_PERMISSIONS
558 (0x1 << 10),// SCRIPT_PERMISSION_TRACK_CAMERA
559 (0x1 << 11),// SCRIPT_PERMISSION_CONTROL_CAMERA
560};
561
562#endif
563