From 420b91db29485df39fd6e724e782c449158811cb Mon Sep 17 00:00:00 2001 From: James Cook Date: Tue, 2 Jan 2007 08:33:20 +0000 Subject: Print done when done. --- indra/lscript/lscript_alloc.h | 344 + indra/lscript/lscript_byteconvert.h | 1087 +++ indra/lscript/lscript_byteformat.h | 544 ++ indra/lscript/lscript_compile/indra.l | 834 ++ indra/lscript/lscript_compile/indra.y | 1680 ++++ indra/lscript/lscript_compile/lscript_alloc.cpp | 8 + indra/lscript/lscript_compile/lscript_bytecode.cpp | 299 + indra/lscript/lscript_compile/lscript_bytecode.h | 71 + indra/lscript/lscript_compile/lscript_error.cpp | 77 + indra/lscript/lscript_compile/lscript_error.h | 132 + indra/lscript/lscript_compile/lscript_heap.cpp | 49 + indra/lscript/lscript_compile/lscript_heap.h | 40 + indra/lscript/lscript_compile/lscript_resource.cpp | 18 + indra/lscript/lscript_compile/lscript_resource.h | 21 + indra/lscript/lscript_compile/lscript_scope.cpp | 13 + indra/lscript/lscript_compile/lscript_scope.h | 388 + indra/lscript/lscript_compile/lscript_tree.cpp | 9998 ++++++++++++++++++++ indra/lscript/lscript_compile/lscript_tree.h | 2279 +++++ .../lscript/lscript_compile/lscript_typecheck.cpp | 562 ++ indra/lscript/lscript_compile/lscript_typecheck.h | 100 + indra/lscript/lscript_execute.h | 364 + indra/lscript/lscript_execute/lscript_execute.cpp | 3910 ++++++++ .../lscript_execute/lscript_heapruntime.cpp | 501 + .../lscript/lscript_execute/lscript_heapruntime.h | 22 + indra/lscript/lscript_execute/lscript_readlso.cpp | 1553 +++ indra/lscript/lscript_execute/lscript_readlso.h | 147 + indra/lscript/lscript_export.h | 16 + indra/lscript/lscript_http.h | 27 + indra/lscript/lscript_library.h | 382 + indra/lscript/lscript_library/lscript_alloc.cpp | 1102 +++ indra/lscript/lscript_library/lscript_export.cpp | 8 + indra/lscript/lscript_library/lscript_library.cpp | 557 ++ indra/lscript/lscript_rt_interface.h | 18 + 33 files changed, 27151 insertions(+) create mode 100644 indra/lscript/lscript_alloc.h create mode 100644 indra/lscript/lscript_byteconvert.h create mode 100644 indra/lscript/lscript_byteformat.h create mode 100644 indra/lscript/lscript_compile/indra.l create mode 100644 indra/lscript/lscript_compile/indra.y create mode 100644 indra/lscript/lscript_compile/lscript_alloc.cpp create mode 100644 indra/lscript/lscript_compile/lscript_bytecode.cpp create mode 100644 indra/lscript/lscript_compile/lscript_bytecode.h create mode 100644 indra/lscript/lscript_compile/lscript_error.cpp create mode 100644 indra/lscript/lscript_compile/lscript_error.h create mode 100644 indra/lscript/lscript_compile/lscript_heap.cpp create mode 100644 indra/lscript/lscript_compile/lscript_heap.h create mode 100644 indra/lscript/lscript_compile/lscript_resource.cpp create mode 100644 indra/lscript/lscript_compile/lscript_resource.h create mode 100644 indra/lscript/lscript_compile/lscript_scope.cpp create mode 100644 indra/lscript/lscript_compile/lscript_scope.h create mode 100644 indra/lscript/lscript_compile/lscript_tree.cpp create mode 100644 indra/lscript/lscript_compile/lscript_tree.h create mode 100644 indra/lscript/lscript_compile/lscript_typecheck.cpp create mode 100644 indra/lscript/lscript_compile/lscript_typecheck.h create mode 100644 indra/lscript/lscript_execute.h create mode 100644 indra/lscript/lscript_execute/lscript_execute.cpp create mode 100644 indra/lscript/lscript_execute/lscript_heapruntime.cpp create mode 100644 indra/lscript/lscript_execute/lscript_heapruntime.h create mode 100644 indra/lscript/lscript_execute/lscript_readlso.cpp create mode 100644 indra/lscript/lscript_execute/lscript_readlso.h create mode 100644 indra/lscript/lscript_export.h create mode 100644 indra/lscript/lscript_http.h create mode 100644 indra/lscript/lscript_library.h create mode 100644 indra/lscript/lscript_library/lscript_alloc.cpp create mode 100644 indra/lscript/lscript_library/lscript_export.cpp create mode 100644 indra/lscript/lscript_library/lscript_library.cpp create mode 100644 indra/lscript/lscript_rt_interface.h (limited to 'indra/lscript') diff --git a/indra/lscript/lscript_alloc.h b/indra/lscript/lscript_alloc.h new file mode 100644 index 0000000000..f0761c0afd --- /dev/null +++ b/indra/lscript/lscript_alloc.h @@ -0,0 +1,344 @@ +/** + * @file lscript_alloc.h + * @brief General heap management for scripting system + * + * Copyright (c) 2002-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + +#ifndef LL_LSCRIPT_ALLOC_H +#define LL_LSCRIPT_ALLOC_H +// #define at top of file accelerates gcc compiles +// Under gcc 2.9, the manual is unclear if comments can appear above #ifndef +// Under gcc 3, the manual explicitly states comments can appear above the #ifndef + +#include "stdtypes.h" +#include "lscript_byteconvert.h" +#include "lscript_library.h" +#include "llrand.h" +#include + +void reset_hp_to_safe_spot(const U8 *buffer); + + +// supported data types + +// basic types +// integer 4 bytes of integer data +// float 4 bytes of float data +// string data null terminated 1 byte string +// key data null terminated 1 byte string +// vector data 12 bytes of 3 floats +// quaternion data 16 bytes of 4 floats + +// list type +// list data 4 bytes of number of entries followed by followed by pointer + +// string pointer 4 bytes of address of string data on the heap (only used in list data) +// key pointer 4 bytes of address of key data on the heap (only used in list data) + +// heap format +// +// 4 byte offset to next block (in bytes) +// 1 byte of type of variable or empty +// 2 bytes of reference count +// nn bytes of data + +const S32 MAX_HEAP_SIZE = TOP_OF_MEMORY; + +class LLScriptAllocEntry +{ +public: + LLScriptAllocEntry() : mSize(0), mType(LST_NULL), mReferenceCount(0) {} + LLScriptAllocEntry(S32 offset, U8 type) : mSize(offset), mType(type), mReferenceCount(1) {} + friend std::ostream& operator<<(std::ostream& s, const LLScriptAllocEntry &a) + { + s << "Size: " << a.mSize << " Type: " << LSCRIPTTypeNames[a.mType] << " Count: " << a.mReferenceCount; + return s; + } + + S32 mSize; + U8 mType; + S16 mReferenceCount; +}; + +// this is only OK because we only load/save via accessors below +const S32 SIZEOF_SCRIPT_ALLOC_ENTRY = 7; + +inline void alloc_entry2bytestream(U8 *buffer, S32 &offset, const LLScriptAllocEntry &entry) +{ + if ( (offset < 0) + ||(offset > MAX_HEAP_SIZE)) + { + set_fault(buffer, LSRF_BOUND_CHECK_ERROR); + } + else + { + integer2bytestream(buffer, offset, entry.mSize); + byte2bytestream(buffer, offset, entry.mType); + s162bytestream(buffer, offset, entry.mReferenceCount); + } +} + +inline void bytestream2alloc_entry(LLScriptAllocEntry &entry, U8 *buffer, S32 &offset) +{ + if ( (offset < 0) + ||(offset > MAX_HEAP_SIZE)) + { + set_fault(buffer, LSRF_BOUND_CHECK_ERROR); + reset_hp_to_safe_spot(buffer); + } + else + { + entry.mSize = bytestream2integer(buffer, offset); + entry.mType = bytestream2byte(buffer, offset); + entry.mReferenceCount = bytestream2s16(buffer, offset); + } +} + +// create a heap from the HR to TM +BOOL lsa_create_heap(U8 *heap_start, S32 size); +void lsa_fprint_heap(U8 *buffer, FILE *fp); + +void lsa_print_heap(U8 *buffer); + +// adding to heap +// if block is empty +// if block is at least block size + 4 larger than data +// split block +// insert data into first part +// return address +// else +// insert data into block +// return address +// else +// if next block is >= SP +// set Stack-Heap collision +// return NULL +// if next block is empty +// merge next block with current block +// go to start of algorithm +// else +// move to next block +// go to start of algorithm + +S32 lsa_heap_add_data(U8 *buffer, LLScriptLibData *data, S32 heapsize, BOOL b_delete); + +S32 lsa_heap_top(U8 *heap_start, S32 maxsize); + +// split block +// set offset to point to new block +// set offset of new block to point to original offset - block size - data size +// set new block to empty +// set new block reference count to 0 +void lsa_split_block(U8 *buffer, S32 &offset, S32 size, LLScriptAllocEntry &entry); + +// insert data +// if data is non-list type +// set type to basic type, set reference count to 1, copy data, return address +// else +// set type to list data type, set reference count to 1 +// for each list entry +// insert data +// return address + +void lsa_insert_data(U8 *buffer, S32 &offset, LLScriptLibData *data, LLScriptAllocEntry &entry, S32 heapsize); + +S32 lsa_create_data_block(U8 **buffer, LLScriptLibData *data, S32 base_offset); + +// increase reference count +// increase reference count by 1 + +void lsa_increase_ref_count(U8 *buffer, S32 offset); + +// decrease reference count +// decrease reference count by 1 +// if reference count == 0 +// set type to empty + +void lsa_decrease_ref_count(U8 *buffer, S32 offset); + +inline S32 get_max_heap_size(U8 *buffer) +{ + return get_register(buffer, LREG_SP) - get_register(buffer, LREG_HR); +} + + +LLScriptLibData *lsa_get_data(U8 *buffer, S32 &offset, BOOL b_dec_ref); +LLScriptLibData *lsa_get_list_ptr(U8 *buffer, S32 &offset, BOOL b_dec_ref); + +S32 lsa_cat_strings(U8 *buffer, S32 offset1, S32 offset2, S32 heapsize); +S32 lsa_cmp_strings(U8 *buffer, S32 offset1, S32 offset2); + +S32 lsa_cat_lists(U8 *buffer, S32 offset1, S32 offset2, S32 heapsize); +S32 lsa_cmp_lists(U8 *buffer, S32 offset1, S32 offset2); +S32 lsa_preadd_lists(U8 *buffer, LLScriptLibData *data, S32 offset2, S32 heapsize); +S32 lsa_postadd_lists(U8 *buffer, S32 offset1, LLScriptLibData *data, S32 heapsize); + +// modifying a list +// insert new list that is modified +// store returned address in original list's variable +// decrease reference count on old list + +// list l1 = [10]; +// list l2 = l1; +// l1 = [11]; + +// we want l2 == [10]; + +// more complicated example: +// list l1 = [10, 11]; +// list l2 = l1; +// l1[0] = 12 + +// I think that we want l2 = [10, 11]; + +// one option would be to use syntax like: +// l1 = llSetList(l1, 0, 12); +// but this would require variable argument list matching +// which maybe is ok, but would be work +// the other option would be changes to lists that have multiple references causes a copy to occur + +// popl @l1, 0, integer, 12 +// +// would cause l1 to be copied, 12 to replace the 0th entry, and the address of the new list to be saved in l1 +// + +inline LLScriptLibData *lsa_bubble_sort(LLScriptLibData *src, S32 stride, S32 ascending) +{ + S32 number = src->getListLength(); + + if (number <= 0) + { + return NULL; + } + + if (stride <= 0) + { + stride = 1; + } + + S32 i = 0; + + if (number % stride) + { + LLScriptLibData *retval = src->mListp; + src->mListp = NULL; + return retval; + } + + LLScriptLibData **sortarray = (LLScriptLibData **)new U32[number]; + + LLScriptLibData *temp = src->mListp; + while (temp) + { + sortarray[i] = temp; + i++; + temp = temp->mListp; + } + + S32 j, s; + + for (i = 0; i < number; i += stride) + { + for (j = i; j < number; j += stride) + { + if ( ((*sortarray[i]) <= (*sortarray[j])) + != (ascending == TRUE)) + { + for (s = 0; s < stride; s++) + { + temp = sortarray[i + s]; + sortarray[i + s] = sortarray[j + s]; + sortarray[j + s] = temp; + } + } + } + } + + i = 1; + temp = sortarray[0]; + while (i < number) + { + temp->mListp = sortarray[i++]; + temp = temp->mListp; + } + temp->mListp = NULL; + + src->mListp = NULL; + + return sortarray[0]; +} + + +inline LLScriptLibData *lsa_randomize(LLScriptLibData *src, S32 stride) +{ + S32 number = src->getListLength(); + + if (number <= 0) + { + return NULL; + } + + if (stride <= 0) + { + stride = 1; + } + + if (number % stride) + { + LLScriptLibData *retval = src->mListp; + src->mListp = NULL; + return retval; + } + + LLScriptLibData **sortarray = (LLScriptLibData **)new U32[number]; + + LLScriptLibData *temp = src->mListp; + S32 i = 0; + while (temp) + { + sortarray[i] = temp; + i++; + temp = temp->mListp; + } + + S32 k, j, s; + + for (k = 0; k < 20; k++) + { + for (i = 0; i < number; i += stride) + { + for (j = i; j < number; j += stride) + { + if (frand(1.f) > 0.5) + { + for (s = 0; s < stride; s++) + { + temp = sortarray[i + s]; + sortarray[i + s] = sortarray[j + s]; + sortarray[j + s] = temp; + } + } + } + } + } + + i = 1; + temp = sortarray[0]; + while (i < number) + { + temp->mListp = sortarray[i++]; + temp = temp->mListp; + } + temp->mListp = NULL; + + src->mListp = NULL; + + LLScriptLibData *ret_value = sortarray[0]; + delete [] sortarray; + + return ret_value; +} + +#endif diff --git a/indra/lscript/lscript_byteconvert.h b/indra/lscript/lscript_byteconvert.h new file mode 100644 index 0000000000..d30c84b28c --- /dev/null +++ b/indra/lscript/lscript_byteconvert.h @@ -0,0 +1,1087 @@ +/** + * @file lscript_byteconvert.h + * @brief Shared code for compiler and assembler for LSL + * + * Copyright (c) 2002-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + +// data shared between compiler/assembler +// used to convert data between byte stream and outside data types + +#ifndef LL_LSCRIPT_BYTECONVERT_H +#define LL_LSCRIPT_BYTECONVERT_H + +#include "stdtypes.h" +#include "v3math.h" +#include "llquaternion.h" +#include "lscript_byteformat.h" +#include "lluuid.h" + +void reset_hp_to_safe_spot(const U8 *buffer); + +// remember that LScript byte stream is BigEndian +void set_fault(const U8 *stream, LSCRIPTRunTimeFaults fault); + +inline S32 bytestream2integer(const U8 *stream, S32 &offset) +{ + stream += offset; + offset += 4; + return (*stream<<24) | (*(stream + 1)<<16) | (*(stream + 2)<<8) | *(stream + 3); +} + +inline U32 bytestream2unsigned_integer(const U8 *stream, S32 &offset) +{ + stream += offset; + offset += 4; + return (*stream<<24) | (*(stream + 1)<<16) | (*(stream + 2)<<8) | *(stream + 3); +} + +inline U64 bytestream2u64(const U8 *stream, S32 &offset) +{ + stream += offset; + offset += 8; + return ((U64)(*stream)<<56)| ((U64)(*(stream + 1))<<48) | ((U64)(*(stream + 2))<<40) | ((U64)(*(stream + 3))<<32) | + ((U64)(*(stream + 4))<<24) | ((U64)(*(stream + 5))<<16) | ((U64)(*(stream + 6))<<8) | (U64)(*(stream + 7)); +} + +inline void integer2bytestream(U8 *stream, S32 &offset, S32 integer) +{ + stream += offset; + offset += 4; + *(stream) = (integer >> 24); + *(stream + 1) = (integer >> 16) & 0xff; + *(stream + 2) = (integer >> 8) & 0xff; + *(stream + 3) = (integer) & 0xff; +} + +inline void unsigned_integer2bytestream(U8 *stream, S32 &offset, U32 integer) +{ + stream += offset; + offset += 4; + *(stream) = (integer >> 24); + *(stream + 1) = (integer >> 16) & 0xff; + *(stream + 2) = (integer >> 8) & 0xff; + *(stream + 3) = (integer) & 0xff; +} +inline void u642bytestream(U8 *stream, S32 &offset, U64 integer) +{ + stream += offset; + offset += 8; + *(stream) = (U8)(integer >> 56); + *(stream + 1) = (U8)((integer >> 48) & 0xff); + *(stream + 2) = (U8)((integer >> 40) & 0xff); + *(stream + 3) = (U8)((integer >> 32) & 0xff); + *(stream + 4) = (U8)((integer >> 24) & 0xff); + *(stream + 5) = (U8)((integer >> 16) & 0xff); + *(stream + 6) = (U8)((integer >> 8) & 0xff); + *(stream + 7) = (U8)((integer) & 0xff); +} + +inline S16 bytestream2s16(const U8 *stream, S32 &offset) +{ + stream += offset; + offset += 2; + return (*stream<<8) | *(stream + 1); +} + +inline void s162bytestream(U8 *stream, S32 &offset, S16 integer) +{ + stream += offset; + offset += 2; + *(stream) = (integer >> 8); + *(stream + 1) = (integer) & 0xff; +} + +inline U16 bytestream2u16(const U8 *stream, S32 &offset) +{ + stream += offset; + offset += 2; + return (*stream<<8) | *(stream + 1); +} + +inline void u162bytestream(U8 *stream, S32 &offset, U16 integer) +{ + stream += offset; + offset += 2; + *(stream) = (integer >> 8); + *(stream + 1) = (integer) & 0xff; +} + +inline F32 bytestream2float(const U8 *stream, S32 &offset) +{ + S32 value = bytestream2integer(stream, offset); + F32 fpvalue = *(F32 *)&value; + if (!llfinite(fpvalue)) + { + fpvalue = 0; + set_fault(stream, LSRF_MATH); + } + return fpvalue; +} + +inline void float2bytestream(U8 *stream, S32 &offset, F32 floatingpoint) +{ + S32 value = *(S32 *)&floatingpoint; + integer2bytestream(stream, offset, value); +} + +inline void bytestream_int2float(U8 *stream, S32 &offset) +{ + S32 value = bytestream2integer(stream, offset); + offset -= 4; + F32 fpvalue = (F32)value; + if (!llfinite(fpvalue)) + { + fpvalue = 0; + set_fault(stream, LSRF_MATH); + } + float2bytestream(stream, offset, fpvalue); +} + +inline void bytestream2char(char *buffer, const U8 *stream, S32 &offset) +{ + while ((*buffer++ = *(stream + offset++))) + ; +} + +inline void char2bytestream(U8 *stream, S32 &offset, char *buffer) +{ + while ((*(stream + offset++) = *buffer++)) + ; +} + +inline U8 bytestream2byte(const U8 *stream, S32 &offset) +{ + return *(stream + offset++); +} + +inline void byte2bytestream(U8 *stream, S32 &offset, U8 byte) +{ + *(stream + offset++) = byte; +} + +inline void bytestream2bytestream(U8 *dest, S32 &dest_offset, const U8 *src, S32 &src_offset, S32 count) +{ + while (count) + { + (*(dest + dest_offset++)) = (*(src + src_offset++)); + count--; + } +} + +inline void uuid2bytestream(U8 *stream, S32 &offset, const LLUUID &uuid) +{ + S32 i; + for (i = 0; i < UUID_BYTES; i++) + { + *(stream + offset++) = uuid.mData[i]; + } +} + +inline void bytestream2uuid(U8 *stream, S32 &offset, LLUUID &uuid) +{ + S32 i; + for (i = 0; i < UUID_BYTES; i++) + { + uuid.mData[i] = *(stream + offset++); + } +} + +// vectors and quaternions and encoded in backwards order to match the way in which they are stored on the stack +inline void bytestream2vector(LLVector3 &vector, const U8 *stream, S32 &offset) +{ + S32 value = bytestream2integer(stream, offset); + vector.mV[VZ] = *(F32 *)&value; + if (!llfinite(vector.mV[VZ])) + { + vector.mV[VZ] = 0; + set_fault(stream, LSRF_MATH); + } + value = bytestream2integer(stream, offset); + vector.mV[VY] = *(F32 *)&value; + if (!llfinite(vector.mV[VY])) + { + vector.mV[VY] = 0; + set_fault(stream, LSRF_MATH); + } + value = bytestream2integer(stream, offset); + vector.mV[VX] = *(F32 *)&value; + if (!llfinite(vector.mV[VX])) + { + vector.mV[VX] = 0; + set_fault(stream, LSRF_MATH); + } +} + +inline void vector2bytestream(U8 *stream, S32 &offset, LLVector3 &vector) +{ + S32 value = *(S32 *)&vector.mV[VZ]; + integer2bytestream(stream, offset, value); + value = *(S32 *)&vector.mV[VY]; + integer2bytestream(stream, offset, value); + value = *(S32 *)&vector.mV[VX]; + integer2bytestream(stream, offset, value); +} + +inline void bytestream2quaternion(LLQuaternion &quat, const U8 *stream, S32 &offset) +{ + S32 value = bytestream2integer(stream, offset); + quat.mQ[VS] = *(F32 *)&value; + if (!llfinite(quat.mQ[VS])) + { + quat.mQ[VS] = 0; + set_fault(stream, LSRF_MATH); + } + value = bytestream2integer(stream, offset); + quat.mQ[VZ] = *(F32 *)&value; + if (!llfinite(quat.mQ[VZ])) + { + quat.mQ[VZ] = 0; + set_fault(stream, LSRF_MATH); + } + value = bytestream2integer(stream, offset); + quat.mQ[VY] = *(F32 *)&value; + if (!llfinite(quat.mQ[VY])) + { + quat.mQ[VY] = 0; + set_fault(stream, LSRF_MATH); + } + value = bytestream2integer(stream, offset); + quat.mQ[VX] = *(F32 *)&value; + if (!llfinite(quat.mQ[VX])) + { + quat.mQ[VX] = 0; + set_fault(stream, LSRF_MATH); + } +} + +inline void quaternion2bytestream(U8 *stream, S32 &offset, LLQuaternion &quat) +{ + S32 value = *(S32 *)&quat.mQ[VS]; + integer2bytestream(stream, offset, value); + value = *(S32 *)&quat.mQ[VZ]; + integer2bytestream(stream, offset, value); + value = *(S32 *)&quat.mQ[VY]; + integer2bytestream(stream, offset, value); + value = *(S32 *)&quat.mQ[VX]; + integer2bytestream(stream, offset, value); +} + +inline S32 get_register(const U8 *stream, LSCRIPTRegisters reg) +{ + S32 offset = gLSCRIPTRegisterAddresses[reg]; + return bytestream2integer(stream, offset); +} + +inline F32 get_register_fp(U8 *stream, LSCRIPTRegisters reg) +{ + S32 offset = gLSCRIPTRegisterAddresses[reg]; + F32 value = bytestream2float(stream, offset); + if (!llfinite(value)) + { + value = 0; + set_fault(stream, LSRF_MATH); + } + return value; +} +inline U64 get_register_u64(U8 *stream, LSCRIPTRegisters reg) +{ + S32 offset = gLSCRIPTRegisterAddresses[reg]; + return bytestream2u64(stream, offset); +} + +inline U64 get_event_register(U8 *stream, LSCRIPTRegisters reg, S32 major_version) +{ + if (major_version == 1) + { + S32 offset = gLSCRIPTRegisterAddresses[reg]; + return (U64)bytestream2integer(stream, offset); + } + else if (major_version == 2) + { + S32 offset = gLSCRIPTRegisterAddresses[reg + (LREG_NCE - LREG_CE)]; + return bytestream2u64(stream, offset); + } + else + { + S32 offset = gLSCRIPTRegisterAddresses[reg]; + return (U64)bytestream2integer(stream, offset); + } +} + +inline void set_register(U8 *stream, LSCRIPTRegisters reg, S32 value) +{ + S32 offset = gLSCRIPTRegisterAddresses[reg]; + integer2bytestream(stream, offset, value); +} + +inline void set_register_fp(U8 *stream, LSCRIPTRegisters reg, F32 value) +{ + S32 offset = gLSCRIPTRegisterAddresses[reg]; + float2bytestream(stream, offset, value); +} + +inline void set_register_u64(U8 *stream, LSCRIPTRegisters reg, U64 value) +{ + S32 offset = gLSCRIPTRegisterAddresses[reg]; + u642bytestream(stream, offset, value); +} + +inline void set_event_register(U8 *stream, LSCRIPTRegisters reg, U64 value, S32 major_version) +{ + if (major_version == 1) + { + S32 offset = gLSCRIPTRegisterAddresses[reg]; + integer2bytestream(stream, offset, (S32)value); + } + else if (major_version == 2) + { + S32 offset = gLSCRIPTRegisterAddresses[reg + (LREG_NCE - LREG_CE)]; + u642bytestream(stream, offset, value); + } + else + { + S32 offset = gLSCRIPTRegisterAddresses[reg]; + integer2bytestream(stream, offset, (S32)value); + } +} + + +inline F32 add_register_fp(U8 *stream, LSCRIPTRegisters reg, F32 value) +{ + S32 offset = gLSCRIPTRegisterAddresses[reg]; + F32 newvalue = bytestream2float(stream, offset); + newvalue += value; + if (!llfinite(newvalue)) + { + newvalue = 0; + set_fault(stream, LSRF_MATH); + } + offset = gLSCRIPTRegisterAddresses[reg]; + float2bytestream(stream, offset, newvalue); + return newvalue; +} + +void lsa_print_heap(U8 *buffer); + + +inline void set_fault(const U8 *stream, LSCRIPTRunTimeFaults fault) +{ + S32 fr = get_register(stream, LREG_FR); + // record the first error + if (!fr) + { + if ( (fault == LSRF_HEAP_ERROR) + ||(fault == LSRF_STACK_HEAP_COLLISION) + ||(fault == LSRF_BOUND_CHECK_ERROR)) + { + reset_hp_to_safe_spot(stream); +// lsa_print_heap((U8 *)stream); + } + fr = LSCRIPTRunTimeFaultBits[fault]; + set_register((U8 *)stream, LREG_FR, fr); + } +} + +inline BOOL set_ip(U8 *stream, S32 ip) +{ + // Verify that the Instruction Pointer is in a valid + // code area (between the Global Function Register + // and Heap Register). + S32 gfr = get_register(stream, LREG_GFR); + if (ip == 0) + { + set_register(stream, LREG_IP, ip); + return TRUE; + } + if (ip < gfr) + { + set_fault(stream, LSRF_BOUND_CHECK_ERROR); + return FALSE; + } + S32 hr = get_register(stream, LREG_HR); + if (ip >= hr) + { + set_fault(stream, LSRF_BOUND_CHECK_ERROR); + return FALSE; + } + set_register(stream, LREG_IP, ip); + return TRUE; +} + +inline BOOL set_bp(U8 *stream, S32 bp) +{ + // Verify that the Base Pointer is in a valid + // data area (between the Heap Pointer and + // the Top of Memory, and below the + // Stack Pointer). + S32 hp = get_register(stream, LREG_HP); + if (bp <= hp) + { + set_fault(stream, LSRF_STACK_HEAP_COLLISION); + return FALSE; + } + S32 tm = get_register(stream, LREG_TM); + if (bp >= tm) + { + set_fault(stream, LSRF_BOUND_CHECK_ERROR); + return FALSE; + } + S32 sp = get_register(stream, LREG_SP); + if (bp < sp) + { + set_fault(stream, LSRF_BOUND_CHECK_ERROR); + return FALSE; + } + set_register(stream, LREG_BP, bp); + return TRUE; +} + +inline BOOL set_sp(U8 *stream, S32 sp) +{ + // Verify that the Stack Pointer is in a valid + // data area (between the Heap Pointer and + // the Top of Memory). + S32 hp = get_register(stream, LREG_HP); + if (sp <= hp) + { + set_fault(stream, LSRF_STACK_HEAP_COLLISION); + return FALSE; + } + S32 tm = get_register(stream, LREG_TM); + if (sp >= tm) + { + set_fault(stream, LSRF_BOUND_CHECK_ERROR); + return FALSE; + } + set_register(stream, LREG_SP, sp); + return TRUE; +} + +inline void lscript_push(U8 *stream, U8 value) +{ + S32 sp = get_register(stream, LREG_SP); + sp -= 1; + + if (set_sp(stream, sp)) + { + *(stream + sp) = value; + } +} + +inline void lscript_push(U8 *stream, S32 value) +{ + S32 sp = get_register(stream, LREG_SP); + sp -= LSCRIPTDataSize[LST_INTEGER]; + + if (set_sp(stream, sp)) + { + integer2bytestream(stream, sp, value); + } +} + +inline void lscript_push(U8 *stream, F32 value) +{ + S32 sp = get_register(stream, LREG_SP); + sp -= LSCRIPTDataSize[LST_FLOATINGPOINT]; + + if (set_sp(stream, sp)) + { + float2bytestream(stream, sp, value); + } +} + +inline void lscript_push(U8 *stream, LLVector3 &value) +{ + S32 sp = get_register(stream, LREG_SP); + sp -= LSCRIPTDataSize[LST_VECTOR]; + + if (set_sp(stream, sp)) + { + vector2bytestream(stream, sp, value); + } +} + +inline void lscript_push(U8 *stream, LLQuaternion &value) +{ + S32 sp = get_register(stream, LREG_SP); + sp -= LSCRIPTDataSize[LST_QUATERNION]; + + if (set_sp(stream, sp)) + { + quaternion2bytestream(stream, sp, value); + } +} + +inline void lscript_pusharg(U8 *stream, S32 arg) +{ + S32 sp = get_register(stream, LREG_SP); + sp -= arg; + + set_sp(stream, sp); +} + +inline void lscript_poparg(U8 *stream, S32 arg) +{ + S32 sp = get_register(stream, LREG_SP); + sp += arg; + + set_sp(stream, sp); +} + +inline U8 lscript_pop_char(U8 *stream) +{ + S32 sp = get_register(stream, LREG_SP); + U8 value = *(stream + sp++); + set_sp(stream, sp); + return value; +} + +inline S32 lscript_pop_int(U8 *stream) +{ + S32 sp = get_register(stream, LREG_SP); + S32 value = bytestream2integer(stream, sp); + set_sp(stream, sp); + return value; +} + +inline F32 lscript_pop_float(U8 *stream) +{ + S32 sp = get_register(stream, LREG_SP); + F32 value = bytestream2float(stream, sp); + if (!llfinite(value)) + { + value = 0; + set_fault(stream, LSRF_MATH); + } + set_sp(stream, sp); + return value; +} + +inline void lscript_pop_vector(U8 *stream, LLVector3 &value) +{ + S32 sp = get_register(stream, LREG_SP); + bytestream2vector(value, stream, sp); + set_sp(stream, sp); +} + +inline void lscript_pop_quaternion(U8 *stream, LLQuaternion &value) +{ + S32 sp = get_register(stream, LREG_SP); + bytestream2quaternion(value, stream, sp); + set_sp(stream, sp); +} + +inline void lscript_pusharge(U8 *stream, S32 value) +{ + S32 sp = get_register(stream, LREG_SP); + sp -= value; + if (set_sp(stream, sp)) + { + S32 i; + for (i = 0; i < value; i++) + { + *(stream + sp++) = 0; + } + } +} + +inline BOOL lscript_check_local(U8 *stream, S32 &address, S32 size) +{ + S32 sp = get_register(stream, LREG_SP); + S32 bp = get_register(stream, LREG_BP); + + address += size; + address = bp - address; + + if (address < sp - size) + { + set_fault(stream, LSRF_BOUND_CHECK_ERROR); + return FALSE; + } + S32 tm = get_register(stream, LREG_TM); + if (address + size > tm) + { + set_fault(stream, LSRF_BOUND_CHECK_ERROR); + return FALSE; + } + return TRUE; +} + +inline BOOL lscript_check_global(U8 *stream, S32 &address, S32 size) +{ + S32 gvr = get_register(stream, LREG_GVR); + + // Possibility of overwriting registers? -- DK 09/07/04 + if (address < 0) + { + set_fault(stream, LSRF_BOUND_CHECK_ERROR); + return FALSE; + } + + address += gvr; + S32 gfr = get_register(stream, LREG_GFR); + + if (address + size > gfr) + { + set_fault(stream, LSRF_BOUND_CHECK_ERROR); + return FALSE; + } + return TRUE; +} + +inline void lscript_local_store(U8 *stream, S32 address, S32 value) +{ + if (lscript_check_local(stream, address, LSCRIPTDataSize[LST_INTEGER])) + integer2bytestream(stream, address, value); +} + +inline void lscript_local_store(U8 *stream, S32 address, F32 value) +{ + if (lscript_check_local(stream, address, LSCRIPTDataSize[LST_FLOATINGPOINT])) + float2bytestream(stream, address, value); +} + +inline void lscript_local_store(U8 *stream, S32 address, LLVector3 value) +{ + if (lscript_check_local(stream, address, LSCRIPTDataSize[LST_VECTOR])) + vector2bytestream(stream, address, value); +} + +inline void lscript_local_store(U8 *stream, S32 address, LLQuaternion value) +{ + if (lscript_check_local(stream, address, LSCRIPTDataSize[LST_QUATERNION])) + quaternion2bytestream(stream, address, value); +} + +inline void lscript_global_store(U8 *stream, S32 address, S32 value) +{ + if (lscript_check_global(stream, address, LSCRIPTDataSize[LST_INTEGER])) + integer2bytestream(stream, address, value); +} + +inline void lscript_global_store(U8 *stream, S32 address, F32 value) +{ + if (lscript_check_global(stream, address, LSCRIPTDataSize[LST_FLOATINGPOINT])) + float2bytestream(stream, address, value); +} + +inline void lscript_global_store(U8 *stream, S32 address, LLVector3 value) +{ + if (lscript_check_global(stream, address, LSCRIPTDataSize[LST_VECTOR])) + vector2bytestream(stream, address, value); +} + +inline void lscript_global_store(U8 *stream, S32 address, LLQuaternion value) +{ + if (lscript_check_global(stream, address, LSCRIPTDataSize[LST_QUATERNION])) + quaternion2bytestream(stream, address, value); +} + +inline S32 lscript_local_get(U8 *stream, S32 address) +{ + if (lscript_check_local(stream, address, LSCRIPTDataSize[LST_INTEGER])) + return bytestream2integer(stream, address); + return 0; +} + +inline void lscript_local_get(U8 *stream, S32 address, F32 &value) +{ + if (lscript_check_local(stream, address, LSCRIPTDataSize[LST_FLOATINGPOINT])) + value = bytestream2float(stream, address); + if (!llfinite(value)) + { + value = 0; + set_fault(stream, LSRF_MATH); + } +} + +inline void lscript_local_get(U8 *stream, S32 address, LLVector3 &value) +{ + if (lscript_check_local(stream, address, LSCRIPTDataSize[LST_VECTOR])) + bytestream2vector(value, stream, address); +} + +inline void lscript_local_get(U8 *stream, S32 address, LLQuaternion &value) +{ + if (lscript_check_local(stream, address, LSCRIPTDataSize[LST_QUATERNION])) + bytestream2quaternion(value, stream, address); +} + +inline S32 lscript_global_get(U8 *stream, S32 address) +{ + if (lscript_check_global(stream, address, LSCRIPTDataSize[LST_INTEGER])) + return bytestream2integer(stream, address); + return 0; +} + +inline void lscript_global_get(U8 *stream, S32 address, F32 &value) +{ + if (lscript_check_global(stream, address, LSCRIPTDataSize[LST_FLOATINGPOINT])) + value = bytestream2float(stream, address); + if (!llfinite(value)) + { + value = 0; + set_fault(stream, LSRF_MATH); + } +} + +inline void lscript_global_get(U8 *stream, S32 address, LLVector3 &value) +{ + if (lscript_check_global(stream, address, LSCRIPTDataSize[LST_VECTOR])) + bytestream2vector(value, stream, address); +} + +inline void lscript_global_get(U8 *stream, S32 address, LLQuaternion &value) +{ + if (lscript_check_global(stream, address, LSCRIPTDataSize[LST_QUATERNION])) + bytestream2quaternion(value, stream, address); +} + + + +inline S32 get_state_event_opcoode_start(U8 *stream, S32 state, LSCRIPTStateEventType event) +{ + // get the start of the state table + S32 sr = get_register(stream, LREG_SR); + + // get the position of the jump to the desired state + S32 value = get_register(stream, LREG_VN); + + S32 state_offset_offset = 0; + S32 major_version = 0; + if (value == LSL2_VERSION1_END_NUMBER) + { + major_version = LSL2_MAJOR_VERSION_ONE; + state_offset_offset = sr + LSCRIPTDataSize[LST_INTEGER] + LSCRIPTDataSize[LST_INTEGER]*2*state; + } + else if (value == LSL2_VERSION_NUMBER) + { + major_version = LSL2_MAJOR_VERSION_TWO; + state_offset_offset = sr + LSCRIPTDataSize[LST_INTEGER] + LSCRIPTDataSize[LST_INTEGER]*3*state; + } + + // get the actual position in memory of the desired state + S32 state_offset = sr + bytestream2integer(stream, state_offset_offset); + + // save that value + S32 state_offset_base = state_offset; + + // jump past the state name + S32 event_jump_offset = state_offset_base + bytestream2integer(stream, state_offset); + + // get the location of the event offset + S32 event_offset = event_jump_offset + LSCRIPTDataSize[LST_INTEGER]*2*get_event_handler_jump_position(get_event_register(stream, LREG_ER, major_version), event); + + // now, jump to the event + S32 event_start = bytestream2integer(stream, event_offset); + event_start += event_jump_offset; + + S32 event_start_original = event_start; + + // now skip past the parameters + S32 opcode_offset = bytestream2integer(stream, event_start); + return opcode_offset + event_start_original; +} + +inline U64 get_handled_events(U8 *stream, S32 state) +{ + U64 retvalue = 0; + // get the start of the state table + S32 sr = get_register(stream, LREG_SR); + + // get the position of the jump to the desired state + S32 value = get_register(stream, LREG_VN); + S32 state_handled_offset = 0; + if (value == LSL2_VERSION1_END_NUMBER) + { + state_handled_offset = sr + LSCRIPTDataSize[LST_INTEGER]*2*state + 2*LSCRIPTDataSize[LST_INTEGER]; + retvalue = bytestream2integer(stream, state_handled_offset); + } + else if (value == LSL2_VERSION_NUMBER) + { + state_handled_offset = sr + LSCRIPTDataSize[LST_INTEGER]*3*state + 2*LSCRIPTDataSize[LST_INTEGER]; + retvalue = bytestream2u64(stream, state_handled_offset); + } + + // get the handled events + return retvalue; +} + +inline S32 get_event_stack_size(U8 *stream, S32 state, LSCRIPTStateEventType event) +{ + // get the start of the state table + S32 sr = get_register(stream, LREG_SR); + + // get state offset + S32 value = get_register(stream, LREG_VN); + S32 state_offset_offset = 0; + S32 major_version = 0; + if (value == LSL2_VERSION1_END_NUMBER) + { + major_version = LSL2_MAJOR_VERSION_ONE; + state_offset_offset = sr + LSCRIPTDataSize[LST_INTEGER] + LSCRIPTDataSize[LST_INTEGER]*2*state; + } + else if (value == LSL2_VERSION_NUMBER) + { + major_version = LSL2_MAJOR_VERSION_TWO; + state_offset_offset = sr + LSCRIPTDataSize[LST_INTEGER] + LSCRIPTDataSize[LST_INTEGER]*3*state; + } + + S32 state_offset = bytestream2integer(stream, state_offset_offset); + state_offset += sr; + + state_offset_offset = state_offset; + + // skip to jump table + S32 jump_table = bytestream2integer(stream, state_offset_offset); + + jump_table += state_offset; + + // get the position of the jump to the desired state + S32 stack_size_offset = jump_table + LSCRIPTDataSize[LST_INTEGER]*2*get_event_handler_jump_position(get_event_register(stream, LREG_ER, major_version), event) + LSCRIPTDataSize[LST_INTEGER]; + + // get the handled events + S32 stack_size = bytestream2integer(stream, stack_size_offset); + return stack_size; +} + +inline LSCRIPTStateEventType return_first_event(S32 event) +{ + S32 count = 1; + while (count < LSTT_EOF) + { + if (event & 0x1) + { + return (LSCRIPTStateEventType) count; + } + else + { + event >>= 1; + count++; + } + } + return LSTT_NULL; +} + + +// the safe instruction versions of these commands will only work if offset is between +// GFR and HR, meaning that it is an instruction (more or less) in global functions or event handlers + +inline BOOL safe_instruction_check_address(U8 *stream, S32 offset, S32 size) +{ + S32 gfr = get_register(stream, LREG_GFR); + if (offset < gfr) + { + set_fault(stream, LSRF_BOUND_CHECK_ERROR); + return FALSE; + } + else + { + S32 hr = get_register(stream, LREG_HR); + if (offset + size > hr) + { + set_fault(stream, LSRF_BOUND_CHECK_ERROR); + return FALSE; + } + else + { + return TRUE; + } + } +} + +inline BOOL safe_heap_check_address(U8 *stream, S32 offset, S32 size) +{ + S32 hr = get_register(stream, LREG_HR); + if (offset < hr) + { + set_fault(stream, LSRF_BOUND_CHECK_ERROR); + return FALSE; + } + else + { + S32 hp = get_register(stream, LREG_HP); + if (offset + size > hp) + { + set_fault(stream, LSRF_BOUND_CHECK_ERROR); + return FALSE; + } + else + { + return TRUE; + } + } +} + +inline U8 safe_instruction_bytestream2byte(U8 *stream, S32 &offset) +{ + if (safe_instruction_check_address(stream, offset, 1)) + { + return *(stream + offset++); + } + else + { + return 0; + } +} + +inline void safe_instruction_byte2bytestream(U8 *stream, S32 &offset, U8 byte) +{ + if (safe_instruction_check_address(stream, offset, 1)) + { + *(stream + offset++) = byte; + } +} + +inline S32 safe_instruction_bytestream2integer(U8 *stream, S32 &offset) +{ + if (safe_instruction_check_address(stream, offset, LSCRIPTDataSize[LST_INTEGER])) + { + return (bytestream2integer(stream, offset)); + } + else + { + return 0; + } +} + +inline void safe_instruction_integer2bytestream(U8 *stream, S32 &offset, S32 value) +{ + if (safe_instruction_check_address(stream, offset, LSCRIPTDataSize[LST_INTEGER])) + { + integer2bytestream(stream, offset, value); + } +} + +inline U16 safe_instruction_bytestream2u16(U8 *stream, S32 &offset) +{ + if (safe_instruction_check_address(stream, offset, 2)) + { + return (bytestream2u16(stream, offset)); + } + else + { + return 0; + } +} + +inline void safe_instruction_u162bytestream(U8 *stream, S32 &offset, U16 value) +{ + if (safe_instruction_check_address(stream, offset, 2)) + { + u162bytestream(stream, offset, value); + } +} + +inline F32 safe_instruction_bytestream2float(U8 *stream, S32 &offset) +{ + if (safe_instruction_check_address(stream, offset, LSCRIPTDataSize[LST_INTEGER])) + { + F32 value = bytestream2float(stream, offset); + if (!llfinite(value)) + { + value = 0; + set_fault(stream, LSRF_MATH); + } + return value; + } + else + { + return 0; + } +} + +inline void safe_instruction_float2bytestream(U8 *stream, S32 &offset, F32 value) +{ + if (safe_instruction_check_address(stream, offset, LSCRIPTDataSize[LST_FLOATINGPOINT])) + { + float2bytestream(stream, offset, value); + } +} + +inline void safe_instruction_bytestream2char(char *buffer, U8 *stream, S32 &offset) +{ + while ( (safe_instruction_check_address(stream, offset, 1)) + &&(*buffer++ = *(stream + offset++))) + ; +} + +inline void safe_instruction_bytestream_count_char(U8 *stream, S32 &offset) +{ + while ( (safe_instruction_check_address(stream, offset, 1)) + &&(*(stream + offset++))) + ; +} + +inline void safe_heap_bytestream_count_char(U8 *stream, S32 &offset) +{ + while ( (safe_heap_check_address(stream, offset, 1)) + &&(*(stream + offset++))) + ; +} + +inline void safe_instruction_char2bytestream(U8 *stream, S32 &offset, char *buffer) +{ + while ( (safe_instruction_check_address(stream, offset, 1)) + &&(*(stream + offset++) = *buffer++)) + ; +} + +inline void safe_instruction_bytestream2vector(LLVector3 &value, U8 *stream, S32 &offset) +{ + if (safe_instruction_check_address(stream, offset, LSCRIPTDataSize[LST_VECTOR])) + { + bytestream2vector(value, stream, offset); + } +} + +inline void safe_instruction_vector2bytestream(U8 *stream, S32 &offset, LLVector3 &value) +{ + if (safe_instruction_check_address(stream, offset, LSCRIPTDataSize[LST_VECTOR])) + { + vector2bytestream(stream, offset, value); + } +} + +inline void safe_instruction_bytestream2quaternion(LLQuaternion &value, U8 *stream, S32 &offset) +{ + if (safe_instruction_check_address(stream, offset, LSCRIPTDataSize[LST_QUATERNION])) + { + bytestream2quaternion(value, stream, offset); + } +} + +inline void safe_instruction_quaternion2bytestream(U8 *stream, S32 &offset, LLQuaternion &value) +{ + if (safe_instruction_check_address(stream, offset, LSCRIPTDataSize[LST_QUATERNION])) + { + quaternion2bytestream(stream, offset, value); + } +} + +static inline LSCRIPTType char2type(char type) +{ + switch(type) + { + case 'i': + return LST_INTEGER; + case 'f': + return LST_FLOATINGPOINT; + case 's': + return LST_STRING; + case 'k': + return LST_KEY; + case 'v': + return LST_VECTOR; + case 'q': + return LST_QUATERNION; + case 'l': + return LST_LIST; + default: + return LST_NULL; + } +} + +#endif diff --git a/indra/lscript/lscript_byteformat.h b/indra/lscript/lscript_byteformat.h new file mode 100644 index 0000000000..a79f2effae --- /dev/null +++ b/indra/lscript/lscript_byteformat.h @@ -0,0 +1,544 @@ +/** + * @file lscript_byteformat.h + * @brief Shared code between compiler and assembler and LSL + * + * Copyright (c) 2002-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + +#ifndef LL_LSCRIPT_BYTEFORMAT_H +#define LL_LSCRIPT_BYTEFORMAT_H + +// Data shared between compiler/assembler and lscript execution code + +#include "stdtypes.h" + +const S32 LSL2_VERSION_NUMBER = 0x0200; +const S32 LSL2_VERSION1_END_NUMBER = 0x0101; +const S32 LSL2_VERSION2_START_NUMBER = 0x0200; + +const S32 LSL2_MAJOR_VERSION_ONE = 1; +const S32 LSL2_MAJOR_VERSION_TWO = 2; +const S32 LSL2_CURRENT_MAJOR_VERSION = LSL2_MAJOR_VERSION_TWO; + +const S32 TOP_OF_MEMORY = 16384; + +typedef enum e_lscript_registers +{ + LREG_INVALID, + LREG_IP, // instruction pointer + LREG_VN, // version number + LREG_BP, // base pointer - what local variables are referenced from + LREG_SP, // stack pointer - where the top of the stack is + LREG_HR, // heap register - where in memory does the heap start + LREG_HP, // heap pointer - where is the top of the heap? + LREG_CS, // current state - what state are we currently in? + LREG_NS, // next state - what state are we currently in? + LREG_CE, // current events - what events are waiting to be handled? + LREG_IE, // in event - which event handler are we currently in? + LREG_ER, // event register - what events do we have active handlers for? + LREG_FR, // fault register - which errors are currently active? + LREG_SLR, // sleep register - are we sleeping? + LREG_GVR, // global variable register - where do global variables start + LREG_GFR, // global function register - where do global functions start + LREG_SR, // state register - where do states start + LREG_TM, // top of memory - where is the top of memory + LREG_PR, // parameter register - data passed to script from launcher + LREG_ESR, // energy supply register - how much energy do we have on board? + LREG_NCE, // 64 bit current envents - what events are waiting to be handled? + LREG_NIE, // 64 bit in event - which event handler are we currently in? + LREG_NER, // 64 bit event register - what events do we have active handlers for? + LREG_EOF +} LSCRIPTRegisters; + +const S32 gLSCRIPTRegisterAddresses[LREG_EOF] = +{ + 0, // LREG_INVALID + 4, // LREG_IP + 8, // LREG_VN + 12, // LREG_BP + 16, // LREG_SP + 20, // LREG_HR + 24, // LREG_HP + 28, // LREG_CS + 32, // LREG_NS + 36, // LREG_CE + 40, // LREG_IE + 44, // LREG_ER + 48, // LREG_FR + 52, // LREG_SLR + 56, // LREG_GVR + 60, // LREG_GFR + 72, // LREG_SR + 0, // LREG_TM + 64, // LREG_PR + 68, // LREG_ESR + 76, // LREG_NCE + 84, // LREG_NIE + 92, // LREG_NER +}; + +const char * const gLSCRIPTRegisterNames[LREG_EOF] = +{ + "INVALID", // LREG_INVALID + "IP", // LREG_IP + "VN", // LREG_VN + "BP", // LREG_BP + "SP", // LREG_SP + "HR", // LREG_HR + "HP", // LREG_HP + "CS", // LREG_CS + "NS", // LREG_NS + "CE", // LREG_CE + "IE", // LREG_IE + "ER", // LREG_ER + "FR", // LREG_FR + "SLR", // LREG_SLR + "GVR", // LREG_GVR + "GFR", // LREG_GFR + "SR", // LREG_SR + "TM", // LREG_TM + "PR", // LREG_PR + "ESR", // LREG_ESR + "NCE", // LREG_NCE + "NIE", // LREG_NIE + "NER", // LREG_NER +}; + +typedef enum e_lscript_op_codes +{ + LOPC_INVALID, + LOPC_NOOP, + LOPC_POP, + LOPC_POPS, + LOPC_POPL, + LOPC_POPV, + LOPC_POPQ, + LOPC_POPARG, + LOPC_POPIP, + LOPC_POPBP, + LOPC_POPSP, + LOPC_POPSLR, + LOPC_DUP, + LOPC_DUPS, + LOPC_DUPL, + LOPC_DUPV, + LOPC_DUPQ, + LOPC_STORE, + LOPC_STORES, + LOPC_STOREL, + LOPC_STOREV, + LOPC_STOREQ, + LOPC_STOREG, + LOPC_STOREGS, + LOPC_STOREGL, + LOPC_STOREGV, + LOPC_STOREGQ, + LOPC_LOADP, + LOPC_LOADSP, + LOPC_LOADLP, + LOPC_LOADVP, + LOPC_LOADQP, + LOPC_LOADGP, + LOPC_LOADGLP, + LOPC_LOADGSP, + LOPC_LOADGVP, + LOPC_LOADGQP, + LOPC_PUSH, + LOPC_PUSHS, + LOPC_PUSHL, + LOPC_PUSHV, + LOPC_PUSHQ, + LOPC_PUSHG, + LOPC_PUSHGS, + LOPC_PUSHGL, + LOPC_PUSHGV, + LOPC_PUSHGQ, + LOPC_PUSHIP, + LOPC_PUSHBP, + LOPC_PUSHSP, + LOPC_PUSHARGB, + LOPC_PUSHARGI, + LOPC_PUSHARGF, + LOPC_PUSHARGS, + LOPC_PUSHARGV, + LOPC_PUSHARGQ, + LOPC_PUSHE, + LOPC_PUSHEV, + LOPC_PUSHEQ, + LOPC_PUSHARGE, + LOPC_ADD, + LOPC_SUB, + LOPC_MUL, + LOPC_DIV, + LOPC_MOD, + LOPC_EQ, + LOPC_NEQ, + LOPC_LEQ, + LOPC_GEQ, + LOPC_LESS, + LOPC_GREATER, + LOPC_BITAND, + LOPC_BITOR, + LOPC_BITXOR, + LOPC_BOOLAND, + LOPC_BOOLOR, + LOPC_NEG, + LOPC_BITNOT, + LOPC_BOOLNOT, + LOPC_JUMP, + LOPC_JUMPIF, + LOPC_JUMPNIF, + LOPC_STATE, + LOPC_CALL, + LOPC_RETURN, + LOPC_CAST, + LOPC_STACKTOS, + LOPC_STACKTOL, + LOPC_PRINT, + LOPC_CALLLIB, + LOPC_CALLLIB_TWO_BYTE, + LOPC_SHL, + LOPC_SHR, + LOPC_EOF +} LSCRIPTOpCodesEnum; + +const U8 LSCRIPTOpCodes[LOPC_EOF] = +{ + 0x00, // LOPC_INVALID + 0x00, // LOPC_NOOP + 0x01, // LOPC_POP + 0x02, // LOPC_POPS + 0x03, // LOPC_POPL + 0x04, // LOPC_POPV + 0x05, // LOPC_POPQ + 0x06, // LOPC_POPARG + 0x07, // LOPC_POPIP + 0x08, // LOPC_POPBP + 0x09, // LOPC_POPSP + 0x0a, // LOPC_POPSLR + 0x20, // LOPC_DUP + 0x21, // LOPC_DUPS + 0x22, // LOPC_DUPL + 0x23, // LOPC_DUPV + 0x24, // LOPC_DUPQ + 0x30, // LOPC_STORE + 0x31, // LOPC_STORES + 0x32, // LOPC_STOREL + 0x33, // LOPC_STOREV + 0x34, // LOPC_STOREQ + 0x35, // LOPC_STOREG + 0x36, // LOPC_STOREGS + 0x37, // LOPC_STOREGL + 0x38, // LOPC_STOREGV + 0x39, // LOPC_STOREGQ + 0x3a, // LOPC_LOADP + 0x3b, // LOPC_LOADSP + 0x3c, // LOPC_LOADLP + 0x3d, // LOPC_LOADVP + 0x3e, // LOPC_LOADQP + 0x3f, // LOPC_LOADGP + 0x40, // LOPC_LOADGSP + 0x41, // LOPC_LOADGLP + 0x42, // LOPC_LOADGVP + 0x43, // LOPC_LOADGQP + 0x50, // LOPC_PUSH + 0x51, // LOPC_PUSHS + 0x52, // LOPC_PUSHL + 0x53, // LOPC_PUSHV + 0x54, // LOPC_PUSHQ + 0x55, // LOPC_PUSHG + 0x56, // LOPC_PUSHGS + 0x57, // LOPC_PUSHGL + 0x58, // LOPC_PUSHGV + 0x59, // LOPC_PUSHGQ + 0x5a, // LOPC_PUSHIP + 0x5b, // LOPC_PUSHBP + 0x5c, // LOPC_PUSHSP + 0x5d, // LOPC_PUSHARGB + 0x5e, // LOPC_PUSHARGI + 0x5f, // LOPC_PUSHARGF + 0x60, // LOPC_PUSHARGS + 0x61, // LOPC_PUSHARGV + 0x62, // LOPC_PUSHARGQ + 0x63, // LOPC_PUSHE + 0x64, // LOPC_PUSHEV + 0x65, // LOPC_PUSHEQ + 0x66, // LOPC_PUSHARGE + 0x70, // LOPC_ADD + 0x71, // LOPC_SUB + 0x72, // LOPC_MUL + 0x73, // LOPC_DIV + 0x74, // LOPC_MOD + 0x75, // LOPC_EQ + 0x76, // LOPC_NEQ + 0x77, // LOPC_LEQ + 0x78, // LOPC_GEQ + 0x79, // LOPC_LESS + 0x7a, // LOPC_GREATER + 0x7b, // LOPC_BITAND + 0x7c, // LOPC_BITOR + 0x7d, // LOPC_BITXOR + 0x7e, // LOPC_BOOLAND + 0x7f, // LOPC_BOOLOR + 0x80, // LOPC_NEG + 0x81, // LOPC_BITNOT + 0x82, // LOPC_BOOLNOT + 0x90, // LOPC_JUMP + 0x91, // LOPC_JUMPIF + 0x92, // LOPC_JUMPNIF + 0x93, // LOPC_STATE + 0x94, // LOPC_CALL + 0x95, // LOPC_RETURN + 0xa0, // LOPC_CAST + 0xb0, // LOPC_STACKTOS + 0xb1, // LOPC_STACKTOL + 0xc0, // LOPC_PRINT + 0xd0, // LOPC_CALLLIB + 0xd1, // LOPC_CALLLIB_TWO_BYTE + 0xe0, // LOPC_SHL + 0xe1 // LOPC_SHR +}; + +typedef enum e_lscript_state_event_type +{ + LSTT_NULL, + LSTT_STATE_ENTRY, + LSTT_STATE_EXIT, + LSTT_TOUCH_START, + LSTT_TOUCH, + LSTT_TOUCH_END, + LSTT_COLLISION_START, + LSTT_COLLISION, + LSTT_COLLISION_END, + LSTT_LAND_COLLISION_START, + LSTT_LAND_COLLISION, + LSTT_LAND_COLLISION_END, + LSTT_TIMER, + LSTT_CHAT, + LSTT_REZ, + LSTT_SENSOR, + LSTT_NO_SENSOR, + LSTT_CONTROL, + LSTT_MONEY, + LSTT_EMAIL, + LSTT_AT_TARGET, + LSTT_NOT_AT_TARGET, + LSTT_AT_ROT_TARGET, + LSTT_NOT_AT_ROT_TARGET, + LSTT_RTPERMISSIONS, + LSTT_INVENTORY, + LSTT_ATTACH, + LSTT_DATASERVER, + LSTT_LINK_MESSAGE, + LSTT_MOVING_START, + LSTT_MOVING_END, + LSTT_OBJECT_REZ, + LSTT_REMOTE_DATA, + LSTT_HTTP_RESPONSE, + LSTT_EOF, + + LSTT_STATE_BEGIN = LSTT_STATE_ENTRY, + LSTT_STATE_END = LSTT_EOF +} LSCRIPTStateEventType; + +const U64 LSCRIPTStateBitField[LSTT_EOF] = +{ + 0x0000000000000000, // LSTT_NULL + 0x0000000000000001, // LSTT_STATE_ENTRY + 0x0000000000000002, // LSTT_STATE_EXIT + 0x0000000000000004, // LSTT_TOUCH_START + 0x0000000000000008, // LSTT_TOUCH + 0x0000000000000010, // LSTT_TOUCH_END + 0x0000000000000020, // LSTT_COLLISION_START + 0x0000000000000040, // LSTT_COLLISION + 0x0000000000000080, // LSTT_COLLISION_END + 0x0000000000000100, // LSTT_LAND_COLLISION_START + 0x0000000000000200, // LSTT_LAND_COLLISION + 0x0000000000000400, // LSTT_LAND_COLLISION_END + 0x0000000000000800, // LSTT_TIMER + 0x0000000000001000, // LSTT_CHAT + 0x0000000000002000, // LSTT_REZ + 0x0000000000004000, // LSTT_SENSOR + 0x0000000000008000, // LSTT_NO_SENSOR + 0x0000000000010000, // LSTT_CONTROL + 0x0000000000020000, // LSTT_MONEY + 0x0000000000040000, // LSTT_EMAIL + 0x0000000000080000, // LSTT_AT_TARGET + 0x0000000000100000, // LSTT_NOT_AT_TARGET + 0x0000000000200000, // LSTT_AT_ROT_TARGET + 0x0000000000400000, // LSTT_NOT_AT_ROT_TARGET + 0x0000000000800000, // LSTT_RTPERMISSIONS + 0x0000000001000000, // LSTT_INVENTORY + 0x0000000002000000, // LSTT_ATTACH + 0x0000000004000000, // LSTT_DATASERVER + 0x0000000008000000, // LSTT_LINK_MESSAGE + 0x0000000010000000, // LSTT_MOVING_START + 0x0000000020000000, // LSTT_MOVING_END + 0x0000000040000000, // LSTT_OBJECT_REZ + 0x0000000080000000, // LSTT_REMOTE_DATA + 0x0000000100000000LL // LSTT_HTTP_RESPOSE +}; + +inline S32 get_event_handler_jump_position(U64 bit_field, LSCRIPTStateEventType type) +{ + S32 count = 0, position = LSTT_STATE_ENTRY; + while (position < type) + { + if (bit_field & 0x1) + { + count++; + } + bit_field >>= 1; + position++; + } + return count; +} + +inline S32 get_number_of_event_handlers(U64 bit_field) +{ + S32 count = 0, position = 0; + while (position < LSTT_EOF) + { + if (bit_field & 0x1) + { + count++; + } + bit_field >>= 1; + position++; + } + return count; +} + +typedef enum e_lscript_types +{ + LST_NULL, + LST_INTEGER, + LST_FLOATINGPOINT, + LST_STRING, + LST_KEY, + LST_VECTOR, + LST_QUATERNION, + LST_LIST, + LST_UNDEFINED, + LST_EOF +} LSCRIPTType; + +const U8 LSCRIPTTypeByte[LST_EOF] = +{ + LST_NULL, + LST_INTEGER, + LST_FLOATINGPOINT, + LST_STRING, + LST_KEY, + LST_VECTOR, + LST_QUATERNION, + LST_LIST, + LST_NULL, +}; + +const U8 LSCRIPTTypeHi4Bits[LST_EOF] = +{ + LST_NULL, + LST_INTEGER << 4, + LST_FLOATINGPOINT << 4, + LST_STRING << 4, + LST_KEY << 4, + LST_VECTOR << 4, + LST_QUATERNION << 4, + LST_LIST << 4, +}; + +const char * const LSCRIPTTypeNames[LST_EOF] = +{ + "VOID", + "integer", + "float", + "string", + "key", + "vector", + "quaternion", + "list", + "invalid" +}; + +const S32 LSCRIPTDataSize[LST_EOF] = +{ + 0, // VOID + 4, // integer + 4, // float + 4, // string + 4, // key + 12, // vector + 16, // quaternion + 4, // list + 0 // invalid +}; + + +typedef enum e_lscript_runtime_faults +{ + LSRF_INVALID, + LSRF_MATH, + LSRF_STACK_HEAP_COLLISION, + LSRF_BOUND_CHECK_ERROR, + LSRF_HEAP_ERROR, + LSRF_VERSION_MISMATCH, + LSRF_MISSING_INVENTORY, + LSRF_SANDBOX, + LSRF_CHAT_OVERRUN, + LSRF_TOO_MANY_LISTENS, + LSRF_NESTING_LISTS, + LSRF_EOF +} LSCRIPTRunTimeFaults; + +extern char *LSCRIPTRunTimeFaultStrings[LSRF_EOF]; + +const S32 LSCRIPTRunTimeFaultBits[LSRF_EOF] = +{ + 0, // LSRF_INVALID + 1, // LSRF_MATH + 2, // LSRF_STACK_HEAP_COLLISION + 3, // LSREF_BOUND_CHECK_ERROR + 4, // LSREF_HEAP_ERROR + 5, // LSREF_VERSION_MISMATCH + 6, // LSREF_MISSING_INVENTORY + 7, // LSRF_SANDBOX + 8, // LSRF_CHAT_OVERRUN + 9, // LSRF_TOO_MANY_LISTENS + 10, // LSRF_NESTING_LISTS +}; + +typedef enum e_lscript_runtime_permissions +{ + SCRIPT_PERMISSION_DEBIT, + SCRIPT_PERMISSION_TAKE_CONTROLS, + SCRIPT_PERMISSION_REMAP_CONTROLS, + SCRIPT_PERMISSION_TRIGGER_ANIMATION, + SCRIPT_PERMISSION_ATTACH, + SCRIPT_PERMISSION_RELEASE_OWNERSHIP, + SCRIPT_PERMISSION_CHANGE_LINKS, + SCRIPT_PERMISSION_CHANGE_JOINTS, + SCRIPT_PERMISSION_CHANGE_PERMISSIONS, + SCRIPT_PERMISSION_TRACK_CAMERA, + SCRIPT_PERMISSION_CONTROL_CAMERA, + SCRIPT_PERMISSION_EOF +} LSCRIPTRunTimePermissions; + +const U32 LSCRIPTRunTimePermissionBits[SCRIPT_PERMISSION_EOF] = +{ + (0x1 << 1), // SCRIPT_PERMISSION_DEBIT, + (0x1 << 2), // SCRIPT_PERMISSION_TAKE_CONTROLS, + (0x1 << 3), // SCRIPT_PERMISSION_REMAP_CONTROLS, + (0x1 << 4), // SCRIPT_PERMISSION_TRIGGER_ANIMATION, + (0x1 << 5), // SCRIPT_PERMISSION_ATTACH, + (0x1 << 6), // SCRIPT_PERMISSION_RELEASE_OWNERSHIP, + (0x1 << 7), // SCRIPT_PERMISSION_CHANGE_LINKS, + (0x1 << 8), // SCRIPT_PERMISSION_CHANGE_JOINTS, + (0x1 << 9), // SCRIPT_PERMISSION_CHANGE_PERMISSIONS + (0x1 << 10),// SCRIPT_PERMISSION_TRACK_CAMERA + (0x1 << 11),// SCRIPT_PERMISSION_CONTROL_CAMERA +}; + +#endif + diff --git a/indra/lscript/lscript_compile/indra.l b/indra/lscript/lscript_compile/indra.l new file mode 100644 index 0000000000..2ee219a8ee --- /dev/null +++ b/indra/lscript/lscript_compile/indra.l @@ -0,0 +1,834 @@ +D [-]?[0-9] +N [0-9] +L [a-zA-Z_] +H [a-fA-F0-9] +E [Ee][+-]?{D}+ +FS (f|F) +%e 8000 +%n 4000 +%p 5000 + +%{ +#include +#include "stdtypes.h" +#include "llmath.h" +#include "lscript_tree.h" +#include "lscript_typecheck.h" +#include "lscript_resource.h" +#include "llfile.h" +#if LL_WINDOWS +#include "ytab.h" +#else +#include "indra.y.h" +#endif +#include "lltimer.h" +#include "indra_constants.h" +#include "llagentconstants.h" +#include "lllslconstants.h" +#include "lluuid.h" +#include "llassetstorage.h" +#include "llpartdata.h" +#include "llvehicleparams.h" +#include "llpermissionsflags.h" +#include "llfollowcamparams.h" +#include "llparcelflags.h" +#include "llregionflags.h" +#include "lscript_http.h" + +void count(); +void comment(); +void parse_string(); + +#define YYLMAX 16384 +#define YY_NEVER_INTERACTIVE 1 /* stops flex from calling isatty() */ + +#if defined(__cplusplus) +extern "C" { int yylex( void ); } +extern "C" { int yyparse( void ); } +extern "C" { int yyerror(const char *fmt, ...); } +#endif + +%} + +%% +"//" { gInternalLine++; gInternalColumn = 0; comment(); } + +"integer" { count(); return(INTEGER); } +"float" { count(); return(FLOAT_TYPE); } +"string" { count(); return(STRING); } +"key" { count(); return(LLKEY); } +"vector" { count(); return(VECTOR); } +"quaternion" { count(); return(QUATERNION); } +"rotation" { count(); return(QUATERNION); } +"list" { count(); return(LIST); } + +"default" { count(); yylval.sval = new char[strlen(yytext) + 1]; strcpy(yylval.sval, yytext); return(STATE_DEFAULT); } +"state" { count(); return(STATE); } +"event" { count(); return(EVENT); } +"jump" { count(); return(JUMP); } +"return" { count(); return(RETURN); } +"if" { count(); return(IF); } +"else" { count(); return(ELSE); } +"for" { count(); return(FOR); } +"do" { count(); return(DO); } +"while" { count(); return(WHILE); } + +"state_entry" { count(); return(STATE_ENTRY); } +"state_exit" { count(); return(STATE_EXIT); } +"touch_start" { count(); return(TOUCH_START); } +"touch" { count(); return(TOUCH); } +"touch_end" { count(); return(TOUCH_END); } +"collision_start" { count(); return(COLLISION_START); } +"collision" { count(); return(COLLISION); } +"collision_end" { count(); return(COLLISION_END); } +"land_collision_start" { count(); return(LAND_COLLISION_START); } +"land_collision" { count(); return(LAND_COLLISION); } +"land_collision_end" { count(); return(LAND_COLLISION_END); } +"timer" { count(); return(TIMER); } +"listen" { count(); return(CHAT); } +"sensor" { count(); return(SENSOR); } +"no_sensor" { count(); return(NO_SENSOR); } +"control" { count(); return(CONTROL); } +"print" { count(); return(PRINT); } +"at_target" { count(); return(AT_TARGET); } +"not_at_target" { count(); return(NOT_AT_TARGET); } +"at_rot_target" { count(); return(AT_ROT_TARGET); } +"not_at_rot_target" { count(); return(NOT_AT_ROT_TARGET); } +"money" { count(); return(MONEY); } +"email" { count(); return(EMAIL); } +"run_time_permissions" { count(); return(RUN_TIME_PERMISSIONS); } +"changed" { count(); return(INVENTORY); } +"attach" { count(); return(ATTACH); } +"dataserver" { count(); return(DATASERVER); } +"moving_start" { count(); return(MOVING_START); } +"moving_end" { count(); return(MOVING_END); } +"link_message" { count(); return(LINK_MESSAGE); } +"on_rez" { count(); return(REZ); } +"object_rez" { count(); return(OBJECT_REZ); } +"remote_data" { count(); return(REMOTE_DATA); } +"http_response" { count(); return(HTTP_RESPONSE); } +"." { count(); return(PERIOD); } + + +0[xX]{H}+ { count(); yylval.ival = strtoul(yytext, NULL, 0); return(INTEGER_CONSTANT); } +{D}+ { count(); yylval.ival = strtoul(yytext, NULL, 10); return(INTEGER_CONSTANT); } +"TRUE" { count(); yylval.ival = 1; return(INTEGER_TRUE); } +"FALSE" { count(); yylval.ival = 0; return(INTEGER_FALSE); } +"STATUS_PHYSICS" { count(); yylval.ival = 0x1; return(INTEGER_CONSTANT); } +"STATUS_ROTATE_X" { count(); yylval.ival = 0x2; return(INTEGER_CONSTANT); } +"STATUS_ROTATE_Y" { count(); yylval.ival = 0x4; return(INTEGER_CONSTANT); } +"STATUS_ROTATE_Z" { count(); yylval.ival = 0x8; return(INTEGER_CONSTANT); } +"STATUS_PHANTOM" { count(); yylval.ival = 0x10; return(INTEGER_CONSTANT); } +"STATUS_SANDBOX" { count(); yylval.ival = 0x20; return(INTEGER_CONSTANT); } +"STATUS_BLOCK_GRAB" { count(); yylval.ival = 0x40; return(INTEGER_CONSTANT); } +"STATUS_DIE_AT_EDGE" { count(); yylval.ival = 0x80; return(INTEGER_CONSTANT); } +"STATUS_RETURN_AT_EDGE" { count(); yylval.ival = 0x100; return(INTEGER_CONSTANT); } +"STATUS_CAST_SHADOWS" { count(); yylval.ival = 0x200; return(INTEGER_CONSTANT); } + +"AGENT_FLYING" { count(); yylval.ival = AGENT_FLYING; return(INTEGER_CONSTANT); } +"AGENT_ATTACHMENTS" { count(); yylval.ival = AGENT_ATTACHMENTS; return(INTEGER_CONSTANT); } +"AGENT_SCRIPTED" { count(); yylval.ival = AGENT_SCRIPTED; return(INTEGER_CONSTANT); } +"AGENT_MOUSELOOK" { count(); yylval.ival = AGENT_MOUSELOOK; return(INTEGER_CONSTANT); } +"AGENT_SITTING" { count(); yylval.ival = AGENT_SITTING; return(INTEGER_CONSTANT); } +"AGENT_ON_OBJECT" { count(); yylval.ival = AGENT_ON_OBJECT; return(INTEGER_CONSTANT); } +"AGENT_AWAY" { count(); yylval.ival = AGENT_AWAY; return(INTEGER_CONSTANT); } +"AGENT_WALKING" { count(); yylval.ival = AGENT_WALKING; return(INTEGER_CONSTANT); } +"AGENT_IN_AIR" { count(); yylval.ival = AGENT_IN_AIR; return(INTEGER_CONSTANT); } +"AGENT_TYPING" { count(); yylval.ival = AGENT_TYPING; return(INTEGER_CONSTANT); } +"AGENT_CROUCHING" { count(); yylval.ival = AGENT_CROUCHING; return(INTEGER_CONSTANT); } +"AGENT_BUSY" { count(); yylval.ival = AGENT_BUSY; return(INTEGER_CONSTANT); } +"AGENT_ALWAYS_RUN" { count(); yylval.ival = AGENT_ALWAYS_RUN; return(INTEGER_CONSTANT); } + +"CAMERA_PITCH" { count(); yylval.ival = FOLLOWCAM_PITCH; return(INTEGER_CONSTANT); } +"CAMERA_FOCUS_OFFSET" { count(); yylval.ival = FOLLOWCAM_FOCUS_OFFSET; return (INTEGER_CONSTANT); } +"CAMERA_POSITION_LAG" { count(); yylval.ival = FOLLOWCAM_POSITION_LAG; return (INTEGER_CONSTANT); } +"CAMERA_FOCUS_LAG" { count(); yylval.ival = FOLLOWCAM_FOCUS_LAG; return (INTEGER_CONSTANT); } +"CAMERA_DISTANCE" { count(); yylval.ival = FOLLOWCAM_DISTANCE; return (INTEGER_CONSTANT); } +"CAMERA_BEHINDNESS_ANGLE" { count(); yylval.ival = FOLLOWCAM_BEHINDNESS_ANGLE; return (INTEGER_CONSTANT); } +"CAMERA_BEHINDNESS_LAG" { count(); yylval.ival = FOLLOWCAM_BEHINDNESS_LAG; return (INTEGER_CONSTANT); } +"CAMERA_POSITION_THRESHOLD" { count(); yylval.ival = FOLLOWCAM_POSITION_THRESHOLD; return (INTEGER_CONSTANT); } +"CAMERA_FOCUS_THRESHOLD" { count(); yylval.ival = FOLLOWCAM_FOCUS_THRESHOLD; return (INTEGER_CONSTANT); } +"CAMERA_ACTIVE" { count(); yylval.ival = FOLLOWCAM_ACTIVE; return (INTEGER_CONSTANT); } +"CAMERA_POSITION" { count(); yylval.ival = FOLLOWCAM_POSITION; return (INTEGER_CONSTANT); } +"CAMERA_FOCUS" { count(); yylval.ival = FOLLOWCAM_FOCUS; return (INTEGER_CONSTANT); } +"CAMERA_POSITION_LOCKED" { count(); yylval.ival = FOLLOWCAM_POSITION_LOCKED; return (INTEGER_CONSTANT); } +"CAMERA_FOCUS_LOCKED" { count(); yylval.ival = FOLLOWCAM_FOCUS_LOCKED; return (INTEGER_CONSTANT); } + +"ANIM_ON" { count(); yylval.ival = 0x1; return(INTEGER_CONSTANT); } +"LOOP" { count(); yylval.ival = 0x2; return(INTEGER_CONSTANT); } +"REVERSE" { count(); yylval.ival = 0x4; return(INTEGER_CONSTANT); } +"PING_PONG" { count(); yylval.ival = 0x8; return(INTEGER_CONSTANT); } +"SMOOTH" { count(); yylval.ival = 0x10; return(INTEGER_CONSTANT); } +"ROTATE" { count(); yylval.ival = 0x20; return(INTEGER_CONSTANT); } +"SCALE" { count(); yylval.ival = 0x40; return(INTEGER_CONSTANT); } + +"ALL_SIDES" { count(); yylval.ival = LSL_ALL_SIDES; return(INTEGER_CONSTANT); } +"LINK_ROOT" { count(); yylval.ival = LSL_LINK_ROOT; return(INTEGER_CONSTANT); } +"LINK_SET" { count(); yylval.ival = LSL_LINK_SET; return(INTEGER_CONSTANT); } +"LINK_ALL_OTHERS" { count(); yylval.ival = LSL_LINK_ALL_OTHERS; return(INTEGER_CONSTANT); } +"LINK_ALL_CHILDREN" { count(); yylval.ival = LSL_LINK_ALL_CHILDREN; return(INTEGER_CONSTANT); } +"LINK_THIS" { count(); yylval.ival = LSL_LINK_THIS; return(INTEGER_CONSTANT); } + +"AGENT" { count(); yylval.ival = 0x1; return(INTEGER_CONSTANT); } +"ACTIVE" { count(); yylval.ival = 0x2; return(INTEGER_CONSTANT); } +"PASSIVE" { count(); yylval.ival = 0x4; return(INTEGER_CONSTANT); } +"SCRIPTED" { count(); yylval.ival = 0x8; return(INTEGER_CONSTANT); } + +"CONTROL_FWD" { count(); yylval.ival = AGENT_CONTROL_AT_POS; return(INTEGER_CONSTANT); } +"CONTROL_BACK" { count(); yylval.ival = AGENT_CONTROL_AT_NEG; return(INTEGER_CONSTANT); } +"CONTROL_LEFT" { count(); yylval.ival = AGENT_CONTROL_LEFT_POS; return(INTEGER_CONSTANT); } +"CONTROL_RIGHT" { count(); yylval.ival = AGENT_CONTROL_LEFT_NEG; return(INTEGER_CONSTANT); } +"CONTROL_ROT_LEFT" { count(); yylval.ival = AGENT_CONTROL_YAW_POS; return(INTEGER_CONSTANT); } +"CONTROL_ROT_RIGHT" { count(); yylval.ival = AGENT_CONTROL_YAW_NEG; return(INTEGER_CONSTANT); } +"CONTROL_UP" { count(); yylval.ival = AGENT_CONTROL_UP_POS; return(INTEGER_CONSTANT); } +"CONTROL_DOWN" { count(); yylval.ival = AGENT_CONTROL_UP_NEG; return(INTEGER_CONSTANT); } +"CONTROL_LBUTTON" { count(); yylval.ival = AGENT_CONTROL_LBUTTON_DOWN; return(INTEGER_CONSTANT); } +"CONTROL_ML_LBUTTON" { count(); yylval.ival = AGENT_CONTROL_ML_LBUTTON_DOWN; return(INTEGER_CONSTANT); } + +"PERMISSION_DEBIT" { count(); yylval.ival = LSCRIPTRunTimePermissionBits[SCRIPT_PERMISSION_DEBIT]; return(INTEGER_CONSTANT); } +"PERMISSION_TAKE_CONTROLS" { count(); yylval.ival = LSCRIPTRunTimePermissionBits[SCRIPT_PERMISSION_TAKE_CONTROLS]; return(INTEGER_CONSTANT); } +"PERMISSION_REMAP_CONTROLS" { count(); yylval.ival = LSCRIPTRunTimePermissionBits[SCRIPT_PERMISSION_REMAP_CONTROLS]; return(INTEGER_CONSTANT); } +"PERMISSION_TRIGGER_ANIMATION" { count(); yylval.ival = LSCRIPTRunTimePermissionBits[SCRIPT_PERMISSION_TRIGGER_ANIMATION]; return(INTEGER_CONSTANT); } +"PERMISSION_ATTACH" { count(); yylval.ival = LSCRIPTRunTimePermissionBits[SCRIPT_PERMISSION_ATTACH]; return(INTEGER_CONSTANT); } +"PERMISSION_RELEASE_OWNERSHIP" { count(); yylval.ival = LSCRIPTRunTimePermissionBits[SCRIPT_PERMISSION_RELEASE_OWNERSHIP]; return(INTEGER_CONSTANT); } +"PERMISSION_CHANGE_LINKS" { count(); yylval.ival = LSCRIPTRunTimePermissionBits[SCRIPT_PERMISSION_CHANGE_LINKS]; return(INTEGER_CONSTANT); } +"PERMISSION_CHANGE_JOINTS" { count(); yylval.ival = LSCRIPTRunTimePermissionBits[SCRIPT_PERMISSION_CHANGE_JOINTS]; return(INTEGER_CONSTANT); } +"PERMISSION_CHANGE_PERMISSIONS" { count(); yylval.ival = LSCRIPTRunTimePermissionBits[SCRIPT_PERMISSION_CHANGE_PERMISSIONS]; return(INTEGER_CONSTANT); } +"PERMISSION_TRACK_CAMERA" { count(); yylval.ival = LSCRIPTRunTimePermissionBits[SCRIPT_PERMISSION_TRACK_CAMERA]; return(INTEGER_CONSTANT); } +"PERMISSION_CONTROL_CAMERA" { count(); yylval.ival = LSCRIPTRunTimePermissionBits[SCRIPT_PERMISSION_CONTROL_CAMERA]; return(INTEGER_CONSTANT); } + +"INVENTORY_TEXTURE" { count(); yylval.ival = LLAssetType::AT_TEXTURE; return(INTEGER_CONSTANT); } +"INVENTORY_SOUND" { count(); yylval.ival = LLAssetType::AT_SOUND; return(INTEGER_CONSTANT); } +"INVENTORY_OBJECT" { count(); yylval.ival = LLAssetType::AT_OBJECT; return(INTEGER_CONSTANT); } +"INVENTORY_SCRIPT" { count(); yylval.ival = LLAssetType::AT_LSL_TEXT; return(INTEGER_CONSTANT); } +"INVENTORY_LANDMARK" { count(); yylval.ival = LLAssetType::AT_LANDMARK; return(INTEGER_CONSTANT); } +"INVENTORY_CLOTHING" { count(); yylval.ival = LLAssetType::AT_CLOTHING; return(INTEGER_CONSTANT); } +"INVENTORY_NOTECARD" { count(); yylval.ival = LLAssetType::AT_NOTECARD; return(INTEGER_CONSTANT); } +"INVENTORY_BODYPART" { count(); yylval.ival = LLAssetType::AT_BODYPART; return(INTEGER_CONSTANT); } +"INVENTORY_ANIMATION" { count(); yylval.ival = LLAssetType::AT_ANIMATION; return(INTEGER_CONSTANT); } +"INVENTORY_GESTURE" { count(); yylval.ival = LLAssetType::AT_GESTURE; return(INTEGER_CONSTANT); } +"INVENTORY_ALL" { count(); yylval.ival = LLAssetType::AT_NONE; return(INTEGER_CONSTANT); } +"INVENTORY_NONE" { count(); yylval.ival = LLAssetType::AT_NONE; return(INTEGER_CONSTANT); } + +"CHANGED_INVENTORY" { count(); yylval.ival = 0x1; return(INTEGER_CONSTANT); } +"CHANGED_COLOR" { count(); yylval.ival = 0x2; return(INTEGER_CONSTANT); } +"CHANGED_SHAPE" { count(); yylval.ival = 0x4; return(INTEGER_CONSTANT); } +"CHANGED_SCALE" { count(); yylval.ival = 0x8; return(INTEGER_CONSTANT); } +"CHANGED_TEXTURE" { count(); yylval.ival = 0x10; return(INTEGER_CONSTANT); } +"CHANGED_LINK" { count(); yylval.ival = 0x20; return(INTEGER_CONSTANT); } +"CHANGED_ALLOWED_DROP" { count(); yylval.ival = 0x40; return(INTEGER_CONSTANT); } +"CHANGED_OWNER" { count(); yylval.ival = 0x80; return(INTEGER_CONSTANT); } +"CHANGED_REGION" { count(); yylval.ival = 0x100; return(INTEGER_CONSTANT); } +"CHANGED_TELEPORT" { count(); yylval.ival = 0x200; return(INTEGER_CONSTANT); } + +"TYPE_INTEGER" { count(); yylval.ival = LST_INTEGER; return(INTEGER_CONSTANT); } +"TYPE_FLOAT" { count(); yylval.ival = LST_FLOATINGPOINT; return(INTEGER_CONSTANT); } +"TYPE_STRING" { count(); yylval.ival = LST_STRING; return(INTEGER_CONSTANT); } +"TYPE_KEY" { count(); yylval.ival = LST_KEY; return(INTEGER_CONSTANT); } +"TYPE_VECTOR" { count(); yylval.ival = LST_VECTOR; return(INTEGER_CONSTANT); } +"TYPE_ROTATION" { count(); yylval.ival = LST_QUATERNION; return(INTEGER_CONSTANT); } +"TYPE_INVALID" { count(); yylval.ival = LST_NULL; return(INTEGER_CONSTANT); } + +"NULL_KEY" { yylval.sval = new char[UUID_STR_LENGTH]; strcpy(yylval.sval, "00000000-0000-0000-0000-000000000000"); return(STRING_CONSTANT); } +"EOF" { yylval.sval = new char[UUID_STR_LENGTH]; strcpy(yylval.sval, "\n\n\n"); return(STRING_CONSTANT); } + +"PI" { count(); yylval.fval = F_PI; return(FP_CONSTANT); } +"TWO_PI" { count(); yylval.fval = F_TWO_PI; return(FP_CONSTANT); } +"PI_BY_TWO" { count(); yylval.fval = F_PI_BY_TWO; return(FP_CONSTANT); } +"DEG_TO_RAD" { count(); yylval.fval = DEG_TO_RAD; return(FP_CONSTANT); } +"RAD_TO_DEG" { count(); yylval.fval = RAD_TO_DEG; return(FP_CONSTANT); } +"SQRT2" { count(); yylval.fval = F_SQRT2; return(FP_CONSTANT); } + +"DEBUG_CHANNEL" { count(); yylval.ival = CHAT_CHANNEL_DEBUG; return(INTEGER_CONSTANT); } +"PUBLIC_CHANNEL" { count(); yylval.ival = 0; return(INTEGER_CONSTANT); } + +"ZERO_VECTOR" { count(); return(ZERO_VECTOR); } +"ZERO_ROTATION" { count(); return(ZERO_ROTATION); } + +"ATTACH_CHEST" { count(); yylval.ival = 1; return(INTEGER_CONSTANT); } +"ATTACH_HEAD" { count(); yylval.ival = 2; return(INTEGER_CONSTANT); } +"ATTACH_LSHOULDER" { count(); yylval.ival = 3; return(INTEGER_CONSTANT); } +"ATTACH_RSHOULDER" { count(); yylval.ival = 4; return(INTEGER_CONSTANT); } +"ATTACH_LHAND" { count(); yylval.ival = 5; return(INTEGER_CONSTANT); } +"ATTACH_RHAND" { count(); yylval.ival = 6; return(INTEGER_CONSTANT); } +"ATTACH_LFOOT" { count(); yylval.ival = 7; return(INTEGER_CONSTANT); } +"ATTACH_RFOOT" { count(); yylval.ival = 8; return(INTEGER_CONSTANT); } +"ATTACH_BACK" { count(); yylval.ival = 9; return(INTEGER_CONSTANT); } +"ATTACH_PELVIS" { count(); yylval.ival = 10; return(INTEGER_CONSTANT); } +"ATTACH_MOUTH" { count(); yylval.ival = 11; return(INTEGER_CONSTANT); } +"ATTACH_CHIN" { count(); yylval.ival = 12; return(INTEGER_CONSTANT); } +"ATTACH_LEAR" { count(); yylval.ival = 13; return(INTEGER_CONSTANT); } +"ATTACH_REAR" { count(); yylval.ival = 14; return(INTEGER_CONSTANT); } +"ATTACH_LEYE" { count(); yylval.ival = 15; return(INTEGER_CONSTANT); } +"ATTACH_REYE" { count(); yylval.ival = 16; return(INTEGER_CONSTANT); } +"ATTACH_NOSE" { count(); yylval.ival = 17; return(INTEGER_CONSTANT); } +"ATTACH_RUARM" { count(); yylval.ival = 18; return(INTEGER_CONSTANT); } +"ATTACH_RLARM" { count(); yylval.ival = 19; return(INTEGER_CONSTANT); } +"ATTACH_LUARM" { count(); yylval.ival = 20; return(INTEGER_CONSTANT); } +"ATTACH_LLARM" { count(); yylval.ival = 21; return(INTEGER_CONSTANT); } +"ATTACH_RHIP" { count(); yylval.ival = 22; return(INTEGER_CONSTANT); } +"ATTACH_RULEG" { count(); yylval.ival = 23; return(INTEGER_CONSTANT); } +"ATTACH_RLLEG" { count(); yylval.ival = 24; return(INTEGER_CONSTANT); } +"ATTACH_LHIP" { count(); yylval.ival = 25; return(INTEGER_CONSTANT); } +"ATTACH_LULEG" { count(); yylval.ival = 26; return(INTEGER_CONSTANT); } +"ATTACH_LLLEG" { count(); yylval.ival = 27; return(INTEGER_CONSTANT); } +"ATTACH_BELLY" { count(); yylval.ival = 28; return(INTEGER_CONSTANT); } +"ATTACH_RPEC" { count(); yylval.ival = 29; return(INTEGER_CONSTANT); } +"ATTACH_LPEC" { count(); yylval.ival = 30; return(INTEGER_CONSTANT); } +"ATTACH_HUD_CENTER_2" { count(); yylval.ival = 31; return(INTEGER_CONSTANT); } +"ATTACH_HUD_TOP_RIGHT" { count(); yylval.ival = 32; return(INTEGER_CONSTANT); } +"ATTACH_HUD_TOP_CENTER" { count(); yylval.ival = 33; return(INTEGER_CONSTANT); } +"ATTACH_HUD_TOP_LEFT" { count(); yylval.ival = 34; return(INTEGER_CONSTANT); } +"ATTACH_HUD_CENTER_1" { count(); yylval.ival = 35; return(INTEGER_CONSTANT); } +"ATTACH_HUD_BOTTOM_LEFT" { count(); yylval.ival = 36; return(INTEGER_CONSTANT); } +"ATTACH_HUD_BOTTOM" { count(); yylval.ival = 37; return(INTEGER_CONSTANT); } +"ATTACH_HUD_BOTTOM_RIGHT" { count(); yylval.ival = 38; return(INTEGER_CONSTANT); } + +"LAND_LEVEL" { count(); yylval.ival = E_LANDBRUSH_LEVEL; return(INTEGER_CONSTANT); } +"LAND_RAISE" { count(); yylval.ival = E_LANDBRUSH_RAISE; return(INTEGER_CONSTANT); } +"LAND_LOWER" { count(); yylval.ival = E_LANDBRUSH_LOWER; return(INTEGER_CONSTANT); } +"LAND_SMOOTH" { count(); yylval.ival = E_LANDBRUSH_SMOOTH; return(INTEGER_CONSTANT); } +"LAND_NOISE" { count(); yylval.ival = E_LANDBRUSH_NOISE; return(INTEGER_CONSTANT); } +"LAND_REVERT" { count(); yylval.ival = E_LANDBRUSH_REVERT; return(INTEGER_CONSTANT); } + +"LAND_SMALL_BRUSH" { count(); yylval.ival = 1; return(INTEGER_CONSTANT); } +"LAND_MEDIUM_BRUSH" { count(); yylval.ival = 2; return(INTEGER_CONSTANT); } +"LAND_LARGE_BRUSH" { count(); yylval.ival = 3; return(INTEGER_CONSTANT); } + +"DATA_ONLINE" { count(); yylval.ival = 1; return(INTEGER_CONSTANT); } +"DATA_NAME" { count(); yylval.ival = 2; return(INTEGER_CONSTANT); } +"DATA_BORN" { count(); yylval.ival = 3; return(INTEGER_CONSTANT); } +"DATA_RATING" { count(); yylval.ival = 4; return(INTEGER_CONSTANT); } +"DATA_SIM_POS" { count(); yylval.ival = 5; return(INTEGER_CONSTANT); } +"DATA_SIM_STATUS" { count(); yylval.ival = 6; return(INTEGER_CONSTANT); } +"DATA_SIM_RATING" { count(); yylval.ival = 7; return(INTEGER_CONSTANT); } +"DATA_PAYINFO" { count(); yylval.ival = 8; return(INTEGER_CONSTANT); } + +"PAYMENT_INFO_ON_FILE" { count(); yylval.ival = 1; return(INTEGER_CONSTANT); } +"PAYMENT_INFO_USED" { count(); yylval.ival = 2; return(INTEGER_CONSTANT); } + +"REMOTE_DATA_CHANNEL" { count(); yylval.ival = LSL_REMOTE_DATA_CHANNEL; return(INTEGER_CONSTANT); } +"REMOTE_DATA_REQUEST" { count(); yylval.ival = LSL_REMOTE_DATA_REQUEST; return(INTEGER_CONSTANT); } +"REMOTE_DATA_REPLY" { count(); yylval.ival = LSL_REMOTE_DATA_REPLY; return(INTEGER_CONSTANT); } + + +"PSYS_PART_FLAGS" { count(); yylval.ival = LLPS_PART_FLAGS; return(INTEGER_CONSTANT); } +"PSYS_PART_START_COLOR" { count(); yylval.ival = LLPS_PART_START_COLOR; return (INTEGER_CONSTANT); } +"PSYS_PART_START_ALPHA" { count(); yylval.ival = LLPS_PART_START_ALPHA; return (INTEGER_CONSTANT); } +"PSYS_PART_START_SCALE" { count(); yylval.ival = LLPS_PART_START_SCALE; return (INTEGER_CONSTANT); } +"PSYS_PART_END_COLOR" { count(); yylval.ival = LLPS_PART_END_COLOR; return (INTEGER_CONSTANT); } +"PSYS_PART_END_ALPHA" { count(); yylval.ival = LLPS_PART_END_ALPHA; return (INTEGER_CONSTANT); } +"PSYS_PART_END_SCALE" { count(); yylval.ival = LLPS_PART_END_SCALE; return (INTEGER_CONSTANT); } +"PSYS_PART_MAX_AGE" { count(); yylval.ival = LLPS_PART_MAX_AGE; return (INTEGER_CONSTANT); } + + +"PSYS_PART_WIND_MASK" { count(); yylval.ival = LLPartData::LL_PART_WIND_MASK; return(INTEGER_CONSTANT); } +"PSYS_PART_INTERP_COLOR_MASK" { count(); yylval.ival = LLPartData::LL_PART_INTERP_COLOR_MASK; return(INTEGER_CONSTANT); } +"PSYS_PART_INTERP_SCALE_MASK" { count(); yylval.ival = LLPartData::LL_PART_INTERP_SCALE_MASK; return(INTEGER_CONSTANT); } +"PSYS_PART_BOUNCE_MASK" { count(); yylval.ival = LLPartData::LL_PART_BOUNCE_MASK; return(INTEGER_CONSTANT); } +"PSYS_PART_FOLLOW_SRC_MASK" { count(); yylval.ival = LLPartData::LL_PART_FOLLOW_SRC_MASK; return(INTEGER_CONSTANT); } +"PSYS_PART_FOLLOW_VELOCITY_MASK" { count(); yylval.ival = LLPartData::LL_PART_FOLLOW_VELOCITY_MASK; return(INTEGER_CONSTANT); } +"PSYS_PART_TARGET_POS_MASK" { count(); yylval.ival = LLPartData::LL_PART_TARGET_POS_MASK; return(INTEGER_CONSTANT); } +"PSYS_PART_EMISSIVE_MASK" { count(); yylval.ival = LLPartData::LL_PART_EMISSIVE_MASK; return(INTEGER_CONSTANT); } +"PSYS_PART_TARGET_LINEAR_MASK" { count(); yylval.ival = LLPartData::LL_PART_TARGET_LINEAR_MASK; return(INTEGER_CONSTANT); } + + +"PSYS_SRC_MAX_AGE" { count(); yylval.ival = LLPS_SRC_MAX_AGE; return(INTEGER_CONSTANT); } +"PSYS_SRC_PATTERN" { count(); yylval.ival = LLPS_SRC_PATTERN; return(INTEGER_CONSTANT); } +"PSYS_SRC_INNERANGLE" { count(); yylval.ival = LLPS_SRC_INNERANGLE; return(INTEGER_CONSTANT); } +"PSYS_SRC_OUTERANGLE" { count(); yylval.ival = LLPS_SRC_OUTERANGLE; return(INTEGER_CONSTANT); } +"PSYS_SRC_ANGLE_BEGIN" { count(); yylval.ival = LLPS_SRC_ANGLE_BEGIN; return(INTEGER_CONSTANT); } +"PSYS_SRC_ANGLE_END" { count(); yylval.ival = LLPS_SRC_ANGLE_END; return(INTEGER_CONSTANT); } +"PSYS_SRC_BURST_RATE" { count(); yylval.ival = LLPS_SRC_BURST_RATE; return(INTEGER_CONSTANT); } +"PSYS_SRC_BURST_PART_COUNT" { count(); yylval.ival = LLPS_SRC_BURST_PART_COUNT; return(INTEGER_CONSTANT); } +"PSYS_SRC_BURST_RADIUS" { count(); yylval.ival = LLPS_SRC_BURST_RADIUS; return(INTEGER_CONSTANT); } +"PSYS_SRC_BURST_SPEED_MIN" { count(); yylval.ival = LLPS_SRC_BURST_SPEED_MIN; return(INTEGER_CONSTANT); } +"PSYS_SRC_BURST_SPEED_MAX" { count(); yylval.ival = LLPS_SRC_BURST_SPEED_MAX; return(INTEGER_CONSTANT); } +"PSYS_SRC_ACCEL" { count(); yylval.ival = LLPS_SRC_ACCEL; return(INTEGER_CONSTANT); } +"PSYS_SRC_TEXTURE" { count(); yylval.ival = LLPS_SRC_TEXTURE; return(INTEGER_CONSTANT); } +"PSYS_SRC_TARGET_KEY" { count(); yylval.ival = LLPS_SRC_TARGET_UUID; return(INTEGER_CONSTANT); } +"PSYS_SRC_OMEGA" { count(); yylval.ival = LLPS_SRC_OMEGA; return(INTEGER_CONSTANT); } + +"PSYS_SRC_OBJ_REL_MASK" { count(); yylval.ival = LLPartSysData::LL_PART_SRC_OBJ_REL_MASK; return(INTEGER_CONSTANT); } + +"PSYS_SRC_PATTERN_DROP" { count(); yylval.ival = LLPartSysData::LL_PART_SRC_PATTERN_DROP; return(INTEGER_CONSTANT); } +"PSYS_SRC_PATTERN_EXPLODE" { count(); yylval.ival = LLPartSysData::LL_PART_SRC_PATTERN_EXPLODE; return(INTEGER_CONSTANT); } +"PSYS_SRC_PATTERN_ANGLE" { count(); yylval.ival = LLPartSysData::LL_PART_SRC_PATTERN_ANGLE; return(INTEGER_CONSTANT); } +"PSYS_SRC_PATTERN_ANGLE_CONE" { count(); yylval.ival = LLPartSysData::LL_PART_SRC_PATTERN_ANGLE_CONE; return(INTEGER_CONSTANT); } +"PSYS_SRC_PATTERN_ANGLE_CONE_EMPTY" { count(); yylval.ival = LLPartSysData::LL_PART_SRC_PATTERN_ANGLE_CONE_EMPTY; return(INTEGER_CONSTANT); } + + +"VEHICLE_TYPE_NONE" { count(); yylval.ival = VEHICLE_TYPE_NONE; return(INTEGER_CONSTANT); } +"VEHICLE_TYPE_SLED" { count(); yylval.ival = VEHICLE_TYPE_SLED; return(INTEGER_CONSTANT); } +"VEHICLE_TYPE_CAR" { count(); yylval.ival = VEHICLE_TYPE_CAR; return(INTEGER_CONSTANT); } +"VEHICLE_TYPE_BOAT" { count(); yylval.ival = VEHICLE_TYPE_BOAT; return(INTEGER_CONSTANT); } +"VEHICLE_TYPE_AIRPLANE" { count(); yylval.ival = VEHICLE_TYPE_AIRPLANE; return(INTEGER_CONSTANT); } +"VEHICLE_TYPE_BALLOON" { count(); yylval.ival = VEHICLE_TYPE_BALLOON; return(INTEGER_CONSTANT); } + +"VEHICLE_REFERENCE_FRAME" { count(); yylval.ival = VEHICLE_REFERENCE_FRAME; return(INTEGER_CONSTANT); } +"VEHICLE_LINEAR_FRICTION_TIMESCALE" { count(); yylval.ival = VEHICLE_LINEAR_FRICTION_TIMESCALE; return(INTEGER_CONSTANT); } +"VEHICLE_ANGULAR_FRICTION_TIMESCALE" { count(); yylval.ival = VEHICLE_ANGULAR_FRICTION_TIMESCALE; return(INTEGER_CONSTANT); } +"VEHICLE_LINEAR_MOTOR_DIRECTION" { count(); yylval.ival = VEHICLE_LINEAR_MOTOR_DIRECTION; return(INTEGER_CONSTANT); } +"VEHICLE_ANGULAR_MOTOR_DIRECTION" { count(); yylval.ival = VEHICLE_ANGULAR_MOTOR_DIRECTION; return(INTEGER_CONSTANT); } +"VEHICLE_LINEAR_MOTOR_OFFSET" { count(); yylval.ival = VEHICLE_LINEAR_MOTOR_OFFSET; return(INTEGER_CONSTANT); } + + + +"VEHICLE_HOVER_HEIGHT" { count(); yylval.ival = VEHICLE_HOVER_HEIGHT; return(INTEGER_CONSTANT); } +"VEHICLE_HOVER_EFFICIENCY" { count(); yylval.ival = VEHICLE_HOVER_EFFICIENCY; return(INTEGER_CONSTANT); } +"VEHICLE_HOVER_TIMESCALE" { count(); yylval.ival = VEHICLE_HOVER_TIMESCALE; return(INTEGER_CONSTANT); } +"VEHICLE_BUOYANCY" { count(); yylval.ival = VEHICLE_BUOYANCY; return(INTEGER_CONSTANT); } + +"VEHICLE_LINEAR_DEFLECTION_EFFICIENCY" { count(); yylval.ival = VEHICLE_LINEAR_DEFLECTION_EFFICIENCY; return(INTEGER_CONSTANT); } +"VEHICLE_LINEAR_DEFLECTION_TIMESCALE" { count(); yylval.ival = VEHICLE_LINEAR_DEFLECTION_TIMESCALE; return(INTEGER_CONSTANT); } +"VEHICLE_LINEAR_MOTOR_TIMESCALE" { count(); yylval.ival = VEHICLE_LINEAR_MOTOR_TIMESCALE; return(INTEGER_CONSTANT); } +"VEHICLE_LINEAR_MOTOR_DECAY_TIMESCALE" { count(); yylval.ival = VEHICLE_LINEAR_MOTOR_DECAY_TIMESCALE; return(INTEGER_CONSTANT); } + +"VEHICLE_ANGULAR_DEFLECTION_EFFICIENCY" { count(); yylval.ival = VEHICLE_ANGULAR_DEFLECTION_EFFICIENCY; return(INTEGER_CONSTANT); } +"VEHICLE_ANGULAR_DEFLECTION_TIMESCALE" { count(); yylval.ival = VEHICLE_ANGULAR_DEFLECTION_TIMESCALE; return(INTEGER_CONSTANT); } +"VEHICLE_ANGULAR_MOTOR_TIMESCALE" { count(); yylval.ival = VEHICLE_ANGULAR_MOTOR_TIMESCALE; return(INTEGER_CONSTANT); } +"VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE" { count(); yylval.ival = VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE; return(INTEGER_CONSTANT); } + +"VEHICLE_VERTICAL_ATTRACTION_EFFICIENCY" { count(); yylval.ival = VEHICLE_VERTICAL_ATTRACTION_EFFICIENCY; return(INTEGER_CONSTANT); } +"VEHICLE_VERTICAL_ATTRACTION_TIMESCALE" { count(); yylval.ival = VEHICLE_VERTICAL_ATTRACTION_TIMESCALE; return(INTEGER_CONSTANT); } + +"VEHICLE_BANKING_EFFICIENCY" { count(); yylval.ival = VEHICLE_BANKING_EFFICIENCY; return(INTEGER_CONSTANT); } +"VEHICLE_BANKING_MIX" { count(); yylval.ival = VEHICLE_BANKING_MIX; return(INTEGER_CONSTANT); } +"VEHICLE_BANKING_TIMESCALE" { count(); yylval.ival = VEHICLE_BANKING_TIMESCALE; return(INTEGER_CONSTANT); } + +"VEHICLE_FLAG_NO_FLY_UP" { count(); yylval.ival = VEHICLE_FLAG_NO_DEFLECTION_UP; return(INTEGER_CONSTANT); } +"VEHICLE_FLAG_NO_DEFLECTION_UP" { count(); yylval.ival = VEHICLE_FLAG_NO_DEFLECTION_UP; return(INTEGER_CONSTANT); } +"VEHICLE_FLAG_LIMIT_ROLL_ONLY" { count(); yylval.ival = VEHICLE_FLAG_LIMIT_ROLL_ONLY; return(INTEGER_CONSTANT); } +"VEHICLE_FLAG_HOVER_WATER_ONLY" { count(); yylval.ival = VEHICLE_FLAG_HOVER_WATER_ONLY; return(INTEGER_CONSTANT); } +"VEHICLE_FLAG_HOVER_TERRAIN_ONLY" { count(); yylval.ival = VEHICLE_FLAG_HOVER_TERRAIN_ONLY; return(INTEGER_CONSTANT); } +"VEHICLE_FLAG_HOVER_GLOBAL_HEIGHT" { count(); yylval.ival = VEHICLE_FLAG_HOVER_GLOBAL_HEIGHT; return(INTEGER_CONSTANT); } +"VEHICLE_FLAG_HOVER_UP_ONLY" { count(); yylval.ival = VEHICLE_FLAG_HOVER_UP_ONLY; return(INTEGER_CONSTANT); } +"VEHICLE_FLAG_LIMIT_MOTOR_UP" { count(); yylval.ival = VEHICLE_FLAG_LIMIT_MOTOR_UP; return(INTEGER_CONSTANT); } +"VEHICLE_FLAG_MOUSELOOK_STEER" { count(); yylval.ival = VEHICLE_FLAG_MOUSELOOK_STEER; return(INTEGER_CONSTANT); } +"VEHICLE_FLAG_MOUSELOOK_BANK" { count(); yylval.ival = VEHICLE_FLAG_MOUSELOOK_BANK; return(INTEGER_CONSTANT); } +"VEHICLE_FLAG_CAMERA_DECOUPLED" { count(); yylval.ival = VEHICLE_FLAG_CAMERA_DECOUPLED; return(INTEGER_CONSTANT); } + + + +"PRIM_TYPE" { count(); yylval.ival = LSL_PRIM_TYPE; return(INTEGER_CONSTANT); } +"PRIM_MATERIAL" { count(); yylval.ival = LSL_PRIM_MATERIAL; return(INTEGER_CONSTANT); } +"PRIM_PHYSICS" { count(); yylval.ival = LSL_PRIM_PHYSICS; return(INTEGER_CONSTANT); } +"PRIM_FLEXIBLE" { count(); yylval.ival = LSL_PRIM_FLEXIBLE; return(INTEGER_CONSTANT); } +"PRIM_POINT_LIGHT" { count(); yylval.ival = LSL_PRIM_POINT_LIGHT; return(INTEGER_CONSTANT); } +"PRIM_TEMP_ON_REZ" { count(); yylval.ival = LSL_PRIM_TEMP_ON_REZ; return(INTEGER_CONSTANT); } +"PRIM_PHANTOM" { count(); yylval.ival = LSL_PRIM_PHANTOM; return(INTEGER_CONSTANT); } +"PRIM_CAST_SHADOWS" { count(); yylval.ival = LSL_PRIM_CAST_SHADOWS; return(INTEGER_CONSTANT); } +"PRIM_POSITION" { count(); yylval.ival = LSL_PRIM_POSITION; return(INTEGER_CONSTANT); } +"PRIM_SIZE" { count(); yylval.ival = LSL_PRIM_SIZE; return(INTEGER_CONSTANT); } +"PRIM_ROTATION" { count(); yylval.ival = LSL_PRIM_ROTATION; return(INTEGER_CONSTANT); } +"PRIM_TEXTURE" { count(); yylval.ival = LSL_PRIM_TEXTURE; return(INTEGER_CONSTANT); } +"PRIM_COLOR" { count(); yylval.ival = LSL_PRIM_COLOR; return(INTEGER_CONSTANT); } +"PRIM_BUMP_SHINY" { count(); yylval.ival = LSL_PRIM_BUMP_SHINY; return(INTEGER_CONSTANT); } +"PRIM_FULLBRIGHT" { count(); yylval.ival = LSL_PRIM_FULLBRIGHT; return(INTEGER_CONSTANT); } +"PRIM_TEXGEN" { count(); yylval.ival = LSL_PRIM_TEXGEN; return(INTEGER_CONSTANT); } + +"PRIM_TYPE_BOX" { count(); yylval.ival = LSL_PRIM_TYPE_BOX; return(INTEGER_CONSTANT); } +"PRIM_TYPE_CYLINDER" { count(); yylval.ival = LSL_PRIM_TYPE_CYLINDER; return(INTEGER_CONSTANT); } +"PRIM_TYPE_PRISM" { count(); yylval.ival = LSL_PRIM_TYPE_PRISM; return(INTEGER_CONSTANT); } +"PRIM_TYPE_SPHERE" { count(); yylval.ival = LSL_PRIM_TYPE_SPHERE; return(INTEGER_CONSTANT); } +"PRIM_TYPE_TORUS" { count(); yylval.ival = LSL_PRIM_TYPE_TORUS; return(INTEGER_CONSTANT); } +"PRIM_TYPE_TUBE" { count(); yylval.ival = LSL_PRIM_TYPE_TUBE; return(INTEGER_CONSTANT); } +"PRIM_TYPE_RING" { count(); yylval.ival = LSL_PRIM_TYPE_RING; return(INTEGER_CONSTANT); } + +"PRIM_HOLE_DEFAULT" { count(); yylval.ival = LSL_PRIM_HOLE_DEFAULT; return(INTEGER_CONSTANT); } +"PRIM_HOLE_CIRCLE" { count(); yylval.ival = LSL_PRIM_HOLE_CIRCLE; return(INTEGER_CONSTANT); } +"PRIM_HOLE_SQUARE" { count(); yylval.ival = LSL_PRIM_HOLE_SQUARE; return(INTEGER_CONSTANT); } +"PRIM_HOLE_TRIANGLE" { count(); yylval.ival = LSL_PRIM_HOLE_TRIANGLE; return(INTEGER_CONSTANT); } + +"PRIM_MATERIAL_STONE" { count(); yylval.ival = LSL_PRIM_MATERIAL_STONE; return(INTEGER_CONSTANT); } +"PRIM_MATERIAL_METAL" { count(); yylval.ival = LSL_PRIM_MATERIAL_METAL; return(INTEGER_CONSTANT); } +"PRIM_MATERIAL_GLASS" { count(); yylval.ival = LSL_PRIM_MATERIAL_GLASS; return(INTEGER_CONSTANT); } +"PRIM_MATERIAL_WOOD" { count(); yylval.ival = LSL_PRIM_MATERIAL_WOOD; return(INTEGER_CONSTANT); } +"PRIM_MATERIAL_FLESH" { count(); yylval.ival = LSL_PRIM_MATERIAL_FLESH; return(INTEGER_CONSTANT); } +"PRIM_MATERIAL_PLASTIC" { count(); yylval.ival = LSL_PRIM_MATERIAL_PLASTIC; return(INTEGER_CONSTANT); } +"PRIM_MATERIAL_RUBBER" { count(); yylval.ival = LSL_PRIM_MATERIAL_RUBBER; return(INTEGER_CONSTANT); } +"PRIM_MATERIAL_LIGHT" { count(); yylval.ival = LSL_PRIM_MATERIAL_LIGHT; return(INTEGER_CONSTANT); } + +"PRIM_SHINY_NONE" { count(); yylval.ival = LSL_PRIM_SHINY_NONE; return(INTEGER_CONSTANT); } +"PRIM_SHINY_LOW" { count(); yylval.ival = LSL_PRIM_SHINY_LOW; return(INTEGER_CONSTANT); } +"PRIM_SHINY_MEDIUM" { count(); yylval.ival = LSL_PRIM_SHINY_MEDIUM; return(INTEGER_CONSTANT); } +"PRIM_SHINY_HIGH" { count(); yylval.ival = LSL_PRIM_SHINY_HIGH; return(INTEGER_CONSTANT); } + +"PRIM_BUMP_NONE" { count(); yylval.ival = LSL_PRIM_BUMP_NONE; return(INTEGER_CONSTANT); } +"PRIM_BUMP_BRIGHT" { count(); yylval.ival = LSL_PRIM_BUMP_BRIGHT; return(INTEGER_CONSTANT); } +"PRIM_BUMP_DARK" { count(); yylval.ival = LSL_PRIM_BUMP_DARK; return(INTEGER_CONSTANT); } +"PRIM_BUMP_WOOD" { count(); yylval.ival = LSL_PRIM_BUMP_WOOD; return(INTEGER_CONSTANT); } +"PRIM_BUMP_BARK" { count(); yylval.ival = LSL_PRIM_BUMP_BARK; return(INTEGER_CONSTANT); } +"PRIM_BUMP_BRICKS" { count(); yylval.ival = LSL_PRIM_BUMP_BRICKS; return(INTEGER_CONSTANT); } +"PRIM_BUMP_CHECKER" { count(); yylval.ival = LSL_PRIM_BUMP_CHECKER; return(INTEGER_CONSTANT); } +"PRIM_BUMP_CONCRETE" { count(); yylval.ival = LSL_PRIM_BUMP_CONCRETE; return(INTEGER_CONSTANT); } +"PRIM_BUMP_TILE" { count(); yylval.ival = LSL_PRIM_BUMP_TILE; return(INTEGER_CONSTANT); } +"PRIM_BUMP_STONE" { count(); yylval.ival = LSL_PRIM_BUMP_STONE; return(INTEGER_CONSTANT); } +"PRIM_BUMP_DISKS" { count(); yylval.ival = LSL_PRIM_BUMP_DISKS; return(INTEGER_CONSTANT); } +"PRIM_BUMP_GRAVEL" { count(); yylval.ival = LSL_PRIM_BUMP_GRAVEL; return(INTEGER_CONSTANT); } +"PRIM_BUMP_BLOBS" { count(); yylval.ival = LSL_PRIM_BUMP_BLOBS; return(INTEGER_CONSTANT); } +"PRIM_BUMP_SIDING" { count(); yylval.ival = LSL_PRIM_BUMP_SIDING; return(INTEGER_CONSTANT); } +"PRIM_BUMP_LARGETILE" { count(); yylval.ival = LSL_PRIM_BUMP_LARGETILE; return(INTEGER_CONSTANT); } +"PRIM_BUMP_STUCCO" { count(); yylval.ival = LSL_PRIM_BUMP_STUCCO; return(INTEGER_CONSTANT); } +"PRIM_BUMP_SUCTION" { count(); yylval.ival = LSL_PRIM_BUMP_SUCTION; return(INTEGER_CONSTANT); } +"PRIM_BUMP_WEAVE" { count(); yylval.ival = LSL_PRIM_BUMP_WEAVE; return(INTEGER_CONSTANT); } + +"PRIM_TEXGEN_DEFAULT" { count(); yylval.ival = LSL_PRIM_TEXGEN_DEFAULT; return(INTEGER_CONSTANT); } +"PRIM_TEXGEN_PLANAR" { count(); yylval.ival = LSL_PRIM_TEXGEN_PLANAR; return(INTEGER_CONSTANT); } + +"MASK_BASE" { count(); yylval.ival = 0; return(INTEGER_CONSTANT); } +"MASK_OWNER" { count(); yylval.ival = 1; return(INTEGER_CONSTANT); } +"MASK_GROUP" { count(); yylval.ival = 2; return(INTEGER_CONSTANT); } +"MASK_EVERYONE" { count(); yylval.ival = 3; return(INTEGER_CONSTANT); } +"MASK_NEXT" { count(); yylval.ival = 4; return(INTEGER_CONSTANT); } + +"PERM_TRANSFER" { count(); yylval.ival = PERM_TRANSFER; return(INTEGER_CONSTANT); } +"PERM_MODIFY" { count(); yylval.ival = PERM_MODIFY; return(INTEGER_CONSTANT); } +"PERM_COPY" { count(); yylval.ival = PERM_COPY; return(INTEGER_CONSTANT); } +"PERM_MOVE" { count(); yylval.ival = PERM_MOVE; return(INTEGER_CONSTANT); } +"PERM_ALL" { count(); yylval.ival = PERM_ALL; return(INTEGER_CONSTANT); } + +"PARCEL_MEDIA_COMMAND_STOP" { count(); yylval.ival = PARCEL_MEDIA_COMMAND_STOP; return(INTEGER_CONSTANT); } +"PARCEL_MEDIA_COMMAND_PAUSE" { count(); yylval.ival = PARCEL_MEDIA_COMMAND_PAUSE; return(INTEGER_CONSTANT); } +"PARCEL_MEDIA_COMMAND_PLAY" { count(); yylval.ival = PARCEL_MEDIA_COMMAND_PLAY; return(INTEGER_CONSTANT); } +"PARCEL_MEDIA_COMMAND_LOOP" { count(); yylval.ival = PARCEL_MEDIA_COMMAND_LOOP; return(INTEGER_CONSTANT); } +"PARCEL_MEDIA_COMMAND_TEXTURE" { count(); yylval.ival = PARCEL_MEDIA_COMMAND_TEXTURE; return(INTEGER_CONSTANT); } +"PARCEL_MEDIA_COMMAND_URL" { count(); yylval.ival = PARCEL_MEDIA_COMMAND_URL; return(INTEGER_CONSTANT); } +"PARCEL_MEDIA_COMMAND_TIME" { count(); yylval.ival = PARCEL_MEDIA_COMMAND_TIME; return(INTEGER_CONSTANT); } +"PARCEL_MEDIA_COMMAND_AGENT" { count(); yylval.ival = PARCEL_MEDIA_COMMAND_AGENT; return(INTEGER_CONSTANT); } +"PARCEL_MEDIA_COMMAND_UNLOAD" { count(); yylval.ival = PARCEL_MEDIA_COMMAND_UNLOAD; return(INTEGER_CONSTANT); } +"PARCEL_MEDIA_COMMAND_AUTO_ALIGN" { count(); yylval.ival = PARCEL_MEDIA_COMMAND_AUTO_ALIGN; return(INTEGER_CONSTANT); } + +"LIST_STAT_MAX" { count(); yylval.ival = LIST_STAT_MAX; return(INTEGER_CONSTANT); } +"LIST_STAT_MIN" { count(); yylval.ival = LIST_STAT_MIN; return(INTEGER_CONSTANT); } +"LIST_STAT_MEAN" { count(); yylval.ival = LIST_STAT_MEAN; return(INTEGER_CONSTANT); } +"LIST_STAT_MEDIAN" { count(); yylval.ival = LIST_STAT_MEDIAN; return(INTEGER_CONSTANT); } +"LIST_STAT_STD_DEV" { count(); yylval.ival = LIST_STAT_STD_DEV; return(INTEGER_CONSTANT); } +"LIST_STAT_SUM" { count(); yylval.ival = LIST_STAT_SUM; return(INTEGER_CONSTANT); } +"LIST_STAT_SUM_SQUARES" { count(); yylval.ival = LIST_STAT_SUM_SQUARES; return(INTEGER_CONSTANT); } +"LIST_STAT_NUM_COUNT" { count(); yylval.ival = LIST_STAT_NUM_COUNT; return(INTEGER_CONSTANT); } +"LIST_STAT_GEOMETRIC_MEAN" { count(); yylval.ival = LIST_STAT_GEO_MEAN; return(INTEGER_CONSTANT); } +"LIST_STAT_RANGE" { count(); yylval.ival = LIST_STAT_RANGE; return(INTEGER_CONSTANT); } + +"PAY_HIDE" { count(); yylval.ival = PAY_PRICE_HIDE; return(INTEGER_CONSTANT); } +"PAY_DEFAULT" { count(); yylval.ival = PAY_PRICE_DEFAULT; return(INTEGER_CONSTANT); } + +"PARCEL_FLAG_ALLOW_FLY" { count(); yylval.ival = PF_ALLOW_FLY; return(INTEGER_CONSTANT); } +"PARCEL_FLAG_ALLOW_GROUP_SCRIPTS" { count(); yylval.ival = PF_ALLOW_GROUP_SCRIPTS; return(INTEGER_CONSTANT); } +"PARCEL_FLAG_ALLOW_SCRIPTS" { count(); yylval.ival = PF_ALLOW_OTHER_SCRIPTS; return(INTEGER_CONSTANT); } +"PARCEL_FLAG_ALLOW_LANDMARK" { count(); yylval.ival = PF_ALLOW_LANDMARK; return(INTEGER_CONSTANT); } +"PARCEL_FLAG_ALLOW_TERRAFORM" { count(); yylval.ival = PF_ALLOW_TERRAFORM; return(INTEGER_CONSTANT); } +"PARCEL_FLAG_ALLOW_DAMAGE" { count(); yylval.ival = PF_ALLOW_DAMAGE; return(INTEGER_CONSTANT); } +"PARCEL_FLAG_ALLOW_CREATE_OBJECTS" { count(); yylval.ival = PF_CREATE_OBJECTS; return(INTEGER_CONSTANT); } +"PARCEL_FLAG_ALLOW_CREATE_GROUP_OBJECTS" { count(); yylval.ival = PF_CREATE_GROUP_OBJECTS; return(INTEGER_CONSTANT); } +"PARCEL_FLAG_USE_ACCESS_GROUP" { count(); yylval.ival = PF_USE_ACCESS_GROUP; return(INTEGER_CONSTANT); } +"PARCEL_FLAG_USE_ACCESS_LIST" { count(); yylval.ival = PF_USE_ACCESS_LIST; return(INTEGER_CONSTANT); } +"PARCEL_FLAG_USE_BAN_LIST" { count(); yylval.ival = PF_USE_BAN_LIST; return(INTEGER_CONSTANT); } +"PARCEL_FLAG_USE_LAND_PASS_LIST" { count(); yylval.ival = PF_USE_PASS_LIST; return(INTEGER_CONSTANT); } +"PARCEL_FLAG_LOCAL_SOUND_ONLY" { count(); yylval.ival = PF_SOUND_LOCAL; return(INTEGER_CONSTANT); } +"PARCEL_FLAG_RESTRICT_PUSHOBJECT" { count(); yylval.ival = PF_RESTRICT_PUSHOBJECT; return(INTEGER_CONSTANT); } +"PARCEL_FLAG_ALLOW_GROUP_OBJECT_ENTRY" { count(); yylval.ival = PF_ALLOW_GROUP_OBJECT_ENTRY; return(INTEGER_CONSTANT); } +"PARCEL_FLAG_ALLOW_ALL_OBJECT_ENTRY" { count(); yylval.ival = PF_ALLOW_ALL_OBJECT_ENTRY; return(INTEGER_CONSTANT); } + +"REGION_FLAG_ALLOW_DAMAGE" { count(); yylval.ival = REGION_FLAGS_ALLOW_DAMAGE; return(INTEGER_CONSTANT); } +"REGION_FLAG_FIXED_SUN" { count(); yylval.ival = REGION_FLAGS_SUN_FIXED; return(INTEGER_CONSTANT); } +"REGION_FLAG_BLOCK_TERRAFORM" { count(); yylval.ival = REGION_FLAGS_BLOCK_TERRAFORM; return(INTEGER_CONSTANT); } +"REGION_FLAG_SANDBOX" { count(); yylval.ival = REGION_FLAGS_SANDBOX; return(INTEGER_CONSTANT); } +"REGION_FLAG_DISABLE_COLLISIONS" { count(); yylval.ival = REGION_FLAGS_SKIP_COLLISIONS; return(INTEGER_CONSTANT); } +"REGION_FLAG_DISABLE_PHYSICS" { count(); yylval.ival = REGION_FLAGS_SKIP_PHYSICS; return(INTEGER_CONSTANT); } +"REGION_FLAG_BLOCK_FLY" { count(); yylval.ival = REGION_FLAGS_BLOCK_FLY; return(INTEGER_CONSTANT); } +"REGION_FLAG_ALLOW_DIRECT_TELEPORT" { count(); yylval.ival = REGION_FLAGS_ALLOW_DIRECT_TELEPORT; return(INTEGER_CONSTANT); } +"REGION_FLAG_RESTRICT_PUSHOBJECT" { count(); yylval.ival = REGION_FLAGS_RESTRICT_PUSHOBJECT; return(INTEGER_CONSTANT); } + +"HTTP_METHOD" { count(); yylval.ival = HTTP_METHOD; return(INTEGER_CONSTANT); } +"HTTP_MIMETYPE" { count(); yylval.ival = HTTP_MIMETYPE; return(INTEGER_CONSTANT); } +"HTTP_BODY_MAXLENGTH" { count(); yylval.ival = HTTP_BODY_MAXLENGTH; return(INTEGER_CONSTANT); } +"HTTP_BODY_TRUNCATED" { count(); yylval.ival = HTTP_BODY_TRUNCATED; return(INTEGER_CONSTANT); } +"HTTP_VERIFY_CERT" { count(); yylval.ival = HTTP_VERIFY_CERT; return(INTEGER_CONSTANT); } + +"PARCEL_COUNT_TOTAL" { count(); yylval.ival = OC_TOTAL; return(INTEGER_CONSTANT); } +"PARCEL_COUNT_OWNER" { count(); yylval.ival = OC_OWNER; return(INTEGER_CONSTANT); } +"PARCEL_COUNT_GROUP" { count(); yylval.ival = OC_GROUP; return(INTEGER_CONSTANT); } +"PARCEL_COUNT_OTHER" { count(); yylval.ival = OC_OTHER; return(INTEGER_CONSTANT); } +"PARCEL_COUNT_SELECTED" { count(); yylval.ival = OC_SELECTED; return(INTEGER_CONSTANT); } +"PARCEL_COUNT_TEMP" { count(); yylval.ival = OC_TEMP; return(INTEGER_CONSTANT); } + +"PARCEL_DETAILS_NAME" { count(); yylval.ival = PARCEL_DETAILS_NAME; return(INTEGER_CONSTANT); } +"PARCEL_DETAILS_DESC" { count(); yylval.ival = PARCEL_DETAILS_DESC; return(INTEGER_CONSTANT); } +"PARCEL_DETAILS_OWNER" { count(); yylval.ival = PARCEL_DETAILS_OWNER; return(INTEGER_CONSTANT); } +"PARCEL_DETAILS_GROUP" { count(); yylval.ival = PARCEL_DETAILS_GROUP; return(INTEGER_CONSTANT); } +"PARCEL_DETAILS_AREA" { count(); yylval.ival = PARCEL_DETAILS_AREA; return(INTEGER_CONSTANT); } + +{L}({L}|{N})* { count(); yylval.sval = new char[strlen(yytext) + 1]; strcpy(yylval.sval, yytext); return(IDENTIFIER); } + +{D}+{E} { count(); yylval.fval = (F32)atof(yytext); return(FP_CONSTANT); } +{D}*"."{D}+({E})?{FS}? { count(); yylval.fval = (F32)atof(yytext); return(FP_CONSTANT); } +{D}+"."{D}*({E})?{FS}? { count(); yylval.fval = (F32)atof(yytext); return(FP_CONSTANT); } + +L?\"(\\.|[^\\"])*\" { parse_string(); count(); return(STRING_CONSTANT); } + +"++" { count(); return(INC_OP); } +"--" { count(); return(DEC_OP); } +"+=" { count(); return(ADD_ASSIGN); } +"-=" { count(); return(SUB_ASSIGN); } +"*=" { count(); return(MUL_ASSIGN); } +"/=" { count(); return(DIV_ASSIGN); } +"%=" { count(); return(MOD_ASSIGN); } +";" { count(); return(';'); } +"{" { count(); return('{'); } +"}" { count(); return('}'); } +"," { count(); return(','); } +"=" { count(); return('='); } +"(" { count(); return('('); } +")" { count(); return(')'); } +"-" { count(); return('-'); } +"+" { count(); return('+'); } +"*" { count(); return('*'); } +"/" { count(); return('/'); } +"%" { count(); return('%'); } +"@" { count(); return('@'); } +":" { count(); return(':'); } +">" { count(); return('>'); } +"<" { count(); return('<'); } +"]" { count(); return(']'); } +"[" { count(); return('['); } +"==" { count(); return(EQ); } +"!=" { count(); return(NEQ); } +">=" { count(); return(GEQ); } +"<=" { count(); return(LEQ); } +"&" { count(); return('&'); } +"|" { count(); return('|'); } +"^" { count(); return('^'); } +"~" { count(); return('~'); } +"!" { count(); return('!'); } +"&&" { count(); return(BOOLEAN_AND); } +"||" { count(); return(BOOLEAN_OR); } +"<<" { count(); return(SHIFT_LEFT); } +">>" { count(); return(SHIFT_RIGHT); } + +[ \t\v\n\f] { count(); } +. { /* ignore bad characters */ } + +%% + +LLScriptAllocationManager *gAllocationManager; +LLScriptScript *gScriptp; + +// Prototype for the yacc parser entry point +int yyparse(void); + +int yyerror(const char *fmt, ...) +{ + gErrorToText.writeError(yyout, gLine, gColumn, LSERROR_SYNTAX_ERROR); + return 0; +} + +#define LL_MKS_YACC 1 +#if LL_WINDOWS && LL_MKS_YACC +int yyinput(void) +{ + return input(); +} +#endif + +//#define EMERGENCY_DEBUG_PRINTOUTS +//#define EMIT_CIL_ASSEMBLER + +BOOL lscript_compile(const char* src_filename, const char* dst_filename, + const char* err_filename, BOOL is_god_like) +{ + BOOL b_parse_ok = FALSE; + BOOL b_dummy = FALSE; + U64 b_dummy_count = FALSE; + LSCRIPTType type = LST_NULL; + + gInternalColumn = 0; + gInternalLine = 0; + gScriptp = NULL; + + gErrorToText.init(); + init_supported_expressions(); + init_temp_jumps(); + gAllocationManager = new LLScriptAllocationManager(); + + yyin = LLFile::fopen(src_filename, "r"); + if (yyin) + { + yyout = LLFile::fopen(err_filename, "w"); + + // Reset the lexer's internal buffering. +#if LL_DARWIN || LL_LINUX || !LL_MKS_YACC + yyrestart(yyin); +#else + yy_reset(); +#endif + b_parse_ok = !yyparse(); + + if (b_parse_ok) + { +#ifdef EMERGENCY_DEBUG_PRINTOUTS + char compiled[256]; + sprintf(compiled, "%s.o", src_filename); + FILE* compfile; + compfile = LLFile::fopen(compiled, "w"); +#endif + + if(dst_filename) + { + gScriptp->setBytecodeDest(dst_filename); + } + + gScriptp->mGodLike = is_god_like; + + gScopeStringTable = new LLStringTable(16384); +#ifdef EMERGENCY_DEBUG_PRINTOUTS + gScriptp->recurse(compfile, 0, 4, LSCP_PRETTY_PRINT, LSPRUNE_INVALID, b_dummy, NULL, type, type, b_dummy_count, NULL, NULL, 0, NULL, 0, NULL); +#endif + gScriptp->recurse(yyout, 0, 0, LSCP_PRUNE, LSPRUNE_INVALID, b_dummy, NULL, type, type, b_dummy_count, NULL, NULL, 0, NULL, 0, NULL); + gScriptp->recurse(yyout, 0, 0, LSCP_SCOPE_PASS1, LSPRUNE_INVALID, b_dummy, NULL, type, type, b_dummy_count, NULL, NULL, 0, NULL, 0, NULL); + gScriptp->recurse(yyout, 0, 0, LSCP_SCOPE_PASS2, LSPRUNE_INVALID, b_dummy, NULL, type, type, b_dummy_count, NULL, NULL, 0, NULL, 0, NULL); + gScriptp->recurse(yyout, 0, 0, LSCP_TYPE, LSPRUNE_INVALID, b_dummy, NULL, type, type, b_dummy_count, NULL, NULL, 0, NULL, 0, NULL); + if (!gErrorToText.getErrors()) + { + gScriptp->recurse(yyout, 0, 0, LSCP_RESOURCE, LSPRUNE_INVALID, b_dummy, NULL, type, type, b_dummy_count, NULL, NULL, 0, NULL, 0, NULL); +#ifdef EMERGENCY_DEBUG_PRINTOUTS + gScriptp->recurse(yyout, 0, 0, LSCP_EMIT_ASSEMBLY, LSPRUNE_INVALID, b_dummy, NULL, type, type, b_dummy_count, NULL, NULL, 0, NULL, 0, NULL); +#endif +#ifdef EMIT_CIL_ASSEMBLER + const char* cil_output_file_name = dst_filename? dst_filename : "lscript.cil"; + FILE* cilout = LLFile::fopen(cil_output_file_name, "w"); + if(NULL == cilout) + { + fprintf(yyout, "Error opening cil output file %s\n", cil_output_file_name); + } + else + { + gScriptp->recurse(cilout, 0, 0, LSCP_EMIT_CIL_ASSEMBLY, LSPRUNE_INVALID, b_dummy, NULL, type, type, b_dummy_count, NULL, NULL, 0, NULL, 0, NULL); + if(fclose(cilout) == EOF) + { + fprintf(yyout, "Error closing cil output file %s\n", cil_output_file_name); + } + } +#endif + gScriptp->recurse(yyout, 0, 0, LSCP_EMIT_BYTE_CODE, LSPRUNE_INVALID, b_dummy, NULL, type, type, b_dummy_count, NULL, NULL, 0, NULL, 0, NULL); + } + delete gScopeStringTable; + gScopeStringTable = NULL; +#ifdef EMERGENCY_DEBUG_PRINTOUTS + fclose(compfile); +#endif + } + fclose(yyout); + } + + fclose(yyin); + delete gAllocationManager; + delete gScopeStringTable; + + return b_parse_ok && !gErrorToText.getErrors(); +} + + +BOOL lscript_compile(char *filename, BOOL is_god_like = FALSE) +{ + char src_filename[MAX_STRING]; + sprintf(src_filename, "%s.lsl", filename); + char err_filename[MAX_STRING]; + sprintf(err_filename, "%s.out", filename); + return lscript_compile(src_filename, NULL, err_filename, is_god_like); +} + + +S32 yywrap() +{ + return(1); +} + +void comment() +{ + char c; + +#if LL_DARWIN + while ((c = yyinput()) != '\n' && c != 0 && c != EOF) + ; +#else + while ((c = yyinput()) != '\n' && c != 0) + ; +#endif + + +} + +void count() +{ + S32 i; + + gColumn = gInternalColumn; + gLine = gInternalLine; + + for (i = 0; yytext[i] != '\0'; i++) + if (yytext[i] == '\n') + { + gInternalLine++; + gInternalColumn = 0; + } + else if (yytext[i] == '\t') + gInternalColumn += 4 - (gInternalColumn % 8); + else + gInternalColumn++; +} + +void parse_string() +{ + S32 length = (S32)strlen(yytext); + length = length - 2; + char *temp = yytext + 1; + + S32 i; + S32 escapes = 0; + S32 tabs = 0; + for (i = 0; i < length; i++) + { + if (temp[i] == '\\') + { + escapes++; + i++; + if (temp[i] == 't') + tabs++; + } + } + + S32 newlength = length - escapes + tabs*3; + yylval.sval = new char[newlength + 1]; + + char *dest = yylval.sval; + + for (i = 0; i < length; i++) + { + if (temp[i] == '\\') + { + i++; + // linefeed + if (temp[i] == 'n') + { + *dest++ = 10; + } + else if (temp[i] == 't') + { + *dest++ = ' '; + *dest++ = ' '; + *dest++ = ' '; + *dest++ = ' '; + } + else + { + *dest++ = temp[i]; + } + } + else + { + *dest++ = temp[i]; + } + } + yylval.sval[newlength] = 0; +} diff --git a/indra/lscript/lscript_compile/indra.y b/indra/lscript/lscript_compile/indra.y new file mode 100644 index 0000000000..7744649a92 --- /dev/null +++ b/indra/lscript/lscript_compile/indra.y @@ -0,0 +1,1680 @@ +%{ + #include "stdtypes.h" + #include "lscript_tree.h" + + #ifdef __cplusplus + extern "C" { + #endif + + int yylex(void); + int yyparse( void ); + int yyerror(const char *fmt, ...); + + #if LL_LINUX + // broken yacc codegen... --ryan. + #define getenv getenv_workaround + #endif + + #ifdef __cplusplus + } + #endif +%} + +%union +{ + S32 ival; + F32 fval; + char *sval; + class LLScriptType *type; + class LLScriptConstant *constant; + class LLScriptIdentifier *identifier; + class LLScriptSimpleAssignable *assignable; + class LLScriptGlobalVariable *global; + class LLScriptEvent *event; + class LLScriptEventHandler *handler; + class LLScriptExpression *expression; + class LLScriptStatement *statement; + class LLScriptGlobalFunctions *global_funcs; + class LLScriptFunctionDec *global_decl; + class LLScriptState *state; + class LLScritpGlobalStorage *global_store; + class LLScriptScript *script; +}; + +%token INTEGER +%token FLOAT_TYPE +%token STRING +%token LLKEY +%token VECTOR +%token QUATERNION +%token LIST + +%token STATE_DEFAULT +%token STATE +%token EVENT +%token JUMP +%token RETURN + +%token STATE_ENTRY +%token STATE_EXIT +%token TOUCH_START +%token TOUCH +%token TOUCH_END +%token COLLISION_START +%token COLLISION +%token COLLISION_END +%token LAND_COLLISION_START +%token LAND_COLLISION +%token LAND_COLLISION_END +%token TIMER +%token CHAT +%token SENSOR +%token NO_SENSOR +%token CONTROL +%token AT_TARGET +%token NOT_AT_TARGET +%token AT_ROT_TARGET +%token NOT_AT_ROT_TARGET +%token MONEY +%token EMAIL +%token RUN_TIME_PERMISSIONS +%token INVENTORY +%token ATTACH +%token DATASERVER +%token MOVING_START +%token MOVING_END +%token REZ +%token OBJECT_REZ +%token LINK_MESSAGE +%token REMOTE_DATA +%token HTTP_RESPONSE + +%token IDENTIFIER +%token STATE_DEFAULT + +%token INTEGER_CONSTANT +%token INTEGER_TRUE +%token INTEGER_FALSE + +%token FP_CONSTANT + +%token STRING_CONSTANT + +%token INC_OP +%token DEC_OP +%token ADD_ASSIGN +%token SUB_ASSIGN +%token MUL_ASSIGN +%token DIV_ASSIGN +%token MOD_ASSIGN + +%token EQ +%token NEQ +%token GEQ +%token LEQ + +%token BOOLEAN_AND +%token BOOLEAN_OR + +%token SHIFT_LEFT +%token SHIFT_RIGHT + +%token IF +%token ELSE +%token FOR +%token DO +%token WHILE + +%token PRINT + +%token PERIOD + +%token ZERO_VECTOR +%token ZERO_ROTATION + +%nonassoc LOWER_THAN_ELSE +%nonassoc ELSE + + +%type