summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xdoc/contributions.txt1
-rwxr-xr-xindra/CMakeLists.txt2
-rwxr-xr-xindra/cmake/CMakeLists.txt1
-rwxr-xr-xindra/cmake/LScript.cmake16
-rwxr-xr-xindra/lscript/CMakeLists.txt21
-rwxr-xr-xindra/lscript/llscriptresource.h69
-rwxr-xr-xindra/lscript/llscriptresourceconsumer.h61
-rwxr-xr-xindra/lscript/llscriptresourcepool.h51
-rwxr-xr-xindra/lscript/lscript_alloc.h293
-rwxr-xr-xindra/lscript/lscript_byteconvert.h1170
-rwxr-xr-xindra/lscript/lscript_byteformat.h566
-rwxr-xr-xindra/lscript/lscript_compile/CMakeLists.txt157
-rw-r--r--indra/lscript/lscript_compile/bison.bat12
-rwxr-xr-xindra/lscript/lscript_compile/indra.l1013
-rwxr-xr-xindra/lscript/lscript_compile/indra.y1791
-rwxr-xr-xindra/lscript/lscript_compile/lscript_alloc.cpp26
-rwxr-xr-xindra/lscript/lscript_compile/lscript_bytecode.cpp317
-rwxr-xr-xindra/lscript/lscript_compile/lscript_bytecode.h90
-rwxr-xr-xindra/lscript/lscript_compile/lscript_error.cpp103
-rwxr-xr-xindra/lscript/lscript_compile/lscript_error.h152
-rwxr-xr-xindra/lscript/lscript_compile/lscript_heap.cpp67
-rwxr-xr-xindra/lscript/lscript_compile/lscript_heap.h58
-rwxr-xr-xindra/lscript/lscript_compile/lscript_resource.cpp36
-rwxr-xr-xindra/lscript/lscript_compile/lscript_resource.h37
-rwxr-xr-xindra/lscript/lscript_compile/lscript_scope.cpp31
-rwxr-xr-xindra/lscript/lscript_compile/lscript_scope.h401
-rwxr-xr-xindra/lscript/lscript_compile/lscript_tree.cpp10895
-rwxr-xr-xindra/lscript/lscript_compile/lscript_tree.h2325
-rwxr-xr-xindra/lscript/lscript_compile/lscript_typecheck.cpp586
-rwxr-xr-xindra/lscript/lscript_compile/lscript_typecheck.h118
-rwxr-xr-xindra/lscript/lscript_compile/windows/unistd.h24
-rwxr-xr-xindra/lscript/lscript_execute.h552
-rwxr-xr-xindra/lscript/lscript_execute/CMakeLists.txt43
-rwxr-xr-xindra/lscript/lscript_execute/llscriptresource.cpp93
-rwxr-xr-xindra/lscript/lscript_execute/llscriptresourceconsumer.cpp106
-rwxr-xr-xindra/lscript/lscript_execute/llscriptresourcepool.cpp44
-rwxr-xr-xindra/lscript/lscript_execute/lscript_execute.cpp4318
-rwxr-xr-xindra/lscript/lscript_execute/lscript_heapruntime.cpp519
-rwxr-xr-xindra/lscript/lscript_execute/lscript_heapruntime.h40
-rwxr-xr-xindra/lscript/lscript_execute/lscript_readlso.cpp1585
-rwxr-xr-xindra/lscript/lscript_execute/lscript_readlso.h164
-rwxr-xr-xindra/lscript/lscript_export.h34
-rwxr-xr-xindra/lscript/lscript_http.h45
-rwxr-xr-xindra/lscript/lscript_library.h427
-rwxr-xr-xindra/lscript/lscript_library/CMakeLists.txt35
-rwxr-xr-xindra/lscript/lscript_library/lscript_alloc.cpp1136
-rwxr-xr-xindra/lscript/lscript_library/lscript_export.cpp26
-rwxr-xr-xindra/lscript/lscript_library/lscript_library.cpp582
-rwxr-xr-xindra/lscript/lscript_rt_interface.h36
-rwxr-xr-xindra/newview/CMakeLists.txt5
-rwxr-xr-xindra/newview/llagent.cpp2
-rwxr-xr-xindra/newview/llpreviewscript.cpp193
-rwxr-xr-xindra/newview/llpreviewscript.h7
-rw-r--r--indra/newview/llscriptruntimeperms.h60
-rwxr-xr-xindra/newview/llviewermessage.cpp69
-rwxr-xr-xindra/test/CMakeLists.txt2
-rwxr-xr-xindra/test/llscriptresource_tut.cpp198
57 files changed, 78 insertions, 30733 deletions
diff --git a/doc/contributions.txt b/doc/contributions.txt
index b55f2179b9..7e1e6fdbf2 100755
--- a/doc/contributions.txt
+++ b/doc/contributions.txt
@@ -315,6 +315,7 @@ Cinder Roxley
BUG-3863
OPEN-185
OPEN-282
+ OPEN-292
STORM-1703
STORM-1948
STORM-1831
diff --git a/indra/CMakeLists.txt b/indra/CMakeLists.txt
index 10692402a5..b0dbe62a0c 100755
--- a/indra/CMakeLists.txt
+++ b/indra/CMakeLists.txt
@@ -39,8 +39,6 @@ add_subdirectory(${LIBS_OPEN_PREFIX}llvfs)
add_subdirectory(${LIBS_OPEN_PREFIX}llwindow)
add_subdirectory(${LIBS_OPEN_PREFIX}llxml)
-add_subdirectory(${LIBS_OPEN_PREFIX}lscript)
-
if (WINDOWS AND EXISTS ${LIBS_CLOSED_DIR}copy_win_scripts)
add_subdirectory(${LIBS_CLOSED_PREFIX}copy_win_scripts)
endif (WINDOWS AND EXISTS ${LIBS_CLOSED_DIR}copy_win_scripts)
diff --git a/indra/cmake/CMakeLists.txt b/indra/cmake/CMakeLists.txt
index 4d98e73092..5bf3bbc61d 100755
--- a/indra/cmake/CMakeLists.txt
+++ b/indra/cmake/CMakeLists.txt
@@ -79,7 +79,6 @@ set(cmake_SOURCE_FILES
LLVFS.cmake
LLWindow.cmake
LLXML.cmake
- LScript.cmake
Linking.cmake
## MediaPluginBase.cmake
NDOF.cmake
diff --git a/indra/cmake/LScript.cmake b/indra/cmake/LScript.cmake
deleted file mode 100755
index 21e78fc2c0..0000000000
--- a/indra/cmake/LScript.cmake
+++ /dev/null
@@ -1,16 +0,0 @@
-# -*- cmake -*-
-
-set(LSCRIPT_INCLUDE_DIRS
- ${LIBS_OPEN_DIR}/lscript
- ${LIBS_OPEN_DIR}/lscript/lscript_compile
- ${LIBS_OPEN_DIR}/lscript/lscript_execute
- ${LIBS_OPEN_DIR}/lscript/lscript_execute_mono
- )
-
-set(LSCRIPT_LIBRARIES
- lscript_compile
- lscript_execute
- lscript_library
- )
-
-set(LSCRIPT_EXECUTE_MONO_LIBRARIES lscript_execute_mono)
diff --git a/indra/lscript/CMakeLists.txt b/indra/lscript/CMakeLists.txt
deleted file mode 100755
index 937e2ec0dc..0000000000
--- a/indra/lscript/CMakeLists.txt
+++ /dev/null
@@ -1,21 +0,0 @@
-# -*- cmake -*-
-
-set(lscript_HEADER_FILES
- llscriptresource.h
- llscriptresourceconsumer.h
- llscriptresourcepool.h
- lscript_alloc.h
- lscript_byteconvert.h
- lscript_byteformat.h
- lscript_execute.h
- lscript_export.h
- lscript_http.h
- lscript_library.h
- lscript_rt_interface.h
- )
-
-add_subdirectory(lscript_compile)
-add_subdirectory(lscript_execute)
-
-add_subdirectory(lscript_library)
-
diff --git a/indra/lscript/llscriptresource.h b/indra/lscript/llscriptresource.h
deleted file mode 100755
index 9dab9ff7ce..0000000000
--- a/indra/lscript/llscriptresource.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/**
- * @file llscriptresource.h
- * @brief LLScriptResource class definition
- *
- * $LicenseInfo:firstyear=2008&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#ifndef LL_LLSCRIPTRESOURCE_H
-#define LL_LLSCRIPTRESOURCE_H
-
-#include "stdtypes.h"
-
-// An LLScriptResource is a limited resource per ID.
-class LLScriptResource
-{
-public:
- LLScriptResource();
-
- // If amount resources are available will mark amount resouces
- // used and returns true
- // Otherwise returns false and doesn't mark any resources used.
- bool request(S32 amount = 1);
-
- // Release amount resources from use if at least amount resources are used and return true
- // If amount is more than currently used no resources are released and return false
- bool release(S32 amount = 1);
-
- // Returns how many resources are available
- S32 getAvailable() const;
-
- // Sets the total amount of available resources
- // It is possible to set the amount to less than currently used
- // Most likely to happen on parcel ownership change
- void setTotal(S32 amount);
-
- // Get the total amount of available resources
- S32 getTotal() const;
-
- // Get the number of resources used
- S32 getUsed() const;
-
- // true if more resources used than total available
- bool isOverLimit() const;
-
-private:
- S32 mTotal; // How many resources have been set aside
- S32 mUsed; // How many resources are currently in use
-};
-
-#endif // LL_LLSCRIPTRESOURCE_H
diff --git a/indra/lscript/llscriptresourceconsumer.h b/indra/lscript/llscriptresourceconsumer.h
deleted file mode 100755
index 82a490d28f..0000000000
--- a/indra/lscript/llscriptresourceconsumer.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/**
- * @file llscriptresourceconsumer.h
- * @brief An interface for a script resource consumer.
- *
- * $LicenseInfo:firstyear=2008&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#ifndef LL_LLSCRIPTRESOURCECONSUMER_H
-#define LL_LLSCRIPTRESOURCECONSUMER_H
-
-#include "linden_common.h"
-
-class LLScriptResourcePool;
-
-// Entities that use limited script resources
-// should implement this interface
-
-class LLScriptResourceConsumer
-{
-public:
- LLScriptResourceConsumer();
-
- virtual ~LLScriptResourceConsumer() { }
-
- // Get the number of public urls used by this consumer.
- virtual S32 getUsedPublicURLs() const = 0;
-
- // Get the resource pool this consumer is currently using.
- LLScriptResourcePool& getScriptResourcePool();
- const LLScriptResourcePool& getScriptResourcePool() const;
-
- bool switchScriptResourcePools(LLScriptResourcePool& new_pool);
- bool canUseScriptResourcePool(const LLScriptResourcePool& resource_pool);
- bool isInPool(const LLScriptResourcePool& resource_pool);
-
-protected:
- virtual void setScriptResourcePool(LLScriptResourcePool& pool);
-
- LLScriptResourcePool* mScriptResourcePool;
-};
-
-#endif // LL_LLSCRIPTRESOURCECONSUMER_H
diff --git a/indra/lscript/llscriptresourcepool.h b/indra/lscript/llscriptresourcepool.h
deleted file mode 100755
index 4ea2556e0f..0000000000
--- a/indra/lscript/llscriptresourcepool.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * @file llscriptresourcepool.h
- * @brief A collection of LLScriptResources
- *
- * $LicenseInfo:firstyear=2008&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#ifndef LL_LLSCRIPTRESOURCEPOOL_H
-#define LL_LLSCRIPTRESOURCEPOOL_H
-
-#include "llscriptresource.h"
-
-// This is just a holder for LLSimResources
-class LLScriptResourcePool
-{
-public:
- LLScriptResourcePool();
- // ~LLSimResourceMgr();
-
- LLScriptResource& getPublicURLResource();
- const LLScriptResource& getPublicURLResource() const;
-
- // An empty resource pool.
- static LLScriptResourcePool null;
-
-private:
- LLScriptResource mLSLPublicURLs;
-};
-
-
-
-#endif
diff --git a/indra/lscript/lscript_alloc.h b/indra/lscript/lscript_alloc.h
deleted file mode 100755
index f8a4e298d2..0000000000
--- a/indra/lscript/lscript_alloc.h
+++ /dev/null
@@ -1,293 +0,0 @@
-/**
- * @file lscript_alloc.h
- * @brief General heap management for scripting system
- *
- * $LicenseInfo:firstyear=2002&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#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 "lscript_byteconvert.h"
-#include "lscript_library.h"
-
-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, LLFILE *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 = new LLScriptLibData*[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;
-
- temp = sortarray[0];
- delete[] sortarray;
- return temp;
-}
-
-
-LLScriptLibData* lsa_randomize(LLScriptLibData* src, S32 stride);
-
-#endif
diff --git a/indra/lscript/lscript_byteconvert.h b/indra/lscript/lscript_byteconvert.h
deleted file mode 100755
index 5b08481d7d..0000000000
--- a/indra/lscript/lscript_byteconvert.h
+++ /dev/null
@@ -1,1170 +0,0 @@
-/**
- * @file lscript_byteconvert.h
- * @brief Shared code for compiler and assembler for LSL
- *
- * $LicenseInfo:firstyear=2002&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-// 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);
-}
-
-// Returns true on success, return false and clip copy on buffer overflow
-inline bool bytestream2char(char *buffer, const U8 *stream, S32 &offset, S32 buffsize)
-{
- S32 source_len = strlen( (const char *)stream+offset );
- S32 copy_len = buffsize - 1;
- if( copy_len > source_len )
- {
- copy_len = source_len;
- }
-
- // strncpy without \0 padding overhead
- memcpy( buffer, stream+offset, copy_len );
- buffer[copy_len] = 0;
-
- offset += source_len + 1; // advance past source string, include terminating '\0'
-
- return source_len < buffsize;
-}
-
-inline void char2bytestream(U8 *stream, S32 &offset, const 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, const 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, const 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 = 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, const 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, const 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, const LLVector3 value)
-{
- if (lscript_check_local(stream, address, LSCRIPTDataSize[LST_VECTOR]))
- vector2bytestream(stream, address, value);
-}
-
-inline void lscript_local_store(U8 *stream, S32 address, const 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, const LLVector3 value)
-{
- if (lscript_check_global(stream, address, LSCRIPTDataSize[LST_VECTOR]))
- vector2bytestream(stream, address, value);
-}
-
-inline void lscript_global_store(U8 *stream, S32 address, const 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;
- }
- if ( state_offset_offset < 0 || state_offset_offset > TOP_OF_MEMORY )
- {
- return -1;
- }
-
- // get the actual position in memory of the desired state
- S32 state_offset = sr + bytestream2integer(stream, state_offset_offset);
- if ( state_offset < 0 || state_offset > TOP_OF_MEMORY )
- {
- return -1;
- }
-
- // 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);
- if ( event_offset < 0 || event_offset > TOP_OF_MEMORY )
- {
- return -1;
- }
-
- // now, jump to the event
- S32 event_start = bytestream2integer(stream, event_offset);
- if ( event_start < 0 || event_start > TOP_OF_MEMORY )
- {
- return -1;
- }
- event_start += event_jump_offset;
-
- S32 event_start_original = event_start;
-
- // now skip past the parameters
- S32 opcode_offset = bytestream2integer(stream, event_start);
- if ( opcode_offset < 0 || opcode_offset > TOP_OF_MEMORY )
- {
- return -1;
- }
-
- 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;
-}
-
-// Returns -1 on error
-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;
- }
-
- if ( state_offset_offset < 0 || state_offset_offset > TOP_OF_MEMORY )
- {
- return -1;
- }
-
- S32 state_offset = bytestream2integer(stream, state_offset_offset);
- state_offset += sr;
-
- state_offset_offset = state_offset;
- if ( state_offset_offset < 0 || state_offset_offset > TOP_OF_MEMORY )
- {
- return -1;
- }
-
- // skip to jump table
- S32 jump_table = bytestream2integer(stream, state_offset_offset);
-
- jump_table += state_offset;
- if ( jump_table < 0 || jump_table > TOP_OF_MEMORY )
- {
- return -1;
- }
-
- // 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);
- if ( stack_size < 0 || stack_size > TOP_OF_MEMORY )
- {
- return -1;
- }
-
- 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, S32 buffsize)
-{
- // This varies from the old method. Previously, we would copy up until we got an error,
- // then halt the script via safe_isntruction_check_address. Now we don't bother
- // copying a thing if there's an error.
-
- if( safe_instruction_check_address(stream, offset, strlen( (const char *)stream + offset ) + 1 ) )
- {
- // Takes the same parms as this function. Won't overread, per above check.
- bytestream2char( buffer, stream, offset, buffsize );
- }
- else
- {
- // Truncate - no point in copying
- *buffer = 0;
- }
-}
-
-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, const 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, const 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, const 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
deleted file mode 100755
index 54031aaf05..0000000000
--- a/indra/lscript/lscript_byteformat.h
+++ /dev/null
@@ -1,566 +0,0 @@
-/**
- * @file lscript_byteformat.h
- * @brief Shared code between compiler and assembler and LSL
- *
- * $LicenseInfo:firstyear=2002&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#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] = /* Flawfinder: ignore */
-{
- 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_HTTP_REQUEST,
- 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
- 0x0000000200000000LL // LSTT_HTTP_REQUEST
-};
-
-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,
- LST_UNDEFINED << 4,
-};
-
-const char * const LSCRIPTTypeNames[LST_EOF] = /*Flawfinder: ignore*/
-{
- "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_CLI,
- LSRF_EOF
-} LSCRIPTRunTimeFaults;
-
-extern const char* LSCRIPTRunTimeFaultStrings[LSRF_EOF]; /*Flawfinder: ignore*/
-
-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_TELEPORT,
- SCRIPT_PERMISSION_EXPERIENCE,
- SCRIPT_PERMISSION_SILENT_ESTATE_MANAGEMENT,
- SCRIPT_PERMISSION_OVERRIDE_ANIMATIONS,
- SCRIPT_PERMISSION_RETURN_OBJECTS,
- 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
- (0x1 << 12),// SCRIPT_PERMISSION_TELEPORT
- (0x1 << 13),// SCRIPT_PERMISSION_EXPERIENCE,
- (0x1 << 14),// SCRIPT_PERMISSION_SILENT_ESTATE_MANAGEMENT,
- (0x1 << 15),// SCRIPT_PERMISSION_OVERRIDE_ANIMATIONS,
- (0x1 << 16),// SCRIPT_PERMISSION_RETURN_OBJECTS,
-};
-
-// http_request string constants
-extern const char* URL_REQUEST_GRANTED;
-extern const char* URL_REQUEST_DENIED;
-extern const U64 LSL_HTTP_REQUEST_TIMEOUT_USEC;
-
-#endif
-
diff --git a/indra/lscript/lscript_compile/CMakeLists.txt b/indra/lscript/lscript_compile/CMakeLists.txt
deleted file mode 100755
index 07662005b9..0000000000
--- a/indra/lscript/lscript_compile/CMakeLists.txt
+++ /dev/null
@@ -1,157 +0,0 @@
-# -*- cmake -*-
-
-include(00-Common)
-include(LLCommon)
-include(LLMath)
-include(LLMessage)
-include(LLInventory)
-include(LLPrimitive)
-include(LScript)
-
-include(FindCygwin)
-
-find_program(FLEX flex
- "C:/Program Files/GnuWin32/bin"
- ${CYGWIN_INSTALL_PATH}/bin
- /bin
- /usr/bin
- /usr/local/bin
- )
-mark_as_advanced(FLEX)
-
-find_program(BISON bison
- "C:/Program Files/GnuWin32/bin"
- ${CYGWIN_INSTALL_PATH}/bin
- /bin
- /usr/bin
- /usr/local/bin
- )
-mark_as_advanced(BISON)
-
-find_program(M4 m4
- "C:/Program Files/GnuWin32/bin"
- ${CYGWIN_INSTALL_PATH}/bin
- /bin
- /usr/bin
- /usr/local/bin
- )
-mark_as_advanced(M4)
-
-include_directories(
- ${LLCOMMON_INCLUDE_DIRS}
- ${LLMATH_INCLUDE_DIRS}
- ${LLMESSAGE_INCLUDE_DIRS}
- ${LLINVENTORY_INCLUDE_DIRS}
- ${LLPRIMITIVE_INCLUDE_DIRS}
- ${LSCRIPT_INCLUDE_DIRS}
- )
-include_directories(SYSTEM
- ${LLCOMMON_SYSTEM_INCLUDE_DIRS}
- )
-
-set(lscript_generated_SOURCE_FILES
- indra.l.cpp
- indra.y.cpp
- )
-
-set(lscript_compile_SOURCE_FILES
- lscript_alloc.cpp
- lscript_bytecode.cpp
- lscript_error.cpp
- lscript_heap.cpp
- lscript_resource.cpp
- lscript_scope.cpp
- lscript_tree.cpp
- lscript_typecheck.cpp
- )
-
-set(lscript_compile_HEADER_FILES
- CMakeLists.txt
-
- indra.l
- indra.y
-
- ../lscript_alloc.h
- ../lscript_byteformat.h
- ../lscript_byteconvert.h
- ../lscript_http.h
-
- lscript_error.h
- lscript_bytecode.h
- lscript_heap.h
- lscript_resource.h
- lscript_scope.h
- lscript_tree.h
- lscript_typecheck.h
- )
-
-set_source_files_properties(${lscript_compile_HEADER_FILES}
- PROPERTIES HEADER_FILE_ONLY TRUE)
-
-set_source_files_properties(${lscript_generated_SOURCE_FILES}
- PROPERTIES HEADER_FILE_ONLY FALSE GENERATED TRUE)
-
-list(APPEND lscript_compile_SOURCE_FILES ${lscript_generated_SOURCE_FILES} ${lscript_compile_HEADER_FILES})
-
-add_custom_command(
- OUTPUT
- ${CMAKE_CURRENT_BINARY_DIR}/indra.l.cpp
- COMMAND ${FLEX}
- ARGS
- -P indra_
- -o${CMAKE_CURRENT_BINARY_DIR}/indra.l.cpp
- ${CMAKE_CURRENT_SOURCE_DIR}/indra.l
- DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/indra.l
- )
-
-if (WINDOWS)
- set_source_files_properties(indra.l.cpp
- PROPERTIES COMPILE_FLAGS /DYY_NO_UNISTD_H)
-endif (WINDOWS)
-
-if (WINDOWS)
- get_filename_component(M4_PATH ${M4} PATH)
- add_custom_command(
- OUTPUT
- ${CMAKE_CURRENT_BINARY_DIR}/indra.y.cpp
- ${CMAKE_CURRENT_BINARY_DIR}/indra.y.hpp
- COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/bison.bat
- ARGS
- ${BISON} ${M4_PATH}
- -p indra_
- -d -o ${CMAKE_CURRENT_BINARY_DIR}/indra.y.cpp
- ${CMAKE_CURRENT_SOURCE_DIR}/indra.y
- DEPENDS
- ${CMAKE_CURRENT_SOURCE_DIR}/bison.bat
- ${CMAKE_CURRENT_SOURCE_DIR}/indra.y
- )
- include_directories(${CMAKE_CURRENT_SOURCE_DIR}/windows)
-else (WINDOWS)
- add_custom_command(
- OUTPUT
- ${CMAKE_CURRENT_BINARY_DIR}/indra.y.cpp
- ${CMAKE_CURRENT_BINARY_DIR}/indra.y.hpp
- COMMAND
- ${BISON}
- ARGS
- -p indra_
- -d -o ${CMAKE_CURRENT_BINARY_DIR}/indra.y.cpp
- ${CMAKE_CURRENT_SOURCE_DIR}/indra.y
- DEPENDS
- ${CMAKE_CURRENT_SOURCE_DIR}/indra.y
- )
-endif (WINDOWS)
-
-if (DARWIN)
- # Mac OS X 10.4 compatibility
- add_custom_command(
- OUTPUT
- ${CMAKE_CURRENT_BINARY_DIR}/indra.y.hpp
- COMMAND
- mv
- ${CMAKE_CURRENT_BINARY_DIR}/indra.y.cpp.h
- ${CMAKE_CURRENT_BINARY_DIR}/indra.y.hpp
- )
-endif (DARWIN)
-
-add_library (lscript_compile ${lscript_compile_SOURCE_FILES})
diff --git a/indra/lscript/lscript_compile/bison.bat b/indra/lscript/lscript_compile/bison.bat
deleted file mode 100644
index d40997225e..0000000000
--- a/indra/lscript/lscript_compile/bison.bat
+++ /dev/null
@@ -1,12 +0,0 @@
-@REM Run bison under Windows. This script is needed so that bison can
-@REM find m4, even if neither program is present in PATH.
-
-@set bison=%1
-shift
-set M4PATH=%1
-shift
-set M4=
-
-set PATH=%M4PATH%;%PATH%
-@REM %* does not work with shift...
-%bison% %1 %2 %3 %4 %5 %6 %7 %8 %9
diff --git a/indra/lscript/lscript_compile/indra.l b/indra/lscript/lscript_compile/indra.l
deleted file mode 100755
index 7772c95609..0000000000
--- a/indra/lscript/lscript_compile/indra.l
+++ /dev/null
@@ -1,1013 +0,0 @@
-
-N [0-9]
-L [a-zA-Z_]
-H [a-fA-F0-9]
-E [Ee][+-]?{N}+
-FS (f|F)
-%e 10000
-%n 4000
-%p 5000
-
-%top {
- #include "linden_common.h"
-}
-
-%{
-// Deal with the fact that lex/yacc generates unreachable code
-#ifdef LL_WINDOWS
-#pragma warning (disable : 4018) // warning C4018: signed/unsigned mismatch
-#pragma warning (disable : 4702) // warning C4702: unreachable code
-#endif // LL_WINDOWS
-#include "llmath.h"
-#include "lscript_tree.h"
-#include "lscript_typecheck.h"
-#include "lscript_resource.h"
-#include "indra.y.hpp"
-#include "lltimer.h"
-#include "indra_constants.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"
-#include "llclickaction.h"
-#include "llmediaentry.h"
-
-void count();
-void line_comment();
-void block_comment();
-void parse_string();
-
-#define YYLMAX 16384
-#define YY_NEVER_INTERACTIVE 1 /* stops flex from calling isatty() */
-#ifdef LL_WINDOWS
-#define isatty(x) 0 /* hack for bug in cygwin flex 2.5.35 */
-#endif
-
-#ifdef ECHO
-#undef ECHO
-#endif
-
-#define ECHO do { } while (0)
-
-#define yyparse indra_parse
-#define yyerror indra_error
-#define yylval indra_lval
-#define yy_create_buffer indra__create_buffer
-#define yy_delete_buffer indra__delete_buffer
-#define yy_flex_debug indra__flex_debug
-#define yy_init_buffer indra__init_buffer
-#define yy_flush_buffer indra__flush_buffer
-#define yy_load_buffer_state indra__load_buffer_state
-#define yy_switch_to_buffer indra__switch_to_buffer
-#define yyin indra_in
-#define yyleng indra_leng
-#define yylex indra_lex
-#define yylineno indra_lineno
-#define yyout indra_out
-#define yyrestart indra_restart
-#define yytext indra_text
-#define yywrap indra_wrap
-#define yyalloc indra_alloc
-#define yyrealloc indra_realloc
-#define yyfree indra_free
-
-
-int yyparse( void );
-int yylex( void );
-int yyerror(const char *fmt, ...);
-
-%}
-
-%%
-"//" { gInternalLine++; gInternalColumn = 0; line_comment(); }
-"/*" { block_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); }
-"http_request" { count(); return(HTTP_REQUEST); }
-"." { count(); return(PERIOD); }
-
-
-0[xX]{H}+ { count(); yylval.ival = strtoul(yytext, NULL, 0); return(INTEGER_CONSTANT); }
-{N}+ { 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); }
-"STATUS_BLOCK_GRAB_OBJECT" { count(); yylval.ival = 0x400; 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); }
-"AGENT_AUTOPILOT" { count(); yylval.ival = AGENT_AUTOPILOT; 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); }
-"PERMISSION_TELEPORT" { count(); yylval.ival = LSCRIPTRunTimePermissionBits[SCRIPT_PERMISSION_TELEPORT]; return(INTEGER_CONSTANT); }
-"PERMISSION_SILENT_ESTATE_MANAGEMENT" { count(); yylval.ival = LSCRIPTRunTimePermissionBits[SCRIPT_PERMISSION_SILENT_ESTATE_MANAGEMENT]; return(INTEGER_CONSTANT); }
-"PERMISSION_OVERRIDE_ANIMATIONS" { count(); yylval.ival = LSCRIPTRunTimePermissionBits[SCRIPT_PERMISSION_OVERRIDE_ANIMATIONS]; 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 = CHANGED_INVENTORY; return(INTEGER_CONSTANT); }
-"CHANGED_COLOR" { count(); yylval.ival = CHANGED_COLOR; return(INTEGER_CONSTANT); }
-"CHANGED_SHAPE" { count(); yylval.ival = CHANGED_SHAPE; return(INTEGER_CONSTANT); }
-"CHANGED_SCALE" { count(); yylval.ival = CHANGED_SCALE; return(INTEGER_CONSTANT); }
-"CHANGED_TEXTURE" { count(); yylval.ival = CHANGED_TEXTURE; return(INTEGER_CONSTANT); }
-"CHANGED_LINK" { count(); yylval.ival = CHANGED_LINK; return(INTEGER_CONSTANT); }
-"CHANGED_ALLOWED_DROP" { count(); yylval.ival = CHANGED_ALLOWED_DROP; return(INTEGER_CONSTANT); }
-"CHANGED_OWNER" { count(); yylval.ival = CHANGED_OWNER; return(INTEGER_CONSTANT); }
-"CHANGED_REGION" { count(); yylval.ival = CHANGED_REGION; return(INTEGER_CONSTANT); }
-"CHANGED_TELEPORT" { count(); yylval.ival = CHANGED_TELEPORT; return(INTEGER_CONSTANT); }
-"CHANGED_REGION_START" { count(); yylval.ival = CHANGED_REGION_START; return(INTEGER_CONSTANT); }
-"CHANGED_MEDIA" { count(); yylval.ival = CHANGED_MEDIA; return(INTEGER_CONSTANT); }
-
-"OBJECT_UNKNOWN_DETAIL" { count(); yylval.ival = OBJECT_UNKNOWN_DETAIL; return(INTEGER_CONSTANT); }
-"OBJECT_NAME" { count(); yylval.ival = OBJECT_NAME; return(INTEGER_CONSTANT); }
-"OBJECT_DESC" { count(); yylval.ival = OBJECT_DESC; return(INTEGER_CONSTANT); }
-"OBJECT_POS" { count(); yylval.ival = OBJECT_POS; return(INTEGER_CONSTANT); }
-"OBJECT_ROT" { count(); yylval.ival = OBJECT_ROT; return(INTEGER_CONSTANT); }
-"OBJECT_VELOCITY" { count(); yylval.ival = OBJECT_VELOCITY; return(INTEGER_CONSTANT); }
-"OBJECT_OWNER" { count(); yylval.ival = OBJECT_OWNER; return(INTEGER_CONSTANT); }
-"OBJECT_GROUP" { count(); yylval.ival = OBJECT_GROUP; return(INTEGER_CONSTANT); }
-"OBJECT_CREATOR" { count(); yylval.ival = OBJECT_CREATOR; return(INTEGER_CONSTANT); }
-"OBJECT_RUNNING_SCRIPT_COUNT" { count(); yylval.ival = OBJECT_RUNNING_SCRIPT_COUNT; return(INTEGER_CONSTANT); }
-"OBJECT_TOTAL_SCRIPT_COUNT" { count(); yylval.ival = OBJECT_TOTAL_SCRIPT_COUNT; return(INTEGER_CONSTANT); }
-"OBJECT_SCRIPT_MEMORY" { count(); yylval.ival = OBJECT_SCRIPT_MEMORY; return(INTEGER_CONSTANT); }
-"OBJECT_SCRIPT_TIME" { count(); yylval.ival = OBJECT_SCRIPT_TIME; return(INTEGER_CONSTANT); }
-"OBJECT_PRIM_EQUIVALENCE" { count(); yylval.ival = OBJECT_PRIM_EQUIVALENCE; return(INTEGER_CONSTANT); }
-"OBJECT_SERVER_COST" { count(); yylval.ival = OBJECT_SERVER_COST; return(INTEGER_CONSTANT); }
-"OBJECT_STREAMING_COST" { count(); yylval.ival = OBJECT_STREAMING_COST; return(INTEGER_CONSTANT); }
-"OBJECT_PHYSICS_COST" { count(); yylval.ival = OBJECT_PHYSICS_COST; return(INTEGER_CONSTANT); }
-"OBJECT_CHARACTER_TIME" { count(); yylval.ival = OBJECT_CHARACTER_TIME; return(INTEGER_CONSTANT); }
-"OBJECT_ROOT" { count(); yylval.ival = OBJECT_ROOT; return(INTEGER_CONSTANT); }
-"OBJECT_ATTACHED_POINT" { count(); yylval.ival = OBJECT_ATTACHED_POINT; return(INTEGER_CONSTANT); }
-"OBJECT_PATHFINDING_TYPE" { count(); yylval.ival = OBJECT_PATHFINDING_TYPE; return(INTEGER_CONSTANT); }
-"OBJECT_PHYSICS" { count(); yylval.ival = OBJECT_PHYSICS; return(INTEGER_CONSTANT); }
-"OBJECT_PHANTOM" { count(); yylval.ival = OBJECT_PHANTOM; return(INTEGER_CONSTANT); }
-"OBJECT_TEMP_ON_REZ" { count(); yylval.ival = OBJECT_TEMP_ON_REZ; return(INTEGER_CONSTANT); }
-"OBJECT_RENDER_WEIGHT" { count(); yylval.ival = OBJECT_RENDER_WEIGHT; 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); }
-"URL_REQUEST_GRANTED" { yylval.sval = new char[UUID_STR_LENGTH]; strcpy(yylval.sval, URL_REQUEST_GRANTED); return(STRING_CONSTANT); }
-"URL_REQUEST_DENIED" { yylval.sval = new char[UUID_STR_LENGTH]; strcpy(yylval.sval, URL_REQUEST_DENIED); 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); }
-"ATTACH_NECK" { count(); yylval.ival = 39; return(INTEGER_CONSTANT); }
-"ATTACH_AVATAR_CENTER" { count(); yylval.ival = 40; 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_BLEND_FUNC_SOURCE" { count(); yylval.ival = LLPS_PART_BLEND_FUNC_SOURCE; return (INTEGER_CONSTANT); }
-"PSYS_PART_BLEND_FUNC_DEST" { count(); yylval.ival = LLPS_PART_BLEND_FUNC_DEST; return (INTEGER_CONSTANT); }
-"PSYS_PART_START_GLOW" { count(); yylval.ival = LLPS_PART_START_GLOW; return (INTEGER_CONSTANT); }
-"PSYS_PART_END_GLOW" { count(); yylval.ival = LLPS_PART_END_GLOW; 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_PART_RIBBON_MASK" { count(); yylval.ival = LLPartData::LL_PART_RIBBON_MASK; return(INTEGER_CONSTANT); }
-
-"PSYS_PART_BF_ONE" { count(); yylval.ival = LLPartData::LL_PART_BF_ONE; return(INTEGER_CONSTANT); }
-"PSYS_PART_BF_ZERO" { count(); yylval.ival = LLPartData::LL_PART_BF_ZERO; return(INTEGER_CONSTANT); }
-"PSYS_PART_BF_DEST_COLOR" { count(); yylval.ival = LLPartData::LL_PART_BF_DEST_COLOR; return(INTEGER_CONSTANT); }
-"PSYS_PART_BF_SOURCE_COLOR" { count(); yylval.ival = LLPartData::LL_PART_BF_SOURCE_COLOR; return(INTEGER_CONSTANT); }
-"PSYS_PART_BF_ONE_MINUS_DEST_COLOR" { count(); yylval.ival = LLPartData::LL_PART_BF_ONE_MINUS_DEST_COLOR; return(INTEGER_CONSTANT); }
-"PSYS_PART_BF_ONE_MINUS_SOURCE_COLOR" { count(); yylval.ival = LLPartData::LL_PART_BF_ONE_MINUS_SOURCE_COLOR; return(INTEGER_CONSTANT); }
-"PSYS_PART_BF_SOURCE_ALPHA" { count(); yylval.ival = LLPartData::LL_PART_BF_SOURCE_ALPHA; return(INTEGER_CONSTANT); }
-"PSYS_PART_BF_ONE_MINUS_SOURCE_ALPHA" { count(); yylval.ival = LLPartData::LL_PART_BF_ONE_MINUS_SOURCE_ALPHA; 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_GLOW" { count(); yylval.ival = LSL_PRIM_GLOW; return(INTEGER_CONSTANT); }
-"PRIM_TEXT" { count(); yylval.ival = LSL_PRIM_TEXT; return(INTEGER_CONSTANT); }
-"PRIM_NAME" { count(); yylval.ival = LSL_PRIM_NAME; return(INTEGER_CONSTANT); }
-"PRIM_DESC" { count(); yylval.ival = LSL_PRIM_DESC; return(INTEGER_CONSTANT); }
-"PRIM_OMEGA" { count(); yylval.ival = LSL_PRIM_OMEGA; return(INTEGER_CONSTANT); }
-"PRIM_LINK_TARGET" { count(); yylval.ival = LSL_PRIM_LINK_TARGET; return(INTEGER_CONSTANT); }
-"PRIM_SLICE" { count(); yylval.ival = LSL_PRIM_SLICE; return(INTEGER_CONSTANT); }
-
-"PRIM_PHYSICS_SHAPE_PRIM" { count(); yylval.ival = LSL_PRIM_PHYSICS_SHAPE_PRIM; return(INTEGER_CONSTANT); }
-"PRIM_PHYSICS_SHAPE_NONE" { count(); yylval.ival = LSL_PRIM_PHYSICS_SHAPE_NONE; return(INTEGER_CONSTANT); }
-"PRIM_PHYSICS_SHAPE_CONVEX" { count(); yylval.ival = LSL_PRIM_PHYSICS_SHAPE_CONVEX; 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_TYPE_SCULPT" { count(); yylval.ival = LSL_PRIM_TYPE_SCULPT; 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); }
-
-"PRIM_SCULPT_TYPE_SPHERE" { count(); yylval.ival = LSL_PRIM_SCULPT_TYPE_SPHERE; return(INTEGER_CONSTANT); }
-"PRIM_SCULPT_TYPE_TORUS" { count(); yylval.ival = LSL_PRIM_SCULPT_TYPE_TORUS; return(INTEGER_CONSTANT); }
-"PRIM_SCULPT_TYPE_PLANE" { count(); yylval.ival = LSL_PRIM_SCULPT_TYPE_PLANE; return(INTEGER_CONSTANT); }
-"PRIM_SCULPT_TYPE_CYLINDER" { count(); yylval.ival = LSL_PRIM_SCULPT_TYPE_CYLINDER; return(INTEGER_CONSTANT); }
-"PRIM_SCULPT_TYPE_MASK" { count(); yylval.ival = LSL_PRIM_SCULPT_TYPE_MASK; return(INTEGER_CONSTANT); }
-"PRIM_SCULPT_FLAG_MIRROR" { count(); yylval.ival = LSL_PRIM_SCULPT_FLAG_MIRROR; return(INTEGER_CONSTANT); }
-"PRIM_SCULPT_FLAG_INVERT" { count(); yylval.ival = LSL_PRIM_SCULPT_FLAG_INVERT; 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); }
-"PARCEL_MEDIA_COMMAND_TYPE" { count(); yylval.ival = PARCEL_MEDIA_COMMAND_TYPE; return(INTEGER_CONSTANT); }
-"PARCEL_MEDIA_COMMAND_SIZE" { count(); yylval.ival = PARCEL_MEDIA_COMMAND_SIZE; return(INTEGER_CONSTANT); }
-"PARCEL_MEDIA_COMMAND_DESC" { count(); yylval.ival = PARCEL_MEDIA_COMMAND_DESC; return(INTEGER_CONSTANT); }
-"PARCEL_MEDIA_COMMAND_LOOP_SET" { count(); yylval.ival = PARCEL_MEDIA_COMMAND_LOOP_SET; 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_BLOCK_FLYOVER" { count(); yylval.ival = REGION_FLAGS_BLOCK_FLYOVER; 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); }
-"PARCEL_DETAILS_ID" { count(); yylval.ival = PARCEL_DETAILS_ID; return(INTEGER_CONSTANT); }
-"PARCEL_DETAILS_SEE_AVATARS" { count(); yylval.ival = PARCEL_DETAILS_SEE_AVATARS; return(INTEGER_CONSTANT); }
-
-"STRING_TRIM_HEAD" { count(); yylval.ival = STRING_TRIM_HEAD; return(INTEGER_CONSTANT); }
-"STRING_TRIM_TAIL" { count(); yylval.ival = STRING_TRIM_TAIL; return(INTEGER_CONSTANT); }
-"STRING_TRIM" { count(); yylval.ival = STRING_TRIM; return(INTEGER_CONSTANT); }
-
-"CLICK_ACTION_NONE" { count(); yylval.ival = CLICK_ACTION_NONE; return(INTEGER_CONSTANT); }
-"CLICK_ACTION_TOUCH" { count(); yylval.ival = CLICK_ACTION_TOUCH; return(INTEGER_CONSTANT); }
-"CLICK_ACTION_SIT" { count(); yylval.ival = CLICK_ACTION_SIT; return(INTEGER_CONSTANT); }
-"CLICK_ACTION_BUY" { count(); yylval.ival = CLICK_ACTION_BUY; return(INTEGER_CONSTANT); }
-"CLICK_ACTION_PAY" { count(); yylval.ival = CLICK_ACTION_PAY; return(INTEGER_CONSTANT); }
-"CLICK_ACTION_OPEN" { count(); yylval.ival = CLICK_ACTION_OPEN; return(INTEGER_CONSTANT); }
-"CLICK_ACTION_PLAY" { count(); yylval.ival = CLICK_ACTION_PLAY; return(INTEGER_CONSTANT); }
-"CLICK_ACTION_OPEN_MEDIA" { count(); yylval.ival = CLICK_ACTION_OPEN_MEDIA; return(INTEGER_CONSTANT); }
-"CLICK_ACTION_ZOOM" { count(); yylval.ival = CLICK_ACTION_ZOOM; return(INTEGER_CONSTANT); }
-
-"TEXTURE_BLANK" { yylval.sval = new char[UUID_STR_LENGTH]; strcpy(yylval.sval, "5748decc-f629-461c-9a36-a35a221fe21f"); return(STRING_CONSTANT); }
-"TEXTURE_DEFAULT" { yylval.sval = new char[UUID_STR_LENGTH]; strcpy(yylval.sval, "89556747-24cb-43ed-920b-47caed15465f"); return(STRING_CONSTANT); }
-"TEXTURE_MEDIA" { yylval.sval = new char[UUID_STR_LENGTH]; strcpy(yylval.sval, "8b5fec65-8d8d-9dc5-cda8-8fdf2716e361"); return(STRING_CONSTANT); }
-"TEXTURE_PLYWOOD" { yylval.sval = new char[UUID_STR_LENGTH]; strcpy(yylval.sval, "89556747-24cb-43ed-920b-47caed15465f"); return(STRING_CONSTANT); }
-"TEXTURE_TRANSPARENT" { yylval.sval = new char[UUID_STR_LENGTH]; strcpy(yylval.sval, "8dcd4a48-2d37-4909-9f78-f7a9eb4ef903"); return(STRING_CONSTANT); }
-
-"TOUCH_INVALID_FACE" { count(); yylval.ival = -1; return(INTEGER_CONSTANT); }
-"TOUCH_INVALID_VECTOR" { count(); return(TOUCH_INVALID_VECTOR); }
-"TOUCH_INVALID_TEXCOORD" { count(); return(TOUCH_INVALID_TEXCOORD); }
-
-"PRIM_MEDIA_ALT_IMAGE_ENABLE" { count(); yylval.ival = LLMediaEntry::ALT_IMAGE_ENABLE_ID; return(INTEGER_CONSTANT); }
-"PRIM_MEDIA_CONTROLS" { count(); yylval.ival = LLMediaEntry::CONTROLS_ID; return(INTEGER_CONSTANT); }
-"PRIM_MEDIA_CURRENT_URL" { count(); yylval.ival = LLMediaEntry::CURRENT_URL_ID; return(INTEGER_CONSTANT); }
-"PRIM_MEDIA_HOME_URL" { count(); yylval.ival = LLMediaEntry::HOME_URL_ID; return(INTEGER_CONSTANT); }
-"PRIM_MEDIA_AUTO_LOOP" { count(); yylval.ival = LLMediaEntry::AUTO_LOOP_ID; return(INTEGER_CONSTANT); }
-"PRIM_MEDIA_AUTO_PLAY" { count(); yylval.ival = LLMediaEntry::AUTO_PLAY_ID; return(INTEGER_CONSTANT); }
-"PRIM_MEDIA_AUTO_SCALE" { count(); yylval.ival = LLMediaEntry::AUTO_SCALE_ID; return(INTEGER_CONSTANT); }
-"PRIM_MEDIA_AUTO_ZOOM" { count(); yylval.ival = LLMediaEntry::AUTO_ZOOM_ID; return(INTEGER_CONSTANT); }
-"PRIM_MEDIA_FIRST_CLICK_INTERACT" { count(); yylval.ival = LLMediaEntry::FIRST_CLICK_INTERACT_ID; return(INTEGER_CONSTANT); }
-"PRIM_MEDIA_WIDTH_PIXELS" { count(); yylval.ival = LLMediaEntry::WIDTH_PIXELS_ID; return(INTEGER_CONSTANT); }
-"PRIM_MEDIA_HEIGHT_PIXELS" { count(); yylval.ival = LLMediaEntry::HEIGHT_PIXELS_ID; return(INTEGER_CONSTANT); }
-"PRIM_MEDIA_WHITELIST_ENABLE" { count(); yylval.ival = LLMediaEntry::WHITELIST_ENABLE_ID; return(INTEGER_CONSTANT); }
-"PRIM_MEDIA_WHITELIST" { count(); yylval.ival = LLMediaEntry::WHITELIST_ID; return(INTEGER_CONSTANT); }
-"PRIM_MEDIA_PERMS_INTERACT" { count(); yylval.ival = LLMediaEntry::PERMS_INTERACT_ID; return(INTEGER_CONSTANT); }
-"PRIM_MEDIA_PERMS_CONTROL" { count(); yylval.ival = LLMediaEntry::PERMS_CONTROL_ID; return(INTEGER_CONSTANT); }
-"PRIM_MEDIA_PARAM_MAX" { count(); yylval.ival = LLMediaEntry::PARAM_MAX_ID; return(INTEGER_CONSTANT); }
-
-"PRIM_MEDIA_CONTROLS_STANDARD" { count(); yylval.ival = LLMediaEntry::STANDARD; return(INTEGER_CONSTANT); }
-"PRIM_MEDIA_CONTROLS_MINI" { count(); yylval.ival = LLMediaEntry::MINI; return(INTEGER_CONSTANT); }
-
-"PRIM_MEDIA_PERM_NONE" { count(); yylval.ival = LLMediaEntry::PERM_NONE; return(INTEGER_CONSTANT); }
-"PRIM_MEDIA_PERM_OWNER" { count(); yylval.ival = LLMediaEntry::PERM_OWNER; return(INTEGER_CONSTANT); }
-"PRIM_MEDIA_PERM_GROUP" { count(); yylval.ival = LLMediaEntry::PERM_GROUP; return(INTEGER_CONSTANT); }
-"PRIM_MEDIA_PERM_ANYONE" { count(); yylval.ival = LLMediaEntry::PERM_ANYONE; return(INTEGER_CONSTANT); }
-
-"PRIM_MEDIA_MAX_URL_LENGTH" { count(); yylval.ival = LLMediaEntry::MAX_URL_LENGTH; return(INTEGER_CONSTANT); }
-"PRIM_MEDIA_MAX_WHITELIST_SIZE" { count(); yylval.ival = LLMediaEntry::MAX_WHITELIST_SIZE; return(INTEGER_CONSTANT); }
-"PRIM_MEDIA_MAX_WHITELIST_COUNT" { count(); yylval.ival = LLMediaEntry::MAX_WHITELIST_COUNT; return(INTEGER_CONSTANT); }
-"PRIM_MEDIA_MAX_WIDTH_PIXELS" { count(); yylval.ival = LLMediaEntry::MAX_WIDTH_PIXELS; return(INTEGER_CONSTANT); }
-"PRIM_MEDIA_MAX_HEIGHT_PIXELS" { count(); yylval.ival = LLMediaEntry::MAX_HEIGHT_PIXELS; return(INTEGER_CONSTANT); }
-
-"STATUS_OK" { count(); yylval.ival = LSL_STATUS_OK; return(INTEGER_CONSTANT); }
-"STATUS_MALFORMED_PARAMS" { count(); yylval.ival = LSL_STATUS_MALFORMED_PARAMS; return(INTEGER_CONSTANT); }
-"STATUS_TYPE_MISMATCH" { count(); yylval.ival = LSL_STATUS_TYPE_MISMATCH; return(INTEGER_CONSTANT); }
-"STATUS_BOUNDS_ERROR" { count(); yylval.ival = LSL_STATUS_BOUNDS_ERROR; return(INTEGER_CONSTANT); }
-"STATUS_NOT_FOUND" { count(); yylval.ival = LSL_STATUS_NOT_FOUND; return(INTEGER_CONSTANT); }
-"STATUS_NOT_SUPPORTED" { count(); yylval.ival = LSL_STATUS_NOT_SUPPORTED; return(INTEGER_CONSTANT); }
-"STATUS_INTERNAL_ERROR" { count(); yylval.ival = LSL_STATUS_INTERNAL_ERROR; return(INTEGER_CONSTANT); }
-"STATUS_WHITELIST_FAILED" { count(); yylval.ival = LSL_STATUS_WHITELIST_FAILED; return(INTEGER_CONSTANT); }
-
-{L}({L}|{N})* { count(); yylval.sval = new char[strlen(yytext) + 1]; strcpy(yylval.sval, yytext); return(IDENTIFIER); }
-
-{N}+{E} { count(); yylval.fval = (F32)atof(yytext); return(FP_CONSTANT); }
-{N}*"."{N}+({E})?{FS}? { count(); yylval.fval = (F32)atof(yytext); return(FP_CONSTANT); }
-{N}+"."{N}*({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 EMERGENCY_DEBUG_PRINTOUTS
-//#define EMIT_CIL_ASSEMBLER
-
-BOOL lscript_compile(const char* src_filename, const char* dst_filename,
- const char* err_filename, BOOL compile_to_mono, const char* class_name, 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(std::string(src_filename), "r");
- if (yyin)
- {
- yyout = LLFile::fopen(std::string(err_filename), "w");
-
- // Reset the lexer's internal buffering.
-
- yyrestart(yyin);
-
- b_parse_ok = !yyparse();
-
- if (b_parse_ok)
- {
-#ifdef EMERGENCY_DEBUG_PRINTOUTS
- char compiled[256];
- sprintf(compiled, "%s.o", src_filename);
- LLFILE* compfile;
- compfile = LLFile::fopen(compiled, "w");
-#endif
-
- if(dst_filename)
- {
- gScriptp->setBytecodeDest(dst_filename);
- }
-
- gScriptp->mGodLike = is_god_like;
-
- gScriptp->setClassName(class_name);
-
- 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
- if(TRUE == compile_to_mono)
- {
- gScriptp->recurse(yyout, 0, 0, LSCP_EMIT_CIL_ASSEMBLY, LSPRUNE_INVALID, b_dummy, NULL, type, type, b_dummy_count, NULL, NULL, 0, NULL, 0, NULL);
- }
- else
- {
- 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 compile_to_mono, 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);
- char class_name[MAX_STRING];
- sprintf(class_name, "%s", filename);
- return lscript_compile(src_filename, NULL, err_filename, compile_to_mono, class_name, is_god_like);
-}
-
-
-S32 yywrap()
-{
-#if defined(FLEX_SCANNER) && !defined(LL_WINDOWS)
- // get gcc to stop complaining about lack of use of yyunput
- (void) yyunput;
-#endif
- return(1);
-}
-
-void line_comment()
-{
- char c;
-
- while ((c = yyinput()) != '\n' && c != 0 && c != EOF)
- ;
-}
-
-void block_comment()
-{
- char c1 = 0;
- char c2 = yyinput();
- while (c2 != 0 && c2 != EOF && !(c1 == '*' && c2 == '/')) {
- if (c2 == '\n')
- {
- gInternalLine++;
- gInternalColumn = 0;
- }
- else if (c2 == '\t')
- gInternalColumn += 4 - (gInternalColumn % 8);
- else
- gInternalColumn++;
- c1 = c2;
- c2 = yyinput();
- }
-}
-
-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
deleted file mode 100755
index a0a034d21c..0000000000
--- a/indra/lscript/lscript_compile/indra.y
+++ /dev/null
@@ -1,1791 +0,0 @@
-%{
- #include "linden_common.h"
- #include "lscript_tree.h"
-
- int yylex(void);
- int yyparse( void );
- int yyerror(const char *fmt, ...);
-
- #if LL_LINUX
- // broken yacc codegen... --ryan.
- #define getenv getenv_workaround
- #endif
-
- #ifdef LL_WINDOWS
- #pragma warning (disable : 4702) // warning C4702: unreachable code
- #pragma warning( disable : 4065 ) // warning: switch statement contains 'default' but no 'case' labels
- #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
-%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 HTTP_REQUEST
-
-%token <sval> IDENTIFIER
-%token <sval> STATE_DEFAULT
-
-%token <ival> INTEGER_CONSTANT
-%token <ival> INTEGER_TRUE
-%token <ival> INTEGER_FALSE
-
-%token <fval> FP_CONSTANT
-
-%token <sval> 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
-
-%token TOUCH_INVALID_VECTOR
-%token TOUCH_INVALID_TEXCOORD
-
-%nonassoc LOWER_THAN_ELSE
-%nonassoc ELSE
-
-
-%type <script> lscript_program
-%type <global_store> globals
-%type <global_store> global
-%type <global> global_variable
-%type <assignable> simple_assignable
-%type <assignable> simple_assignable_no_list
-%type <constant> constant
-%type <ival> integer_constant
-%type <fval> fp_constant
-%type <assignable> special_constant
-%type <assignable> vector_constant
-%type <assignable> quaternion_constant
-%type <assignable> list_constant
-%type <assignable> list_entries
-%type <assignable> list_entry
-%type <type> typename
-%type <global_funcs> global_function
-%type <global_decl> function_parameters
-%type <global_decl> function_parameter
-%type <state> states
-%type <state> other_states
-%type <state> default
-%type <state> state
-%type <handler> state_body
-%type <handler> event
-%type <event> state_entry
-%type <event> state_exit
-%type <event> touch_start
-%type <event> touch
-%type <event> touch_end
-%type <event> collision_start
-%type <event> collision
-%type <event> collision_end
-%type <event> land_collision_start
-%type <event> land_collision
-%type <event> land_collision_end
-%type <event> at_target
-%type <event> not_at_target
-%type <event> at_rot_target
-%type <event> not_at_rot_target
-%type <event> money
-%type <event> email
-%type <event> run_time_permissions
-%type <event> inventory
-%type <event> attach
-%type <event> dataserver
-%type <event> moving_start
-%type <event> moving_end
-%type <event> rez
-%type <event> object_rez
-%type <event> remote_data
-%type <event> http_response
-%type <event> http_request
-%type <event> link_message
-%type <event> timer
-%type <event> chat
-%type <event> sensor
-%type <event> no_sensor
-%type <event> control
-%type <statement> compound_statement
-%type <statement> statement
-%type <statement> statements
-%type <statement> declaration
-%type <statement> ';'
-%type <statement> '@'
-%type <expression> nextforexpressionlist
-%type <expression> forexpressionlist
-%type <expression> nextfuncexpressionlist
-%type <expression> funcexpressionlist
-%type <expression> nextlistexpressionlist
-%type <expression> listexpressionlist
-%type <expression> unarypostfixexpression
-%type <expression> vector_initializer
-%type <expression> quaternion_initializer
-%type <expression> list_initializer
-%type <expression> lvalue
-%type <expression> '-'
-%type <expression> '!'
-%type <expression> '~'
-%type <expression> '='
-%type <expression> '<'
-%type <expression> '>'
-%type <expression> '+'
-%type <expression> '*'
-%type <expression> '/'
-%type <expression> '%'
-%type <expression> '&'
-%type <expression> '|'
-%type <expression> '^'
-%type <expression> ADD_ASSIGN
-%type <expression> SUB_ASSIGN
-%type <expression> MUL_ASSIGN
-%type <expression> DIV_ASSIGN
-%type <expression> MOD_ASSIGN
-%type <expression> EQ
-%type <expression> NEQ
-%type <expression> LEQ
-%type <expression> GEQ
-%type <expression> BOOLEAN_AND
-%type <expression> BOOLEAN_OR
-%type <expression> SHIFT_LEFT
-%type <expression> SHIFT_RIGHT
-%type <expression> INC_OP
-%type <expression> DEC_OP
-%type <expression> '('
-%type <expression> ')'
-%type <expression> PRINT
-%type <identifier> name_type
-%type <expression> expression
-%type <expression> unaryexpression
-%type <expression> typecast
-
-%right '=' MUL_ASSIGN DIV_ASSIGN MOD_ASSIGN ADD_ASSIGN SUB_ASSIGN
-%left BOOLEAN_AND BOOLEAN_OR
-%left '|'
-%left '^'
-%left '&'
-%left EQ NEQ
-%left '<' LEQ '>' GEQ
-%left SHIFT_LEFT SHIFT_RIGHT
-%left '+' '-'
-%left '*' '/' '%'
-%right '!' '~' INC_OP DEC_OP
-%nonassoc INITIALIZER
-
-%%
-
-lscript_program
- : globals states
- {
- $$ = new LLScriptScript($1, $2);
- gAllocationManager->addAllocation($$);
- gScriptp = $$;
- }
- | states
- {
- $$ = new LLScriptScript(NULL, $1);
- gAllocationManager->addAllocation($$);
- gScriptp = $$;
- }
- ;
-
-globals
- : global
- {
- $$ = $1;
- }
- | global globals
- {
- $$ = $1;
- $1->addGlobal($2);
- }
- ;
-
-global
- : global_variable
- {
- $$ = new LLScritpGlobalStorage($1);
- gAllocationManager->addAllocation($$);
- }
- | global_function
- {
- $$ = new LLScritpGlobalStorage($1);
- gAllocationManager->addAllocation($$);
- }
- ;
-
-name_type
- : typename IDENTIFIER
- {
- $$ = new LLScriptIdentifier(gLine, gColumn, $2, $1);
- gAllocationManager->addAllocation($$);
- }
- ;
-
-global_variable
- : name_type ';'
- {
- $$ = new LLScriptGlobalVariable(gLine, gColumn, $1->mType, $1, NULL);
- gAllocationManager->addAllocation($$);
- }
- | name_type '=' simple_assignable ';'
- {
- $$ = new LLScriptGlobalVariable(gLine, gColumn, $1->mType, $1, $3);
- gAllocationManager->addAllocation($$);
- }
- ;
-
-simple_assignable
- : simple_assignable_no_list
- {
- $$ = $1;
- }
- | list_constant
- {
- $$ = $1;
- }
- ;
-
-simple_assignable_no_list
- : IDENTIFIER
- {
- LLScriptIdentifier *id = new LLScriptIdentifier(gLine, gColumn, $1);
- gAllocationManager->addAllocation(id);
- $$ = new LLScriptSAIdentifier(gLine, gColumn, id);
- gAllocationManager->addAllocation($$);
- }
- | constant
- {
- $$ = new LLScriptSAConstant(gLine, gColumn, $1);
- gAllocationManager->addAllocation($$);
- }
- | special_constant
- {
- $$ = $1;
- }
- ;
-
-constant
- : integer_constant
- {
- $$ = new LLScriptConstantInteger(gLine, gColumn, $1);
- gAllocationManager->addAllocation($$);
- }
- | fp_constant
- {
- $$ = new LLScriptConstantFloat(gLine, gColumn, $1);
- gAllocationManager->addAllocation($$);
- }
- | STRING_CONSTANT
- {
- $$ = new LLScriptConstantString(gLine, gColumn, $1);
- gAllocationManager->addAllocation($$);
- }
- ;
-
-fp_constant
- : FP_CONSTANT
- {
- $$ = $1;
- }
- | '-' FP_CONSTANT
- {
- $$ = -$2;
- }
- ;
-
-integer_constant
- : INTEGER_CONSTANT
- {
- $$ = $1;
- }
- | INTEGER_TRUE
- {
- $$ = $1;
- }
- | INTEGER_FALSE
- {
- $$ = $1;
- }
- | '-' INTEGER_CONSTANT
- {
- $$ = -$2;
- }
- ;
-
-special_constant
- : vector_constant
- {
- $$ = $1;
- }
- | quaternion_constant
- {
- $$ = $1;
- }
- ;
-
-vector_constant
- : '<' simple_assignable ',' simple_assignable ',' simple_assignable '>'
- {
- $$ = new LLScriptSAVector(gLine, gColumn, $2, $4, $6);
- gAllocationManager->addAllocation($$);
- }
- | ZERO_VECTOR
- {
- LLScriptConstantFloat *cf0 = new LLScriptConstantFloat(gLine, gColumn, 0.f);
- gAllocationManager->addAllocation(cf0);
- LLScriptSAConstant *sa0 = new LLScriptSAConstant(gLine, gColumn, cf0);
- gAllocationManager->addAllocation(sa0);
- LLScriptConstantFloat *cf1 = new LLScriptConstantFloat(gLine, gColumn, 0.f);
- gAllocationManager->addAllocation(cf1);
- LLScriptSAConstant *sa1 = new LLScriptSAConstant(gLine, gColumn, cf1);
- gAllocationManager->addAllocation(sa1);
- LLScriptConstantFloat *cf2 = new LLScriptConstantFloat(gLine, gColumn, 0.f);
- gAllocationManager->addAllocation(cf2);
- LLScriptSAConstant *sa2 = new LLScriptSAConstant(gLine, gColumn, cf2);
- gAllocationManager->addAllocation(sa2);
- $$ = new LLScriptSAVector(gLine, gColumn, sa0, sa1, sa2);
- gAllocationManager->addAllocation($$);
- }
- | TOUCH_INVALID_VECTOR
- {
- LLScriptConstantFloat *cf0 = new LLScriptConstantFloat(gLine, gColumn, 0.f);
- gAllocationManager->addAllocation(cf0);
- LLScriptSAConstant *sa0 = new LLScriptSAConstant(gLine, gColumn, cf0);
- gAllocationManager->addAllocation(sa0);
- LLScriptConstantFloat *cf1 = new LLScriptConstantFloat(gLine, gColumn, 0.f);
- gAllocationManager->addAllocation(cf1);
- LLScriptSAConstant *sa1 = new LLScriptSAConstant(gLine, gColumn, cf1);
- gAllocationManager->addAllocation(sa1);
- LLScriptConstantFloat *cf2 = new LLScriptConstantFloat(gLine, gColumn, 0.f);
- gAllocationManager->addAllocation(cf2);
- LLScriptSAConstant *sa2 = new LLScriptSAConstant(gLine, gColumn, cf2);
- gAllocationManager->addAllocation(sa2);
- $$ = new LLScriptSAVector(gLine, gColumn, sa0, sa1, sa2);
- gAllocationManager->addAllocation($$);
- }
- | TOUCH_INVALID_TEXCOORD
- {
- LLScriptConstantFloat *cf0 = new LLScriptConstantFloat(gLine, gColumn, -1.f);
- gAllocationManager->addAllocation(cf0);
- LLScriptSAConstant *sa0 = new LLScriptSAConstant(gLine, gColumn, cf0);
- gAllocationManager->addAllocation(sa0);
- LLScriptConstantFloat *cf1 = new LLScriptConstantFloat(gLine, gColumn, -1.f);
- gAllocationManager->addAllocation(cf1);
- LLScriptSAConstant *sa1 = new LLScriptSAConstant(gLine, gColumn, cf1);
- gAllocationManager->addAllocation(sa1);
- LLScriptConstantFloat *cf2 = new LLScriptConstantFloat(gLine, gColumn, 0.f);
- gAllocationManager->addAllocation(cf2);
- LLScriptSAConstant *sa2 = new LLScriptSAConstant(gLine, gColumn, cf2);
- gAllocationManager->addAllocation(sa2);
- $$ = new LLScriptSAVector(gLine, gColumn, sa0, sa1, sa2);
- gAllocationManager->addAllocation($$);
- }
- ;
-
-quaternion_constant
- : '<' simple_assignable ',' simple_assignable ',' simple_assignable ',' simple_assignable '>'
- {
- $$ = new LLScriptSAQuaternion(gLine, gColumn, $2, $4, $6, $8);
- gAllocationManager->addAllocation($$);
- }
- | ZERO_ROTATION
- {
- LLScriptConstantFloat *cf0 = new LLScriptConstantFloat(gLine, gColumn, 0.f);
- gAllocationManager->addAllocation(cf0);
- LLScriptSAConstant *sa0 = new LLScriptSAConstant(gLine, gColumn, cf0);
- gAllocationManager->addAllocation(sa0);
- LLScriptConstantFloat *cf1 = new LLScriptConstantFloat(gLine, gColumn, 0.f);
- gAllocationManager->addAllocation(cf1);
- LLScriptSAConstant *sa1 = new LLScriptSAConstant(gLine, gColumn, cf1);
- gAllocationManager->addAllocation(sa1);
- LLScriptConstantFloat *cf2 = new LLScriptConstantFloat(gLine, gColumn, 0.f);
- gAllocationManager->addAllocation(cf2);
- LLScriptSAConstant *sa2 = new LLScriptSAConstant(gLine, gColumn, cf2);
- gAllocationManager->addAllocation(sa2);
- LLScriptConstantFloat *cf3 = new LLScriptConstantFloat(gLine, gColumn, 1.f);
- gAllocationManager->addAllocation(cf3);
- LLScriptSAConstant *sa3 = new LLScriptSAConstant(gLine, gColumn, cf3);
- gAllocationManager->addAllocation(sa3);
- $$ = new LLScriptSAQuaternion(gLine, gColumn, sa0, sa1, sa2, sa3);
- gAllocationManager->addAllocation($$);
- }
- ;
-
-list_constant
- : '[' list_entries ']'
- {
- $$ = new LLScriptSAList(gLine, gColumn, $2);
- gAllocationManager->addAllocation($$);
- }
- | '[' ']'
- {
- $$ = new LLScriptSAList(gLine, gColumn, NULL);
- gAllocationManager->addAllocation($$);
- }
- ;
-
-list_entries
- : list_entry
- {
- $$ = $1;
- }
- | list_entry ',' list_entries
- {
- $$ = $1;
- $1->addAssignable($3);
- }
- ;
-
-list_entry
- : simple_assignable_no_list
- {
- $$ = $1;
- }
- ;
-
-typename
- : INTEGER
- {
- $$ = new LLScriptType(gLine, gColumn, LST_INTEGER);
- gAllocationManager->addAllocation($$);
- }
- | FLOAT_TYPE
- {
- $$ = new LLScriptType(gLine, gColumn, LST_FLOATINGPOINT);
- gAllocationManager->addAllocation($$);
- }
- | STRING
- {
- $$ = new LLScriptType(gLine, gColumn, LST_STRING);
- gAllocationManager->addAllocation($$);
- }
- | LLKEY
- {
- $$ = new LLScriptType(gLine, gColumn, LST_KEY);
- gAllocationManager->addAllocation($$);
- }
- | VECTOR
- {
- $$ = new LLScriptType(gLine, gColumn, LST_VECTOR);
- gAllocationManager->addAllocation($$);
- }
- | QUATERNION
- {
- $$ = new LLScriptType(gLine, gColumn, LST_QUATERNION);
- gAllocationManager->addAllocation($$);
- }
- | LIST
- {
- $$ = new LLScriptType(gLine, gColumn, LST_LIST);
- gAllocationManager->addAllocation($$);
- }
- ;
-
-global_function
- : IDENTIFIER '(' ')' compound_statement
- {
- LLScriptIdentifier *id = new LLScriptIdentifier(gLine, gColumn, $1);
- gAllocationManager->addAllocation(id);
- $$ = new LLScriptGlobalFunctions(gLine, gColumn, NULL, id, NULL, $4);
- gAllocationManager->addAllocation($$);
- }
- | name_type '(' ')' compound_statement
- {
- $$ = new LLScriptGlobalFunctions(gLine, gColumn, $1->mType, $1, NULL, $4);
- gAllocationManager->addAllocation($$);
- }
- | IDENTIFIER '(' function_parameters ')' compound_statement
- {
- LLScriptIdentifier *id = new LLScriptIdentifier(gLine, gColumn, $1);
- gAllocationManager->addAllocation(id);
- $$ = new LLScriptGlobalFunctions(gLine, gColumn, NULL, id, $3, $5);
- gAllocationManager->addAllocation($$);
- }
- | name_type '(' function_parameters ')' compound_statement
- {
- $$ = new LLScriptGlobalFunctions(gLine, gColumn, $1->mType, $1, $3, $5);
- gAllocationManager->addAllocation($$);
- }
- ;
-
-function_parameters
- : function_parameter
- {
- $$ = $1;
- }
- | function_parameter ',' function_parameters
- {
- $$ = $1;
- $1->addFunctionParameter($3);
- }
- ;
-
-function_parameter
- : typename IDENTIFIER
- {
- LLScriptIdentifier *id = new LLScriptIdentifier(gLine, gColumn, $2);
- gAllocationManager->addAllocation(id);
- $$ = new LLScriptFunctionDec(gLine, gColumn, $1, id);
- gAllocationManager->addAllocation($$);
- }
- ;
-
-states
- : default
- {
- $$ = $1;
- }
- | default other_states
- {
- $$ = $1;
- $1->mNextp = $2;
- }
- ;
-
-other_states
- : state
- {
- $$ = $1;
- }
- | state other_states
- {
- $$ = $1;
- $1->addState($2);
- }
- ;
-
-default
- : STATE_DEFAULT '{' state_body '}'
- {
- LLScriptIdentifier *id = new LLScriptIdentifier(gLine, gColumn, $1);
- gAllocationManager->addAllocation(id);
- $$ = new LLScriptState(gLine, gColumn, LSSTYPE_DEFAULT, id, $3);
- gAllocationManager->addAllocation($$);
- }
- ;
-
-state
- : STATE IDENTIFIER '{' state_body '}'
- {
- LLScriptIdentifier *id = new LLScriptIdentifier(gLine, gColumn, $2);
- gAllocationManager->addAllocation(id);
- $$ = new LLScriptState(gLine, gColumn, LSSTYPE_USER, id, $4);
- gAllocationManager->addAllocation($$);
- }
- ;
-
-state_body
- : event
- {
- $$ = $1;
- }
- | event state_body
- {
- $$ = $1;
- $1->addEvent($2);
- }
- ;
-
-event
- : state_entry compound_statement
- {
- $$ = new LLScriptEventHandler(gLine, gColumn, $1, $2);
- gAllocationManager->addAllocation($$);
- }
- | state_exit compound_statement
- {
- $$ = new LLScriptEventHandler(gLine, gColumn, $1, $2);
- gAllocationManager->addAllocation($$);
- }
- | touch_start compound_statement
- {
- $$ = new LLScriptEventHandler(gLine, gColumn, $1, $2);
- gAllocationManager->addAllocation($$);
- }
- | touch compound_statement
- {
- $$ = new LLScriptEventHandler(gLine, gColumn, $1, $2);
- gAllocationManager->addAllocation($$);
- }
- | touch_end compound_statement
- {
- $$ = new LLScriptEventHandler(gLine, gColumn, $1, $2);
- gAllocationManager->addAllocation($$);
- }
- | collision_start compound_statement
- {
- $$ = new LLScriptEventHandler(gLine, gColumn, $1, $2);
- gAllocationManager->addAllocation($$);
- }
- | collision compound_statement
- {
- $$ = new LLScriptEventHandler(gLine, gColumn, $1, $2);
- gAllocationManager->addAllocation($$);
- }
- | collision_end compound_statement
- {
- $$ = new LLScriptEventHandler(gLine, gColumn, $1, $2);
- gAllocationManager->addAllocation($$);
- }
- | land_collision_start compound_statement
- {
- $$ = new LLScriptEventHandler(gLine, gColumn, $1, $2);
- gAllocationManager->addAllocation($$);
- }
- | land_collision compound_statement
- {
- $$ = new LLScriptEventHandler(gLine, gColumn, $1, $2);
- gAllocationManager->addAllocation($$);
- }
- | land_collision_end compound_statement
- {
- $$ = new LLScriptEventHandler(gLine, gColumn, $1, $2);
- gAllocationManager->addAllocation($$);
- }
- | timer compound_statement
- {
- $$ = new LLScriptEventHandler(gLine, gColumn, $1, $2);
- gAllocationManager->addAllocation($$);
- }
- | chat compound_statement
- {
- $$ = new LLScriptEventHandler(gLine, gColumn, $1, $2);
- gAllocationManager->addAllocation($$);
- }
- | sensor compound_statement
- {
- $$ = new LLScriptEventHandler(gLine, gColumn, $1, $2);
- gAllocationManager->addAllocation($$);
- }
- | no_sensor compound_statement
- {
- $$ = new LLScriptEventHandler(gLine, gColumn, $1, $2);
- gAllocationManager->addAllocation($$);
- }
- | at_target compound_statement
- {
- $$ = new LLScriptEventHandler(gLine, gColumn, $1, $2);
- gAllocationManager->addAllocation($$);
- }
- | not_at_target compound_statement
- {
- $$ = new LLScriptEventHandler(gLine, gColumn, $1, $2);
- gAllocationManager->addAllocation($$);
- }
- | at_rot_target compound_statement
- {
- $$ = new LLScriptEventHandler(gLine, gColumn, $1, $2);
- gAllocationManager->addAllocation($$);
- }
- | not_at_rot_target compound_statement
- {
- $$ = new LLScriptEventHandler(gLine, gColumn, $1, $2);
- gAllocationManager->addAllocation($$);
- }
- | money compound_statement
- {
- $$ = new LLScriptEventHandler(gLine, gColumn, $1, $2);
- gAllocationManager->addAllocation($$);
- }
- | email compound_statement
- {
- $$ = new LLScriptEventHandler(gLine, gColumn, $1, $2);
- gAllocationManager->addAllocation($$);
- }
- | run_time_permissions compound_statement
- {
- $$ = new LLScriptEventHandler(gLine, gColumn, $1, $2);
- gAllocationManager->addAllocation($$);
- }
- | inventory compound_statement
- {
- $$ = new LLScriptEventHandler(gLine, gColumn, $1, $2);
- gAllocationManager->addAllocation($$);
- }
- | attach compound_statement
- {
- $$ = new LLScriptEventHandler(gLine, gColumn, $1, $2);
- gAllocationManager->addAllocation($$);
- }
- | dataserver compound_statement
- {
- $$ = new LLScriptEventHandler(gLine, gColumn, $1, $2);
- gAllocationManager->addAllocation($$);
- }
- | control compound_statement
- {
- $$ = new LLScriptEventHandler(gLine, gColumn, $1, $2);
- gAllocationManager->addAllocation($$);
- }
- | moving_start compound_statement
- {
- $$ = new LLScriptEventHandler(gLine, gColumn, $1, $2);
- gAllocationManager->addAllocation($$);
- }
- | moving_end compound_statement
- {
- $$ = new LLScriptEventHandler(gLine, gColumn, $1, $2);
- gAllocationManager->addAllocation($$);
- }
- | rez compound_statement
- {
- $$ = new LLScriptEventHandler(gLine, gColumn, $1, $2);
- gAllocationManager->addAllocation($$);
- }
- | object_rez compound_statement
- {
- $$ = new LLScriptEventHandler(gLine, gColumn, $1, $2);
- gAllocationManager->addAllocation($$);
- }
- | link_message compound_statement
- {
- $$ = new LLScriptEventHandler(gLine, gColumn, $1, $2);
- gAllocationManager->addAllocation($$);
- }
- | remote_data compound_statement
- {
- $$ = new LLScriptEventHandler(gLine, gColumn, $1, $2);
- gAllocationManager->addAllocation($$);
- }
- | http_response compound_statement
- {
- $$ = new LLScriptEventHandler(gLine, gColumn, $1, $2);
- gAllocationManager->addAllocation($$);
- }
- | http_request compound_statement
- {
- $$ = new LLScriptEventHandler(gLine, gColumn, $1, $2);
- gAllocationManager->addAllocation($$);
- }
- ;
-
-state_entry
- : STATE_ENTRY '(' ')'
- {
- $$ = new LLScriptStateEntryEvent(gLine, gColumn);
- gAllocationManager->addAllocation($$);
- }
- ;
-
-state_exit
- : STATE_EXIT '(' ')'
- {
- $$ = new LLScriptStateExitEvent(gLine, gColumn);
- gAllocationManager->addAllocation($$);
- }
- ;
-
-touch_start
- : TOUCH_START '(' INTEGER IDENTIFIER ')'
- {
- LLScriptIdentifier *id1 = new LLScriptIdentifier(gLine, gColumn, $4);
- gAllocationManager->addAllocation(id1);
- $$ = new LLScriptTouchStartEvent(gLine, gColumn, id1);
- gAllocationManager->addAllocation($$);
- }
- ;
-
-touch
- : TOUCH '(' INTEGER IDENTIFIER ')'
- {
- LLScriptIdentifier *id1 = new LLScriptIdentifier(gLine, gColumn, $4);
- gAllocationManager->addAllocation(id1);
- $$ = new LLScriptTouchEvent(gLine, gColumn, id1);
- gAllocationManager->addAllocation($$);
- }
- ;
-
-touch_end
- : TOUCH_END '(' INTEGER IDENTIFIER ')'
- {
- LLScriptIdentifier *id1 = new LLScriptIdentifier(gLine, gColumn, $4);
- gAllocationManager->addAllocation(id1);
- $$ = new LLScriptTouchEndEvent(gLine, gColumn, id1);
- gAllocationManager->addAllocation($$);
- }
- ;
-
-collision_start
- : COLLISION_START '(' INTEGER IDENTIFIER ')'
- {
- LLScriptIdentifier *id1 = new LLScriptIdentifier(gLine, gColumn, $4);
- gAllocationManager->addAllocation(id1);
- $$ = new LLScriptCollisionStartEvent(gLine, gColumn, id1);
- gAllocationManager->addAllocation($$);
- }
- ;
-
-collision
- : COLLISION '(' INTEGER IDENTIFIER ')'
- {
- LLScriptIdentifier *id1 = new LLScriptIdentifier(gLine, gColumn, $4);
- gAllocationManager->addAllocation(id1);
- $$ = new LLScriptCollisionEvent(gLine, gColumn, id1);
- gAllocationManager->addAllocation($$);
- }
- ;
-
-collision_end
- : COLLISION_END '(' INTEGER IDENTIFIER ')'
- {
- LLScriptIdentifier *id1 = new LLScriptIdentifier(gLine, gColumn, $4);
- gAllocationManager->addAllocation(id1);
- $$ = new LLScriptCollisionEndEvent(gLine, gColumn, id1);
- gAllocationManager->addAllocation($$);
- }
- ;
-
-land_collision_start
- : LAND_COLLISION_START '(' VECTOR IDENTIFIER ')'
- {
- LLScriptIdentifier *id1 = new LLScriptIdentifier(gLine, gColumn, $4);
- gAllocationManager->addAllocation(id1);
- $$ = new LLScriptLandCollisionStartEvent(gLine, gColumn, id1);
- gAllocationManager->addAllocation($$);
- }
- ;
-
-land_collision
- : LAND_COLLISION '(' VECTOR IDENTIFIER ')'
- {
- LLScriptIdentifier *id1 = new LLScriptIdentifier(gLine, gColumn, $4);
- gAllocationManager->addAllocation(id1);
- $$ = new LLScriptLandCollisionEvent(gLine, gColumn, id1);
- gAllocationManager->addAllocation($$);
- }
- ;
-
-land_collision_end
- : LAND_COLLISION_END '(' VECTOR IDENTIFIER ')'
- {
- LLScriptIdentifier *id1 = new LLScriptIdentifier(gLine, gColumn, $4);
- gAllocationManager->addAllocation(id1);
- $$ = new LLScriptLandCollisionEndEvent(gLine, gColumn, id1);
- gAllocationManager->addAllocation($$);
- }
- ;
-
-at_target
- : AT_TARGET '(' INTEGER IDENTIFIER ',' VECTOR IDENTIFIER ',' VECTOR IDENTIFIER ')'
- {
- LLScriptIdentifier *id1 = new LLScriptIdentifier(gLine, gColumn, $4);
- gAllocationManager->addAllocation(id1);
- LLScriptIdentifier *id2 = new LLScriptIdentifier(gLine, gColumn, $7);
- gAllocationManager->addAllocation(id2);
- LLScriptIdentifier *id3 = new LLScriptIdentifier(gLine, gColumn, $10);
- gAllocationManager->addAllocation(id3);
- $$ = new LLScriptAtTarget(gLine, gColumn, id1, id2, id3);
- gAllocationManager->addAllocation($$);
- }
- ;
-
-not_at_target
- : NOT_AT_TARGET '(' ')'
- {
- $$ = new LLScriptNotAtTarget(gLine, gColumn);
- gAllocationManager->addAllocation($$);
- }
- ;
-
-at_rot_target
- : AT_ROT_TARGET '(' INTEGER IDENTIFIER ',' QUATERNION IDENTIFIER ',' QUATERNION IDENTIFIER ')'
- {
- LLScriptIdentifier *id1 = new LLScriptIdentifier(gLine, gColumn, $4);
- gAllocationManager->addAllocation(id1);
- LLScriptIdentifier *id2 = new LLScriptIdentifier(gLine, gColumn, $7);
- gAllocationManager->addAllocation(id2);
- LLScriptIdentifier *id3 = new LLScriptIdentifier(gLine, gColumn, $10);
- gAllocationManager->addAllocation(id3);
- $$ = new LLScriptAtRotTarget(gLine, gColumn, id1, id2, id3);
- gAllocationManager->addAllocation($$);
- }
- ;
-
-not_at_rot_target
- : NOT_AT_ROT_TARGET '(' ')'
- {
- $$ = new LLScriptNotAtRotTarget(gLine, gColumn);
- gAllocationManager->addAllocation($$);
- }
- ;
-
-money
- : MONEY '(' LLKEY IDENTIFIER ',' INTEGER IDENTIFIER ')'
- {
- LLScriptIdentifier *id1 = new LLScriptIdentifier(gLine, gColumn, $4);
- gAllocationManager->addAllocation(id1);
- LLScriptIdentifier *id2 = new LLScriptIdentifier(gLine, gColumn, $7);
- gAllocationManager->addAllocation(id2);
- $$ = new LLScriptMoneyEvent(gLine, gColumn, id1, id2);
- gAllocationManager->addAllocation($$);
- }
- ;
-
-email
- : EMAIL '(' STRING IDENTIFIER ',' STRING IDENTIFIER ',' STRING IDENTIFIER ',' STRING IDENTIFIER ',' INTEGER IDENTIFIER ')'
- {
- LLScriptIdentifier *id1 = new LLScriptIdentifier(gLine, gColumn, $4);
- gAllocationManager->addAllocation(id1);
- LLScriptIdentifier *id2 = new LLScriptIdentifier(gLine, gColumn, $7);
- gAllocationManager->addAllocation(id2);
- LLScriptIdentifier *id3 = new LLScriptIdentifier(gLine, gColumn, $10);
- gAllocationManager->addAllocation(id3);
- LLScriptIdentifier *id4 = new LLScriptIdentifier(gLine, gColumn, $13);
- gAllocationManager->addAllocation(id4);
- LLScriptIdentifier *id5 = new LLScriptIdentifier(gLine, gColumn, $16);
- gAllocationManager->addAllocation(id5);
- $$ = new LLScriptEmailEvent(gLine, gColumn, id1, id2, id3, id4, id5);
- gAllocationManager->addAllocation($$);
- }
- ;
-
-run_time_permissions
- : RUN_TIME_PERMISSIONS '(' INTEGER IDENTIFIER ')'
- {
- LLScriptIdentifier *id1 = new LLScriptIdentifier(gLine, gColumn, $4);
- gAllocationManager->addAllocation(id1);
- $$ = new LLScriptRTPEvent(gLine, gColumn, id1);
- gAllocationManager->addAllocation($$);
- }
- ;
-
-inventory
- : INVENTORY '(' INTEGER IDENTIFIER ')'
- {
- LLScriptIdentifier *id1 = new LLScriptIdentifier(gLine, gColumn, $4);
- gAllocationManager->addAllocation(id1);
- $$ = new LLScriptInventoryEvent(gLine, gColumn, id1);
- gAllocationManager->addAllocation($$);
- }
- ;
-
-attach
- : ATTACH '(' LLKEY IDENTIFIER ')'
- {
- LLScriptIdentifier *id1 = new LLScriptIdentifier(gLine, gColumn, $4);
- gAllocationManager->addAllocation(id1);
- $$ = new LLScriptAttachEvent(gLine, gColumn, id1);
- gAllocationManager->addAllocation($$);
- }
- ;
-
-dataserver
- : DATASERVER '(' LLKEY IDENTIFIER ',' STRING IDENTIFIER')'
- {
- LLScriptIdentifier *id1 = new LLScriptIdentifier(gLine, gColumn, $4);
- gAllocationManager->addAllocation(id1);
- LLScriptIdentifier *id2 = new LLScriptIdentifier(gLine, gColumn, $7);
- gAllocationManager->addAllocation(id2);
- $$ = new LLScriptDataserverEvent(gLine, gColumn, id1, id2);
- gAllocationManager->addAllocation($$);
- }
- ;
-
-moving_start
- : MOVING_START '(' ')'
- {
- $$ = new LLScriptMovingStartEvent(gLine, gColumn);
- gAllocationManager->addAllocation($$);
- }
- ;
-
-moving_end
- : MOVING_END '(' ')'
- {
- $$ = new LLScriptMovingEndEvent(gLine, gColumn);
- gAllocationManager->addAllocation($$);
- }
- ;
-
-timer
- : TIMER '(' ')'
- {
- $$ = new LLScriptTimerEvent(gLine, gColumn);
- gAllocationManager->addAllocation($$);
- }
- ;
-
-chat
- : CHAT '(' INTEGER IDENTIFIER ',' STRING IDENTIFIER ',' LLKEY IDENTIFIER ',' STRING IDENTIFIER ')'
- {
- LLScriptIdentifier *id1 = new LLScriptIdentifier(gLine, gColumn, $4);
- gAllocationManager->addAllocation(id1);
- LLScriptIdentifier *id2 = new LLScriptIdentifier(gLine, gColumn, $7);
- gAllocationManager->addAllocation(id2);
- LLScriptIdentifier *id3 = new LLScriptIdentifier(gLine, gColumn, $10);
- gAllocationManager->addAllocation(id3);
- LLScriptIdentifier *id4 = new LLScriptIdentifier(gLine, gColumn, $13);
- gAllocationManager->addAllocation(id4);
- $$ = new LLScriptChatEvent(gLine, gColumn, id1, id2, id3, id4);
- gAllocationManager->addAllocation($$);
- }
- ;
-
-sensor
- : SENSOR '(' INTEGER IDENTIFIER ')'
- {
- LLScriptIdentifier *id1 = new LLScriptIdentifier(gLine, gColumn, $4);
- gAllocationManager->addAllocation(id1);
- $$ = new LLScriptSensorEvent(gLine, gColumn, id1);
- gAllocationManager->addAllocation($$);
- }
- ;
-
-no_sensor
- : NO_SENSOR '(' ')'
- {
- $$ = new LLScriptNoSensorEvent(gLine, gColumn);
- gAllocationManager->addAllocation($$);
- }
- ;
-
-control
- : CONTROL '(' LLKEY IDENTIFIER ',' INTEGER IDENTIFIER ',' INTEGER IDENTIFIER ')'
- {
- LLScriptIdentifier *id1 = new LLScriptIdentifier(gLine, gColumn, $4);
- gAllocationManager->addAllocation(id1);
- LLScriptIdentifier *id2 = new LLScriptIdentifier(gLine, gColumn, $7);
- gAllocationManager->addAllocation(id2);
- LLScriptIdentifier *id3 = new LLScriptIdentifier(gLine, gColumn, $10);
- gAllocationManager->addAllocation(id3);
- $$ = new LLScriptControlEvent(gLine, gColumn, id1, id2, id3);
- gAllocationManager->addAllocation($$);
- }
- ;
-
-rez
- : REZ '(' INTEGER IDENTIFIER ')'
- {
- LLScriptIdentifier *id1 = new LLScriptIdentifier(gLine, gColumn, $4);
- gAllocationManager->addAllocation(id1);
- $$ = new LLScriptRezEvent(gLine, gColumn, id1);
- gAllocationManager->addAllocation($$);
- }
- ;
-
-object_rez
- : OBJECT_REZ '(' LLKEY IDENTIFIER ')'
- {
- LLScriptIdentifier *id1 = new LLScriptIdentifier(gLine, gColumn, $4);
- gAllocationManager->addAllocation(id1);
- $$ = new LLScriptObjectRezEvent(gLine, gColumn, id1);
- gAllocationManager->addAllocation($$);
- }
- ;
-
-link_message
- : LINK_MESSAGE '(' INTEGER IDENTIFIER ',' INTEGER IDENTIFIER ',' STRING IDENTIFIER ',' LLKEY IDENTIFIER ')'
- {
- LLScriptIdentifier *id1 = new LLScriptIdentifier(gLine, gColumn, $4);
- gAllocationManager->addAllocation(id1);
- LLScriptIdentifier *id2 = new LLScriptIdentifier(gLine, gColumn, $7);
- gAllocationManager->addAllocation(id2);
- LLScriptIdentifier *id3 = new LLScriptIdentifier(gLine, gColumn, $10);
- gAllocationManager->addAllocation(id3);
- LLScriptIdentifier *id4 = new LLScriptIdentifier(gLine, gColumn, $13);
- gAllocationManager->addAllocation(id4);
- $$ = new LLScriptLinkMessageEvent(gLine, gColumn, id1, id2, id3, id4);
- gAllocationManager->addAllocation($$);
- }
- ;
-
-remote_data
- : REMOTE_DATA '(' INTEGER IDENTIFIER ',' LLKEY IDENTIFIER ',' LLKEY IDENTIFIER ',' STRING IDENTIFIER ',' INTEGER IDENTIFIER ',' STRING IDENTIFIER ')'
- {
- LLScriptIdentifier *id1 = new LLScriptIdentifier(gLine, gColumn, $4);
- gAllocationManager->addAllocation(id1);
- LLScriptIdentifier *id2 = new LLScriptIdentifier(gLine, gColumn, $7);
- gAllocationManager->addAllocation(id2);
- LLScriptIdentifier *id3 = new LLScriptIdentifier(gLine, gColumn, $10);
- gAllocationManager->addAllocation(id3);
- LLScriptIdentifier *id4 = new LLScriptIdentifier(gLine, gColumn, $13);
- gAllocationManager->addAllocation(id4);
- LLScriptIdentifier *id5 = new LLScriptIdentifier(gLine, gColumn, $16);
- gAllocationManager->addAllocation(id4);
- LLScriptIdentifier *id6 = new LLScriptIdentifier(gLine, gColumn, $19);
- gAllocationManager->addAllocation(id4);
- $$ = new LLScriptRemoteEvent(gLine, gColumn, id1, id2, id3, id4, id5, id6);
- gAllocationManager->addAllocation($$);
- }
- ;
-
-http_response
- : HTTP_RESPONSE '(' LLKEY IDENTIFIER ',' INTEGER IDENTIFIER ',' LIST IDENTIFIER ',' STRING IDENTIFIER ')'
- {
- LLScriptIdentifier *id1 = new LLScriptIdentifier(gLine, gColumn, $4);
- gAllocationManager->addAllocation(id1);
- LLScriptIdentifier *id2 = new LLScriptIdentifier(gLine, gColumn, $7);
- gAllocationManager->addAllocation(id2);
- LLScriptIdentifier *id3 = new LLScriptIdentifier(gLine, gColumn, $10);
- gAllocationManager->addAllocation(id3);
- LLScriptIdentifier *id4 = new LLScriptIdentifier(gLine, gColumn, $13);
- gAllocationManager->addAllocation(id4);
- $$ = new LLScriptHTTPResponseEvent(gLine, gColumn, id1, id2, id3, id4);
- gAllocationManager->addAllocation($$);
- }
- ;
-
-http_request
- : HTTP_REQUEST '(' LLKEY IDENTIFIER ',' STRING IDENTIFIER ',' STRING IDENTIFIER ')'
- {
- LLScriptIdentifier *id1 = new LLScriptIdentifier(gLine, gColumn, $4);
- gAllocationManager->addAllocation(id1);
- LLScriptIdentifier *id2 = new LLScriptIdentifier(gLine, gColumn, $7);
- gAllocationManager->addAllocation(id2);
- LLScriptIdentifier *id3 = new LLScriptIdentifier(gLine, gColumn, $10);
- gAllocationManager->addAllocation(id3);
- $$ = new LLScriptHTTPRequestEvent(gLine, gColumn, id1, id2, id3);
- gAllocationManager->addAllocation($$);
- }
- ;
-
-compound_statement
- : '{' '}'
- {
- $$ = new LLScriptCompoundStatement(gLine, gColumn, NULL);
- gAllocationManager->addAllocation($$);
- }
- | '{' statements '}'
- {
- $$ = new LLScriptCompoundStatement(gLine, gColumn, $2);
- gAllocationManager->addAllocation($$);
- }
- ;
-
-statements
- : statement
- {
- $$ = $1;
- }
- | statements statement
- {
- $$ = new LLScriptStatementSequence(gLine, gColumn, $1, $2);
- gAllocationManager->addAllocation($$);
- }
- ;
-
-statement
- : ';'
- {
- $$ = new LLScriptNOOP(gLine, gColumn);
- gAllocationManager->addAllocation($$);
- }
- | STATE IDENTIFIER ';'
- {
- LLScriptIdentifier *id = new LLScriptIdentifier(gLine, gColumn, $2);
- gAllocationManager->addAllocation(id);
- $$ = new LLScriptStateChange(gLine, gColumn, id);
- gAllocationManager->addAllocation($$);
- }
- | STATE STATE_DEFAULT ';'
- {
- LLScriptIdentifier *id = new LLScriptIdentifier(gLine, gColumn, $2);
- gAllocationManager->addAllocation(id);
- $$ = new LLScriptStateChange(gLine, gColumn, id);
- gAllocationManager->addAllocation($$);
- }
- | JUMP IDENTIFIER ';'
- {
- LLScriptIdentifier *id = new LLScriptIdentifier(gLine, gColumn, $2);
- gAllocationManager->addAllocation(id);
- $$ = new LLScriptJump(gLine, gColumn, id);
- gAllocationManager->addAllocation($$);
- }
- | '@' IDENTIFIER ';'
- {
- LLScriptIdentifier *id = new LLScriptIdentifier(gLine, gColumn, $2);
- gAllocationManager->addAllocation(id);
- $$ = new LLScriptLabel(gLine, gColumn, id);
- gAllocationManager->addAllocation($$);
- }
- | RETURN expression ';'
- {
- $$ = new LLScriptReturn(gLine, gColumn, $2);
- gAllocationManager->addAllocation($$);
- }
- | RETURN ';'
- {
- $$ = new LLScriptReturn(gLine, gColumn, NULL);
- gAllocationManager->addAllocation($$);
- }
- | expression ';'
- {
- $$ = new LLScriptExpressionStatement(gLine, gColumn, $1);
- gAllocationManager->addAllocation($$);
- }
- | declaration ';'
- {
- $$ = $1;
- }
- | compound_statement
- {
- $$ = $1;
- }
- | IF '(' expression ')' statement %prec LOWER_THAN_ELSE
- {
- $$ = new LLScriptIf(gLine, gColumn, $3, $5);
- $5->mAllowDeclarations = FALSE;
- gAllocationManager->addAllocation($$);
- }
- | IF '(' expression ')' statement ELSE statement
- {
- $$ = new LLScriptIfElse(gLine, gColumn, $3, $5, $7);
- $5->mAllowDeclarations = FALSE;
- $7->mAllowDeclarations = FALSE;
- gAllocationManager->addAllocation($$);
- }
- | FOR '(' forexpressionlist ';' expression ';' forexpressionlist ')' statement
- {
- $$ = new LLScriptFor(gLine, gColumn, $3, $5, $7, $9);
- $9->mAllowDeclarations = FALSE;
- gAllocationManager->addAllocation($$);
- }
- | DO statement WHILE '(' expression ')' ';'
- {
- $$ = new LLScriptDoWhile(gLine, gColumn, $2, $5);
- $2->mAllowDeclarations = FALSE;
- gAllocationManager->addAllocation($$);
- }
- | WHILE '(' expression ')' statement
- {
- $$ = new LLScriptWhile(gLine, gColumn, $3, $5);
- $5->mAllowDeclarations = FALSE;
- gAllocationManager->addAllocation($$);
- }
- ;
-
-declaration
- : typename IDENTIFIER
- {
- LLScriptIdentifier *id = new LLScriptIdentifier(gLine, gColumn, $2);
- gAllocationManager->addAllocation(id);
- $$ = new LLScriptDeclaration(gLine, gColumn, $1, id, NULL);
- gAllocationManager->addAllocation($$);
- }
- | typename IDENTIFIER '=' expression
- {
- LLScriptIdentifier *id = new LLScriptIdentifier(gLine, gColumn, $2);
- gAllocationManager->addAllocation(id);
- $$ = new LLScriptDeclaration(gLine, gColumn, $1, id, $4);
- gAllocationManager->addAllocation($$);
- }
- ;
-
-forexpressionlist
- : /* empty */
- {
- $$ = NULL;
- }
- | nextforexpressionlist
- {
- $$ = $1;
- }
- ;
-
-nextforexpressionlist
- : expression
- {
- $$ = new LLScriptForExpressionList(gLine, gColumn, $1, NULL);
- gAllocationManager->addAllocation($$);
- }
- | expression ',' nextforexpressionlist
- {
- $$ = new LLScriptForExpressionList(gLine, gColumn, $1, $3);
- gAllocationManager->addAllocation($$);
- }
- ;
-
-funcexpressionlist
- : /* empty */
- {
- $$ = NULL;
- }
- | nextfuncexpressionlist
- {
- $$ = $1;
- }
- ;
-
-nextfuncexpressionlist
- : expression
- {
- $$ = new LLScriptFuncExpressionList(gLine, gColumn, $1, NULL);
- gAllocationManager->addAllocation($$);
- }
- | expression ',' nextfuncexpressionlist
- {
- $$ = new LLScriptFuncExpressionList(gLine, gColumn, $1, $3);
- gAllocationManager->addAllocation($$);
- }
- ;
-
-listexpressionlist
- : /* empty */
- {
- $$ = NULL;
- }
- | nextlistexpressionlist
- {
- $$ = $1;
- }
- ;
-
-nextlistexpressionlist
- : expression
- {
- $$ = new LLScriptListExpressionList(gLine, gColumn, $1, NULL);
- gAllocationManager->addAllocation($$);
- }
- | expression ',' nextlistexpressionlist
- {
- $$ = new LLScriptListExpressionList(gLine, gColumn, $1, $3);
- gAllocationManager->addAllocation($$);
- }
- ;
-
-expression
- : unaryexpression
- {
- $$ = $1;
- }
- | lvalue '=' expression
- {
- $$ = new LLScriptAssignment(gLine, gColumn, $1, $3);
- gAllocationManager->addAllocation($$);
- }
- | lvalue ADD_ASSIGN expression
- {
- $$ = new LLScriptAddAssignment(gLine, gColumn, $1, $3);
- gAllocationManager->addAllocation($$);
- }
- | lvalue SUB_ASSIGN expression
- {
- $$ = new LLScriptSubAssignment(gLine, gColumn, $1, $3);
- gAllocationManager->addAllocation($$);
- }
- | lvalue MUL_ASSIGN expression
- {
- $$ = new LLScriptMulAssignment(gLine, gColumn, $1, $3);
- gAllocationManager->addAllocation($$);
- }
- | lvalue DIV_ASSIGN expression
- {
- $$ = new LLScriptDivAssignment(gLine, gColumn, $1, $3);
- gAllocationManager->addAllocation($$);
- }
- | lvalue MOD_ASSIGN expression
- {
- $$ = new LLScriptModAssignment(gLine, gColumn, $1, $3);
- gAllocationManager->addAllocation($$);
- }
- | expression EQ expression
- {
- $$ = new LLScriptEquality(gLine, gColumn, $1, $3);
- gAllocationManager->addAllocation($$);
- }
- | expression NEQ expression
- {
- $$ = new LLScriptNotEquals(gLine, gColumn, $1, $3);
- gAllocationManager->addAllocation($$);
- }
- | expression LEQ expression
- {
- $$ = new LLScriptLessEquals(gLine, gColumn, $1, $3);
- gAllocationManager->addAllocation($$);
- }
- | expression GEQ expression
- {
- $$ = new LLScriptGreaterEquals(gLine, gColumn, $1, $3);
- gAllocationManager->addAllocation($$);
- }
- | expression '<' expression
- {
- $$ = new LLScriptLessThan(gLine, gColumn, $1, $3);
- gAllocationManager->addAllocation($$);
- }
- | expression '>' expression
- {
- $$ = new LLScriptGreaterThan(gLine, gColumn, $1, $3);
- gAllocationManager->addAllocation($$);
- }
- | expression '+' expression
- {
- $$ = new LLScriptPlus(gLine, gColumn, $1, $3);
- gAllocationManager->addAllocation($$);
- }
- | expression '-' expression
- {
- $$ = new LLScriptMinus(gLine, gColumn, $1, $3);
- gAllocationManager->addAllocation($$);
- }
- | expression '*' expression
- {
- $$ = new LLScriptTimes(gLine, gColumn, $1, $3);
- gAllocationManager->addAllocation($$);
- }
- | expression '/' expression
- {
- $$ = new LLScriptDivide(gLine, gColumn, $1, $3);
- gAllocationManager->addAllocation($$);
- }
- | expression '%' expression
- {
- $$ = new LLScriptMod(gLine, gColumn, $1, $3);
- gAllocationManager->addAllocation($$);
- }
- | expression '&' expression
- {
- $$ = new LLScriptBitAnd(gLine, gColumn, $1, $3);
- gAllocationManager->addAllocation($$);
- }
- | expression '|' expression
- {
- $$ = new LLScriptBitOr(gLine, gColumn, $1, $3);
- gAllocationManager->addAllocation($$);
- }
- | expression '^' expression
- {
- $$ = new LLScriptBitXor(gLine, gColumn, $1, $3);
- gAllocationManager->addAllocation($$);
- }
- | expression BOOLEAN_AND expression
- {
- $$ = new LLScriptBooleanAnd(gLine, gColumn, $1, $3);
- gAllocationManager->addAllocation($$);
- }
- | expression BOOLEAN_OR expression
- {
- $$ = new LLScriptBooleanOr(gLine, gColumn, $1, $3);
- gAllocationManager->addAllocation($$);
- }
- | expression SHIFT_LEFT expression
- {
- $$ = new LLScriptShiftLeft(gLine, gColumn, $1, $3);
- gAllocationManager->addAllocation($$);
- }
- | expression SHIFT_RIGHT expression
- {
- $$ = new LLScriptShiftRight(gLine, gColumn, $1, $3);
- gAllocationManager->addAllocation($$);
- }
- ;
-
-unaryexpression
- : '-' expression
- {
- $$ = new LLScriptUnaryMinus(gLine, gColumn, $2);
- gAllocationManager->addAllocation($$);
- }
- | '!' expression
- {
- $$ = new LLScriptBooleanNot(gLine, gColumn, $2);
- gAllocationManager->addAllocation($$);
- }
- | '~' expression
- {
- $$ = new LLScriptBitNot(gLine, gColumn, $2);
- gAllocationManager->addAllocation($$);
- }
- | INC_OP lvalue
- {
- $$ = new LLScriptPreIncrement(gLine, gColumn, $2);
- gAllocationManager->addAllocation($$);
- }
- | DEC_OP lvalue
- {
- $$ = new LLScriptPreDecrement(gLine, gColumn, $2);
- gAllocationManager->addAllocation($$);
- }
- | typecast
- {
- $$ = $1;
- }
- | unarypostfixexpression
- {
- $$ = $1;
- }
- | '(' expression ')'
- {
- $$ = new LLScriptParenthesis(gLine, gColumn, $2);
- gAllocationManager->addAllocation($$);
- }
- ;
-
-typecast
- : '(' typename ')' lvalue
- {
- $$ = new LLScriptTypeCast(gLine, gColumn, $2, $4);
- gAllocationManager->addAllocation($$);
- }
- | '(' typename ')' constant
- {
- LLScriptConstantExpression *temp = new LLScriptConstantExpression(gLine, gColumn, $4);
- gAllocationManager->addAllocation(temp);
- $$ = new LLScriptTypeCast(gLine, gColumn, $2, temp);
- gAllocationManager->addAllocation($$);
- }
- | '(' typename ')' unarypostfixexpression
- {
- $$ = new LLScriptTypeCast(gLine, gColumn, $2, $4);
- gAllocationManager->addAllocation($$);
- }
- | '(' typename ')' '(' expression ')'
- {
- $$ = new LLScriptTypeCast(gLine, gColumn, $2, $5);
- gAllocationManager->addAllocation($$);
- }
- ;
-
-unarypostfixexpression
- : vector_initializer
- {
- $$ = $1;
- }
- | quaternion_initializer
- {
- $$ = $1;
- }
- | list_initializer
- {
- $$ = $1;
- }
- | lvalue
- {
- $$ = $1;
- }
- | lvalue INC_OP
- {
- $$ = new LLScriptPostIncrement(gLine, gColumn, $1);
- gAllocationManager->addAllocation($$);
- }
- | lvalue DEC_OP
- {
- $$ = new LLScriptPostDecrement(gLine, gColumn, $1);
- gAllocationManager->addAllocation($$);
- }
- | IDENTIFIER '(' funcexpressionlist ')'
- {
- LLScriptIdentifier *id = new LLScriptIdentifier(gLine, gColumn, $1);
- gAllocationManager->addAllocation(id);
- $$ = new LLScriptFunctionCall(gLine, gColumn, id, $3);
- gAllocationManager->addAllocation($$);
- }
- | PRINT '(' expression ')'
- {
- $$ = new LLScriptPrint(gLine, gColumn, $3);
- gAllocationManager->addAllocation($$);
- }
- | constant
- {
- $$ = new LLScriptConstantExpression(gLine, gColumn, $1);
- gAllocationManager->addAllocation($$);
- }
- ;
-
-vector_initializer
- : '<' expression ',' expression ',' expression '>' %prec INITIALIZER
- {
- $$ = new LLScriptVectorInitializer(gLine, gColumn, $2, $4, $6);
- gAllocationManager->addAllocation($$);
- }
- | ZERO_VECTOR
- {
- LLScriptConstantFloat *cf0 = new LLScriptConstantFloat(gLine, gColumn, 0.f);
- gAllocationManager->addAllocation(cf0);
- LLScriptConstantExpression *sa0 = new LLScriptConstantExpression(gLine, gColumn, cf0);
- gAllocationManager->addAllocation(sa0);
- LLScriptConstantFloat *cf1 = new LLScriptConstantFloat(gLine, gColumn, 0.f);
- gAllocationManager->addAllocation(cf1);
- LLScriptConstantExpression *sa1 = new LLScriptConstantExpression(gLine, gColumn, cf1);
- gAllocationManager->addAllocation(sa1);
- LLScriptConstantFloat *cf2 = new LLScriptConstantFloat(gLine, gColumn, 0.f);
- gAllocationManager->addAllocation(cf2);
- LLScriptConstantExpression *sa2 = new LLScriptConstantExpression(gLine, gColumn, cf2);
- gAllocationManager->addAllocation(sa2);
- $$ = new LLScriptVectorInitializer(gLine, gColumn, sa0, sa1, sa2);
- gAllocationManager->addAllocation($$);
- }
- | TOUCH_INVALID_VECTOR
- {
- LLScriptConstantFloat *cf0 = new LLScriptConstantFloat(gLine, gColumn, 0.f);
- gAllocationManager->addAllocation(cf0);
- LLScriptConstantExpression *sa0 = new LLScriptConstantExpression(gLine, gColumn, cf0);
- gAllocationManager->addAllocation(sa0);
- LLScriptConstantFloat *cf1 = new LLScriptConstantFloat(gLine, gColumn, 0.f);
- gAllocationManager->addAllocation(cf1);
- LLScriptConstantExpression *sa1 = new LLScriptConstantExpression(gLine, gColumn, cf1);
- gAllocationManager->addAllocation(sa1);
- LLScriptConstantFloat *cf2 = new LLScriptConstantFloat(gLine, gColumn, 0.f);
- gAllocationManager->addAllocation(cf2);
- LLScriptConstantExpression *sa2 = new LLScriptConstantExpression(gLine, gColumn, cf2);
- gAllocationManager->addAllocation(sa2);
- $$ = new LLScriptVectorInitializer(gLine, gColumn, sa0, sa1, sa2);
- gAllocationManager->addAllocation($$);
- }
- | TOUCH_INVALID_TEXCOORD
- {
- LLScriptConstantFloat *cf0 = new LLScriptConstantFloat(gLine, gColumn, -1.f);
- gAllocationManager->addAllocation(cf0);
- LLScriptConstantExpression *sa0 = new LLScriptConstantExpression(gLine, gColumn, cf0);
- gAllocationManager->addAllocation(sa0);
- LLScriptConstantFloat *cf1 = new LLScriptConstantFloat(gLine, gColumn, -1.f);
- gAllocationManager->addAllocation(cf1);
- LLScriptConstantExpression *sa1 = new LLScriptConstantExpression(gLine, gColumn, cf1);
- gAllocationManager->addAllocation(sa1);
- LLScriptConstantFloat *cf2 = new LLScriptConstantFloat(gLine, gColumn, 0.f);
- gAllocationManager->addAllocation(cf2);
- LLScriptConstantExpression *sa2 = new LLScriptConstantExpression(gLine, gColumn, cf2);
- gAllocationManager->addAllocation(sa2);
- $$ = new LLScriptVectorInitializer(gLine, gColumn, sa0, sa1, sa2);
- gAllocationManager->addAllocation($$);
- }
- ;
-
-quaternion_initializer
- : '<' expression ',' expression ',' expression ',' expression '>' %prec INITIALIZER
- {
- $$ = new LLScriptQuaternionInitializer(gLine, gColumn, $2, $4, $6, $8);
- gAllocationManager->addAllocation($$);
- }
- | ZERO_ROTATION
- {
- LLScriptConstantFloat *cf0 = new LLScriptConstantFloat(gLine, gColumn, 0.f);
- gAllocationManager->addAllocation(cf0);
- LLScriptConstantExpression *sa0 = new LLScriptConstantExpression(gLine, gColumn, cf0);
- gAllocationManager->addAllocation(sa0);
- LLScriptConstantFloat *cf1 = new LLScriptConstantFloat(gLine, gColumn, 0.f);
- gAllocationManager->addAllocation(cf1);
- LLScriptConstantExpression *sa1 = new LLScriptConstantExpression(gLine, gColumn, cf1);
- gAllocationManager->addAllocation(sa1);
- LLScriptConstantFloat *cf2 = new LLScriptConstantFloat(gLine, gColumn, 0.f);
- gAllocationManager->addAllocation(cf2);
- LLScriptConstantExpression *sa2 = new LLScriptConstantExpression(gLine, gColumn, cf2);
- gAllocationManager->addAllocation(sa2);
- LLScriptConstantFloat *cf3 = new LLScriptConstantFloat(gLine, gColumn, 1.f);
- gAllocationManager->addAllocation(cf3);
- LLScriptConstantExpression *sa3 = new LLScriptConstantExpression(gLine, gColumn, cf3);
- gAllocationManager->addAllocation(sa3);
- $$ = new LLScriptQuaternionInitializer(gLine, gColumn, sa0, sa1, sa2, sa3);
- gAllocationManager->addAllocation($$);
- }
- ;
-
-list_initializer
- : '[' listexpressionlist ']' %prec INITIALIZER
- {
- $$ = new LLScriptListInitializer(gLine, gColumn, $2);
- gAllocationManager->addAllocation($$);
- }
- ;
-
-lvalue
- : IDENTIFIER
- {
- LLScriptIdentifier *id = new LLScriptIdentifier(gLine, gColumn, $1);
- gAllocationManager->addAllocation(id);
- $$ = new LLScriptLValue(gLine, gColumn, id, NULL);
- gAllocationManager->addAllocation($$);
- }
- | IDENTIFIER PERIOD IDENTIFIER
- {
- LLScriptIdentifier *id = new LLScriptIdentifier(gLine, gColumn, $1);
- gAllocationManager->addAllocation(id);
- LLScriptIdentifier *ac = new LLScriptIdentifier(gLine, gColumn, $3);
- gAllocationManager->addAllocation(id);
- $$ = new LLScriptLValue(gLine, gColumn, id, ac);
- gAllocationManager->addAllocation($$);
- }
- ;
-
-%%
diff --git a/indra/lscript/lscript_compile/lscript_alloc.cpp b/indra/lscript/lscript_compile/lscript_alloc.cpp
deleted file mode 100755
index 5856a94e48..0000000000
--- a/indra/lscript/lscript_compile/lscript_alloc.cpp
+++ /dev/null
@@ -1,26 +0,0 @@
-/**
- * @file lscript_alloc.cpp
- * @brief Allocation tracking
- *
- * $LicenseInfo:firstyear=2002&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
diff --git a/indra/lscript/lscript_compile/lscript_bytecode.cpp b/indra/lscript/lscript_compile/lscript_bytecode.cpp
deleted file mode 100755
index 667e5dafc1..0000000000
--- a/indra/lscript/lscript_compile/lscript_bytecode.cpp
+++ /dev/null
@@ -1,317 +0,0 @@
-/**
- * @file lscript_bytecode.cpp
- * @brief classes to build actual bytecode
- *
- * $LicenseInfo:firstyear=2002&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#include "linden_common.h"
-
-#include "lscript_bytecode.h"
-#include "lscript_error.h"
-
-#if defined(_MSC_VER)
-# pragma warning(disable: 4102) // 'yy_more' : unreferenced label
-# pragma warning(disable: 4702) // unreachable code
-#endif
-
-LLScriptJumpTable::LLScriptJumpTable()
-{
-}
-
-LLScriptJumpTable::~LLScriptJumpTable()
-{
- delete_and_clear(mLabelMap);
- delete_and_clear(mJumpMap);
-}
-
-void LLScriptJumpTable::addLabel(char *name, S32 offset)
-{
- char *temp = gScopeStringTable->addString(name);
- mLabelMap[temp] = new S32(offset);
-}
-
-void LLScriptJumpTable::addJump(char *name, S32 offset)
-{
- char *temp = gScopeStringTable->addString(name);
- mJumpMap[temp] = new S32(offset);
-}
-
-
-LLScriptByteCodeChunk::LLScriptByteCodeChunk(BOOL b_need_jumps)
-: mCodeChunk(NULL), mCurrentOffset(0), mJumpTable(NULL)
-{
- if (b_need_jumps)
- {
- mJumpTable = new LLScriptJumpTable();
- }
-}
-
-LLScriptByteCodeChunk::~LLScriptByteCodeChunk()
-{
- delete [] mCodeChunk;
- delete mJumpTable;
-}
-
-void LLScriptByteCodeChunk::addByte(U8 byte)
-{
- if (mCodeChunk)
- {
- U8 *temp = new U8[mCurrentOffset + 1];
- memcpy(temp, mCodeChunk, mCurrentOffset); /* Flawfinder: ignore */
- delete [] mCodeChunk;
- mCodeChunk = temp;
- }
- else
- {
- mCodeChunk = new U8[1];
- }
- *(mCodeChunk + mCurrentOffset++) = byte;
-}
-
-void LLScriptByteCodeChunk::addU16(U16 data)
-{
- U8 temp[2];
- S32 offset = 0;
- u162bytestream(temp, offset, data);
- addBytes(temp, 2);
-}
-
-void LLScriptByteCodeChunk::addBytes(const U8 *bytes, S32 size)
-{
- if (mCodeChunk)
- {
- U8 *temp = new U8[mCurrentOffset + size];
- memcpy(temp, mCodeChunk, mCurrentOffset); /* Flawfinder: ignore */
- delete [] mCodeChunk;
- mCodeChunk = temp;
- }
- else
- {
- mCodeChunk = new U8[size];
- }
- memcpy(mCodeChunk + mCurrentOffset, bytes, size);/* Flawfinder: ignore */
- mCurrentOffset += size;
-}
-
-void LLScriptByteCodeChunk::addBytes(const char *bytes, S32 size)
-{
- if (mCodeChunk)
- {
- U8 *temp = new U8[mCurrentOffset + size];
- memcpy(temp, mCodeChunk, mCurrentOffset); /*Flawfinder: ignore*/
- delete [] mCodeChunk;
- mCodeChunk = temp;
- }
- else
- {
- mCodeChunk = new U8[size];
- }
- memcpy(mCodeChunk + mCurrentOffset, bytes, size); /*Flawfinder: ignore*/
- mCurrentOffset += size;
-}
-
-void LLScriptByteCodeChunk::addBytes(S32 size)
-{
- if (mCodeChunk)
- {
- U8 *temp = new U8[mCurrentOffset + size];
- memcpy(temp, mCodeChunk, mCurrentOffset); /*Flawfinder: ignore*/
- delete [] mCodeChunk;
- mCodeChunk = temp;
- }
- else
- {
- mCodeChunk = new U8[size];
- }
- memset(mCodeChunk + mCurrentOffset, 0, size);
- mCurrentOffset += size;
-}
-
-void LLScriptByteCodeChunk::addBytesDontInc(S32 size)
-{
- if (mCodeChunk)
- {
- U8 *temp = new U8[mCurrentOffset + size];
- memcpy(temp, mCodeChunk, mCurrentOffset); /*Flawfinder: ignore*/
- delete [] mCodeChunk;
- mCodeChunk = temp;
- }
- else
- {
- mCodeChunk = new U8[size];
- }
- memset(mCodeChunk + mCurrentOffset, 0, size);
-}
-
-void LLScriptByteCodeChunk::addInteger(S32 value)
-{
- U8 temp[4];
- S32 offset = 0;
- integer2bytestream(temp, offset, value);
- addBytes(temp, 4);
-}
-
-void LLScriptByteCodeChunk::addFloat(F32 value)
-{
- U8 temp[4];
- S32 offset = 0;
- float2bytestream(temp, offset, value);
- addBytes(temp, 4);
-}
-
-void LLScriptByteCodeChunk::addLabel(char *name)
-{
- if (mJumpTable)
- {
- mJumpTable->addLabel(name, mCurrentOffset);
- }
-}
-
-void LLScriptByteCodeChunk::addJump(char *name)
-{
- if (mJumpTable)
- {
- mJumpTable->addJump(name, mCurrentOffset);
- }
-}
-
-// format is Byte 0: jump op code Byte 1 - 4: offset
-// the jump position points to Byte 5, so we need to add the data at
-// offset - 4, offset - 3, offset - 2, and offset - 1
-
-// offset is label - jump
-
-void LLScriptByteCodeChunk::connectJumps()
-{
- if (mJumpTable)
- {
- for(std::map<char *, S32 *>::iterator it = mJumpTable->mJumpMap.begin(), end_it = mJumpTable->mJumpMap.end();
- it != end_it;
- ++it)
- {
- S32 jumppos = *it->second;
- S32 offset = *mJumpTable->mLabelMap[it->first] - jumppos;
- jumppos = jumppos - 4;
- integer2bytestream(mCodeChunk, jumppos, offset);
- }
- }
-}
-
-LLScriptScriptCodeChunk::LLScriptScriptCodeChunk(S32 total_size)
-: mTotalSize(total_size), mCompleteCode(NULL)
-{
- mRegisters = new LLScriptByteCodeChunk(FALSE);
- mGlobalVariables = new LLScriptByteCodeChunk(FALSE);
- mGlobalFunctions = new LLScriptByteCodeChunk(FALSE);
- mStates = new LLScriptByteCodeChunk(FALSE);
- mHeap = new LLScriptByteCodeChunk(FALSE);
-}
-
-LLScriptScriptCodeChunk::~LLScriptScriptCodeChunk()
-{
- delete mRegisters;
- delete mGlobalVariables;
- delete mGlobalFunctions;
- delete mStates;
- delete mHeap;
- delete [] mCompleteCode;
-}
-
-void LLScriptScriptCodeChunk::build(LLFILE *efp, LLFILE *bcfp)
-{
- S32 code_data_size = mRegisters->mCurrentOffset +
- mGlobalVariables->mCurrentOffset +
- mGlobalFunctions->mCurrentOffset +
- mStates->mCurrentOffset +
- mHeap->mCurrentOffset;
-
- S32 offset = 0;
-
- if (code_data_size < mTotalSize)
- {
- mCompleteCode = new U8[mTotalSize];
- memset(mCompleteCode, 0, mTotalSize);
-
- memcpy(mCompleteCode, mRegisters->mCodeChunk, mRegisters->mCurrentOffset);
- offset += mRegisters->mCurrentOffset;
-
- set_register(mCompleteCode, LREG_IP, 0);
- set_register(mCompleteCode, LREG_VN, LSL2_VERSION_NUMBER);
- set_event_register(mCompleteCode, LREG_IE, 0, LSL2_CURRENT_MAJOR_VERSION);
- set_register(mCompleteCode, LREG_BP, mTotalSize - 1);
- set_register(mCompleteCode, LREG_SP, mTotalSize - 1);
-
- set_register(mCompleteCode, LREG_GVR, offset);
-
- memcpy(mCompleteCode + offset, mGlobalVariables->mCodeChunk, mGlobalVariables->mCurrentOffset); /*Flawfinder: ignore*/
- offset += mGlobalVariables->mCurrentOffset;
-
- set_register(mCompleteCode, LREG_GFR, offset);
-
- memcpy(mCompleteCode + offset, mGlobalFunctions->mCodeChunk, mGlobalFunctions->mCurrentOffset); /*Flawfinder: ignore*/
- offset += mGlobalFunctions->mCurrentOffset;
-
- set_register(mCompleteCode, LREG_SR, offset);
- // zero is, by definition the default state
- set_register(mCompleteCode, LREG_CS, 0);
- set_register(mCompleteCode, LREG_NS, 0);
- set_event_register(mCompleteCode, LREG_CE, LSCRIPTStateBitField[LSTT_STATE_ENTRY], LSL2_CURRENT_MAJOR_VERSION);
- S32 default_state_offset = 0;
- if (LSL2_CURRENT_MAJOR_VERSION == LSL2_MAJOR_VERSION_TWO)
- {
- default_state_offset = 8;
- }
- else
- {
- default_state_offset = 4;
- }
- set_event_register(mCompleteCode, LREG_ER, bytestream2u64(mStates->mCodeChunk, default_state_offset), LSL2_CURRENT_MAJOR_VERSION);
-
- memcpy(mCompleteCode + offset, mStates->mCodeChunk, mStates->mCurrentOffset); /*Flawfinder: ignore*/
- offset += mStates->mCurrentOffset;
-
- set_register(mCompleteCode, LREG_HR, offset);
-
- memcpy(mCompleteCode + offset, mHeap->mCodeChunk, mHeap->mCurrentOffset); /*Flawfinder: ignore*/
- offset += mHeap->mCurrentOffset;
-
- set_register(mCompleteCode, LREG_HP, offset);
- set_register(mCompleteCode, LREG_FR, 0);
- set_register(mCompleteCode, LREG_SLR, 0);
- set_register(mCompleteCode, LREG_ESR, 0);
- set_register(mCompleteCode, LREG_PR, 0);
- set_register(mCompleteCode, LREG_TM, mTotalSize);
-
-
- if (fwrite(mCompleteCode, 1, mTotalSize, bcfp) != (size_t)mTotalSize)
- {
- LL_WARNS() << "Short write" << LL_ENDL;
- }
- }
- else
- {
- gErrorToText.writeError(efp, 0, 0, LSERROR_ASSEMBLE_OUT_OF_MEMORY);
- }
-}
-
-LLScriptScriptCodeChunk *gScriptCodeChunk;
diff --git a/indra/lscript/lscript_compile/lscript_bytecode.h b/indra/lscript/lscript_compile/lscript_bytecode.h
deleted file mode 100755
index 1908bebcb9..0000000000
--- a/indra/lscript/lscript_compile/lscript_bytecode.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/**
- * @file lscript_bytecode.h
- * @brief classes to build actual bytecode
- *
- * $LicenseInfo:firstyear=2002&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#ifndef LL_LSCRIPT_BYTECODE_H
-#define LL_LSCRIPT_BYTECODE_H
-
-#include "lscript_byteconvert.h"
-#include "lscript_scope.h"
-#include <map>
-
-class LLScriptJumpTable
-{
-public:
- LLScriptJumpTable();
- ~LLScriptJumpTable();
-
- void addLabel(char *name, S32 offset);
- void addJump(char *name, S32 offset);
-
- std::map<char *, S32 *> mLabelMap;
- std::map<char *, S32 *> mJumpMap;
-};
-
-class LLScriptByteCodeChunk
-{
-public:
- LLScriptByteCodeChunk(BOOL b_need_jumps);
- ~LLScriptByteCodeChunk();
-
- void addByte(U8 byte);
- void addU16(U16 data);
- void addBytes(const U8 *bytes, S32 size);
- void addBytes(const char *bytes, S32 size);
- void addBytes(S32 size);
- void addBytesDontInc(S32 size);
- void addInteger(S32 value);
- void addFloat(F32 value);
- void addLabel(char *name);
- void addJump(char *name);
- void connectJumps();
-
- U8 *mCodeChunk;
- S32 mCurrentOffset;
- LLScriptJumpTable *mJumpTable;
-};
-
-class LLScriptScriptCodeChunk
-{
-public:
- LLScriptScriptCodeChunk(S32 total_size);
- ~LLScriptScriptCodeChunk();
-
- void build(LLFILE *efp, LLFILE *bcfp);
-
- LLScriptByteCodeChunk *mRegisters;
- LLScriptByteCodeChunk *mGlobalVariables;
- LLScriptByteCodeChunk *mGlobalFunctions;
- LLScriptByteCodeChunk *mStates;
- LLScriptByteCodeChunk *mHeap;
- S32 mTotalSize;
- U8 *mCompleteCode;
-};
-
-extern LLScriptScriptCodeChunk *gScriptCodeChunk;
-
-#endif
-
diff --git a/indra/lscript/lscript_compile/lscript_error.cpp b/indra/lscript/lscript_compile/lscript_error.cpp
deleted file mode 100755
index a574981555..0000000000
--- a/indra/lscript/lscript_compile/lscript_error.cpp
+++ /dev/null
@@ -1,103 +0,0 @@
-/**
- * @file lscript_error.cpp
- * @brief error reporting class and strings
- *
- * $LicenseInfo:firstyear=2002&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#include "linden_common.h"
-
-#include "lscript_error.h"
-
-S32 gColumn = 0;
-S32 gLine = 0;
-S32 gInternalColumn = 0;
-S32 gInternalLine = 0;
-
-LLScriptGenerateErrorText gErrorToText;
-
-void LLScriptFilePosition::fdotabs(LLFILE *fp, S32 tabs, S32 tabsize)
-{
- S32 i;
- for (i = 0; i < tabs * tabsize; i++)
- {
- fprintf(fp, " ");
- }
-}
-
-const char* gWarningText[LSWARN_EOF] = /*Flawfinder: ignore*/
-{
- "INVALID",
- "Dead code found beyond return statement"
-};
-
-const char* gErrorText[LSERROR_EOF] = /*Flawfinder: ignore*/
-{
- "INVALID",
- "Syntax error",
- "Not all code paths return a value",
- "Function returns a value but return statement doesn't",
- "Return statement type doesn't match function return type",
- "Global functions can't change state",
- "Name previously declared within scope",
- "Name not defined within scope",
- "Type mismatch",
- "Expression must act on LValue",
- "Byte code assembly failed -- out of memory",
- "Function call mismatches type or number of arguments",
- "Use of vector or quaternion method on incorrect type",
- "Lists can't be included in lists",
- "Unitialized variables can't be included in lists",
- "Declaration requires a new scope -- use { and }",
- "CIL assembler failed",
- "Bytecode transformer failed",
- "Bytecode verification failed"
-};
-
-void LLScriptGenerateErrorText::writeWarning(LLFILE *fp, LLScriptFilePosition *pos, LSCRIPTWarnings warning)
-{
- fprintf(fp, "(%d, %d) : WARNING : %s\n", pos->mLineNumber, pos->mColumnNumber, gWarningText[warning]);
- mTotalWarnings++;
-}
-
-void LLScriptGenerateErrorText::writeWarning(LLFILE *fp, S32 line, S32 col, LSCRIPTWarnings warning)
-{
- fprintf(fp, "(%d, %d) : WARNING : %s\n", line, col, gWarningText[warning]);
- mTotalWarnings++;
-}
-
-void LLScriptGenerateErrorText::writeError(LLFILE *fp, LLScriptFilePosition *pos, LSCRIPTErrors error)
-{
- fprintf(fp, "(%d, %d) : ERROR : %s\n", pos->mLineNumber, pos->mColumnNumber, gErrorText[error]);
- mTotalErrors++;
-}
-
-void LLScriptGenerateErrorText::writeError(LLFILE *fp, S32 line, S32 col, LSCRIPTErrors error)
-{
- fprintf(fp, "(%d, %d) : ERROR : %s\n", line, col, gErrorText[error]);
- mTotalErrors++;
-}
-
-std::string getLScriptErrorString(LSCRIPTErrors error)
-{
- return gErrorText[error];
-}
diff --git a/indra/lscript/lscript_compile/lscript_error.h b/indra/lscript/lscript_compile/lscript_error.h
deleted file mode 100755
index 43fb968a40..0000000000
--- a/indra/lscript/lscript_compile/lscript_error.h
+++ /dev/null
@@ -1,152 +0,0 @@
-/**
- * @file lscript_error.h
- * @brief error reporting class and strings
- *
- * $LicenseInfo:firstyear=2002&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#ifndef LL_LSCRIPT_ERROR_H
-#define LL_LSCRIPT_ERROR_H
-
-#include "lscript_scope.h"
-
-typedef enum e_lscript_compile_pass
-{
- LSCP_INVALID,
- LSCP_PRETTY_PRINT,
- LSCP_PRUNE,
- LSCP_SCOPE_PASS1,
- LSCP_SCOPE_PASS2,
- LSCP_TYPE,
- LSCP_RESOURCE,
- LSCP_EMIT_ASSEMBLY,
- LSCP_EMIT_BYTE_CODE,
- LSCP_DETERMINE_HANDLERS,
- LSCP_LIST_BUILD_SIMPLE,
- LSCP_TO_STACK,
- LSCP_BUILD_FUNCTION_ARGS,
- LSCP_EMIT_CIL_ASSEMBLY,
- LSCP_EOF
-} LSCRIPTCompilePass;
-
-typedef enum e_lscript_prune_type
-{
- LSPRUNE_INVALID,
- LSPRUNE_GLOBAL_VOIDS,
- LSPRUNE_GLOBAL_NON_VOIDS,
- LSPRUNE_EVENTS,
- LSPRUNE_DEAD_CODE,
- LSPRUNE_EOF
-} LSCRIPTPruneType;
-
-extern S32 gColumn;
-extern S32 gLine;
-extern S32 gInternalColumn;
-extern S32 gInternalLine;
-
-
-// used to describe where in the file this piece is
-class LLScriptByteCodeChunk;
-
-class LLScriptLibData;
-
-class LLScriptFilePosition
-{
-public:
- LLScriptFilePosition(S32 line, S32 col)
- : mLineNumber(line), mColumnNumber(col), mByteOffset(0), mByteSize(0)
- {
- }
-
- virtual ~LLScriptFilePosition() {}
-
- virtual void recurse(LLFILE *fp, S32 tabs, S32 tabsize,
- LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg,
- LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count,
- LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata) = 0;
- virtual S32 getSize() = 0;
-
- void fdotabs(LLFILE *fp, S32 tabs, S32 tabsize);
-
- S32 mLineNumber;
- S32 mColumnNumber;
-
- S32 mByteOffset;
- S32 mByteSize;
-};
-
-typedef enum e_lscript_warnings
-{
- LSWARN_INVALID,
- LSWARN_DEAD_CODE,
- LSWARN_EOF
-} LSCRIPTWarnings;
-
-typedef enum e_lscript_errors
-{
- LSERROR_INVALID,
- LSERROR_SYNTAX_ERROR,
- LSERROR_NO_RETURN,
- LSERROR_INVALID_VOID_RETURN,
- LSERROR_INVALID_RETURN,
- LSERROR_STATE_CHANGE_IN_GLOBAL,
- LSERROR_DUPLICATE_NAME,
- LSERROR_UNDEFINED_NAME,
- LSERROR_TYPE_MISMATCH,
- LSERROR_EXPRESSION_ON_LVALUE,
- LSERROR_ASSEMBLE_OUT_OF_MEMORY,
- LSERROR_FUNCTION_TYPE_ERROR,
- LSERROR_VECTOR_METHOD_ERROR,
- LSERROR_NO_LISTS_IN_LISTS,
- LSERROR_NO_UNITIALIZED_VARIABLES_IN_LISTS,
- LSERROR_NEED_NEW_SCOPE,
- LSERROR_CIL_ASSEMBLER_FAILED = 16, // Mono build error.
- LSERROR_BYTECODE_TRANSFORM_FAILED = 17, // Mono build error.
- LSERROR_BYTECODE_VERIFICATION_FAILED, // Mono build error.
- LSERROR_EOF
-} LSCRIPTErrors;
-
-class LLScriptGenerateErrorText
-{
-public:
- LLScriptGenerateErrorText() { init(); }
- ~LLScriptGenerateErrorText() {}
-
- void init() { mTotalErrors = 0; mTotalWarnings = 0; }
-
- void writeWarning(LLFILE *fp, LLScriptFilePosition *pos, LSCRIPTWarnings warning);
- void writeWarning(LLFILE *fp, S32 line, S32 col, LSCRIPTWarnings warning);
- void writeError(LLFILE *fp, LLScriptFilePosition *pos, LSCRIPTErrors error);
- void writeError(LLFILE *fp, S32 line, S32 col, LSCRIPTErrors error);
-
- BOOL getErrors() { return mTotalErrors; }
- BOOL getWarnings() { return mTotalWarnings; }
-
- S32 mTotalErrors;
- S32 mTotalWarnings;
-};
-
-std::string getLScriptErrorString(LSCRIPTErrors error);
-
-extern LLScriptGenerateErrorText gErrorToText;
-
-#endif
diff --git a/indra/lscript/lscript_compile/lscript_heap.cpp b/indra/lscript/lscript_compile/lscript_heap.cpp
deleted file mode 100755
index 476c1ac5a6..0000000000
--- a/indra/lscript/lscript_compile/lscript_heap.cpp
+++ /dev/null
@@ -1,67 +0,0 @@
-/**
- * @file lscript_heap.cpp
- * @brief classes to manage script heap
- *
- * $LicenseInfo:firstyear=2002&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#if 0
-
-#include "linden_common.h"
-
-#include "lscript_heap.h"
-
-LLScriptHeapEntry::LLScriptHeapEntry(U8 *entry)
-: mEntry(entry)
-{
- S32 offset = 0;
- mNext = bytestream2integer(entry, offset);
- mRefCount = bytestream2integer(entry, offset);
- mType = *(entry + offset);
- mData = entry + offset;
- mListOffset = offset;
-}
-
-LLScriptHeapEntry::LLScriptHeapEntry(U8 *heap, S32 offset)
-: mNext(0x9), mType(0), mRefCount(0), mEntry(heap + offset), mData(heap + offset + 0x9), mListOffset(0x9)
-{
-}
-
-LLScriptHeapEntry::~LLScriptHeapEntry()
-{
-}
-
-void LLScriptHeapEntry::addString(char *string)
-{
- S32 size = strlen(string) + 1; /*Flawfinder: ignore*/
- S32 offset = 0;
- memcpy(mData, string, size); /*Flawfinder: ignore*/
- mNext += size;
- integer2bytestream(mEntry, offset, mNext);
- mRefCount++;
- integer2bytestream(mEntry, offset, mRefCount);
- *(mEntry + offset) = LSCRIPTTypeByte[LST_STRING];
-}
-
-
-
-#endif
diff --git a/indra/lscript/lscript_compile/lscript_heap.h b/indra/lscript/lscript_compile/lscript_heap.h
deleted file mode 100755
index 7762a367d6..0000000000
--- a/indra/lscript/lscript_compile/lscript_heap.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/**
- * @file lscript_heap.h
- * @brief classes to manage script heap
- *
- * $LicenseInfo:firstyear=2002&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#if 0
-
-#ifndef LL_LSCRIPT_HEAP_H
-#define LL_LSCRIPT_HEAP_H
-
-#include "lscript_byteconvert.h"
-//#include "vmath.h"
-#include "v3math.h"
-#include "llquaternion.h"
-
-class LLScriptHeapEntry
-{
-public:
- LLScriptHeapEntry(U8 *entry);
- LLScriptHeapEntry(U8 *heap, S32 offset);
- ~LLScriptHeapEntry();
-
- void addString(char *string);
-
- S32 mNext;
- U8 mType;
- S32 mRefCount;
- S32 mListOffset;
- U8 *mEntry;
- U8 *mData;
- U8 *mListEntry;
-};
-
-#endif
-
-#endif
-
diff --git a/indra/lscript/lscript_compile/lscript_resource.cpp b/indra/lscript/lscript_compile/lscript_resource.cpp
deleted file mode 100755
index 6cc3e3c5ee..0000000000
--- a/indra/lscript/lscript_compile/lscript_resource.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * @file lscript_resource.cpp
- * @brief resource determination prior to assembly
- *
- * $LicenseInfo:firstyear=2002&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#include "linden_common.h"
-
-#include "lscript_resource.h"
-
-void init_temp_jumps()
-{
- gTempJumpCount = 0;
-}
-
-S32 gTempJumpCount = 0;
diff --git a/indra/lscript/lscript_compile/lscript_resource.h b/indra/lscript/lscript_compile/lscript_resource.h
deleted file mode 100755
index 82cece0a85..0000000000
--- a/indra/lscript/lscript_compile/lscript_resource.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- * @file lscript_resource.h
- * @brief resource determination prior to assembly
- *
- * $LicenseInfo:firstyear=2002&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#ifndef LL_LSCRIPT_RESOURCE_H
-#define LL_LSCRIPT_RESOURCE_H
-
-#include "lscript_scope.h"
-
-void init_temp_jumps();
-
-extern S32 gTempJumpCount;
-
-#endif
-
diff --git a/indra/lscript/lscript_compile/lscript_scope.cpp b/indra/lscript/lscript_compile/lscript_scope.cpp
deleted file mode 100755
index e0fdf44d7a..0000000000
--- a/indra/lscript/lscript_compile/lscript_scope.cpp
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- * @file lscript_scope.cpp
- * @brief builds nametable and checks scope
- *
- * $LicenseInfo:firstyear=2002&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#include "linden_common.h"
-
-#include "lscript_tree.h"
-
-LLStringTable *gScopeStringTable;
diff --git a/indra/lscript/lscript_compile/lscript_scope.h b/indra/lscript/lscript_compile/lscript_scope.h
deleted file mode 100755
index ffff91c81b..0000000000
--- a/indra/lscript/lscript_compile/lscript_scope.h
+++ /dev/null
@@ -1,401 +0,0 @@
-/**
- * @file lscript_scope.h
- * @brief builds nametable and checks scope
- *
- * $LicenseInfo:firstyear=2002&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#ifndef LL_LSCRIPT_SCOPE_H
-#define LL_LSCRIPT_SCOPE_H
-
-#include <map>
-#include "llstringtable.h"
-#include "lscript_byteformat.h"
-
-typedef enum e_lscript_identifier_type
-{
- LIT_INVALID,
- LIT_GLOBAL,
- LIT_VARIABLE,
- LIT_FUNCTION,
- LIT_LABEL,
- LIT_STATE,
- LIT_HANDLER,
- LIT_LIBRARY_FUNCTION,
- LIT_EOF
-} LSCRIPTIdentifierType;
-
-const char LSCRIPTFunctionTypeStrings[LST_EOF] = /*Flawfinder: ignore*/
-{
- '0',
- 'i',
- 'f',
- 's',
- 'k',
- 'v',
- 'q',
- 'l',
- '0'
-};
-
-const char * const LSCRIPTListDescription[LST_EOF] = /*Flawfinder: ignore*/
-{
- "PUSHARGB 0",
- "PUSHARGB 1",
- "PUSHARGB 2",
- "PUSHARGB 3",
- "PUSHARGB 4",
- "PUSHARGB 5",
- "PUSHARGB 6",
- "PUSHARGB 7",
- "PUSHARGB 0"
-};
-
-const char * const LSCRIPTTypePush[LST_EOF] = /*Flawfinder: ignore*/
-{
- "INVALID",
- "PUSHE",
- "PUSHE",
- "PUSHE",
- "PUSHE",
- "PUSHEV",
- "PUSHEQ",
- "PUSHE",
- "undefined"
-};
-
-const char * const LSCRIPTTypeReturn[LST_EOF] = /*Flawfinder: ignore*/
-{
- "INVALID",
- "LOADP -12",
- "LOADP -12",
- "STORES -12\nPOP",
- "STORES -12\nPOP",
- "LOADVP -20",
- "LOADQP -24",
- "LOADLP -12",
- "undefined"
-};
-
-const char * const LSCRIPTTypePop[LST_EOF] = /*Flawfinder: ignore*/
-{
- "INVALID",
- "POP",
- "POP",
- "POPS",
- "POPS",
- "POPV",
- "POPQ",
- "POPL",
- "undefined"
-};
-
-const char * const LSCRIPTTypeDuplicate[LST_EOF] = /*Flawfinder: ignore*/
-{
- "INVALID",
- "DUP",
- "DUP",
- "DUPS",
- "DUPS",
- "DUPV",
- "DUPQ",
- "DUPL",
- "undefined"
-};
-
-const char * const LSCRIPTTypeLocalStore[LST_EOF] = /*Flawfinder: ignore*/
-{
- "INVALID",
- "STORE ",
- "STORE ",
- "STORES ",
- "STORES ",
- "STOREV ",
- "STOREQ ",
- "STOREL ",
- "undefined"
-};
-
-const char * const LSCRIPTTypeLocalDeclaration[LST_EOF] = /*Flawfinder: ignore*/
-{
- "INVALID",
- "STOREP ",
- "STOREP ",
- "STORESP ",
- "STORESP ",
- "STOREVP ",
- "STOREQP ",
- "STORELP ",
- "undefined"
-};
-
-const char * const LSCRIPTTypeGlobalStore[LST_EOF] = /*Flawfinder: ignore*/
-{
- "INVALID",
- "STOREG ",
- "STOREG ",
- "STORESG ",
- "STORESG ",
- "STOREGV ",
- "STOREGQ ",
- "STORELG ",
- "undefined"
-};
-
-const char * const LSCRIPTTypeLocalPush[LST_EOF] = /*Flawfinder: ignore*/
-{
- "INVALID",
- "PUSH ",
- "PUSH ",
- "PUSHS ",
- "PUSHS ",
- "PUSHV ",
- "PUSHQ ",
- "PUSHL ",
- "undefined"
-};
-
-const char * const LSCRIPTTypeLocalPush1[LST_EOF] = /*Flawfinder: ignore*/
-{
- "INVALID",
- "PUSHARGI 1",
- "PUSHARGF 1",
- "undefined",
- "undefined",
- "undefined",
- "undefined",
- "undefined",
- "undefined"
-};
-
-const char * const LSCRIPTTypeGlobalPush[LST_EOF] = /*Flawfinder: ignore*/
-{
- "INVALID",
- "PUSHG ",
- "PUSHG ",
- "PUSHGS ",
- "PUSHGS ",
- "PUSHGV ",
- "PUSHGQ ",
- "PUSHGL ",
- "undefined"
-};
-
-class LLScriptSimpleAssignable;
-
-class LLScriptArgString
-{
-public:
- LLScriptArgString() : mString(NULL) {}
- ~LLScriptArgString() { delete [] mString; }
-
- LSCRIPTType getType(S32 count)
- {
- if (!mString)
- return LST_NULL;
- S32 length = (S32)strlen(mString); /*Flawfinder: ignore*/
- if (count >= length)
- {
- return LST_NULL;
- }
- switch(mString[count])
- {
- 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;
- }
- }
-
- void addType(LSCRIPTType type)
- {
- S32 count = 0;
- if (mString)
- {
- count = (S32)strlen(mString); /*Flawfinder: ignore*/
- char *temp = new char[count + 2];
- memcpy(temp, mString, count); /*Flawfinder: ignore*/
- delete [] mString;
- mString = temp;
- mString[count + 1] = 0;
- }
- else
- {
- mString = new char[count + 2];
- mString[count + 1] = 0;
- }
- mString[count++] = LSCRIPTFunctionTypeStrings[type];
- }
-
- S32 getNumber()
- {
- if (mString)
- return (S32)strlen(mString); /*Flawfinder: ignore*/
- else
- return 0;
- }
-
- char *mString;
-};
-
-class LLScriptScopeEntry
-{
-public:
- LLScriptScopeEntry(const char *identifier, LSCRIPTIdentifierType idtype, LSCRIPTType type, S32 count = 0)
- : mIdentifier(identifier), mIDType(idtype), mType(type), mOffset(0), mSize(0), mAssignable(NULL), mCount(count), mLibraryNumber(0)
- {
- }
-
- ~LLScriptScopeEntry() {}
-
- const char *mIdentifier;
- LSCRIPTIdentifierType mIDType;
- LSCRIPTType mType;
- S32 mOffset;
- S32 mSize;
- LLScriptSimpleAssignable *mAssignable;
- S32 mCount; // NOTE: Index for locals in CIL.
- U16 mLibraryNumber;
- LLScriptArgString mFunctionArgs;
- LLScriptArgString mLocals;
-};
-
-class LLScriptScope
-{
-public:
- LLScriptScope(LLStringTable *stable)
- : mParentScope(NULL), mSTable(stable), mFunctionCount(0), mStateCount(0)
- {
- }
-
- ~LLScriptScope()
- {
- delete_and_clear(mEntryMap);
- }
-
- LLScriptScopeEntry *addEntry(const char *identifier, LSCRIPTIdentifierType idtype, LSCRIPTType type)
- {
- const char *name = mSTable->addString(identifier);
- if (mEntryMap.find(name) == mEntryMap.end())
- {
- if (idtype == LIT_FUNCTION)
- mEntryMap[name] = new LLScriptScopeEntry(name, idtype, type, mFunctionCount++);
- else if (idtype == LIT_STATE)
- mEntryMap[name] = new LLScriptScopeEntry(name, idtype, type, mStateCount++);
- else
- mEntryMap[name] = new LLScriptScopeEntry(name, idtype, type);
- return mEntryMap[name];
- }
- else
- {
- // identifier already exists at this scope
- return NULL;
- }
- }
-
- bool checkEntry(const char *identifier)
- {
- const char *name = mSTable->addString(identifier);
- return mEntryMap.find(name) != mEntryMap.end();
- }
-
- LLScriptScopeEntry *findEntry(const char *identifier)
- {
- const char *name = mSTable->addString(identifier);
- LLScriptScope *scope = this;
-
- while (scope)
- {
- entry_map_t::iterator found_it = mEntryMap.find(name);
- if (found_it != mEntryMap.end())
- {
- // cool, we found it at this scope
- return found_it->second;
- }
- scope = scope->mParentScope;
- }
- return NULL;
- }
-
- LLScriptScopeEntry *findEntryTyped(const char *identifier, LSCRIPTIdentifierType idtype)
- {
- const char *name = mSTable->addString(identifier);
- LLScriptScope *scope = this;
-
- while (scope)
- {
- entry_map_t::iterator found_it = scope->mEntryMap.find(name);
- if (found_it != scope->mEntryMap.end())
- {
- // need to check type, and if type is function we need to check both types
- if (idtype == LIT_FUNCTION)
- {
- if (found_it->second->mIDType == LIT_FUNCTION)
- {
- return (found_it->second);
- }
- else if (found_it->second->mIDType == LIT_LIBRARY_FUNCTION)
- {
- return (found_it->second);
- }
- }
- else if (found_it->second->mIDType == idtype)
- {
- // cool, we found it at this scope
- return (found_it->second);
- }
- }
- scope = scope->mParentScope;
- }
- return NULL;
- }
-
- void addParentScope(LLScriptScope *scope)
- {
- mParentScope = scope;
- }
-
- typedef std::map<const char *, LLScriptScopeEntry *> entry_map_t;
- entry_map_t mEntryMap;
- LLScriptScope* mParentScope;
- LLStringTable* mSTable;
- S32 mFunctionCount;
- S32 mStateCount;
-};
-
-extern LLStringTable *gScopeStringTable;
-
-
-
-#endif
diff --git a/indra/lscript/lscript_compile/lscript_tree.cpp b/indra/lscript/lscript_compile/lscript_tree.cpp
deleted file mode 100755
index 8a70dd9ac1..0000000000
--- a/indra/lscript/lscript_compile/lscript_tree.cpp
+++ /dev/null
@@ -1,10895 +0,0 @@
-/**
- * @file lscript_tree.cpp
- * @brief implements methods for lscript_tree.h classes
- *
- * $LicenseInfo:firstyear=2002&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-// TO DO: Move print functionality from .h file to here
-
-#include "linden_common.h"
-
-#include "lscript_tree.h"
-#include "lscript_typecheck.h"
-#include "lscript_resource.h"
-#include "lscript_bytecode.h"
-#include "lscript_heap.h"
-#include "lscript_library.h"
-#include "lscript_alloc.h"
-
-//#define LSL_INCLUDE_DEBUG_INFO
-
-
-static void print_cil_box(LLFILE* fp, LSCRIPTType type)
-{
-
-switch(type)
- {
- case LST_INTEGER:
- fprintf(fp, "box [mscorlib]System.Int32\n");
- break;
- case LST_FLOATINGPOINT:
- fprintf(fp, "box [mscorlib]System.Single\n");
- break;
- case LST_STRING:
- // System.String is not a System.ValueType,
- // so does not need to be boxed.
- break;
- case LST_KEY:
- fprintf(fp, "box [ScriptTypes]LindenLab.SecondLife.Key\n");
- break;
- case LST_VECTOR:
- fprintf(fp, "box [ScriptTypes]LindenLab.SecondLife.Vector\n");
- break;
- case LST_QUATERNION:
- fprintf(fp, "box [ScriptTypes]LindenLab.SecondLife.Quaternion\n");
- break;
- default:
- llassert(false);
- break;
- }
-}
-
-static void print_cil_type(LLFILE* fp, LSCRIPTType type)
-{
- switch(type)
- {
- case LST_INTEGER:
- fprintf(fp, "int32");
- break;
- case LST_FLOATINGPOINT:
- fprintf(fp, "float32");
- break;
- case LST_STRING:
- fprintf(fp, "string");
- break;
- case LST_KEY:
- fprintf(fp, "valuetype [ScriptTypes]LindenLab.SecondLife.Key");
- break;
- case LST_VECTOR:
- fprintf(fp, "class [ScriptTypes]LindenLab.SecondLife.Vector");
- break;
- case LST_QUATERNION:
- fprintf(fp, "class [ScriptTypes]LindenLab.SecondLife.Quaternion");
- break;
- case LST_LIST:
- fprintf(fp, "class [mscorlib]System.Collections.ArrayList");
- break;
- case LST_NULL:
- fprintf(fp, "void");
- break;
- default:
- break;
- }
-}
-
-void LLScriptType::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- case LSCP_EMIT_ASSEMBLY:
- fprintf(fp,"%s",LSCRIPTTypeNames[mType]);
- break;
- case LSCP_TYPE:
- type = mType;
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- print_cil_type(fp, mType);
- break;
- default:
- break;
- }
-}
-
-S32 LLScriptType::getSize()
-{
- return LSCRIPTDataSize[mType];
-}
-
-void LLScriptConstant::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- case LSCP_EMIT_ASSEMBLY:
- fprintf(fp,"Script Constant Base class -- should never get here!\n");
- break;
- default:
- break;
- }
-}
-
-S32 LLScriptConstant::getSize()
-{
- printf("Script Constant Base class -- should never get here!\n");
- return 0;
-}
-
-
-
-void LLScriptConstantInteger::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- fprintf(fp, "%d", mValue);
- break;
- case LSCP_EMIT_ASSEMBLY:
- fprintf(fp, "PUSHARGI %d\n", mValue);
- break;
- case LSCP_TYPE:
- type = mType;
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
- chunk->addInteger(mValue);
- type = mType;
- }
- break;
- case LSCP_TO_STACK:
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHARGI]);
- chunk->addInteger(mValue);
- type = mType;
- }
- break;
- case LSCP_LIST_BUILD_SIMPLE:
- {
- *ldata = new LLScriptLibData(mValue);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- fprintf(fp, "ldc.i4 %d\n", mValue);
- type = mType;
- break;
- default:
- break;
- }
-}
-
-S32 LLScriptConstantInteger::getSize()
-{
- return LSCRIPTDataSize[LST_INTEGER];
-}
-
-void LLScriptConstantFloat::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- fprintf(fp, "%5.5f", mValue);
- break;
- case LSCP_EMIT_ASSEMBLY:
- fprintf(fp, "PUSHARGF %5.5f\n", mValue);
- break;
- case LSCP_TYPE:
- type = mType;
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
- chunk->addFloat(mValue);
- type = mType;
- }
- break;
- case LSCP_TO_STACK:
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHARGF]);
- chunk->addFloat(mValue);
- type = mType;
- }
- break;
- case LSCP_LIST_BUILD_SIMPLE:
- {
- *ldata = new LLScriptLibData(mValue);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- {
- double v = (double)mValue;
- U8 * p = (U8 *)&v; // See ECMA-335 Partition VI, Appendix C.4.6 Examples, line 4
- fprintf(fp, "ldc.r8 (%02x %02x %02x %02x %02x %02x %02x %02x)\n", p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7]);
- type = mType;
- }
- break;
- default:
- break;
- }
-}
-
-S32 LLScriptConstantFloat::getSize()
-{
- return LSCRIPTDataSize[LST_FLOATINGPOINT];
-}
-
-void print_escaped(LLFILE* fp, const char* str)
-{
- putc('"', fp);
- for(const char* c = str; *c != '\0'; ++c)
- {
- switch(*c)
- {
- case '"':
- putc('\\', fp);
- putc(*c, fp);
- break;
- case '\n':
- putc('\\', fp);
- putc('n', fp);
- break;
- case '\t':
- putc(' ', fp);
- putc(' ', fp);
- putc(' ', fp);
- putc(' ', fp);
- break;
- case '\\':
- putc('\\', fp);
- putc('\\', fp);
- break;
- default:
- putc(*c, fp);
- }
- }
- putc('"', fp);
-}
-
-void LLScriptConstantString::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- fprintf(fp, "\"%s\"", mValue);
- break;
- case LSCP_EMIT_ASSEMBLY:
- fprintf(fp, "PUSHARGS \"%s\"\n", mValue);
- break;
- case LSCP_TYPE:
- type = mType;
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
- chunk->addInteger(heap->mCurrentOffset + 1);
- LLScriptLibData *data = new LLScriptLibData(mValue);
- U8 *temp;
- S32 size = lsa_create_data_block(&temp, data, heap->mCurrentOffset);
-
- heap->addBytes(temp, size);
- delete [] temp;
- delete data;
- }
- break;
- case LSCP_TO_STACK:
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHARGS]);
- chunk->addBytes(mValue, (S32)strlen(mValue) + 1);
- type = mType;
- }
- break;
- case LSCP_LIST_BUILD_SIMPLE:
- {
- *ldata = new LLScriptLibData(mValue);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- fprintf(fp, "ldstr ");
- print_escaped(fp, mValue);
- fprintf(fp, "\n");
- default:
- break;
- }
-}
-
-S32 LLScriptConstantString::getSize()
-{
- return (S32)strlen(mValue) + 1;
-}
-
-void LLScriptIdentifier::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- fprintf(fp, "%s", mName);
- break;
- case LSCP_EMIT_ASSEMBLY:
- if (mScopeEntry)
- {
- if (mScopeEntry->mIDType == LIT_VARIABLE)
- {
- fprintf(fp, "$BP + %d [%s]", mScopeEntry->mOffset, mName);
- }
- else if (mScopeEntry->mIDType == LIT_GLOBAL)
- {
- fprintf(fp, "$GVR + %d [%s]", mScopeEntry->mOffset, mName);
- }
- else
- {
- fprintf(fp, "%s", mName);
- }
- }
- break;
- case LSCP_TYPE:
- if (mScopeEntry)
- type = mScopeEntry->mType;
- else
- type = LST_NULL;
- break;
- case LSCP_RESOURCE:
- if (mScopeEntry)
- {
- if (mScopeEntry->mIDType == LIT_VARIABLE)
- {
-// fprintf(fp, "LOCAL : %d : %d : %s\n", mScopeEntry->mOffset, mScopeEntry->mSize, mName);
- }
- else if (mScopeEntry->mIDType == LIT_GLOBAL)
- {
-// fprintf(fp, "GLOBAL: %d : %d : %s\n", mScopeEntry->mOffset, mScopeEntry->mSize, mName);
- }
- }
- break;
- case LSCP_LIST_BUILD_SIMPLE:
- {
- if (mScopeEntry)
- {
- if (mScopeEntry->mType == LST_LIST)
- {
- gErrorToText.writeError(fp, this, LSERROR_NO_LISTS_IN_LISTS);
- }
- else if (mScopeEntry->mAssignable)
- {
- mScopeEntry->mAssignable->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, ldata);
- }
- else
- {
- gErrorToText.writeError(fp, this, LSERROR_NO_UNITIALIZED_VARIABLES_IN_LISTS);
- }
- }
- else
- {
- gErrorToText.writeError(fp, this, LSERROR_UNDEFINED_NAME);
- }
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- fprintf(fp, "'%s'", mName);
- break;
- default:
- break;
- }
-}
-
-S32 LLScriptIdentifier::getSize()
-{
-
- return 0;
-}
-
-
-
-void LLScriptSimpleAssignable::addAssignable(LLScriptSimpleAssignable *assign)
-{
- if (mNextp)
- {
- assign->mNextp = mNextp;
- }
- mNextp = assign;
-}
-
-void LLScriptSimpleAssignable::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- fprintf(fp, "Simple Assignable Base Class -- should never get here!\n");
-}
-
-S32 LLScriptSimpleAssignable::getSize()
-{
-
- printf("Simple Assignable Base Class -- should never get here!\n");
- return 0;
-}
-
-static void print_cil_member(LLFILE* fp, LLScriptIdentifier *ident)
-{
- print_cil_type(fp, ident->mScopeEntry->mType);
- fprintf(fp, " %s::'%s'\n", gScriptp->getClassName(), ident->mScopeEntry->mIdentifier);
-}
-
-void LLScriptSAIdentifier::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- case LSCP_EMIT_ASSEMBLY:
- mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mNextp)
- {
- fprintf(fp, ", ");
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- case LSCP_SCOPE_PASS1:
- {
- LLScriptScopeEntry *entry = scope->findEntry(mIdentifier->mName);
- if (!entry)
- {
- gErrorToText.writeError(fp, this, LSERROR_UNDEFINED_NAME);
- }
- else
- {
- // if we did find it, make sure this identifier is associated with the correct scope entry
- mIdentifier->mScopeEntry = entry;
- }
- if (mNextp)
- {
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- }
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
- if (mIdentifier->mScopeEntry)
- {
- if(mIdentifier->mScopeEntry->mAssignable)
- {
- mIdentifier->mScopeEntry->mAssignable->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- else
- {
- // Babbage: 29/8/06: If the scope entry has no mAssignable,
- // set the default type and add the default 0 value to the
- // chunk. Without this SAVectors and SAQuaternions will
- // assume the arbitrary current type is the assignable type
- // and may attempt to access a null chunk. (SL-20156)
- type = mIdentifier->mScopeEntry->mType;
- chunk->addBytes(LSCRIPTDataSize[type]);
- }
- }
- if (mNextp)
- {
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- }
- break;
- case LSCP_LIST_BUILD_SIMPLE:
- {
- mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, ldata);
- if (mNextp)
- {
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, &(*ldata)->mListp);
- }
- }
- break;
-
- case LSCP_EMIT_CIL_ASSEMBLY:
- {
- fprintf(fp, "ldarg.0\n");
- fprintf(fp, "ldfld ");
- print_cil_member(fp, mIdentifier);
- fprintf(fp, "\n");
- if (mNextp)
- {
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- }
- default:
- mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mNextp)
- {
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- }
-}
-
-S32 LLScriptSAIdentifier::getSize()
-{
- return mIdentifier->getSize();
-}
-
-void LLScriptSAConstant::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- case LSCP_EMIT_ASSEMBLY:
- mConstant->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mNextp)
- {
- fprintf(fp, ", ");
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- case LSCP_LIST_BUILD_SIMPLE:
- {
- mConstant->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, ldata);
- if (mNextp)
- {
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, &(*ldata)->mListp);
- }
- }
- break;
- default:
- mConstant->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mNextp)
- {
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- }
-}
-
-S32 LLScriptSAConstant::getSize()
-{
- return mConstant->getSize();
-}
-
-
-static void print_cil_cast(LLFILE* fp, LSCRIPTType srcType, LSCRIPTType targetType)
-{
- switch(srcType)
- {
- case LST_INTEGER:
- switch(targetType)
- {
- case LST_FLOATINGPOINT:
- fprintf(fp, "conv.r8\n");
- break;
- case LST_STRING:
- fprintf(fp, "call string class [mscorlib]System.Convert::ToString(int32)\n");
- break;
- case LST_LIST:
- print_cil_box(fp, LST_INTEGER);
- fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::CreateList(object)\n");
- break;
- default:
- break;
- }
- break;
- case LST_FLOATINGPOINT:
- switch(targetType)
- {
- case LST_INTEGER:
- fprintf(fp, "call int32 [LslLibrary]LindenLab.SecondLife.LslRunTime::ToInteger(float32)\n");
- break;
- case LST_STRING:
- fprintf(fp, "call string [LslLibrary]LindenLab.SecondLife.LslRunTime::ToString(float32)\n");
- break;
- case LST_LIST:
- print_cil_box(fp, LST_FLOATINGPOINT);
- fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::CreateList(object)\n");
- break;
- default:
- break;
- }
- break;
- case LST_STRING:
- switch(targetType)
- {
- case LST_INTEGER:
- fprintf(fp, "call int32 [LslLibrary]LindenLab.SecondLife.LslRunTime::StringToInt(string)\n");
- break;
- case LST_FLOATINGPOINT:
- fprintf(fp, "call float32 [LslLibrary]LindenLab.SecondLife.LslRunTime::StringToFloat(string)\n");
- break;
- case LST_KEY:
- fprintf(fp, "call valuetype [ScriptTypes]LindenLab.SecondLife.Key class [LslUserScript]LindenLab.SecondLife.LslUserScript::'CreateKey'(string)\n");
- break;
- case LST_LIST:
- fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::CreateList(object)\n");
- break;
- case LST_VECTOR:
- fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Vector class [LslUserScript]LindenLab.SecondLife.LslUserScript::'ParseVector'(string)\n");
- break;
- case LST_QUATERNION:
- fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Quaternion class [LslUserScript]LindenLab.SecondLife.LslUserScript::'ParseQuaternion'(string)\n");
- break;
- default:
- break;
- }
- break;
- case LST_KEY:
- switch(targetType)
- {
- case LST_KEY:
- break;
- case LST_STRING:
- fprintf(fp, "call string [LslUserScript]LindenLab.SecondLife.LslUserScript::'ToString'(valuetype [ScriptTypes]LindenLab.SecondLife.Key)\n");
- break;
- case LST_LIST:
- print_cil_box(fp, LST_KEY);
- fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::CreateList(object)\n");
- break;
- default:
- break;
- }
- break;
- case LST_VECTOR:
- switch(targetType)
- {
- case LST_VECTOR:
- break;
- case LST_STRING:
- fprintf(fp, "call string [LslUserScript]LindenLab.SecondLife.LslUserScript::'ToString'(valuetype [ScriptTypes]LindenLab.SecondLife.Vector)\n");
- break;
- case LST_LIST:
- print_cil_box(fp, LST_VECTOR);
- fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::CreateList(object)\n");
- break;
- default:
- break;
- }
- break;
- case LST_QUATERNION:
- switch(targetType)
- {
- case LST_QUATERNION:
- break;
- case LST_STRING:
- fprintf(fp, "call string [LslUserScript]LindenLab.SecondLife.LslUserScript::'ToString'(valuetype [ScriptTypes]LindenLab.SecondLife.Quaternion)\n");
- break;
- case LST_LIST:
- print_cil_box(fp, LST_QUATERNION);
- fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::CreateList(object)\n");
- break;
- default:
- break;
- }
- break;
- case LST_LIST:
- switch(targetType)
- {
- case LST_LIST:
- break;
- case LST_STRING:
- fprintf(fp, "call string [LslLibrary]LindenLab.SecondLife.LslRunTime::ListToString(class [mscorlib]System.Collections.ArrayList)\n");
- break;
- default:
- break;
- }
- break;
- default:
- break;
- }
-}
-
-static void print_cil_numeric_cast(LLFILE* fp, LSCRIPTType currentArg, LSCRIPTType otherArg)
-{
- if((currentArg == LST_INTEGER) && ((otherArg == LST_FLOATINGPOINT) || (otherArg == LST_VECTOR)))
- {
- print_cil_cast(fp, LST_INTEGER, LST_FLOATINGPOINT);
- }
-}
-
-static void print_cil_assignment_cast(LLFILE* fp, LSCRIPTType src,
- LSCRIPTType dest)
-{
- if (LST_STRING == src && LST_KEY == dest)
- {
- print_cil_cast(fp, src, dest);
- }
- else if(LST_KEY == src && LST_STRING == dest)
- {
- print_cil_cast(fp, src, dest);
- }
- else
- {
- print_cil_numeric_cast(fp, src, dest);
- }
-}
-
-// HACK! Babbage: should be converted to virtual on LSCRIPTSimpleAssignableType to avoid downcasts.
-LSCRIPTType get_type(LLScriptSimpleAssignable* sa)
-{
- LSCRIPTType result = LST_NULL;
- switch(sa->mType)
- {
- case LSSAT_IDENTIFIER:
- result = ((LLScriptSAIdentifier*) sa)->mIdentifier->mScopeEntry->mType;
- break;
- case LSSAT_CONSTANT:
- result = ((LLScriptSAConstant*) sa)->mConstant->mType;
- break;
- case LSSAT_VECTOR_CONSTANT:
- result = LST_VECTOR;
- break;
- case LSSAT_QUATERNION_CONSTANT:
- result = LST_QUATERNION;
- break;
- case LSSAT_LIST_CONSTANT:
- result = LST_LIST;
- break;
- default:
- result = LST_UNDEFINED;
- break;
- }
- return result;
-}
-
-void LLScriptSAVector::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- case LSCP_EMIT_ASSEMBLY:
- fprintf(fp, "< ");
- mEntry3->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", ");
- mEntry2->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", ");
- mEntry1->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " >");
- if (mNextp)
- {
- fprintf(fp, ", ");
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- case LSCP_TYPE:
- // vector's take floats
- mEntry3->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (!legal_assignment(LST_FLOATINGPOINT, type))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- mEntry2->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (!legal_assignment(LST_FLOATINGPOINT, type))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- mEntry1->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (!legal_assignment(LST_FLOATINGPOINT, type))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- type = LST_VECTOR;
- if (mNextp)
- {
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- case LSCP_EMIT_BYTE_CODE:
- mEntry3->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (type == LST_INTEGER)
- {
- S32 offset = chunk->mCurrentOffset - 4;
- bytestream_int2float(chunk->mCodeChunk, offset);
- }
- mEntry2->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (type == LST_INTEGER)
- {
- S32 offset = chunk->mCurrentOffset - 4;
- bytestream_int2float(chunk->mCodeChunk, offset);
- }
- mEntry1->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (type == LST_INTEGER)
- {
- S32 offset = chunk->mCurrentOffset - 4;
- bytestream_int2float(chunk->mCodeChunk, offset);
- }
- if (mNextp)
- {
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- case LSCP_LIST_BUILD_SIMPLE:
- {
- LLScriptByteCodeChunk *list = new LLScriptByteCodeChunk(FALSE);
- mEntry3->recurse(fp, tabs, tabsize, LSCP_EMIT_BYTE_CODE, ptype, prunearg, scope, type, basetype, count, list, heap, stacksize, entry, entrycount, NULL);
- if (type == LST_INTEGER)
- {
- S32 offset = list->mCurrentOffset - 4;
- bytestream_int2float(list->mCodeChunk, offset);
- }
- mEntry2->recurse(fp, tabs, tabsize, LSCP_EMIT_BYTE_CODE, ptype, prunearg, scope, type, basetype, count, list, heap, stacksize, entry, entrycount, NULL);
- if (type == LST_INTEGER)
- {
- S32 offset = list->mCurrentOffset - 4;
- bytestream_int2float(list->mCodeChunk, offset);
- }
- mEntry1->recurse(fp, tabs, tabsize, LSCP_EMIT_BYTE_CODE, ptype, prunearg, scope, type, basetype, count, list, heap, stacksize, entry, entrycount, NULL);
- if (type == LST_INTEGER)
- {
- S32 offset = list->mCurrentOffset - 4;
- bytestream_int2float(list->mCodeChunk, offset);
- }
- LLVector3 vec;
- S32 offset = 0;
- bytestream2vector(vec, list->mCodeChunk, offset);
- *ldata = new LLScriptLibData(vec);
- delete list;
- if (mNextp)
- {
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, &(*ldata)->mListp);
- }
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
-
- // Load arguments.
- mEntry1->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if(LST_INTEGER == get_type(mEntry1))
- {
- print_cil_cast(fp, LST_INTEGER, LST_FLOATINGPOINT);
- }
- mEntry2->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if(LST_INTEGER == get_type(mEntry2))
- {
- print_cil_cast(fp, LST_INTEGER, LST_FLOATINGPOINT);
- }
- mEntry3->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if(LST_INTEGER == get_type(mEntry3))
- {
- print_cil_cast(fp, LST_INTEGER, LST_FLOATINGPOINT);
- }
-
- // Call named ctor, which leaves new Vector on stack, so it can be saved in to local or argument just like a primitive type.
- fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Vector class [LslUserScript]LindenLab.SecondLife.LslUserScript::'CreateVector'(float32, float32, float32)\n");
-
- // Next.
- if (mNextp)
- {
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- default:
- mEntry3->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mEntry2->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mEntry1->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mNextp)
- {
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- }
-}
-
-S32 LLScriptSAVector::getSize()
-{
- return mEntry1->getSize() + mEntry2->getSize() + mEntry3->getSize();
-}
-
-void LLScriptSAQuaternion::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- case LSCP_EMIT_ASSEMBLY:
- fprintf(fp, "< ");
- mEntry4->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", ");
- mEntry3->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", ");
- mEntry2->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", ");
- mEntry1->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " >");
- if (mNextp)
- {
- fprintf(fp, ", ");
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- case LSCP_TYPE:
- // vector's take floats
- mEntry4->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (!legal_assignment(LST_FLOATINGPOINT, type))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- mEntry3->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (!legal_assignment(LST_FLOATINGPOINT, type))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- mEntry2->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (!legal_assignment(LST_FLOATINGPOINT, type))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- mEntry1->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (!legal_assignment(LST_FLOATINGPOINT, type))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- type = LST_QUATERNION;
- if (mNextp)
- {
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- case LSCP_EMIT_BYTE_CODE:
- mEntry4->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (type == LST_INTEGER)
- {
- S32 offset = chunk->mCurrentOffset - 4;
- bytestream_int2float(chunk->mCodeChunk, offset);
- }
- mEntry3->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (type == LST_INTEGER)
- {
- S32 offset = chunk->mCurrentOffset - 4;
- bytestream_int2float(chunk->mCodeChunk, offset);
- }
- mEntry2->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (type == LST_INTEGER)
- {
- S32 offset = chunk->mCurrentOffset - 4;
- bytestream_int2float(chunk->mCodeChunk, offset);
- }
- mEntry1->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (type == LST_INTEGER)
- {
- S32 offset = chunk->mCurrentOffset - 4;
- bytestream_int2float(chunk->mCodeChunk, offset);
- }
- if (mNextp)
- {
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- case LSCP_LIST_BUILD_SIMPLE:
- {
- LLScriptByteCodeChunk *list = new LLScriptByteCodeChunk(FALSE);
- mEntry4->recurse(fp, tabs, tabsize, LSCP_EMIT_BYTE_CODE, ptype, prunearg, scope, type, basetype, count, list, heap, stacksize, entry, entrycount, NULL);
- if (type == LST_INTEGER)
- {
- S32 offset = list->mCurrentOffset - 4;
- bytestream_int2float(list->mCodeChunk, offset);
- }
- mEntry3->recurse(fp, tabs, tabsize, LSCP_EMIT_BYTE_CODE, ptype, prunearg, scope, type, basetype, count, list, heap, stacksize, entry, entrycount, NULL);
- if (type == LST_INTEGER)
- {
- S32 offset = list->mCurrentOffset - 4;
- bytestream_int2float(list->mCodeChunk, offset);
- }
- mEntry2->recurse(fp, tabs, tabsize, LSCP_EMIT_BYTE_CODE, ptype, prunearg, scope, type, basetype, count, list, heap, stacksize, entry, entrycount, NULL);
- if (type == LST_INTEGER)
- {
- S32 offset = list->mCurrentOffset - 4;
- bytestream_int2float(list->mCodeChunk, offset);
- }
- mEntry1->recurse(fp, tabs, tabsize, LSCP_EMIT_BYTE_CODE, ptype, prunearg, scope, type, basetype, count, list, heap, stacksize, entry, entrycount, NULL);
- if (type == LST_INTEGER)
- {
- S32 offset = list->mCurrentOffset - 4;
- bytestream_int2float(list->mCodeChunk, offset);
- }
- LLQuaternion quat;
- S32 offset = 0;
- bytestream2quaternion(quat, list->mCodeChunk, offset);
- *ldata = new LLScriptLibData(quat);
- delete list;
- if (mNextp)
- {
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, &(*ldata)->mListp);
- }
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
-
- // Load arguments.
- mEntry1->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if(LST_INTEGER == get_type(mEntry1))
- {
- print_cil_cast(fp, LST_INTEGER, LST_FLOATINGPOINT);
- }
- mEntry2->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if(LST_INTEGER == get_type(mEntry2))
- {
- print_cil_cast(fp, LST_INTEGER, LST_FLOATINGPOINT);
- }
- mEntry3->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if(LST_INTEGER == get_type(mEntry3))
- {
- print_cil_cast(fp, LST_INTEGER, LST_FLOATINGPOINT);
- }
- mEntry4->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if(LST_INTEGER == get_type(mEntry4))
- {
- print_cil_cast(fp, LST_INTEGER, LST_FLOATINGPOINT);
- }
-
- // Call named ctor, which leaves new Vector on stack, so it can be saved in to local or argument just like a primitive type.
- fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Quaternion class [LslUserScript]LindenLab.SecondLife.LslUserScript::'CreateQuaternion'(float32, float32, float32, float32)\n");
-
- // Next.
- if (mNextp)
- {
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- default:
- mEntry4->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mEntry3->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mEntry2->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mEntry1->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mNextp)
- {
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- }
-}
-
-S32 LLScriptSAQuaternion::getSize()
-{
- return mEntry1->getSize() + mEntry2->getSize() + mEntry3->getSize() + mEntry4->getSize();
-}
-
-void LLScriptSAList::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- case LSCP_EMIT_ASSEMBLY:
- fprintf(fp, "[ ");
- if (mEntryList)
- mEntryList->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " ]");
- if (mNextp)
- {
- fprintf(fp, ", ");
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- case LSCP_TYPE:
- if (mEntryList)
- mEntryList->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- type = LST_LIST;
- if (mNextp)
- {
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
- LLScriptLibData *list_data = new LLScriptLibData;
-
- list_data->mType = LST_LIST;
- if (mEntryList)
- mEntryList->recurse(fp, tabs, tabsize, LSCP_LIST_BUILD_SIMPLE, ptype, prunearg, scope, type, basetype, count, chunk, NULL, stacksize, entry, entrycount, &(list_data->mListp));
-
- U8 *temp;
- chunk->addInteger(heap->mCurrentOffset + 1);
- S32 size = lsa_create_data_block(&temp, list_data, heap->mCurrentOffset);
- heap->addBytes(temp, size);
- delete list_data;
- delete [] temp;
-
- if (mNextp)
- {
- mNextp->recurse(fp, tabs, tabsize, LSCP_EMIT_BYTE_CODE, ptype, prunearg, scope, type, basetype, count, chunk, NULL, stacksize, entry, entrycount, NULL);
- }
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- {
- // Create list.
- fprintf(fp, "call class [mscorlib]System.Collections.ArrayList [LslUserScript]LindenLab.SecondLife.LslUserScript::CreateList()\n");
-
- // Add elements.
- LLScriptSimpleAssignable* current_entry = mEntryList;
- LLScriptSimpleAssignable* next_entry = NULL;
- while(NULL != current_entry)
- {
- next_entry = current_entry->mNextp;
-
- // Null mNextp pointer, so only current list element is processed.
- current_entry->mNextp = NULL;
- current_entry->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
-
- // Restore mNextp pointer.
- current_entry->mNextp = next_entry;
-
- // Box element and store in list.
- print_cil_box(fp, get_type(current_entry));
- fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::Append(class [mscorlib]System.Collections.ArrayList, object)\n");
-
- // Process next element.
- current_entry = next_entry;
- }
-
- // Process next list.
- if (mNextp)
- {
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- }
- break;
- default:
- if (mEntryList)
- mEntryList->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, ldata);
- if (mNextp)
- {
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, ldata);
- }
- break;
- }
-}
-
-S32 LLScriptSAList::getSize()
-{
- return mEntryList->getSize();
-}
-
-void LLScriptGlobalVariable::addGlobal(LLScriptGlobalVariable *global)
-{
- if (mNextp)
- {
- global->mNextp = mNextp;
- }
- mNextp = global;
-}
-
-void LLScriptGlobalVariable::gonext(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- if (mNextp)
- {
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- default:
- if (mNextp)
- {
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- }
-}
-
-// Push initialised variable of type on to stack.
-static void print_cil_init_variable(LLFILE* fp, LSCRIPTType type)
-{
- switch(type)
- {
- case LST_INTEGER:
- fprintf(fp, "ldc.i4.0\n");
- break;
- case LST_FLOATINGPOINT:
- fprintf(fp, "ldc.r8 0\n");
- break;
- case LST_STRING:
- fprintf(fp, "ldstr \"\"\n");
- break;
- case LST_KEY:
- fprintf(fp, "ldstr \"\"\n");
- fprintf(fp, "call valuetype [ScriptTypes]LindenLab.SecondLife.Key class [LslUserScript]LindenLab.SecondLife.LslUserScript::'CreateKey'(string)\n");
- break;
- case LST_VECTOR:
- fprintf(fp, "ldc.r8 0\n");
- fprintf(fp, "ldc.r8 0\n");
- fprintf(fp, "ldc.r8 0\n");
- fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Vector class [LslUserScript]LindenLab.SecondLife.LslUserScript::'CreateVector'(float32, float32, float32)\n");
- break;
- case LST_QUATERNION:
- fprintf(fp, "ldc.r8 0\n");
- fprintf(fp, "ldc.r8 0\n");
- fprintf(fp, "ldc.r8 0\n");
- fprintf(fp, "ldc.r8 1\n");
- fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Quaternion class [LslUserScript]LindenLab.SecondLife.LslUserScript::'CreateQuaternion'(float32, float32, float32, float32)\n");
- break;
- case LST_LIST:
- fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::CreateList()\n");
- break;
- default:
- break;
- }
-}
-
-void LLScriptGlobalVariable::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- mType->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp,"\t");
- mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mAssignable)
- {
- fprintf(fp, " = ");
- mAssignable->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- fprintf(fp, ";\n");
- break;
- case LSCP_EMIT_ASSEMBLY:
- mType->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp,"\t");
- mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mAssignable)
- {
- fprintf(fp, " = ");
- mAssignable->recurse(fp, tabs, tabsize, LSCP_PRETTY_PRINT, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "\n");
- fprintf(fp, "Offset: %d Type: %d\n", mIdentifier->mScopeEntry->mOffset, (S32)LSCRIPTTypeByte[mType->mType]);
- }
- else
- {
- fprintf(fp, "\n");
- fprintf(fp, "Offset: %d Type: %d\n", mIdentifier->mScopeEntry->mOffset, (S32)LSCRIPTTypeByte[mType->mType]);
- }
- break;
- case LSCP_SCOPE_PASS1:
- if (scope->checkEntry(mIdentifier->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- if (mAssignable)
- {
- mAssignable->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- // this needs to go after expression decent to make sure that we don't add ourselves or something silly
- mIdentifier->mScopeEntry = scope->addEntry(mIdentifier->mName, LIT_GLOBAL, mType->mType);
- if (mIdentifier->mScopeEntry && mAssignable)
- mIdentifier->mScopeEntry->mAssignable = mAssignable;
- }
- break;
- case LSCP_TYPE:
- // if the variable has an assignable, it must assignable to the variable's type
- if (mAssignable)
- {
- mAssignable->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mAssignableType = type;
- if (!legal_assignment(mType->mType, mAssignableType))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- }
- break;
- case LSCP_RESOURCE:
- {
- // we're just tryng to determine how much space the variable needs
- // it also includes the name of the variable as well as the type
- // plus 4 bytes of offset from it's apparent address to the actual data
-#ifdef LSL_INCLUDE_DEBUG_INFO
- count += strlen(mIdentifier->mName) + 1 + 1 + 4;
-#else
- count += 1 + 1 + 4;
-#endif
- mIdentifier->mScopeEntry->mOffset = (S32)count;
- mIdentifier->mScopeEntry->mSize = mType->getSize();
- count += mIdentifier->mScopeEntry->mSize;
- mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
- // order for global variables
- // 0 - 4: offset to actual data
- S32 offsetoffset = chunk->mCurrentOffset;
- S32 offsetdelta = 0;
- chunk->addBytes(4);
- // type
- char vtype;
- vtype = LSCRIPTTypeByte[mType->mType];
- chunk->addBytes(&vtype, 1);
- // null terminated name
-#ifdef LSL_INCLUDE_DEBUG_INFO
- chunk->addBytes(mIdentifier->mName, strlen(mIdentifier->mName) + 1);
-#else
- chunk->addBytes(1);
-#endif
- // put correct offset delta in
- offsetdelta = chunk->mCurrentOffset - offsetoffset;
- integer2bytestream(chunk->mCodeChunk, offsetoffset, offsetdelta);
-
- // now we need space for the variable itself
- LLScriptByteCodeChunk *value = new LLScriptByteCodeChunk(FALSE);
- if (mAssignable)
- {
- mAssignable->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, value, heap, stacksize, entry, entrycount, NULL);
- // need to put sneaky type conversion here
- if (mAssignableType != mType->mType)
- {
- // the only legal case that is a problem is int->float
- if (mType->mType == LST_FLOATINGPOINT && mAssignableType == LST_INTEGER)
- {
- S32 offset = value->mCurrentOffset - 4;
- bytestream_int2float(value->mCodeChunk, offset);
- }
- }
- }
- else
- {
- if ( (mType->mType == LST_STRING)
- ||(mType->mType == LST_KEY))
- {
- // string and keys (even empty ones) need heap entries
- chunk->addInteger(heap->mCurrentOffset + 1);
- LLScriptLibData *data = new LLScriptLibData("");
- U8 *temp;
- S32 size = lsa_create_data_block(&temp, data, heap->mCurrentOffset);
-
- heap->addBytes(temp, size);
- delete [] temp;
- delete data;
- }
- else if (mType->mType == LST_LIST)
- {
- chunk->addInteger(heap->mCurrentOffset + 1);
- LLScriptLibData *data = new LLScriptLibData;
- data->mType = LST_LIST;
- U8 *temp;
- S32 size = lsa_create_data_block(&temp, data, heap->mCurrentOffset);
-
- heap->addBytes(temp, size);
- delete [] temp;
- delete data;
- }
- else if (mType->mType == LST_QUATERNION)
- {
- chunk->addFloat(1.f);
- chunk->addFloat(0.f);
- chunk->addFloat(0.f);
- chunk->addFloat(0.f);
- }
- else
- {
- value->addBytes(LSCRIPTDataSize[mType->mType]);
- }
- }
- chunk->addBytes(value->mCodeChunk, value->mCurrentOffset);
- delete value;
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
-
- // Initialisation inside ctor.
- fprintf(fp, "ldarg.0\n");
- if (mAssignable)
- {
- // Initialise to value.
- mAssignable->recurse(fp, tabs, tabsize, LSCP_EMIT_CIL_ASSEMBLY,
- ptype, prunearg, scope, type, basetype,
- count, chunk, heap, stacksize, entry,
- entrycount, NULL);
- print_cil_assignment_cast(fp, get_type(mAssignable), mType->mType);
- }
- else
- {
- // Initialise to zero.
- print_cil_init_variable(fp, mType->mType);
- }
- // Store value.
- fprintf(fp, "stfld ");
- mType->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp," %s::", gScriptp->getClassName());
- mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "\n");
- break;
- default:
- mType->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mAssignable)
- {
- mAssignable->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
-}
-
-S32 LLScriptGlobalVariable::getSize()
-{
- S32 return_size;
-
- return_size = mType->getSize();
- return return_size;
-}
-
-void LLScriptEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- fprintf(fp, "Event Base Class -- should never get here!\n");
-}
-
-S32 LLScriptEvent::getSize()
-{
- printf("Event Base Class -- should never get here!\n");
- return 0;
-}
-static void checkForDuplicateHandler(LLFILE *fp, LLScriptFilePosition *pos,
- LLScriptScope *scope,
- const char* name)
-{
- LLScriptScope *parent = scope->mParentScope;
- if (parent->checkEntry((char*)name))
- {
- gErrorToText.writeError(fp, pos, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- parent->addEntry(((char*)name), LIT_HANDLER, LST_NULL);
- }
-}
-
-void LLScriptStateEntryEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "state_entry()\n");
- break;
- case LSCP_EMIT_ASSEMBLY:
- fprintf(fp, "state_entry()\n");
- break;
- case LSCP_SCOPE_PASS1:
- checkForDuplicateHandler(fp, this, scope, "state_entry");
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
-#ifdef LSL_INCLUDE_DEBUG_INFO
- char name[] = "state_entry";
- chunk->addBytes(name, strlen(name) + 1);
-#endif
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- fprintf(fp, "state_entry()");
- break;
- default:
- break;
- }
-}
-
-S32 LLScriptStateEntryEvent::getSize()
-{
- return 0;
-}
-
-void LLScriptStateExitEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "state_exit()\n");
- break;
- case LSCP_SCOPE_PASS1:
- checkForDuplicateHandler(fp, this, scope, "state_exit");
- break;
- case LSCP_EMIT_ASSEMBLY:
- fprintf(fp, "state_exit()\n");
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
-#ifdef LSL_INCLUDE_DEBUG_INFO
- char name[] = "state_exit";
- chunk->addBytes(name, strlen(name) + 1);
-#endif
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- fprintf(fp, "state_exit()");
- break;
- default:
- break;
- }
-}
-
-S32 LLScriptStateExitEvent::getSize()
-{
- return 0;
-}
-
-void LLScriptTouchStartEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- case LSCP_EMIT_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "touch_start( integer ");
- mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )\n");
- break;
- break;
- case LSCP_SCOPE_PASS1:
- checkForDuplicateHandler(fp, this, scope, "touch_start");
- if (scope->checkEntry(mCount->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mCount->mScopeEntry = scope->addEntry(mCount->mName, LIT_VARIABLE, LST_INTEGER);
- }
- break;
- case LSCP_RESOURCE:
- {
- // we're just tryng to determine how much space the variable needs
- if (mCount->mScopeEntry)
- {
- mCount->mScopeEntry->mOffset = (S32)count;
- mCount->mScopeEntry->mSize = 4;
- count += mCount->mScopeEntry->mSize;
- }
- }
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
-#ifdef LSL_INCLUDE_DEBUG_INFO
- char name[] = "touch_start";
- chunk->addBytes(name, strlen(name) + 1);
- chunk->addBytes(mCount->mName, strlen(mCount->mName) + 1);
-#endif
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "touch_start( int32 ");
- mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )");
- break;
- break;
- default:
- mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
-}
-
-S32 LLScriptTouchStartEvent::getSize()
-{
- // integer = 4
- return 4;
-}
-
-void LLScriptTouchEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- case LSCP_EMIT_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "touch( integer ");
- mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )\n");
- break;
- break;
- case LSCP_SCOPE_PASS1:
- checkForDuplicateHandler(fp, this, scope, "touch");
- if (scope->checkEntry(mCount->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mCount->mScopeEntry = scope->addEntry(mCount->mName, LIT_VARIABLE, LST_INTEGER);
- }
- break;
- case LSCP_RESOURCE:
- {
- // we're just tryng to determine how much space the variable needs
- if (mCount->mScopeEntry)
- {
- mCount->mScopeEntry->mOffset = (S32)count;
- mCount->mScopeEntry->mSize = 4;
- count += mCount->mScopeEntry->mSize;
- }
- }
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
-#ifdef LSL_INCLUDE_DEBUG_INFO
- char name[] = "touch";
- chunk->addBytes(name, strlen(name) + 1);
- chunk->addBytes(mCount->mName, strlen(mCount->mName) + 1);
-#endif
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "touch( int32 ");
- mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )");
- break;
- break;
- default:
- mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
-}
-
-S32 LLScriptTouchEvent::getSize()
-{
- // integer = 4
- return 4;
-}
-
-void LLScriptTouchEndEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- case LSCP_EMIT_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "touch_end( integer ");
- mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )\n");
- break;
- break;
- case LSCP_SCOPE_PASS1:
- checkForDuplicateHandler(fp, this, scope, "touch_end");
- if (scope->checkEntry(mCount->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mCount->mScopeEntry = scope->addEntry(mCount->mName, LIT_VARIABLE, LST_INTEGER);
- }
- break;
- case LSCP_RESOURCE:
- {
- // we're just tryng to determine how much space the variable needs
- if (mCount->mScopeEntry)
- {
- mCount->mScopeEntry->mOffset = (S32)count;
- mCount->mScopeEntry->mSize = 4;
- count += mCount->mScopeEntry->mSize;
- }
- }
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
-#ifdef LSL_INCLUDE_DEBUG_INFO
- char name[] = "touch_end";
- chunk->addBytes(name, strlen(name) + 1);
- chunk->addBytes(mCount->mName, strlen(mCount->mName) + 1);
-#endif
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "touch_end( int32 ");
- mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )");
- break;
- break;
- default:
- mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
-}
-
-S32 LLScriptTouchEndEvent::getSize()
-{
- // integer = 4
- return 4;
-}
-
-void LLScriptCollisionStartEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- case LSCP_EMIT_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "collision_start( integer ");
- mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )\n");
- break;
- break;
- case LSCP_SCOPE_PASS1:
- checkForDuplicateHandler(fp, this, scope, "collision_start");
- if (scope->checkEntry(mCount->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mCount->mScopeEntry = scope->addEntry(mCount->mName, LIT_VARIABLE, LST_INTEGER);
- }
- break;
- case LSCP_RESOURCE:
- {
- // we're just tryng to determine how much space the variable needs
- if (mCount->mScopeEntry)
- {
- mCount->mScopeEntry->mOffset = (S32)count;
- mCount->mScopeEntry->mSize = 4;
- count += mCount->mScopeEntry->mSize;
- }
- }
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
-#ifdef LSL_INCLUDE_DEBUG_INFO
- char name[] = "collision_start";
- chunk->addBytes(name, (S32)strlen(name) + 1);
- chunk->addBytes(mCount->mName, (S32)strlen(mCount->mName) + 1);
-#endif
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "collision_start( int32 ");
- mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )");
- break;
- default:
- mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
-}
-
-S32 LLScriptCollisionStartEvent::getSize()
-{
- // integer = 4
- return 4;
-}
-
-void LLScriptCollisionEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- case LSCP_EMIT_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "collision( integer ");
- mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )\n");
- break;
- break;
- case LSCP_SCOPE_PASS1:
- checkForDuplicateHandler(fp, this, scope, "collision");
- if (scope->checkEntry(mCount->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mCount->mScopeEntry = scope->addEntry(mCount->mName, LIT_VARIABLE, LST_INTEGER);
- }
- break;
- case LSCP_RESOURCE:
- {
- // we're just tryng to determine how much space the variable needs
- if (mCount->mScopeEntry)
- {
- mCount->mScopeEntry->mOffset = (S32)count;
- mCount->mScopeEntry->mSize = 4;
- count += mCount->mScopeEntry->mSize;
- }
- }
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
-#ifdef LSL_INCLUDE_DEBUG_INFO
- char name[] = "collision";
- chunk->addBytes(name, strlen(name) + 1);
- chunk->addBytes(mCount->mName, strlen(mCount->mName) + 1);
-#endif
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- fprintf(fp, "collision( int32 ");
- mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )");
- break;
- default:
- mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
-}
-
-S32 LLScriptCollisionEvent::getSize()
-{
- // integer = 4
- return 4;
-}
-
-void LLScriptCollisionEndEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- case LSCP_EMIT_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "collision_end( integer ");
- mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )\n");
- break;
- break;
- case LSCP_SCOPE_PASS1:
- checkForDuplicateHandler(fp, this, scope, "collision_end");
- if (scope->checkEntry(mCount->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mCount->mScopeEntry = scope->addEntry(mCount->mName, LIT_VARIABLE, LST_INTEGER);
- }
- break;
- case LSCP_RESOURCE:
- {
- // we're just tryng to determine how much space the variable needs
- if (mCount->mScopeEntry)
- {
- mCount->mScopeEntry->mOffset = (S32)count;
- mCount->mScopeEntry->mSize = 4;
- count += mCount->mScopeEntry->mSize;
- }
- }
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
-#ifdef LSL_INCLUDE_DEBUG_INFO
- char name[] = "collision_end";
- chunk->addBytes(name, strlen(name) + 1);
- chunk->addBytes(mCount->mName, strlen(mCount->mName) + 1);
-#endif
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "collision_end( int32 ");
- mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )");
- break;
- default:
- mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
-}
-
-S32 LLScriptCollisionEndEvent::getSize()
-{
- // integer = 4
- return 4;
-}
-
-void LLScriptLandCollisionStartEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- case LSCP_EMIT_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "land_collision_start( vector ");
- mPosition->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )\n");
- break;
- case LSCP_SCOPE_PASS1:
- checkForDuplicateHandler(fp, this, scope, "land_collision_start");
- if (scope->checkEntry(mPosition->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mPosition->mScopeEntry = scope->addEntry(mPosition->mName, LIT_VARIABLE, LST_VECTOR);
- }
- break;
- case LSCP_RESOURCE:
- {
- // we're just tryng to determine how much space the variable needs
- if (mPosition->mScopeEntry)
- {
- mPosition->mScopeEntry->mOffset = (S32)count;
- mPosition->mScopeEntry->mSize = 12;
- count += mPosition->mScopeEntry->mSize;
- }
- }
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
-#ifdef LSL_INCLUDE_DEBUG_INFO
- char name[] = "land_collision_start";
- chunk->addBytes(name, strlen(name) + 1);
- chunk->addBytes(mPosition->mName, strlen(mPosition->mName) + 1);
-#endif
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "land_collision_start( class [ScriptTypes]LindenLab.SecondLife.Vector ");
- mPosition->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )");
- break;
- default:
- mPosition->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
-}
-
-S32 LLScriptLandCollisionStartEvent::getSize()
-{
- // vector = 12
- return 12;
-}
-
-
-
-void LLScriptLandCollisionEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- case LSCP_EMIT_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "land_collision( vector ");
- mPosition->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )\n");
- break;
- case LSCP_SCOPE_PASS1:
- checkForDuplicateHandler(fp, this, scope, "land_collision");
- if (scope->checkEntry(mPosition->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mPosition->mScopeEntry = scope->addEntry(mPosition->mName, LIT_VARIABLE, LST_VECTOR);
- }
- break;
- case LSCP_RESOURCE:
- {
- // we're just tryng to determine how much space the variable needs
- if (mPosition->mScopeEntry)
- {
- mPosition->mScopeEntry->mOffset = (S32)count;
- mPosition->mScopeEntry->mSize = 12;
- count += mPosition->mScopeEntry->mSize;
- }
- }
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
-#ifdef LSL_INCLUDE_DEBUG_INFO
- char name[] = "land_collision";
- chunk->addBytes(name, strlen(name) + 1);
- chunk->addBytes(mPosition->mName, strlen(mPosition->mName) + 1);
-#endif
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "land_collision( class [ScriptTypes]LindenLab.SecondLife.Vector ");
- mPosition->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )");
- break;
- default:
- mPosition->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
-}
-
-S32 LLScriptLandCollisionEvent::getSize()
-{
- // vector = 12
- return 12;
-}
-
-
-void LLScriptLandCollisionEndEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- case LSCP_EMIT_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "land_collision_end( vector ");
- mPosition->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )\n");
- break;
- case LSCP_SCOPE_PASS1:
- checkForDuplicateHandler(fp, this, scope, "land_collision_end");
- if (scope->checkEntry(mPosition->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mPosition->mScopeEntry = scope->addEntry(mPosition->mName, LIT_VARIABLE, LST_VECTOR);
- }
- break;
- case LSCP_RESOURCE:
- {
- // we're just tryng to determine how much space the variable needs
- if (mPosition->mScopeEntry)
- {
- mPosition->mScopeEntry->mOffset = (S32)count;
- mPosition->mScopeEntry->mSize = 12;
- count += mPosition->mScopeEntry->mSize;
- }
- }
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
-#ifdef LSL_INCLUDE_DEBUG_INFO
- char name[] = "land_collision_end";
- chunk->addBytes(name, strlen(name) + 1);
- chunk->addBytes(mPosition->mName, strlen(mPosition->mName) + 1);
-#endif
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "land_collision_end( class [ScriptTypes]LindenLab.SecondLife.Vector ");
- mPosition->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )");
- break;
- default:
- mPosition->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
-}
-
-S32 LLScriptLandCollisionEndEvent::getSize()
-{
- // vector = 12
- return 12;
-}
-
-
-void LLScriptInventoryEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- case LSCP_EMIT_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "changed( integer ");
- mChange->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )\n");
- break;
- case LSCP_SCOPE_PASS1:
- checkForDuplicateHandler(fp, this, scope, "changed");
- if (scope->checkEntry(mChange->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mChange->mScopeEntry = scope->addEntry(mChange->mName, LIT_VARIABLE, LST_INTEGER);
- }
- break;
- case LSCP_RESOURCE:
- {
- // we're just tryng to determine how much space the variable needs
- if (mChange->mScopeEntry)
- {
- mChange->mScopeEntry->mOffset = (S32)count;
- mChange->mScopeEntry->mSize = 4;
- count += mChange->mScopeEntry->mSize;
- }
- }
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
-#ifdef LSL_INCLUDE_DEBUG_INFO
- char name[] = "changed";
- chunk->addBytes(name, strlen(name) + 1);
- chunk->addBytes(mChange->mName, strlen(mChange->mName) + 1);
-#endif
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "changed( int32 ");
- mChange->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )");
- break;
- default:
- mChange->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
-}
-
-S32 LLScriptInventoryEvent::getSize()
-{
- // integer = 4
- return 4;
-}
-
-void LLScriptAttachEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- case LSCP_EMIT_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "attach( key ");
- mAttach->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )\n");
- break;
- case LSCP_SCOPE_PASS1:
- checkForDuplicateHandler(fp, this, scope, "attach");
- if (scope->checkEntry(mAttach->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mAttach->mScopeEntry = scope->addEntry(mAttach->mName, LIT_VARIABLE, LST_KEY);
- }
- break;
- case LSCP_RESOURCE:
- {
- // we're just tryng to determine how much space the variable needs
- if (mAttach->mScopeEntry)
- {
- mAttach->mScopeEntry->mOffset = (S32)count;
- mAttach->mScopeEntry->mSize = 4;
- count += mAttach->mScopeEntry->mSize;
- }
- }
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
-#ifdef LSL_INCLUDE_DEBUG_INFO
- char name[] = "attach";
- chunk->addBytes(name, strlen(name) + 1);
- chunk->addBytes(mAttach->mName, strlen(mAttach->mName) + 1);
-#endif
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "attach( valuetype [ScriptTypes]LindenLab.SecondLife.Key ");
- mAttach->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )\n");
- break;
- default:
- mAttach->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
-}
-
-S32 LLScriptAttachEvent::getSize()
-{
- // key = 4
- return 4;
-}
-
-void LLScriptDataserverEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- case LSCP_EMIT_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "dataserver( key ");
- mID->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", string ");
- mData->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )\n");
- break;
- case LSCP_SCOPE_PASS1:
- checkForDuplicateHandler(fp, this, scope, "dataserver");
- if (scope->checkEntry(mID->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mID->mScopeEntry = scope->addEntry(mID->mName, LIT_VARIABLE, LST_KEY);
- }
- if (scope->checkEntry(mData->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mData->mScopeEntry = scope->addEntry(mData->mName, LIT_VARIABLE, LST_STRING);
- }
- break;
- case LSCP_RESOURCE:
- {
- // we're just tryng to determine how much space the variable needs
- if (mID->mScopeEntry)
- {
- mID->mScopeEntry->mOffset = (S32)count;
- mID->mScopeEntry->mSize = 4;
- count += mID->mScopeEntry->mSize;
- mData->mScopeEntry->mOffset = (S32)count;
- mData->mScopeEntry->mSize = 4;
- count += mData->mScopeEntry->mSize;
- }
- }
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
-#ifdef LSL_INCLUDE_DEBUG_INFO
- char name[] = "dataserver";
- chunk->addBytes(name, strlen(name) + 1);
- chunk->addBytes(mID->mName, strlen(mID->mName) + 1);
- chunk->addBytes(mData->mName, strlen(mData->mName) + 1);
-#endif
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "dataserver( valuetype [ScriptTypes]LindenLab.SecondLife.Key ");
- mID->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", string ");
- mData->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )");
- break;
- default:
- mID->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mData->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
-}
-
-S32 LLScriptDataserverEvent::getSize()
-{
- // key + string = 8
- return 8;
-}
-
-void LLScriptTimerEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "timer()\n");
- break;
- case LSCP_EMIT_ASSEMBLY:
- fprintf(fp, "timer()\n");
- break;
- case LSCP_SCOPE_PASS1:
- checkForDuplicateHandler(fp, this, scope, "timer");
- break;
-
- case LSCP_EMIT_BYTE_CODE:
- {
-#ifdef LSL_INCLUDE_DEBUG_INFO
- char name[] = "timer";
- chunk->addBytes(name, strlen(name) + 1);
-#endif
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- fprintf(fp, "timer()");
- break;
- default:
- break;
- }
-}
-
-S32 LLScriptTimerEvent::getSize()
-{
- return 0;
-}
-
-void LLScriptMovingStartEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- case LSCP_EMIT_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "moving_start()\n");
- break;
- case LSCP_SCOPE_PASS1:
- checkForDuplicateHandler(fp, this, scope, "moving_start");
- break;
-
- case LSCP_EMIT_BYTE_CODE:
- {
-#ifdef LSL_INCLUDE_DEBUG_INFO
- char name[] = "moving_start";
- chunk->addBytes(name, strlen(name) + 1);
-#endif
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- fprintf(fp, "moving_start()");
- break;
- default:
- break;
- }
-}
-
-S32 LLScriptMovingStartEvent::getSize()
-{
- return 0;
-}
-
-void LLScriptMovingEndEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- case LSCP_EMIT_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "moving_end()\n");
- break;
- case LSCP_SCOPE_PASS1:
- checkForDuplicateHandler(fp, this, scope, "moving_end");
- break;
-
- case LSCP_EMIT_BYTE_CODE:
- {
-#ifdef LSL_INCLUDE_DEBUG_INFO
- char name[] = "moving_end";
- chunk->addBytes(name, strlen(name) + 1);
-#endif
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- fprintf(fp, "moving_end()");
- break;
- default:
- break;
- }
-}
-
-S32 LLScriptMovingEndEvent::getSize()
-{
- return 0;
-}
-
-void LLScriptRTPEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- case LSCP_EMIT_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "chat( integer ");
- mRTPermissions->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )\n");
- break;
- case LSCP_SCOPE_PASS1:
- checkForDuplicateHandler(fp, this, scope, "run_time_perms");
- if (scope->checkEntry(mRTPermissions->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mRTPermissions->mScopeEntry = scope->addEntry(mRTPermissions->mName, LIT_VARIABLE, LST_INTEGER);
- }
- break;
- case LSCP_RESOURCE:
- {
- // we're just tryng to determine how much space the variable needs
- if (mRTPermissions->mScopeEntry)
- {
- mRTPermissions->mScopeEntry->mOffset = (S32)count;
- mRTPermissions->mScopeEntry->mSize = 4;
- count += mRTPermissions->mScopeEntry->mSize;
- }
- }
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
-#ifdef LSL_INCLUDE_DEBUG_INFO
- char name[] = "chat";
- chunk->addBytes(name, strlen(name) + 1);
- chunk->addBytes(mRTPermissions->mName, strlen(mRTPermissions->mName) + 1);
-#endif
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- // NOTE: Not replicating LSL2 bug by calling RTP event hander "chat"
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "run_time_perms( int32 ");
- mRTPermissions->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )");
- break;
- default:
- mRTPermissions->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
-}
-
-S32 LLScriptRTPEvent::getSize()
-{
- // integer = 4
- return 4;
-}
-
-void LLScriptChatEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- case LSCP_EMIT_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "chat( integer ");
- mChannel->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", string ");
- mName->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", key ");
- mID->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", string ");
- mMessage->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )\n");
- break;
- case LSCP_SCOPE_PASS1:
- checkForDuplicateHandler(fp, this, scope, "listen"); // note: this is actually listen in lsl source
- if (scope->checkEntry(mChannel->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mChannel->mScopeEntry = scope->addEntry(mChannel->mName, LIT_VARIABLE, LST_INTEGER);
- }
- if (scope->checkEntry(mName->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mName->mScopeEntry = scope->addEntry(mName->mName, LIT_VARIABLE, LST_STRING);
- }
- if (scope->checkEntry(mID->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mID->mScopeEntry = scope->addEntry(mID->mName, LIT_VARIABLE, LST_KEY);
- }
- if (scope->checkEntry(mMessage->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mMessage->mScopeEntry = scope->addEntry(mMessage->mName, LIT_VARIABLE, LST_STRING);
- }
- break;
- case LSCP_RESOURCE:
- {
- // we're just tryng to determine how much space the variable needs
- if (mName->mScopeEntry)
- {
- mChannel->mScopeEntry->mOffset = (S32)count;
- mChannel->mScopeEntry->mSize = 4;
- count += mChannel->mScopeEntry->mSize;
- mName->mScopeEntry->mOffset = (S32)count;
- mName->mScopeEntry->mSize = 4;
- count += mName->mScopeEntry->mSize;
- mID->mScopeEntry->mOffset = (S32)count;
- mID->mScopeEntry->mSize = 4;
- count += mID->mScopeEntry->mSize;
- mMessage->mScopeEntry->mOffset = (S32)count;
- mMessage->mScopeEntry->mSize = 4;
- count += mMessage->mScopeEntry->mSize;
- }
- }
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
-#ifdef LSL_INCLUDE_DEBUG_INFO
- char name[] = "chat";
- chunk->addBytes(name, strlen(name) + 1);
- chunk->addBytes(mChannel->mName, strlen(mChannel->mName) + 1);
- chunk->addBytes(mName->mName, strlen(mName->mName) + 1);
- chunk->addBytes(mID->mName, strlen(mID->mName) + 1);
- chunk->addBytes(mMessage->mName, strlen(mMessage->mName) + 1);
-#endif
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "chat( int32 ");
- mChannel->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", string ");
- mName->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", valuetype [ScriptTypes]LindenLab.SecondLife.Key ");
- mID->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", string ");
- mMessage->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )");
- break;
- default:
- mChannel->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mName->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mID->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mMessage->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
-}
-
-S32 LLScriptChatEvent::getSize()
-{
- // integer + key + string + string = 16
- return 16;
-}
-
-void LLScriptSensorEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- case LSCP_EMIT_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "sensor( integer ");
- mNumber->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )\n");
- break;
- case LSCP_SCOPE_PASS1:
- checkForDuplicateHandler(fp, this, scope, "sensor");
- if (scope->checkEntry(mNumber->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mNumber->mScopeEntry = scope->addEntry(mNumber->mName, LIT_VARIABLE, LST_INTEGER);
- }
- break;
- case LSCP_RESOURCE:
- {
- // we're just tryng to determine how much space the variable needs
- if (mNumber->mScopeEntry)
- {
- mNumber->mScopeEntry->mOffset = (S32)count;
- mNumber->mScopeEntry->mSize = 4;
- count += mNumber->mScopeEntry->mSize;
- }
- }
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
-#ifdef LSL_INCLUDE_DEBUG_INFO
- char name[] = "sensor";
- chunk->addBytes(name, strlen(name) + 1);
- chunk->addBytes(mNumber->mName, strlen(mNumber->mName) + 1);
-#endif
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "sensor( int32 ");
- mNumber->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )");
- break;
- default:
- mNumber->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
-}
-
-S32 LLScriptSensorEvent::getSize()
-{
- // integer = 4
- return 4;
-}
-
-void LLScriptObjectRezEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- case LSCP_EMIT_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "object_rez( key ");
- mID->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )\n");
- break;
- case LSCP_SCOPE_PASS1:
- checkForDuplicateHandler(fp, this, scope, "object_rez");
- if (scope->checkEntry(mID->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mID->mScopeEntry = scope->addEntry(mID->mName, LIT_VARIABLE, LST_KEY);
- }
- break;
- case LSCP_RESOURCE:
- {
- // we're just tryng to determine how much space the variable needs
- if (mID->mScopeEntry)
- {
- mID->mScopeEntry->mOffset = (S32)count;
- mID->mScopeEntry->mSize = 4;
- count += mID->mScopeEntry->mSize;
- }
- }
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
-#ifdef LSL_INCLUDE_DEBUG_INFO
- char name[] = "sensor";
- chunk->addBytes(name, strlen(name) + 1);
- chunk->addBytes(mID->mName, strlen(mID->mName) + 1);
-#endif
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "object_rez( valuetype [ScriptTypes]LindenLab.SecondLife.Key ");
- mID->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )");
- break;
- default:
- mID->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
-}
-
-S32 LLScriptObjectRezEvent::getSize()
-{
- // key = 4
- return 4;
-}
-
-void LLScriptControlEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- case LSCP_EMIT_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "control( key ");
- mName->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", integer ");
- mLevels->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", integer ");
- mEdges->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )\n");
- break;
- case LSCP_SCOPE_PASS1:
- checkForDuplicateHandler(fp, this, scope, "control");
- if (scope->checkEntry(mName->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mName->mScopeEntry = scope->addEntry(mName->mName, LIT_VARIABLE, LST_KEY);
- }
- if (scope->checkEntry(mLevels->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mLevels->mScopeEntry = scope->addEntry(mLevels->mName, LIT_VARIABLE, LST_INTEGER);
- }
- if (scope->checkEntry(mEdges->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mEdges->mScopeEntry = scope->addEntry(mEdges->mName, LIT_VARIABLE, LST_INTEGER);
- }
- break;
- case LSCP_RESOURCE:
- {
- // we're just tryng to determine how much space the variable needs
- if (mName->mScopeEntry)
- {
- mName->mScopeEntry->mOffset = (S32)count;
- mName->mScopeEntry->mSize = 4;
- count += mName->mScopeEntry->mSize;
- mLevels->mScopeEntry->mOffset = (S32)count;
- mLevels->mScopeEntry->mSize = 4;
- count += mLevels->mScopeEntry->mSize;
- mEdges->mScopeEntry->mOffset = (S32)count;
- mEdges->mScopeEntry->mSize = 4;
- count += mEdges->mScopeEntry->mSize;
- }
- }
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
-#ifdef LSL_INCLUDE_DEBUG_INFO
- char name[] = "control";
- chunk->addBytes(name, strlen(name) + 1);
- chunk->addBytes(mName->mName, strlen(mName->mName) + 1);
- chunk->addBytes(mLevels->mName, strlen(mLevels->mName) + 1);
- chunk->addBytes(mEdges->mName, strlen(mEdges->mName) + 1);
-#endif
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "control( valuetype [ScriptTypes]LindenLab.SecondLife.Key ");
- mName->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", int32 ");
- mLevels->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", int32 ");
- mEdges->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )");
- break;
- default:
- mName->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLevels->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mEdges->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
-}
-
-S32 LLScriptControlEvent::getSize()
-{
- // key + integer + integer = 12
- return 12;
-}
-
-void LLScriptLinkMessageEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- case LSCP_EMIT_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "link_message( integer ");
- mSender->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", integer ");
- mNum->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", string ");
- mStr->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", key ");
- mID->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )\n");
- break;
- case LSCP_SCOPE_PASS1:
- checkForDuplicateHandler(fp, this, scope, "link_message");
- if (scope->checkEntry(mSender->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mSender->mScopeEntry = scope->addEntry(mSender->mName, LIT_VARIABLE, LST_INTEGER);
- }
- if (scope->checkEntry(mNum->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mNum->mScopeEntry = scope->addEntry(mNum->mName, LIT_VARIABLE, LST_INTEGER);
- }
- if (scope->checkEntry(mStr->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mStr->mScopeEntry = scope->addEntry(mStr->mName, LIT_VARIABLE, LST_STRING);
- }
- if (scope->checkEntry(mID->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mID->mScopeEntry = scope->addEntry(mID->mName, LIT_VARIABLE, LST_KEY);
- }
- break;
- case LSCP_RESOURCE:
- {
- // we're just tryng to determine how much space the variable needs
- if (mSender->mScopeEntry)
- {
- mSender->mScopeEntry->mOffset = (S32)count;
- mSender->mScopeEntry->mSize = 4;
- count += mSender->mScopeEntry->mSize;
- mNum->mScopeEntry->mOffset = (S32)count;
- mNum->mScopeEntry->mSize = 4;
- count += mNum->mScopeEntry->mSize;
- mStr->mScopeEntry->mOffset = (S32)count;
- mStr->mScopeEntry->mSize = 4;
- count += mStr->mScopeEntry->mSize;
- mID->mScopeEntry->mOffset = (S32)count;
- mID->mScopeEntry->mSize = 4;
- count += mID->mScopeEntry->mSize;
- }
- }
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
-#ifdef LSL_INCLUDE_DEBUG_INFO
- char name[] = "link_message";
- chunk->addBytes(name, strlen(name) + 1);
- chunk->addBytes(mSender->mName, strlen(mSender->mName) + 1);
- chunk->addBytes(mNum->mName, strlen(mNum->mName) + 1);
- chunk->addBytes(mStr->mName, strlen(mStr->mName) + 1);
- chunk->addBytes(mID->mName, strlen(mID->mName) + 1);
-#endif
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "link_message( int32 ");
- mSender->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", int32 ");
- mNum->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", string ");
- mStr->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", valuetype [ScriptTypes]LindenLab.SecondLife.Key ");
- mID->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )");
- break;
- default:
- mSender->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mNum->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mStr->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mID->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
-}
-
-S32 LLScriptLinkMessageEvent::getSize()
-{
- // integer + key + integer + string = 16
- return 16;
-}
-
-void LLScriptRemoteEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- case LSCP_EMIT_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "remote_event( integer ");
- mType->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", key ");
- mChannel->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", key ");
- mMessageID->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", string ");
- mSender->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", integer ");
- mIntVal->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", string ");
- mStrVal->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )\n");
- break;
- case LSCP_SCOPE_PASS1:
- checkForDuplicateHandler(fp, this, scope, "remote_event");
- if (scope->checkEntry(mType->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mType->mScopeEntry = scope->addEntry(mType->mName, LIT_VARIABLE, LST_INTEGER);
- }
- if (scope->checkEntry(mChannel->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mChannel->mScopeEntry = scope->addEntry(mChannel->mName, LIT_VARIABLE, LST_KEY);
- }
- if (scope->checkEntry(mMessageID->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mMessageID->mScopeEntry = scope->addEntry(mMessageID->mName, LIT_VARIABLE, LST_KEY);
- }
- if (scope->checkEntry(mSender->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mSender->mScopeEntry = scope->addEntry(mSender->mName, LIT_VARIABLE, LST_STRING);
- }
- if (scope->checkEntry(mIntVal->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mIntVal->mScopeEntry = scope->addEntry(mIntVal->mName, LIT_VARIABLE, LST_INTEGER);
- }
- if (scope->checkEntry(mStrVal->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mStrVal->mScopeEntry = scope->addEntry(mStrVal->mName, LIT_VARIABLE, LST_STRING);
- }
- break;
- case LSCP_RESOURCE:
- {
- // we're just tryng to determine how much space the variable needs
- if (mType->mScopeEntry)
- {
- mType->mScopeEntry->mOffset = (S32)count;
- mType->mScopeEntry->mSize = 4;
- count += mType->mScopeEntry->mSize;
- mChannel->mScopeEntry->mOffset = (S32)count;
- mChannel->mScopeEntry->mSize = 4;
- count += mChannel->mScopeEntry->mSize;
- mMessageID->mScopeEntry->mOffset = (S32)count;
- mMessageID->mScopeEntry->mSize = 4;
- count += mMessageID->mScopeEntry->mSize;
- mSender->mScopeEntry->mOffset = (S32)count;
- mSender->mScopeEntry->mSize = 4;
- count += mSender->mScopeEntry->mSize;
- mIntVal->mScopeEntry->mOffset = (S32)count;
- mIntVal->mScopeEntry->mSize = 4;
- count += mIntVal->mScopeEntry->mSize;
- mStrVal->mScopeEntry->mOffset = (S32)count;
- mStrVal->mScopeEntry->mSize = 4;
- count += mStrVal->mScopeEntry->mSize;
- }
- }
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
-#ifdef LSL_INCLUDE_DEBUG_INFO
- char name[] = "remote_event";
- chunk->addBytes(name, strlen(name) + 1);
- chunk->addBytes(mType->mName, strlen(mType->mName) + 1);
- chunk->addBytes(mChannel->mName, strlen(mChannel->mName) + 1);
- chunk->addBytes(mMessageID->mName, strlen(mMessageID->mName) + 1);
- chunk->addBytes(mSender->mName, strlen(mSender->mName) + 1);
- chunk->addBytes(mIntVal->mName, strlen(mIntVal->mName) + 1);
- chunk->addBytes(mStrVal->mName, strlen(mStrVal->mName) + 1);
-#endif
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "remote_event( int32 ");
- mType->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", valuetype [ScriptTypes]LindenLab.SecondLife.Key ");
- mChannel->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", valuetype [ScriptTypes]LindenLab.SecondLife.Key ");
- mMessageID->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", string ");
- mSender->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", int32 ");
- mIntVal->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", string ");
- mStrVal->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )");
- break;
- default:
- mType->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mChannel->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mMessageID->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mSender->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mIntVal->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mStrVal->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
-}
-
-S32 LLScriptRemoteEvent::getSize()
-{
- // integer + key + key + string + integer + string = 24
- return 24;
-}
-
-void LLScriptHTTPResponseEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- case LSCP_EMIT_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "http_response( key ");
- mRequestId->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", integer ");
- mStatus->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", class [mscorlib]System.Collections.ArrayList ");
- mMetadata->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", string ");
- mBody->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )\n");
- break;
-
- case LSCP_SCOPE_PASS1:
- checkForDuplicateHandler(fp, this, scope, "http_response");
- if (scope->checkEntry(mRequestId->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mRequestId->mScopeEntry = scope->addEntry(mRequestId->mName, LIT_VARIABLE, LST_KEY);
- }
-
- if (scope->checkEntry(mStatus->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mStatus->mScopeEntry = scope->addEntry(mStatus->mName, LIT_VARIABLE, LST_INTEGER);
- }
-
- if (scope->checkEntry(mMetadata->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mMetadata->mScopeEntry = scope->addEntry(mMetadata->mName, LIT_VARIABLE, LST_LIST);
- }
-
- if (scope->checkEntry(mBody->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mBody->mScopeEntry = scope->addEntry(mBody->mName, LIT_VARIABLE, LST_STRING);
- }
- break;
-
- case LSCP_RESOURCE:
- {
- // we're just tryng to determine how much space the variable needs
- if (mRequestId->mScopeEntry)
- {
- mRequestId->mScopeEntry->mOffset = (S32)count;
- mRequestId->mScopeEntry->mSize = 4;
- count += mRequestId->mScopeEntry->mSize;
-
- mStatus->mScopeEntry->mOffset = (S32)count;
- mStatus->mScopeEntry->mSize = 4;
- count += mStatus->mScopeEntry->mSize;
-
- mMetadata->mScopeEntry->mOffset = (S32)count;
- mMetadata->mScopeEntry->mSize = 4;
- count += mMetadata->mScopeEntry->mSize;
-
- mBody->mScopeEntry->mOffset = (S32)count;
- mBody->mScopeEntry->mSize = 4;
- count += mBody->mScopeEntry->mSize;
- }
- }
- break;
-
- case LSCP_EMIT_BYTE_CODE:
- {
-#ifdef LSL_INCLUDE_DEBUG_INFO
- char name[] = "http_response";
- chunk->addBytes(name, strlen(name) + 1);
- chunk->addBytes(mRequestId->mName, strlen(mRequestId->mName) + 1);
- chunk->addBytes(mStatus->mName, strlen(mStatus->mName) + 1);
- chunk->addBytes(mMetadata->mName, strlen(mMetadata->mName) + 1);
- chunk->addBytes(mBody->mName, strlen(mBody->mName) + 1);
-#endif
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "http_response( valuetype [ScriptTypes]LindenLab.SecondLife.Key ");
- mRequestId->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", int32 ");
- mStatus->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", class [mscorlib]System.Collections.ArrayList ");
- mMetadata->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", string ");
- mBody->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )\n");
- break;
- default:
- mRequestId->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mStatus->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mMetadata->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mBody->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
-}
-
-S32 LLScriptHTTPResponseEvent::getSize()
-{
- // key + integer + list + string = 16
- return 16;
-}
-
-void LLScriptHTTPRequestEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- case LSCP_EMIT_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "http_request( key ");
- mRequestId->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", string ");
- mMethod->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", string ");
- mBody->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )\n");
- break;
-
- case LSCP_SCOPE_PASS1:
- checkForDuplicateHandler(fp, this, scope, "http_request");
- if (scope->checkEntry(mRequestId->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mRequestId->mScopeEntry = scope->addEntry(mRequestId->mName, LIT_VARIABLE, LST_KEY);
- }
-
- if (scope->checkEntry(mMethod->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mMethod->mScopeEntry = scope->addEntry(mMethod->mName, LIT_VARIABLE, LST_STRING);
- }
-
- if (scope->checkEntry(mBody->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mBody->mScopeEntry = scope->addEntry(mBody->mName, LIT_VARIABLE, LST_STRING);
- }
- break;
-
- case LSCP_RESOURCE:
- {
- // we're just tryng to determine how much space the variable needs
- if (mRequestId->mScopeEntry)
- {
- mRequestId->mScopeEntry->mOffset = (S32)count;
- mRequestId->mScopeEntry->mSize = 4;
- count += mRequestId->mScopeEntry->mSize;
-
- mMethod->mScopeEntry->mOffset = (S32)count;
- mMethod->mScopeEntry->mSize = 4;
- count += mMethod->mScopeEntry->mSize;
-
- mBody->mScopeEntry->mOffset = (S32)count;
- mBody->mScopeEntry->mSize = 4;
- count += mBody->mScopeEntry->mSize;
- }
- }
- break;
-
- case LSCP_EMIT_BYTE_CODE:
- {
-#ifdef LSL_INCLUDE_DEBUG_INFO
- char name[] = "http_request";
- chunk->addBytes(name, strlen(name) + 1); /*Flawfinder: ignore*/
- chunk->addBytes(mRequestId->mName, strlen(mRequestId->mName) + 1); /*Flawfinder: ignore*/
- chunk->addBytes(mMethod->mName, strlen(mMethod->mName) + 1); /*Flawfinder: ignore*/
- chunk->addBytes(mBody->mName, strlen(mBody->mName) + 1); /*Flawfinder: ignore*/
-#endif
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "http_request( valuetype [ScriptTypes]LindenLab.SecondLife.Key ");
- mRequestId->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", string ");
- mMethod->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", string ");
- mBody->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )\n");
- break;
- default:
- mRequestId->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mMethod->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mBody->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
-}
-
-S32 LLScriptHTTPRequestEvent::getSize()
-{
- // key + string + string = 12
- return 12;
-}
-
-void LLScriptMoneyEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- case LSCP_EMIT_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "money( key ");
- mName->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", integer ");
- mAmount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )\n");
- break;
- case LSCP_SCOPE_PASS1:
- checkForDuplicateHandler(fp, this, scope, "money");
- if (scope->checkEntry(mName->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mName->mScopeEntry = scope->addEntry(mName->mName, LIT_VARIABLE, LST_KEY);
- }
- if (scope->checkEntry(mAmount->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mAmount->mScopeEntry = scope->addEntry(mAmount->mName, LIT_VARIABLE, LST_INTEGER);
- }
- break;
- case LSCP_RESOURCE:
- {
- // we're just tryng to determine how much space the variable needs
- if (mName->mScopeEntry)
- {
- mName->mScopeEntry->mOffset = (S32)count;
- mName->mScopeEntry->mSize = 4;
- count += mName->mScopeEntry->mSize;
- mAmount->mScopeEntry->mOffset = (S32)count;
- mAmount->mScopeEntry->mSize = 4;
- count += mAmount->mScopeEntry->mSize;
- }
- }
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
-#ifdef LSL_INCLUDE_DEBUG_INFO
- char name[] = "money";
- chunk->addBytes(name, strlen(name) + 1);
- chunk->addBytes(mName->mName, strlen(mName->mName) + 1);
- chunk->addBytes(mAmount->mName, strlen(mAmount->mName) + 1);
-#endif
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "money( valuetype [ScriptTypes]LindenLab.SecondLife.Key ");
- mName->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", int32 ");
- mAmount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )");
- break;
- default:
- mName->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mAmount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
-}
-
-S32 LLScriptMoneyEvent::getSize()
-{
- // key + integer = 8
- return 8;
-}
-
-void LLScriptEmailEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- case LSCP_EMIT_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "email( string ");
- mTime->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", string ");
- mAddress->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", string ");
- mSubject->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", string ");
- mBody->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", integer ");
- mNumber->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )\n");
- break;
- case LSCP_SCOPE_PASS1:
- checkForDuplicateHandler(fp, this, scope, "email");
- if (scope->checkEntry(mTime->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mTime->mScopeEntry = scope->addEntry(mTime->mName, LIT_VARIABLE, LST_STRING);
- }
- if (scope->checkEntry(mAddress->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mAddress->mScopeEntry = scope->addEntry(mAddress->mName, LIT_VARIABLE, LST_STRING);
- }
- if (scope->checkEntry(mSubject->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mSubject->mScopeEntry = scope->addEntry(mSubject->mName, LIT_VARIABLE, LST_STRING);
- }
- if (scope->checkEntry(mBody->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mBody->mScopeEntry = scope->addEntry(mBody->mName, LIT_VARIABLE, LST_STRING);
- }
- if (scope->checkEntry(mNumber->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mNumber->mScopeEntry = scope->addEntry(mNumber->mName, LIT_VARIABLE, LST_INTEGER);
- }
- break;
- case LSCP_RESOURCE:
- {
- // we're just tryng to determine how much space the variable needs
- if (mAddress->mScopeEntry)
- {
- mTime->mScopeEntry->mOffset = (S32)count;
- mTime->mScopeEntry->mSize = 4;
- count += mTime->mScopeEntry->mSize;
- mAddress->mScopeEntry->mOffset = (S32)count;
- mAddress->mScopeEntry->mSize = 4;
- count += mAddress->mScopeEntry->mSize;
- mSubject->mScopeEntry->mOffset = (S32)count;
- mSubject->mScopeEntry->mSize = 4;
- count += mSubject->mScopeEntry->mSize;
- mBody->mScopeEntry->mOffset = (S32)count;
- mBody->mScopeEntry->mSize = 4;
- count += mBody->mScopeEntry->mSize;
- mNumber->mScopeEntry->mOffset = (S32)count;
- mNumber->mScopeEntry->mSize = 4;
- count += mNumber->mScopeEntry->mSize;
- }
- }
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
-#ifdef LSL_INCLUDE_DEBUG_INFO
- char name[] = "email";
- chunk->addBytes(name, strlen(name) + 1);
- chunk->addBytes(mTime->mName, strlen(mTime->mName) + 1);
- chunk->addBytes(mAddress->mName, strlen(mAddress->mName) + 1);
- chunk->addBytes(mSubject->mName, strlen(mSubject->mName) + 1);
- chunk->addBytes(mBody->mName, strlen(mBody->mName) + 1);
- chunk->addBytes(mNumber->mName, strlen(mNumber->mName) + 1);
-#endif
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "email( string ");
- mTime->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", string ");
- mAddress->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", string ");
- mSubject->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", string ");
- mBody->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", int32 ");
- mNumber->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )");
- break;
- default:
- mTime->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mAddress->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mSubject->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mBody->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mNumber->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
-}
-
-S32 LLScriptEmailEvent::getSize()
-{
- // string + string + string + string + integer = 16
- return 20;
-}
-
-void LLScriptRezEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- case LSCP_EMIT_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "rez( integer ");
- mStartParam->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )\n");
- break;
- case LSCP_SCOPE_PASS1:
- checkForDuplicateHandler(fp, this, scope, "on_rez");
- if (scope->checkEntry(mStartParam->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mStartParam->mScopeEntry = scope->addEntry(mStartParam->mName, LIT_VARIABLE, LST_INTEGER);
- }
- break;
- case LSCP_RESOURCE:
- {
- // we're just tryng to determine how much space the variable needs
- if (mStartParam->mScopeEntry)
- {
- mStartParam->mScopeEntry->mOffset = (S32)count;
- mStartParam->mScopeEntry->mSize = 4;
- count += mStartParam->mScopeEntry->mSize;
- }
- }
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
-#ifdef LSL_INCLUDE_DEBUG_INFO
- char name[] = "rez";
- chunk->addBytes(name, strlen(name) + 1);
- chunk->addBytes(mStartParam->mName, strlen(mStartParam->mName) + 1);
-#endif
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "rez( int32 ");
- mStartParam->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )");
- break;
- default:
- mStartParam->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
-}
-
-S32 LLScriptRezEvent::getSize()
-{
- // integer = 4
- return 4;
-}
-
-void LLScriptNoSensorEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "no_sensor()\n");
- break;
- case LSCP_EMIT_ASSEMBLY:
- fprintf(fp, "no_sensor()\n");
- break;
- case LSCP_SCOPE_PASS1:
- checkForDuplicateHandler(fp, this, scope, "no_sensor");
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
-#ifdef LSL_INCLUDE_DEBUG_INFO
- char name[] = "no_sensor";
- chunk->addBytes(name, strlen(name) + 1);
-#endif
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- fprintf(fp, "no_sensor()");
- break;
- default:
- break;
- }
-}
-
-S32 LLScriptNoSensorEvent::getSize()
-{
- return 0;
-}
-
-void LLScriptAtTarget::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- case LSCP_EMIT_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "at_target( integer ");
- mTargetNumber->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", vector ");
- mTargetPosition->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", vector ");
- mOurPosition->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )\n");
- break;
- case LSCP_SCOPE_PASS1:
- checkForDuplicateHandler(fp, this, scope, "at_target");
- if (scope->checkEntry(mTargetNumber->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mTargetNumber->mScopeEntry = scope->addEntry(mTargetNumber->mName, LIT_VARIABLE, LST_INTEGER);
- }
- if (scope->checkEntry(mTargetPosition->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mTargetPosition->mScopeEntry = scope->addEntry(mTargetPosition->mName, LIT_VARIABLE, LST_VECTOR);
- }
- if (scope->checkEntry(mOurPosition->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mOurPosition->mScopeEntry = scope->addEntry(mOurPosition->mName, LIT_VARIABLE, LST_VECTOR);
- }
- break;
- case LSCP_RESOURCE:
- {
- // we're just tryng to determine how much space the variable needs
- if (mTargetNumber->mScopeEntry)
- {
- mTargetNumber->mScopeEntry->mOffset = (S32)count;
- mTargetNumber->mScopeEntry->mSize = 4;
- count += mTargetNumber->mScopeEntry->mSize;
- mTargetPosition->mScopeEntry->mOffset = (S32)count;
- mTargetPosition->mScopeEntry->mSize = 12;
- count += mTargetPosition->mScopeEntry->mSize;
- mOurPosition->mScopeEntry->mOffset = (S32)count;
- mOurPosition->mScopeEntry->mSize = 12;
- count += mOurPosition->mScopeEntry->mSize;
- }
- }
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
-#ifdef LSL_INCLUDE_DEBUG_INFO
- char name[] = "at_target";
- chunk->addBytes(name, strlen(name) + 1);
- chunk->addBytes(mTargetNumber->mName, strlen(mTargetNumber->mName) + 1);
- chunk->addBytes(mTargetPosition->mName, strlen(mTargetPosition->mName) + 1);
- chunk->addBytes(mOurPosition->mName, strlen(mOurPosition->mName) + 1);
-#endif
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "at_target( int32 ");
- mTargetNumber->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", class [ScriptTypes]LindenLab.SecondLife.Vector ");
- mTargetPosition->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", class [ScriptTypes]LindenLab.SecondLife.Vector ");
- mOurPosition->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )");
- break;
- default:
- mTargetNumber->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mTargetPosition->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mOurPosition->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
-}
-
-S32 LLScriptAtTarget::getSize()
-{
- // integer + vector + vector = 28
- return 28;
-}
-
-
-
-void LLScriptNotAtTarget::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "not_at_target()\n");
- break;
- case LSCP_EMIT_ASSEMBLY:
- fprintf(fp, "not_at_target()\n");
- break;
- case LSCP_SCOPE_PASS1:
- checkForDuplicateHandler(fp, this, scope, "not_at_target");
- break;
-
- case LSCP_EMIT_BYTE_CODE:
- {
-#ifdef LSL_INCLUDE_DEBUG_INFO
- char name[] = "not_at_target";
- chunk->addBytes(name, strlen(name) + 1);
-#endif
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- fprintf(fp, "not_at_target()");
- break;
- default:
- break;
- }
-}
-
-S32 LLScriptNotAtTarget::getSize()
-{
- return 0;
-}
-
-void LLScriptAtRotTarget::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- case LSCP_EMIT_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "at_rot_target( integer ");
- mTargetNumber->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", quaternion ");
- mTargetRotation->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", quaternion ");
- mOurRotation->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )\n");
- break;
- case LSCP_SCOPE_PASS1:
- checkForDuplicateHandler(fp, this, scope, "at_rot_target");
- if (scope->checkEntry(mTargetNumber->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mTargetNumber->mScopeEntry = scope->addEntry(mTargetNumber->mName, LIT_VARIABLE, LST_INTEGER);
- }
- if (scope->checkEntry(mTargetRotation->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mTargetRotation->mScopeEntry = scope->addEntry(mTargetRotation->mName, LIT_VARIABLE, LST_QUATERNION);
- }
- if (scope->checkEntry(mOurRotation->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mOurRotation->mScopeEntry = scope->addEntry(mOurRotation->mName, LIT_VARIABLE, LST_QUATERNION);
- }
- break;
- case LSCP_RESOURCE:
- {
- // we're just tryng to determine how much space the variable needs
- if (mTargetNumber->mScopeEntry)
- {
- mTargetNumber->mScopeEntry->mOffset = (S32)count;
- mTargetNumber->mScopeEntry->mSize = 4;
- count += mTargetNumber->mScopeEntry->mSize;
- mTargetRotation->mScopeEntry->mOffset = (S32)count;
- mTargetRotation->mScopeEntry->mSize = 16;
- count += mTargetRotation->mScopeEntry->mSize;
- mOurRotation->mScopeEntry->mOffset = (S32)count;
- mOurRotation->mScopeEntry->mSize = 16;
- count += mOurRotation->mScopeEntry->mSize;
- }
- }
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
-#ifdef LSL_INCLUDE_DEBUG_INFO
- char name[] = "at_rot_target";
- chunk->addBytes(name, strlen(name) + 1);
- chunk->addBytes(mTargetNumber->mName, strlen(mTargetNumber->mName) + 1);
- chunk->addBytes(mTargetRotation->mName, strlen(mTargetRotation->mName) + 1);
- chunk->addBytes(mOurRotation->mName, strlen(mOurRotation->mName) + 1);
-#endif
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "at_rot_target( int32 ");
- mTargetNumber->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", class [ScriptTypes]LindenLab.SecondLife.Quaternion ");
- mTargetRotation->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", class [ScriptTypes]LindenLab.SecondLife.Quaternion ");
- mOurRotation->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )");
- break;
- default:
- mTargetNumber->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mTargetRotation->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mOurRotation->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
-}
-
-S32 LLScriptAtRotTarget::getSize()
-{
- // integer + quaternion + quaternion = 36
- return 36;
-}
-
-
-
-void LLScriptNotAtRotTarget::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "not_at_rot_target()\n");
- break;
- case LSCP_EMIT_ASSEMBLY:
- fprintf(fp, "not_at_rot_target()\n");
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
-#ifdef LSL_INCLUDE_DEBUG_INFO
- char name[] = "not_at_rot_target";
- chunk->addBytes(name, strlen(name) + 1);
-#endif
- }
- break;
- case LSCP_SCOPE_PASS1:
- checkForDuplicateHandler(fp, this, scope, "not_at_rot_target");
- break;
-
- case LSCP_EMIT_CIL_ASSEMBLY:
- fprintf(fp, "not_at_rot_target()");
- break;
- default:
- break;
- }
-}
-
-S32 LLScriptNotAtRotTarget::getSize()
-{
- return 0;
-}
-
-
-
-void LLScriptExpression::addExpression(LLScriptExpression *expression)
-{
- if (mNextp)
- {
- expression->mNextp = mNextp;
- }
- mNextp = expression;
-}
-
-void LLScriptExpression::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- fprintf(fp, "Expression Base Class -- should never get here!\n");
-}
-
-S32 LLScriptExpression::getSize()
-{
- printf("Expression Base Class -- should never get here!\n");
- return 0;
-}
-
-void LLScriptExpression::gonext(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- if (mNextp)
- {
- fprintf(fp, ", ");
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- default:
- if (mNextp)
- {
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- }
-}
-
-void LLScriptForExpressionList::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- mFirstp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mSecondp)
- {
- fprintf(fp, ", ");
- mSecondp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- case LSCP_EMIT_ASSEMBLY:
- mFirstp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mFirstp->mReturnType)
- {
- fprintf(fp, "%s\n", LSCRIPTTypePop[mFirstp->mReturnType]);
- }
- if (mSecondp)
- {
- mSecondp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mSecondp->mReturnType)
- {
- fprintf(fp, "%s\n", LSCRIPTTypePop[mSecondp->mReturnType]);
- }
- }
- break;
- case LSCP_TO_STACK:
- mFirstp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- switch(mFirstp->mReturnType)
- {
- case LST_INTEGER:
- case LST_FLOATINGPOINT:
- chunk->addByte(LSCRIPTOpCodes[LOPC_POP]);
- break;
- case LST_STRING:
- case LST_KEY:
- chunk->addByte(LSCRIPTOpCodes[LOPC_POPS]);
- break;
- case LST_LIST:
- chunk->addByte(LSCRIPTOpCodes[LOPC_POPL]);
- break;
- case LST_VECTOR:
- chunk->addByte(LSCRIPTOpCodes[LOPC_POPV]);
- break;
- case LST_QUATERNION:
- chunk->addByte(LSCRIPTOpCodes[LOPC_POPQ]);
- break;
- default:
- break;
- }
- if (mSecondp)
- {
- mSecondp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- switch(mSecondp->mReturnType)
- {
- case LST_INTEGER:
- case LST_FLOATINGPOINT:
- chunk->addByte(LSCRIPTOpCodes[LOPC_POP]);
- break;
- case LST_STRING:
- case LST_KEY:
- chunk->addByte(LSCRIPTOpCodes[LOPC_POPS]);
- break;
- case LST_LIST:
- chunk->addByte(LSCRIPTOpCodes[LOPC_POPL]);
- break;
- case LST_VECTOR:
- chunk->addByte(LSCRIPTOpCodes[LOPC_POPV]);
- break;
- case LST_QUATERNION:
- chunk->addByte(LSCRIPTOpCodes[LOPC_POPQ]);
- break;
- default:
- break;
- }
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- mFirstp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mFirstp->mReturnType)
- {
- fprintf(fp, "pop\n");
- }
- if (mSecondp)
- {
- mSecondp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mSecondp->mReturnType)
- {
- fprintf(fp, "pop\n");
- }
- }
- break;
- default:
- mFirstp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mSecondp)
- {
- mSecondp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- }
-}
-
-S32 LLScriptForExpressionList::getSize()
-{
- return 0;
-}
-
-// CIL code generation requires both caller and callee scope entries, so cannot use normal recurse signature.
-// TODO: Refactor general purpose recurse calls in to pass specific virtuals using visitor pattern to select method by pass and node type.
-static void print_cil_func_expression_list(LLScriptFuncExpressionList* self, LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata, LLScriptScopeEntry *callee_entry)
-{
- self->mFirstp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- LSCRIPTType argtype = callee_entry->mFunctionArgs.getType(entrycount);
- if (argtype != self->mFirstp->mReturnType)
- {
- print_cil_cast(fp, self->mFirstp->mReturnType, argtype);
- }
- entrycount++;
- if (self->mSecondp)
- {
- llassert(LET_FUNC_EXPRESSION_LIST == self->mSecondp->mType);
- print_cil_func_expression_list((LLScriptFuncExpressionList*) self->mSecondp, fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL, callee_entry);
-
- }
-}
-
-void LLScriptFuncExpressionList::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- mFirstp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mSecondp)
- {
- fprintf(fp, ", ");
- mSecondp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- case LSCP_TYPE:
- {
- mFirstp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (!entry->mFunctionArgs.getType(entrycount))
- {
- gErrorToText.writeError(fp, this, LSERROR_FUNCTION_TYPE_ERROR);
- }
- if (!legal_assignment(entry->mFunctionArgs.getType(entrycount), mFirstp->mReturnType))
- {
- gErrorToText.writeError(fp, this, LSERROR_FUNCTION_TYPE_ERROR);
- }
- count++;
- entrycount++;
- if (mSecondp)
- {
- mSecondp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mSecondp->mReturnType)
- {
- count++;
- if (!entry->mFunctionArgs.getType(entrycount))
- {
- gErrorToText.writeError(fp, this, LSERROR_FUNCTION_TYPE_ERROR);
- }
- if (!legal_assignment(entry->mFunctionArgs.getType(entrycount), mSecondp->mReturnType))
- {
- gErrorToText.writeError(fp, this, LSERROR_FUNCTION_TYPE_ERROR);
- }
- }
- }
- }
- break;
- case LSCP_EMIT_ASSEMBLY:
- {
- mFirstp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- LSCRIPTType argtype = entry->mFunctionArgs.getType(entrycount);
- if (argtype != mFirstp->mReturnType)
- {
- fprintf(fp, "CAST %s->%s\n", LSCRIPTTypeNames[mFirstp->mReturnType], LSCRIPTTypeNames[argtype]);
- }
- entrycount++;
- if (mSecondp)
- {
- mSecondp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mSecondp->mReturnType)
- {
- argtype = entry->mFunctionArgs.getType(entrycount);
- if (argtype != mSecondp->mReturnType)
- {
- fprintf(fp, "CAST %s->%s\n", LSCRIPTTypeNames[mSecondp->mReturnType], LSCRIPTTypeNames[argtype]);
- }
- }
- }
- }
- break;
- case LSCP_TO_STACK:
- {
- mFirstp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- LSCRIPTType argtype = entry->mFunctionArgs.getType(entrycount);
- if (argtype != mFirstp->mReturnType)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_CAST]);
- U8 castbyte = LSCRIPTTypeByte[argtype] | LSCRIPTTypeHi4Bits[mFirstp->mReturnType];
- chunk->addByte(castbyte);
- }
- entrycount++;
- if (mSecondp)
- {
- mSecondp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mSecondp->mReturnType)
- {
- argtype = entry->mFunctionArgs.getType(entrycount);
- if (argtype != mSecondp->mReturnType)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_CAST]);
- U8 castbyte = LSCRIPTTypeByte[argtype] | LSCRIPTTypeHi4Bits[mSecondp->mReturnType];
- chunk->addByte(castbyte);
- }
- }
- }
- }
- break;
- default:
- mFirstp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mSecondp)
- {
- mSecondp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- }
-}
-
-S32 LLScriptFuncExpressionList::getSize()
-{
- return 0;
-}
-
-void LLScriptListExpressionList::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- mFirstp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mSecondp)
- {
- fprintf(fp, ", ");
- mSecondp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- case LSCP_EMIT_ASSEMBLY:
- mFirstp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mFirstp->mType != LET_LIST_EXPRESSION_LIST)
- {
- fprintf(fp, "%s\n", LSCRIPTListDescription[mFirstp->mReturnType]);
- count++;
- }
- if (mSecondp)
- {
- mSecondp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mSecondp->mType != LET_LIST_EXPRESSION_LIST)
- {
- fprintf(fp, "%s\n", LSCRIPTListDescription[mSecondp->mReturnType]);
- count++;
- }
- }
- break;
- case LSCP_TO_STACK:
- mFirstp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mFirstp->mType != LET_LIST_EXPRESSION_LIST)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHARGB]);
- chunk->addByte(LSCRIPTTypeByte[mFirstp->mReturnType]);
- count++;
- }
- if (mSecondp)
- {
- mSecondp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mSecondp->mType != LET_LIST_EXPRESSION_LIST)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHARGB]);
- chunk->addByte(LSCRIPTTypeByte[mSecondp->mReturnType]);
- count++;
- }
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- mFirstp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mFirstp->mType != LET_LIST_EXPRESSION_LIST)
- {
- // Box value.
- print_cil_box(fp, mFirstp->mReturnType);
- ++count;
- }
- if (mSecondp)
- {
- mSecondp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mSecondp->mType != LET_LIST_EXPRESSION_LIST)
- {
- // Box value.
- print_cil_box(fp, mSecondp->mReturnType);
- ++count;
- }
- }
- break;
- default:
- mFirstp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mSecondp)
- {
- mSecondp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- }
-}
-
-S32 LLScriptListExpressionList::getSize()
-{
- return 0;
-}
-
-// Returns true if identifier is a parameter and false if identifier is a local variable within function_scope.
-bool is_parameter(LLScriptIdentifier* identifier, LLScriptScopeEntry* function_scope)
-{
- // Function stores offset of first local.
- if(0 == function_scope->mOffset)
- {
- // Function offset 0 -> no parameters -> identifier is a local.
- return false;
- }
- else
- {
- // Compare variable offset with function offset to
- // determine whether variable is local or parameter.
- return (identifier->mScopeEntry->mOffset < function_scope->mOffset);
- }
-}
-
-// If assignment is to global variable, pushes this pointer on to stack.
-static void print_cil_load_address(LLFILE* fp, LLScriptExpression* exp, LLScriptScopeEntry* function_scope)
-{
- LLScriptLValue *lvalue = (LLScriptLValue *) exp;
- LLScriptIdentifier *ident = lvalue->mIdentifier;
-
- // If global (member), load this pointer.
- if(ident->mScopeEntry->mIDType == LIT_GLOBAL)
- {
- fprintf(fp, "ldarg.0\n");
- }
-
- // If accessor, load value type address, consumed by ldfld.
- if(lvalue->mAccessor)
- {
- if(ident->mScopeEntry->mIDType == LIT_VARIABLE)
- {
- if(is_parameter(ident, function_scope))
- {
- // Parameter, load by name.
- fprintf(fp, "ldarga.s '%s'\n", ident->mScopeEntry->mIdentifier);
- }
- else
- {
- // Local, load by index.
- fprintf(fp, "ldloca.s %d\n", ident->mScopeEntry->mCount);
- }
- }
- else if (ident->mScopeEntry->mIDType == LIT_GLOBAL)
- {
- fprintf(fp, "ldflda ");
- print_cil_member(fp, ident);
- }
- }
-}
-
-static void print_cil_accessor(LLFILE* fp, LLScriptLValue *lvalue)
-
-{
- LLScriptIdentifier *ident = lvalue->mIdentifier;
- print_cil_type(fp, lvalue->mReturnType);
- fprintf(fp, " ");
- print_cil_type(fp, ident->mScopeEntry->mType);
- fprintf(fp, "::%s\n", lvalue->mAccessor->mName);
-}
-
-void LLScriptLValue::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mAccessor)
- {
- fprintf(fp, ".");
- mAccessor->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- case LSCP_EMIT_ASSEMBLY:
- if (mIdentifier->mScopeEntry->mIDType == LIT_VARIABLE)
- {
- if (mAccessor)
- {
- fprintf(fp, "%s%d [%s.%s]\n", LSCRIPTTypeLocalPush[mReturnType], mIdentifier->mScopeEntry->mOffset + mOffset, mIdentifier->mName, mAccessor->mName);
- }
- else
- {
- fprintf(fp, "%s%d [%s]\n", LSCRIPTTypeLocalPush[mIdentifier->mScopeEntry->mType], mIdentifier->mScopeEntry->mOffset, mIdentifier->mName);
- }
- }
- else if (mIdentifier->mScopeEntry->mIDType == LIT_GLOBAL)
- {
- if (mAccessor)
- {
- fprintf(fp, "%s%d [%s.%s]\n", LSCRIPTTypeGlobalPush[mReturnType], mIdentifier->mScopeEntry->mOffset + mOffset, mIdentifier->mName, mAccessor->mName);
- }
- else
- {
- fprintf(fp, "%s%d [%s]\n", LSCRIPTTypeGlobalPush[mIdentifier->mScopeEntry->mType], mIdentifier->mScopeEntry->mOffset, mIdentifier->mName);
- }
- }
- else
- {
- fprintf(fp, "Unexpected LValue!\n");
- }
- break;
- case LSCP_SCOPE_PASS1:
- {
- LLScriptScopeEntry *entry = scope->findEntry(mIdentifier->mName);
- if (!entry || ( (entry->mIDType != LIT_GLOBAL) && (entry->mIDType != LIT_VARIABLE)))
- {
- gErrorToText.writeError(fp, this, LSERROR_UNDEFINED_NAME);
- }
- else
- {
- // if we did find it, make sure this identifier is associated with the correct scope entry
- mIdentifier->mScopeEntry = entry;
- }
- }
- break;
- case LSCP_TYPE:
- // if we have an accessor, we need to change what type our identifier returns and set our offset value
- if (mIdentifier->mScopeEntry)
- {
- if (mAccessor)
- {
- BOOL b_ok = FALSE;
- if (mIdentifier->mScopeEntry->mIDType == LIT_VARIABLE)
- {
- if (mIdentifier->mScopeEntry->mType == LST_VECTOR)
- {
- if (!strcmp("x", mAccessor->mName))
- {
- mOffset = 0;
- b_ok = TRUE;
- }
- else if (!strcmp("y", mAccessor->mName))
- {
- mOffset = 4;
- b_ok = TRUE;
- }
- else if (!strcmp("z", mAccessor->mName))
- {
- mOffset = 8;
- b_ok = TRUE;
- }
- }
- else if (mIdentifier->mScopeEntry->mType == LST_QUATERNION)
- {
- if (!strcmp("x", mAccessor->mName))
- {
- mOffset = 0;
- b_ok = TRUE;
- }
- else if (!strcmp("y", mAccessor->mName))
- {
- mOffset = 4;
- b_ok = TRUE;
- }
- else if (!strcmp("z", mAccessor->mName))
- {
- mOffset = 8;
- b_ok = TRUE;
- }
- else if (!strcmp("s", mAccessor->mName))
- {
- mOffset = 12;
- b_ok = TRUE;
- }
- }
- }
- else
- {
- if (mIdentifier->mScopeEntry->mType == LST_VECTOR)
- {
- if (!strcmp("x", mAccessor->mName))
- {
- mOffset = 8;
- b_ok = TRUE;
- }
- else if (!strcmp("y", mAccessor->mName))
- {
- mOffset = 4;
- b_ok = TRUE;
- }
- else if (!strcmp("z", mAccessor->mName))
- {
- mOffset = 0;
- b_ok = TRUE;
- }
- }
- else if (mIdentifier->mScopeEntry->mType == LST_QUATERNION)
- {
- if (!strcmp("x", mAccessor->mName))
- {
- mOffset = 12;
- b_ok = TRUE;
- }
- else if (!strcmp("y", mAccessor->mName))
- {
- mOffset = 8;
- b_ok = TRUE;
- }
- else if (!strcmp("z", mAccessor->mName))
- {
- mOffset = 4;
- b_ok = TRUE;
- }
- else if (!strcmp("s", mAccessor->mName))
- {
- mOffset = 0;
- b_ok = TRUE;
- }
- }
- }
- if (b_ok)
- {
- mReturnType = type = LST_FLOATINGPOINT;
- }
- else
- {
- gErrorToText.writeError(fp, this, LSERROR_VECTOR_METHOD_ERROR);
- }
- }
- else
- {
- mReturnType = type = mIdentifier->mScopeEntry->mType;
- }
- }
- else
- {
- mReturnType = type = LST_UNDEFINED;
- }
- break;
- case LSCP_TO_STACK:
- {
- switch(mReturnType)
- {
- case LST_INTEGER:
- case LST_FLOATINGPOINT:
- if (mIdentifier->mScopeEntry->mIDType == LIT_VARIABLE)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_PUSH]);
- }
- else
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHG]);
- }
- break;
- case LST_KEY:
- case LST_STRING:
- if (mIdentifier->mScopeEntry->mIDType == LIT_VARIABLE)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHS]);
- }
- else
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHGS]);
- }
- break;
- case LST_LIST:
- if (mIdentifier->mScopeEntry->mIDType == LIT_VARIABLE)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHL]);
- }
- else
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHGL]);
- }
- break;
- case LST_VECTOR:
- if (mIdentifier->mScopeEntry->mIDType == LIT_VARIABLE)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHV]);
- }
- else
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHGV]);
- }
- break;
- case LST_QUATERNION:
- if (mIdentifier->mScopeEntry->mIDType == LIT_VARIABLE)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHQ]);
- }
- else
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHGQ]);
- }
- break;
- default:
- if (mIdentifier->mScopeEntry->mIDType == LIT_VARIABLE)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_PUSH]);
- }
- else
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHG]);
- }
- break;
- }
- S32 address = mIdentifier->mScopeEntry->mOffset + mOffset;
- chunk->addInteger(address);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- print_cil_load_address(fp, this, entry);
- if(mAccessor)
- {
- fprintf(fp, "ldfld ");
- print_cil_accessor(fp, this);
- }
- else if(mIdentifier->mScopeEntry->mIDType == LIT_VARIABLE)
- {
- if(is_parameter(mIdentifier, entry))
- {
- // Parameter, load by name.
- fprintf(fp, "ldarg.s '%s'\n", mIdentifier->mScopeEntry->mIdentifier);
- }
- else
- {
- // Local, load by index.
- fprintf(fp, "ldloc.s %d\n", mIdentifier->mScopeEntry->mCount);
- }
- }
- else if (mIdentifier->mScopeEntry->mIDType == LIT_GLOBAL)
- {
- fprintf(fp, "ldfld ");
- print_cil_member(fp, mIdentifier);
- }
- else
- {
- fprintf(fp, "Unexpected LValue!\n");
- }
- break;
- default:
- mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
-}
-
-S32 LLScriptLValue::getSize()
-{
- return 0;
-}
-
-static void print_assignment(LLFILE *fp, LLScriptExpression *exp)
-{
- LLScriptLValue *lvalue = (LLScriptLValue *)exp;
- LLScriptIdentifier *ident = lvalue->mIdentifier;
- if (lvalue->mAccessor)
- {
- if (ident->mScopeEntry->mIDType == LIT_VARIABLE)
- {
- fprintf(fp, "%s%d [%s.%s]\n", LSCRIPTTypeLocalStore[ident->mScopeEntry->mType], ident->mScopeEntry->mOffset + lvalue->mOffset, ident->mName, lvalue->mAccessor->mName);
- }
- else if (ident->mScopeEntry->mIDType == LIT_GLOBAL)
- {
- fprintf(fp, "%s%d [%s.%s]\n", LSCRIPTTypeGlobalStore[ident->mScopeEntry->mType], ident->mScopeEntry->mOffset + lvalue->mOffset, ident->mName, lvalue->mAccessor->mName);
- }
- }
- else
- {
- if (ident->mScopeEntry->mIDType == LIT_VARIABLE)
- {
- fprintf(fp, "%s%d [%s]\n", LSCRIPTTypeLocalStore[ident->mScopeEntry->mType], ident->mScopeEntry->mOffset, ident->mName);
- }
- else if (ident->mScopeEntry->mIDType == LIT_GLOBAL)
- {
- fprintf(fp, "%s%d [%s]\n", LSCRIPTTypeGlobalStore[ident->mScopeEntry->mType], ident->mScopeEntry->mOffset, ident->mName);
- }
- }
-}
-
-static void print_cil_assignment(LLFILE *fp, LLScriptExpression *exp, LLScriptScopeEntry* function_scope)
-{
- LLScriptLValue *lvalue = (LLScriptLValue *) exp;
- LLScriptIdentifier *ident = lvalue->mIdentifier;
- if (lvalue->mAccessor)
- {
- // Object address loaded, store in to field.
- fprintf(fp, "stfld ");
- print_cil_accessor(fp, lvalue);
-
- // Load object address.
- print_cil_load_address(fp, exp, function_scope);
-
- // Load field.
- fprintf(fp, "ldfld ");
- print_cil_accessor(fp, lvalue);
- }
- else
- {
- if (ident->mScopeEntry->mIDType == LIT_VARIABLE)
- {
- // Language semantics require value of assignment to be left on stack.
- // TODO: Optimise away redundant dup/pop pairs.
- fprintf(fp, "dup\n");
- if(is_parameter(ident, function_scope))
- {
- // Parameter, store by name.
- fprintf(fp, "starg.s '%s'\n", ident->mScopeEntry->mIdentifier);
- }
- else
- {
- // Local, store by index.
- fprintf(fp, "stloc.s %d\n", ident->mScopeEntry->mCount);
- }
- }
- else if (ident->mScopeEntry->mIDType == LIT_GLOBAL)
- {
- // Object address loaded, store in to field.
- fprintf(fp, "stfld ");
- print_cil_member(fp, ident);
-
- // Load object address.
- print_cil_load_address(fp, exp, function_scope);
-
- // Load field.
- fprintf(fp, "ldfld ");
- print_cil_member(fp, ident);
- }
- }
-}
-
-void print_cast(LLFILE *fp, LSCRIPTType ret_type, LSCRIPTType right_type)
-{
- if (right_type != ret_type)
- {
- fprintf(fp, "CAST %s->%s\n", LSCRIPTTypeNames[right_type], LSCRIPTTypeNames[ret_type]);
- }
-}
-
-void cast2stack(LLScriptByteCodeChunk *chunk, LSCRIPTType ret_type, LSCRIPTType right_type)
-{
- if (right_type != ret_type)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_CAST]);
- U8 castbyte = LSCRIPTTypeByte[right_type] | LSCRIPTTypeHi4Bits[ret_type];
- chunk->addByte(castbyte);
- }
-}
-
-void operation2stack(LLScriptByteCodeChunk *chunk, LSCRIPTType ret_type, LSCRIPTType right_type)
-{
- U8 typebyte = LSCRIPTTypeByte[right_type] | LSCRIPTTypeHi4Bits[ret_type];
- chunk->addByte(typebyte);
-}
-
-void store2stack(LLScriptExpression *exp, LLScriptExpression *lv, LLScriptByteCodeChunk *chunk, LSCRIPTType right_type)
-{
- LLScriptLValue *lvalue = (LLScriptLValue *)lv;
- LLScriptIdentifier *ident = lvalue->mIdentifier;
- LSCRIPTType rettype = exp->mReturnType;
-
- if (exp->mRightType != LST_NULL)
- {
- if (legal_binary_expression(rettype, exp->mLeftType, exp->mRightType, exp->mType))
- cast2stack(chunk, right_type, exp->mReturnType);
- }
- switch(exp->mReturnType)
- {
- case LST_INTEGER:
- case LST_FLOATINGPOINT:
- if (ident->mScopeEntry->mIDType == LIT_VARIABLE)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_STORE]);
- }
- else
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_STOREG]);
- }
- break;
- case LST_KEY:
- case LST_STRING:
- if (ident->mScopeEntry->mIDType == LIT_VARIABLE)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_STORES]);
- }
- else
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_STOREGS]);
- }
- break;
- case LST_LIST:
- if (ident->mScopeEntry->mIDType == LIT_VARIABLE)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_STOREL]);
- }
- else
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_STOREGL]);
- }
- break;
- case LST_VECTOR:
- if (ident->mScopeEntry->mIDType == LIT_VARIABLE)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_STOREV]);
- }
- else
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_STOREGV]);
- }
- break;
- case LST_QUATERNION:
- if (ident->mScopeEntry->mIDType == LIT_VARIABLE)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_STOREQ]);
- }
- else
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_STOREGQ]);
- }
- break;
- default:
- if (ident->mScopeEntry->mIDType == LIT_VARIABLE)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_STORE]);
- }
- else
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_STOREG]);
- }
- break;
- }
- S32 address = ident->mScopeEntry->mOffset + lvalue->mOffset;
- chunk->addInteger(address);
-}
-
-void LLScriptAssignment::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " = ");
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_EMIT_ASSEMBLY:
- {
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cast(fp, mReturnType, mRightType);
- print_assignment(fp, mLValue);
- }
- break;
- case LSCP_TYPE:
- {
- mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftType = type;
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightType = type;
- if (!legal_assignment(mLeftType, mRightType))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- type = mReturnType = mLeftType;
- }
- break;
- case LSCP_TO_STACK:
- {
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- store2stack(this, mLValue, chunk, mRightType);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- {
- print_cil_load_address(fp, mLValue, entry);
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_assignment_cast(fp, mRightType, mReturnType);
- print_cil_assignment(fp, mLValue, entry);
- }
- break;
- default:
- mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
-}
-
-S32 LLScriptAssignment::getSize()
-{
- return 0;
-}
-
-static void print_cil_add(LLFILE* fp, LSCRIPTType left_type, LSCRIPTType right_type)
-{
- if(LST_LIST == right_type && LST_LIST != left_type)
- {
- print_cil_box(fp, left_type);
- fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::Prepend(class [mscorlib]System.Collections.ArrayList, object)\n");
- return;
- }
-
- switch(left_type)
- {
- case LST_INTEGER:
- case LST_FLOATINGPOINT:
-
- // Numeric addition.
- fprintf(fp, "add\n");
- break;
-
- case LST_STRING:
- case LST_KEY:
-
- // String concatenation.
- fprintf(fp, "call string valuetype [LslUserScript]LindenLab.SecondLife.LslUserScript::Add(string, string)\n");
- break;
-
- case LST_VECTOR:
-
- // Vector addition.
- fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Vector class [LslUserScript]LindenLab.SecondLife.LslUserScript::'Add'(class [ScriptTypes]LindenLab.SecondLife.Vector, class [ScriptTypes]LindenLab.SecondLife.Vector)\n");
- break;
-
- case LST_QUATERNION:
-
- // Rotation addition.
- fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Quaternion class [LslUserScript]LindenLab.SecondLife.LslUserScript::'Add'(class [ScriptTypes]LindenLab.SecondLife.Quaternion, class [ScriptTypes]LindenLab.SecondLife.Quaternion)\n");
- break;
-
- case LST_LIST:
- switch(right_type)
- {
- case LST_LIST:
- // Concatenate lists.
- fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::Append(class [mscorlib]System.Collections.ArrayList, class [mscorlib]System.Collections.ArrayList)\n");
- break;
- case LST_INTEGER:
- fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::Append(int32, class [mscorlib]System.Collections.ArrayList)\n");
- break;
- case LST_FLOATINGPOINT:
- fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::Append(float32, class [mscorlib]System.Collections.ArrayList)\n");
- break;
- case LST_STRING:
- fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::Append(string, class [mscorlib]System.Collections.ArrayList)\n");
- break;
- case LST_KEY:
- fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::Append(valuetype [ScriptTypes]LindenLab.SecondLife.Key, class [mscorlib]System.Collections.ArrayList)\n");
- break;
- case LST_VECTOR:
- fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::Append(valuetype [ScriptTypes]LindenLab.SecondLife.Vector, class [mscorlib]System.Collections.ArrayList)\n");
- break;
- case LST_QUATERNION:
- fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::Append(valuetype [ScriptTypes]LindenLab.SecondLife.Quaternion, class [mscorlib]System.Collections.ArrayList)\n");
- break;
- default:
- break;
- }
-
- default:
- break;
- }
-}
-
-void LLScriptAddAssignment::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " += ");
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_EMIT_ASSEMBLY:
- {
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "ADD %s, %s\n", LSCRIPTTypeNames[mRightType], LSCRIPTTypeNames[mLeftType]);
- print_assignment(fp, mLValue);
- }
- break;
- case LSCP_TYPE:
- {
- mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftType = type;
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightType = type;
- if (!legal_binary_expression(mReturnType, mLeftType, mRightType, mType))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- type = mReturnType;
- }
- break;
- case LSCP_TO_STACK:
- {
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- chunk->addByte(LSCRIPTOpCodes[LOPC_ADD]);
- operation2stack(chunk, mReturnType, mRightType);
- store2stack(this, mLValue, chunk, mReturnType);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- {
- print_cil_load_address(fp, mLValue, entry);
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_numeric_cast(fp, mRightSide->mReturnType, mLValue->mReturnType);
- mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_numeric_cast(fp, mLValue->mReturnType, mRightSide->mReturnType);
- print_cil_add(fp, mLValue->mReturnType, mRightSide->mReturnType);
- print_cil_assignment(fp, mLValue, entry);
- }
- break;
- default:
- mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
-}
-
-S32 LLScriptAddAssignment::getSize()
-{
- return 0;
-}
-
-static void print_cil_sub(LLFILE* fp, LSCRIPTType left_type, LSCRIPTType right_type)
-{
- switch(left_type)
- {
- case LST_INTEGER:
- if(LST_INTEGER == right_type)
- {
- fprintf(fp, "call int32 [LslUserScript]LindenLab.SecondLife.LslUserScript::Subtract(int32, int32)\n");
- break;
- }
- case LST_FLOATINGPOINT:
- // Numeric subtraction.
- fprintf(fp, "call float64 [LslUserScript]LindenLab.SecondLife.LslUserScript::Subtract(float64, float64)\n");
- break;
- case LST_VECTOR:
-
- // Vector subtraction.
- fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Vector class [LslUserScript]LindenLab.SecondLife.LslUserScript::'Subtract'(class [ScriptTypes]LindenLab.SecondLife.Vector, class [ScriptTypes]LindenLab.SecondLife.Vector)\n");
- break;
-
- case LST_QUATERNION:
-
- // Rotation subtraction.
- fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Quaternion class [LslUserScript]LindenLab.SecondLife.LslUserScript::'Subtract'(class [ScriptTypes]LindenLab.SecondLife.Quaternion, class [ScriptTypes]LindenLab.SecondLife.Quaternion)\n");
- break;
-
- default:
-
- // Error.
- break;
- }
-}
-
-void LLScriptSubAssignment::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " -= ");
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_EMIT_ASSEMBLY:
- {
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "SUB %s, %s\n", LSCRIPTTypeNames[mRightType], LSCRIPTTypeNames[mLeftType]);
- print_assignment(fp, mLValue);
- }
- break;
- case LSCP_TYPE:
- {
- mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftType = type;
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightType = type;
- if (!legal_binary_expression(mReturnType, mLeftType, mRightType, mType))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- type = mReturnType;
- }
- break;
- case LSCP_TO_STACK:
- {
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- chunk->addByte(LSCRIPTOpCodes[LOPC_SUB]);
- operation2stack(chunk, mReturnType, mRightType);
- store2stack(this, mLValue, chunk, mReturnType);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- {
- print_cil_load_address(fp, mLValue, entry);
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_numeric_cast(fp, mRightSide->mReturnType, mLValue->mReturnType);
- mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_numeric_cast(fp, mLValue->mReturnType, mRightSide->mReturnType);
- print_cil_sub(fp, mLValue->mReturnType, mRightSide->mReturnType);
- print_cil_assignment(fp, mLValue, entry);
- }
- break;
- default:
- mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
-}
-
-S32 LLScriptSubAssignment::getSize()
-{
- return 0;
-}
-
-static void print_cil_neg(LLFILE* fp, LSCRIPTType type)
-{
- switch(type)
- {
- case LST_INTEGER:
- case LST_FLOATINGPOINT:
- fprintf(fp, "neg\n");
- break;
- case LST_VECTOR:
- fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Vector class [LslUserScript]LindenLab.SecondLife.LslUserScript::'Negate'(class [ScriptTypes]LindenLab.SecondLife.Vector)\n");
- break;
- case LST_QUATERNION:
- fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Quaternion class [LslUserScript]LindenLab.SecondLife.LslUserScript::'Negate'(class [ScriptTypes]LindenLab.SecondLife.Quaternion)\n");
- break;
- default:
- break;
- }
-}
-
-static void print_cil_mul(LLFILE* fp, LSCRIPTType left_type, LSCRIPTType right_type)
-{
- switch(left_type)
- {
- case LST_INTEGER:
-
- switch(right_type)
- {
- case LST_INTEGER:
- case LST_FLOATINGPOINT:
-
- // Numeric multiplication.
- fprintf(fp, "mul\n");
- break;
-
- case LST_VECTOR:
-
- // Vector scaling.
- fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Vector class [LslUserScript]LindenLab.SecondLife.LslUserScript::'Multiply'(class [ScriptTypes]LindenLab.SecondLife.Vector, float32)\n");
- break;
- default:
- break;
- }
- break;
-
- case LST_FLOATINGPOINT:
-
- switch(right_type)
- {
- case LST_INTEGER:
- case LST_FLOATINGPOINT:
-
- // Numeric multiplication.
- fprintf(fp, "mul\n");
- break;
-
- case LST_VECTOR:
-
- // Vector scaling.
- fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Vector class [LslUserScript]LindenLab.SecondLife.LslUserScript::'Multiply'(class [ScriptTypes]LindenLab.SecondLife.Vector, float32)\n");
- break;
-
- default:
- break;
- }
- break;
-
- case LST_VECTOR:
-
- switch(right_type)
- {
- case LST_INTEGER:
- case LST_FLOATINGPOINT:
-
- // Vector scaling.
- fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Vector class [LslUserScript]LindenLab.SecondLife.LslUserScript::'Multiply'(float32, class [ScriptTypes]LindenLab.SecondLife.Vector)\n");
- break;
-
- case LST_VECTOR:
-
- // Dot product.
- fprintf(fp, "call float32 class [LslUserScript]LindenLab.SecondLife.LslUserScript::'Multiply'(class [ScriptTypes]LindenLab.SecondLife.Vector, class [ScriptTypes]LindenLab.SecondLife.Vector)\n");
- break;
-
- case LST_QUATERNION:
-
- // Vector rotation.
- fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Vector class [LslUserScript]LindenLab.SecondLife.LslUserScript::'Multiply'(class [ScriptTypes]LindenLab.SecondLife.Quaternion, class [ScriptTypes]LindenLab.SecondLife.Vector)\n");
- break;
-
- default:
- break;
- }
- break;
-
- case LST_QUATERNION:
-
- // Rotation multiplication.
- fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Quaternion class [LslUserScript]LindenLab.SecondLife.LslUserScript::'Multiply'(class [ScriptTypes]LindenLab.SecondLife.Quaternion, class [ScriptTypes]LindenLab.SecondLife.Quaternion)\n");
- break;
-
- default:
-
- // Error.
- break;
- }
-}
-
-void LLScriptMulAssignment::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " *= ");
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_EMIT_ASSEMBLY:
- {
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "MUL %s, %s\n", LSCRIPTTypeNames[mRightType], LSCRIPTTypeNames[mLeftType]);
- print_assignment(fp, mLValue);
- }
- break;
- case LSCP_TYPE:
- {
- mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftType = type;
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightType = type;
- if (!legal_binary_expression(mReturnType, mLeftType, mRightType, mType) /*|| !legal_assignment(mLValue->mReturnType, mReturnType)*/)
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- type = mReturnType;
- }
- break;
- case LSCP_TO_STACK:
- {
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- chunk->addByte(LSCRIPTOpCodes[LOPC_MUL]);
- operation2stack(chunk, mReturnType, mRightType);
- store2stack(this, mLValue, chunk, mReturnType);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- {
- print_cil_load_address(fp, mLValue, entry);
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_numeric_cast(fp, mRightSide->mReturnType, mLValue->mReturnType);
- mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_numeric_cast(fp, mLValue->mReturnType, mRightSide->mReturnType);
- print_cil_mul(fp, mLValue->mReturnType, mRightSide->mReturnType);
- if((mLValue->mReturnType == LST_INTEGER) &&
- (mRightSide->mReturnType == LST_FLOATINGPOINT))
- {
- print_cil_cast(fp, LST_FLOATINGPOINT, LST_INTEGER);
- }
- print_cil_assignment(fp, mLValue, entry);
- }
- break;
- default:
- mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
-}
-
-S32 LLScriptMulAssignment::getSize()
-{
- return 0;
-}
-
-static void print_cil_div(LLFILE* fp, LSCRIPTType left_type, LSCRIPTType right_type)
-{
- switch(left_type)
- {
- case LST_INTEGER:
- if(LST_INTEGER == right_type)
- {
- fprintf(fp, "call int32 [LslUserScript]LindenLab.SecondLife.LslUserScript::Divide(int32, int32)\n");
- break;
- }
- case LST_FLOATINGPOINT:
-
- // Numeric division.
- fprintf(fp, "call float64 [LslUserScript]LindenLab.SecondLife.LslUserScript::Divide(float64, float64)\n");
- break;
-
- case LST_VECTOR:
-
- switch(right_type)
- {
- case LST_INTEGER:
- case LST_FLOATINGPOINT:
-
- // Scale.
- fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Vector class [LslUserScript]LindenLab.SecondLife.LslUserScript::'Divide'(float32, class [ScriptTypes]LindenLab.SecondLife.Vector)\n");
- break;
-
- case LST_QUATERNION:
-
- // Inverse rotation.
- fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Vector class [LslUserScript]LindenLab.SecondLife.LslUserScript::'Divide'(class [ScriptTypes]LindenLab.SecondLife.Quaternion, class [ScriptTypes]LindenLab.SecondLife.Vector)\n");
- break;
-
- default:
- break;
- }
- break;
-
- case LST_QUATERNION:
-
- fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Quaternion class [LslUserScript]LindenLab.SecondLife.LslUserScript::'Divide'(class [ScriptTypes]LindenLab.SecondLife.Quaternion, class [ScriptTypes]LindenLab.SecondLife.Quaternion)\n");
- break;
-
- default:
-
- // Error.
- break;
- }
-}
-
-void LLScriptDivAssignment::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " /= ");
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_EMIT_ASSEMBLY:
- {
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "DIV %s, %s\n", LSCRIPTTypeNames[mRightType], LSCRIPTTypeNames[mLeftType]);
- print_assignment(fp, mLValue);
- }
- break;
- case LSCP_TYPE:
- {
- mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftType = type;
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightType = type;
- if (!legal_binary_expression(mReturnType, mLeftType, mRightType, mType))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- type = mReturnType;
- }
- break;
- case LSCP_TO_STACK:
- {
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- chunk->addByte(LSCRIPTOpCodes[LOPC_DIV]);
- operation2stack(chunk, mReturnType, mRightType);
- store2stack(this, mLValue, chunk, mReturnType);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- {
- print_cil_load_address(fp, mLValue, entry);
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_numeric_cast(fp, mRightSide->mReturnType, mLValue->mReturnType);
- mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_numeric_cast(fp, mLValue->mReturnType, mRightSide->mReturnType);
- print_cil_div(fp, mLValue->mReturnType, mRightSide->mReturnType);
- print_cil_assignment(fp, mLValue, entry);
- }
- break;
- default:
- mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
-}
-
-S32 LLScriptDivAssignment::getSize()
-{
- return 0;
-}
-
-static void print_cil_mod(LLFILE* fp, LSCRIPTType left_type, LSCRIPTType right_type)
-{
- switch(left_type)
- {
- case LST_INTEGER:
-
- // Numeric remainder.
- fprintf(fp, "call int32 [LslUserScript]LindenLab.SecondLife.LslUserScript::Modulo(int32, int32)\n");
- break;
-
- case LST_VECTOR:
-
- // Vector cross product.
- fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Vector class [LslUserScript]LindenLab.SecondLife.LslUserScript::'Modulo'(class [ScriptTypes]LindenLab.SecondLife.Vector, class [ScriptTypes]LindenLab.SecondLife.Vector)\n");
- break;
-
- default:
-
- // Error.
- break;
- }
-}
-
-void LLScriptModAssignment::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " %%= ");
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_EMIT_ASSEMBLY:
- {
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "MOD %s, %s\n", LSCRIPTTypeNames[mRightType], LSCRIPTTypeNames[mLeftType]);
- print_assignment(fp, mLValue);
- }
- break;
- case LSCP_TYPE:
- {
- mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftType = type;
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightType = type;
- if (!legal_binary_expression(mReturnType, mLeftType, mRightType, mType))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- type = mReturnType;
- }
- break;
- case LSCP_TO_STACK:
- {
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- chunk->addByte(LSCRIPTOpCodes[LOPC_MOD]);
- operation2stack(chunk, mReturnType, mRightType);
- store2stack(this, mLValue, chunk, mReturnType);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- {
- print_cil_load_address(fp, mLValue, entry);
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_mod(fp, mLValue->mReturnType, mRightSide->mReturnType);
- print_cil_assignment(fp, mLValue, entry);
- }
- break;
- default:
- mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
-}
-
-S32 LLScriptModAssignment::getSize()
-{
- return 0;
-}
-
-static void print_cil_eq(LLFILE* fp, LSCRIPTType left_type, LSCRIPTType right_type)
-{
-
- switch(right_type)
- {
- case LST_INTEGER:
- case LST_FLOATINGPOINT:
-
- // Numeric equality.
- fprintf(fp, "ceq\n");
- break;
-
- case LST_STRING:
- // NOTE: babbage: strings and keys can be compared, so a cast
- // may be required
- print_cil_cast(fp, left_type, right_type);
- // String equality.
- fprintf(fp, "call bool valuetype [mscorlib]System.String::op_Equality(string, string)\n");
- break;
-
- case LST_KEY:
- // NOTE: babbage: strings and keys can be compared, so a cast
- // may be required
- print_cil_cast(fp, left_type, right_type);
-
- // Key equality.
- fprintf(fp, "call int32 [LslUserScript]LindenLab.SecondLife.LslUserScript::'Equals'(valuetype [ScriptTypes]LindenLab.SecondLife.Key, valuetype [ScriptTypes]LindenLab.SecondLife.Key)\n");
- break;
-
- case LST_VECTOR:
-
- // Vector equality.
- fprintf(fp, "call int32 [LslUserScript]LindenLab.SecondLife.LslUserScript::'Equals'(class [ScriptTypes]LindenLab.SecondLife.Vector, class [ScriptTypes]LindenLab.SecondLife.Vector)\n");
- break;
-
- case LST_QUATERNION:
-
- // Rotation equality.
- fprintf(fp, "call int32 [LslUserScript]LindenLab.SecondLife.LslUserScript::'Equals'(class [ScriptTypes]LindenLab.SecondLife.Quaternion, class [ScriptTypes]LindenLab.SecondLife.Quaternion)\n");
- break;
-
- case LST_LIST:
- fprintf(fp, "call int32 [LslUserScript]LindenLab.SecondLife.LslUserScript::Equals(class [mscorlib]System.Collections.ArrayList, class [mscorlib]System.Collections.ArrayList)\n");
- break;
-
- default:
-
- // Error.
- break;
- }
-}
-
-void LLScriptEquality::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " == ");
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_EMIT_ASSEMBLY:
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "EQ %s, %s\n", LSCRIPTTypeNames[mRightType], LSCRIPTTypeNames[mLeftType]);
- break;
- case LSCP_TYPE:
- {
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftType = type;
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightType = type;
- if (!legal_binary_expression(mReturnType, mLeftType, mRightType, mType))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- type = mReturnType;
- }
- break;
- case LSCP_TO_STACK:
- {
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- U8 typebyte = LSCRIPTTypeByte[mRightType] | LSCRIPTTypeHi4Bits[mLeftType];
- chunk->addByte(LSCRIPTOpCodes[LOPC_EQ]);
- chunk->addByte(typebyte);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_numeric_cast(fp, mRightSide->mReturnType, mLeftSide->mReturnType);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_numeric_cast(fp, mLeftSide->mReturnType, mRightSide->mReturnType);
- print_cil_eq(fp, mLeftSide->mReturnType, mRightSide->mReturnType);
- break;
- default:
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
-}
-
-S32 LLScriptEquality::getSize()
-{
- return 0;
-}
-
-void LLScriptNotEquals::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " != ");
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_EMIT_ASSEMBLY:
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "NEQ %s, %s\n", LSCRIPTTypeNames[mRightType], LSCRIPTTypeNames[mLeftType]);
- break;
- case LSCP_TYPE:
- {
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftType = type;
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightType = type;
- if (!legal_binary_expression(mReturnType, mLeftType, mRightType, mType))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- type = mReturnType;
- }
- break;
- case LSCP_TO_STACK:
- {
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- U8 typebyte = LSCRIPTTypeByte[mRightType] | LSCRIPTTypeHi4Bits[mLeftType];
- chunk->addByte(LSCRIPTOpCodes[LOPC_NEQ]);
- chunk->addByte(typebyte);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_numeric_cast(fp, mRightSide->mReturnType, mLeftSide->mReturnType);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_numeric_cast(fp, mLeftSide->mReturnType, mRightSide->mReturnType);
- if (LST_LIST == mLeftSide->mReturnType)
- {
- fprintf(fp, "call int32 [LslUserScript]LindenLab.SecondLife.LslUserScript::NotEquals(class [mscorlib]System.Collections.ArrayList, class [mscorlib]System.Collections.ArrayList)\n");
- }
- else
- {
- print_cil_eq(fp, mLeftSide->mReturnType, mRightSide->mReturnType);
- fprintf(fp, "ldc.i4.0\n");
- fprintf(fp, "ceq\n"); // Compare result of first compare equal with 0 to get compare not equal.
- }
- break;
- default:
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
-}
-
-S32 LLScriptNotEquals::getSize()
-{
- return 0;
-}
-
-static void print_cil_lte(LLFILE* fp)
-{
- // NOTE: LSL pushes operands backwards, so <= becomes >=
- fprintf(fp, "clt\n");
- fprintf(fp, "ldc.i4.0\n");
- fprintf(fp, "ceq\n");
-}
-
-void LLScriptLessEquals::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " <= ");
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_EMIT_ASSEMBLY:
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "LEQ %s, %s\n", LSCRIPTTypeNames[mRightType], LSCRIPTTypeNames[mLeftType]);
- break;
- case LSCP_TYPE:
- {
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftType = type;
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightType = type;
- if (!legal_binary_expression(mReturnType, mLeftType, mRightType, mType))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- type = mReturnType;
- }
- break;
- case LSCP_TO_STACK:
- {
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- U8 typebyte = LSCRIPTTypeByte[mRightType] | LSCRIPTTypeHi4Bits[mLeftType];
- chunk->addByte(LSCRIPTOpCodes[LOPC_LEQ]);
- chunk->addByte(typebyte);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_numeric_cast(fp, mRightSide->mReturnType, mLeftSide->mReturnType);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_numeric_cast(fp, mLeftSide->mReturnType, mRightSide->mReturnType);
- print_cil_lte(fp);
- break;
- default:
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
-}
-
-S32 LLScriptLessEquals::getSize()
-{
- return 0;
-}
-
-static void print_cil_gte(LLFILE* fp)
-{
- // NOTE: LSL pushes operands backwards, so >= becomes <=
- fprintf(fp, "cgt\n");
- fprintf(fp, "ldc.i4.0\n");
- fprintf(fp, "ceq\n");
-}
-
-void LLScriptGreaterEquals::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " >= ");
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_EMIT_ASSEMBLY:
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "GEQ %s, %s\n", LSCRIPTTypeNames[mRightType], LSCRIPTTypeNames[mLeftType]);
- break;
- case LSCP_TYPE:
- {
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftType = type;
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightType = type;
- if (!legal_binary_expression(mReturnType, mLeftType, mRightType, mType))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- type = mReturnType;
- }
- break;
- case LSCP_TO_STACK:
- {
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- U8 typebyte = LSCRIPTTypeByte[mRightType] | LSCRIPTTypeHi4Bits[mLeftType];
- chunk->addByte(LSCRIPTOpCodes[LOPC_GEQ]);
- chunk->addByte(typebyte);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_numeric_cast(fp, mRightSide->mReturnType, mLeftSide->mReturnType);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_numeric_cast(fp, mLeftSide->mReturnType, mRightSide->mReturnType);
- print_cil_gte(fp);
- break;
- default:
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
-}
-
-S32 LLScriptGreaterEquals::getSize()
-{
- return 0;
-}
-
-static void print_cil_lt(LLFILE* fp)
-{
- // NOTE: LSL pushes operands backwards, so < becomes >
- fprintf(fp, "cgt\n");
-}
-
-void LLScriptLessThan::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " < ");
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_EMIT_ASSEMBLY:
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "LESS %s, %s\n", LSCRIPTTypeNames[mRightType], LSCRIPTTypeNames[mLeftType]);
- break;
- case LSCP_TYPE:
- {
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftType = type;
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightType = type;
- if (!legal_binary_expression(mReturnType, mLeftType, mRightType, mType))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- type = mReturnType;
- }
- break;
- case LSCP_TO_STACK:
- {
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- U8 typebyte = LSCRIPTTypeByte[mRightType] | LSCRIPTTypeHi4Bits[mLeftType];
- chunk->addByte(LSCRIPTOpCodes[LOPC_LESS]);
- chunk->addByte(typebyte);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_numeric_cast(fp, mRightSide->mReturnType, mLeftSide->mReturnType);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_numeric_cast(fp, mLeftSide->mReturnType, mRightSide->mReturnType);
- print_cil_lt(fp);
- break;
- default:
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
-}
-
-S32 LLScriptLessThan::getSize()
-{
- return 0;
-}
-
-static void print_cil_gt(LLFILE* fp)
-{
- // NOTE: LSL pushes operands backwards, so > becomes <
- fprintf(fp, "clt\n");
-}
-
-void LLScriptGreaterThan::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " > ");
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_EMIT_ASSEMBLY:
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "GREATER %s, %s\n", LSCRIPTTypeNames[mRightType], LSCRIPTTypeNames[mLeftType]);
- break;
- case LSCP_TYPE:
- {
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftType = type;
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightType = type;
- if (!legal_binary_expression(mReturnType, mLeftType, mRightType, mType))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- type = mReturnType;
- }
- break;
- case LSCP_TO_STACK:
- {
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- U8 typebyte = LSCRIPTTypeByte[mRightType] | LSCRIPTTypeHi4Bits[mLeftType];
- chunk->addByte(LSCRIPTOpCodes[LOPC_GREATER]);
- chunk->addByte(typebyte);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_numeric_cast(fp, mRightSide->mReturnType, mLeftSide->mReturnType);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_numeric_cast(fp, mLeftSide->mReturnType, mRightSide->mReturnType);
- print_cil_gt(fp);
- break;
- default:
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
-}
-
-S32 LLScriptGreaterThan::getSize()
-{
- return 0;
-}
-
-void LLScriptPlus::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " + ");
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_EMIT_ASSEMBLY:
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "ADD %s, %s\n", LSCRIPTTypeNames[mRightType], LSCRIPTTypeNames[mLeftType]);
- break;
- case LSCP_TYPE:
- {
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftType = type;
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightType = type;
- if (!legal_binary_expression(mReturnType, mLeftType, mRightType, mType))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- type = mReturnType;
- }
- break;
- case LSCP_TO_STACK:
- {
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- U8 typebyte = LSCRIPTTypeByte[mRightType] | LSCRIPTTypeHi4Bits[mLeftType];
- chunk->addByte(LSCRIPTOpCodes[LOPC_ADD]);
- chunk->addByte(typebyte);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_numeric_cast(fp, mRightSide->mReturnType, mLeftSide->mReturnType);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_numeric_cast(fp, mLeftSide->mReturnType, mRightSide->mReturnType);
- print_cil_add(fp, mLeftSide->mReturnType, mRightSide->mReturnType);
- break;
- default:
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
-}
-
-S32 LLScriptPlus::getSize()
-{
- return 0;
-}
-
-void LLScriptMinus::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " - ");
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_EMIT_ASSEMBLY:
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "SUB %s, %s\n", LSCRIPTTypeNames[mRightType], LSCRIPTTypeNames[mLeftType]);
- break;
- case LSCP_TYPE:
- {
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftType = type;
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightType = type;
- if (!legal_binary_expression(mReturnType, mLeftType, mRightType, mType))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- type = mReturnType;
- }
- break;
- case LSCP_TO_STACK:
- {
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- U8 typebyte = LSCRIPTTypeByte[mRightType] | LSCRIPTTypeHi4Bits[mLeftType];
- chunk->addByte(LSCRIPTOpCodes[LOPC_SUB]);
- chunk->addByte(typebyte);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_numeric_cast(fp, mRightSide->mReturnType, mLeftSide->mReturnType);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_numeric_cast(fp, mLeftSide->mReturnType, mRightSide->mReturnType);
- print_cil_sub(fp, mLeftSide->mReturnType, mRightSide->mReturnType);
- break;
- default:
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
-}
-
-S32 LLScriptMinus::getSize()
-{
- return 0;
-}
-
-void LLScriptTimes::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " * ");
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_EMIT_ASSEMBLY:
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "MUL %s, %s\n", LSCRIPTTypeNames[mRightType], LSCRIPTTypeNames[mLeftType]);
- break;
- case LSCP_TYPE:
- {
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftType = type;
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightType = type;
- if (!legal_binary_expression(mReturnType, mLeftType, mRightType, mType))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- type = mReturnType;
- }
- break;
- case LSCP_TO_STACK:
- {
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- U8 typebyte = LSCRIPTTypeByte[mRightType] | LSCRIPTTypeHi4Bits[mLeftType];
- chunk->addByte(LSCRIPTOpCodes[LOPC_MUL]);
- chunk->addByte(typebyte);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_numeric_cast(fp, mRightSide->mReturnType, mLeftSide->mReturnType);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_numeric_cast(fp, mLeftSide->mReturnType, mRightSide->mReturnType);
- print_cil_mul(fp, mLeftSide->mReturnType, mRightSide->mReturnType);
- break;
- default:
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
-}
-
-S32 LLScriptTimes::getSize()
-{
- return 0;
-}
-
-void LLScriptDivide::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " / ");
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_EMIT_ASSEMBLY:
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "DIV %s, %s\n", LSCRIPTTypeNames[mRightType], LSCRIPTTypeNames[mLeftType]);
- break;
- case LSCP_TYPE:
- {
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftType = type;
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightType = type;
- if (!legal_binary_expression(mReturnType, mLeftType, mRightType, mType))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- type = mReturnType;
- }
- break;
- case LSCP_TO_STACK:
- {
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- U8 typebyte = LSCRIPTTypeByte[mRightType] | LSCRIPTTypeHi4Bits[mLeftType];
- chunk->addByte(LSCRIPTOpCodes[LOPC_DIV]);
- chunk->addByte(typebyte);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_numeric_cast(fp, mRightSide->mReturnType, mLeftSide->mReturnType);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_numeric_cast(fp, mLeftSide->mReturnType, mRightSide->mReturnType);
- print_cil_div(fp, mLeftSide->mReturnType, mRightSide->mReturnType);
- break;
- default:
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
-}
-
-S32 LLScriptDivide::getSize()
-{
- return 0;
-}
-
-void LLScriptMod::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " %% ");
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_EMIT_ASSEMBLY:
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "MOD %s, %s\n", LSCRIPTTypeNames[mRightType], LSCRIPTTypeNames[mLeftType]);
- break;
- case LSCP_TYPE:
- {
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftType = type;
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightType = type;
- if (!legal_binary_expression(mReturnType, mLeftType, mRightType, mType))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- type = mReturnType;
- }
- break;
- case LSCP_TO_STACK:
- {
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- U8 typebyte = LSCRIPTTypeByte[mRightType] | LSCRIPTTypeHi4Bits[mLeftType];
- chunk->addByte(LSCRIPTOpCodes[LOPC_MOD]);
- chunk->addByte(typebyte);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_mod(fp, mLeftSide->mReturnType, mRightSide->mReturnType);
- break;
- default:
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
-}
-
-S32 LLScriptMod::getSize()
-{
- return 0;
-}
-
-void LLScriptBitAnd::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " & ");
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_EMIT_ASSEMBLY:
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "BITAND\n");
- break;
- case LSCP_TYPE:
- {
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftType = type;
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightType = type;
- if (!legal_binary_expression(mReturnType, mLeftType, mRightType, mType))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- type = mReturnType;
- }
- break;
- case LSCP_TO_STACK:
- {
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- chunk->addByte(LSCRIPTOpCodes[LOPC_BITAND]);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "and\n");
- break;
- default:
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
-}
-
-S32 LLScriptBitAnd::getSize()
-{
- return 0;
-}
-
-void LLScriptBitOr::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " | ");
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_EMIT_ASSEMBLY:
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "BITOR\n");
- break;
- case LSCP_TYPE:
- {
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftType = type;
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightType = type;
- if (!legal_binary_expression(mReturnType, mLeftType, mRightType, mType))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- type = mReturnType;
- }
- break;
- case LSCP_TO_STACK:
- {
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- chunk->addByte(LSCRIPTOpCodes[LOPC_BITOR]);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "or\n");
- break;
- default:
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
-}
-
-S32 LLScriptBitOr::getSize()
-{
- return 0;
-}
-
-void LLScriptBitXor::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " ^ ");
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_EMIT_ASSEMBLY:
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "BITXOR\n");
- break;
- case LSCP_TYPE:
- {
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftType = type;
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightType = type;
- if (!legal_binary_expression(mReturnType, mLeftType, mRightType, mType))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- type = mReturnType;
- }
- break;
- case LSCP_TO_STACK:
- {
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- chunk->addByte(LSCRIPTOpCodes[LOPC_BITXOR]);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "xor\n");
- break;
- default:
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
-}
-
-S32 LLScriptBitXor::getSize()
-{
- return 0;
-}
-
-void LLScriptBooleanAnd::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " && ");
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_EMIT_ASSEMBLY:
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "BOOLAND\n");
- break;
- case LSCP_TYPE:
- {
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftType = type;
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightType = type;
- if (!legal_binary_expression(mReturnType, mLeftType, mRightType, mType))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- type = mReturnType;
- }
- break;
- case LSCP_TO_STACK:
- {
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- chunk->addByte(LSCRIPTOpCodes[LOPC_BOOLAND]);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "ldc.i4.0\n");
- fprintf(fp, "ceq\n");
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "ldc.i4.0\n");
- fprintf(fp, "ceq\n");
- fprintf(fp, "or\n");
- fprintf(fp, "ldc.i4.0\n");
- fprintf(fp, "ceq\n");
- break;
- default:
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
-}
-
-S32 LLScriptBooleanAnd::getSize()
-{
- return 0;
-}
-
-void LLScriptBooleanOr::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " || ");
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_EMIT_ASSEMBLY:
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "BOOLOR\n");
- break;
- case LSCP_TYPE:
- {
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftType = type;
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightType = type;
- if (!legal_binary_expression(mReturnType, mLeftType, mRightType, mType))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- type = mReturnType;
- }
- break;
- case LSCP_TO_STACK:
- {
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- chunk->addByte(LSCRIPTOpCodes[LOPC_BOOLOR]);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "or\n");
- fprintf(fp, "ldc.i4.0\n");
- fprintf(fp, "ceq\n");
- fprintf(fp, "ldc.i4.0\n");
- fprintf(fp, "ceq\n");
- break;
- default:
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
-}
-
-S32 LLScriptBooleanOr::getSize()
-{
- return 0;
-}
-
-void LLScriptShiftLeft::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " << ");
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_EMIT_ASSEMBLY:
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "SHL\n");
- break;
- case LSCP_TYPE:
- {
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftType = type;
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightType = type;
- if (!legal_binary_expression(mReturnType, mLeftType, mRightType, mType))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- type = mReturnType;
- }
- break;
- case LSCP_TO_STACK:
- {
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- chunk->addByte(LSCRIPTOpCodes[LOPC_SHL]);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "call int32 [LslUserScript]LindenLab.SecondLife.LslUserScript::ShiftLeft(int32, int32)\n");
- break;
- default:
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
-}
-
-S32 LLScriptShiftLeft::getSize()
-{
- return 0;
-}
-
-
-void LLScriptShiftRight::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " >> ");
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_EMIT_ASSEMBLY:
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "SHR\n");
- break;
- case LSCP_TYPE:
- {
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftType = type;
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightType = type;
- if (!legal_binary_expression(mReturnType, mLeftType, mRightType, mType))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- type = mReturnType;
- }
- break;
- case LSCP_TO_STACK:
- {
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- chunk->addByte(LSCRIPTOpCodes[LOPC_SHR]);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "call int32 [LslUserScript]LindenLab.SecondLife.LslUserScript::ShiftRight(int32, int32)\n");
- break;
- default:
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
-}
-
-S32 LLScriptShiftRight::getSize()
-{
- return 0;
-}
-
-void LLScriptParenthesis::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- fprintf(fp, "( ");
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )");
- break;
- case LSCP_TYPE:
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mReturnType = mLeftType = type;
- break;
- case LSCP_EMIT_ASSEMBLY:
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mReturnType = mLeftType = type;
- break;
- default:
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
-}
-
-S32 LLScriptParenthesis::getSize()
-{
- return 0;
-}
-
-void LLScriptUnaryMinus::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- fprintf(fp, "-");
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_EMIT_ASSEMBLY:
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "NEG %s\n", LSCRIPTTypeNames[mLeftType]);
- break;
- case LSCP_TYPE:
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (!legal_unary_expression(type, type, mType))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- else
- {
- mReturnType = mLeftType = type;
- }
- break;
- case LSCP_TO_STACK:
- {
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- U8 typebyte = LSCRIPTTypeByte[mLeftType];
- chunk->addByte(LSCRIPTOpCodes[LOPC_NEG]);
- chunk->addByte(typebyte);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- {
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_neg(fp, mLeftType);
- }
- break;
- default:
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
-}
-
-S32 LLScriptUnaryMinus::getSize()
-{
- return 0;
-}
-
-void LLScriptBooleanNot::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- fprintf(fp, "!");
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_EMIT_ASSEMBLY:
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "BOOLNOT\n");
- break;
- case LSCP_TYPE:
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (!legal_unary_expression(type, type, mType))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- else
- {
- mReturnType = mLeftType = type;
- }
- break;
- case LSCP_TO_STACK:
- {
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- chunk->addByte(LSCRIPTOpCodes[LOPC_BOOLNOT]);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "ldc.i4.0\n");
- fprintf(fp, "ceq\n"); // If f(e) is (e == 0), f(e) returns 1 if e is 0 and 0 otherwise, therefore f(e) implements boolean not.
- break;
- default:
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
-}
-
-S32 LLScriptBooleanNot::getSize()
-{
- return 0;
-}
-
-void LLScriptBitNot::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- fprintf(fp, "~");
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_EMIT_ASSEMBLY:
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "BITNOT\n");
- break;
- case LSCP_TYPE:
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (!legal_unary_expression(type, type, mType))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- else
- {
- mReturnType = mLeftType = type;
- }
- break;
- case LSCP_TO_STACK:
- {
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- chunk->addByte(LSCRIPTOpCodes[LOPC_BITNOT]);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "not\n");
- break;
- default:
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
-}
-
-S32 LLScriptBitNot::getSize()
-{
- return 0;
-}
-
-void LLScriptPreIncrement::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- fprintf(fp, "++");
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_EMIT_ASSEMBLY:
- {
- if (mReturnType == LST_INTEGER)
- {
- fprintf(fp, "PUSHARGI 1\n");
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "\n");
- fprintf(fp, "ADD integer, integer\n");
- }
- else if (mReturnType == LST_FLOATINGPOINT)
- {
- fprintf(fp, "PUSHARGF 1\n");
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "\n");
- fprintf(fp, "ADD float, float\n");
- }
- else
- {
- fprintf(fp, "Unexpected Type\n");
- }
- print_assignment(fp, mExpression);
- }
- break;
- case LSCP_TYPE:
- if (mExpression->mType != LET_LVALUE)
- {
- gErrorToText.writeError(fp, this, LSERROR_EXPRESSION_ON_LVALUE);
- }
- else
- {
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (!legal_unary_expression(type, type, mType))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- else
- {
- mReturnType = mLeftType = type;
- }
- }
- break;
- case LSCP_TO_STACK:
- {
- if (mReturnType == LST_INTEGER)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHARGI]);
- chunk->addInteger(1);
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- chunk->addByte(LSCRIPTOpCodes[LOPC_ADD]);
- chunk->addByte(LSCRIPTTypeByte[LST_INTEGER] | LSCRIPTTypeHi4Bits[LST_INTEGER]);
- }
- else if (mReturnType == LST_FLOATINGPOINT)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHARGF]);
- chunk->addFloat(1.f);
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- chunk->addByte(LSCRIPTOpCodes[LOPC_ADD]);
- chunk->addByte(LSCRIPTTypeByte[LST_FLOATINGPOINT] | LSCRIPTTypeHi4Bits[LST_FLOATINGPOINT]);
- }
- store2stack(this, mExpression, chunk, mReturnType);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- {
- print_cil_load_address(fp, mExpression, entry);
- if (mReturnType == LST_INTEGER)
- {
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "ldc.i4.1\n");
- fprintf(fp, "add\n");
- }
- else if (mReturnType == LST_FLOATINGPOINT)
- {
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "ldc.r8 1\n");
- fprintf(fp, "add\n");
- }
- else
- {
- fprintf(fp, "Unexpected Type\n");
- }
- print_cil_assignment(fp, mExpression, entry);
- }
- break;
- default:
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
-}
-
-S32 LLScriptPreIncrement::getSize()
-{
- return 0;
-}
-
-void LLScriptPreDecrement::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- fprintf(fp, "--");
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_EMIT_ASSEMBLY:
- {
- if (mReturnType == LST_INTEGER)
- {
- fprintf(fp, "PUSHARGI 1\n");
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "\n");
- fprintf(fp, "SUB integer, integer\n");
- }
- else if (mReturnType == LST_FLOATINGPOINT)
- {
- fprintf(fp, "PUSHARGF 1\n");
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "\n");
- fprintf(fp, "SUB float, float\n");
- }
- else
- {
- fprintf(fp, "Unexpected Type\n");
- }
- print_assignment(fp, mExpression);
- }
- break;
- case LSCP_TYPE:
- if (mExpression->mType != LET_LVALUE)
- {
- gErrorToText.writeError(fp, this, LSERROR_EXPRESSION_ON_LVALUE);
- }
- else
- {
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (!legal_unary_expression(type, type, mType))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- else
- {
- mReturnType = mLeftType = type;
- }
- }
- break;
- case LSCP_TO_STACK:
- {
- if (mReturnType == LST_INTEGER)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHARGI]);
- chunk->addInteger(1);
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- chunk->addByte(LSCRIPTOpCodes[LOPC_SUB]);
- chunk->addByte(LSCRIPTTypeByte[LST_INTEGER] | LSCRIPTTypeHi4Bits[LST_INTEGER]);
- }
- else if (mReturnType == LST_FLOATINGPOINT)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHARGF]);
- chunk->addFloat(1.f);
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- chunk->addByte(LSCRIPTOpCodes[LOPC_SUB]);
- chunk->addByte(LSCRIPTTypeByte[LST_FLOATINGPOINT] | LSCRIPTTypeHi4Bits[LST_FLOATINGPOINT]);
- }
- store2stack(this, mExpression, chunk, mReturnType);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- {
- print_cil_load_address(fp, mExpression, entry);
- if (mReturnType == LST_INTEGER)
- {
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "ldc.i4.1\n");
- fprintf(fp, "sub\n");
- }
- else if (mReturnType == LST_FLOATINGPOINT)
- {
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "ldc.r8 1\n");
- fprintf(fp, "sub\n");
- }
- else
- {
- fprintf(fp, "Unexpected Type\n");
- }
- print_cil_assignment(fp, mExpression, entry);
- }
- break;
- default:
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
-}
-
-S32 LLScriptPreDecrement::getSize()
-{
- return 0;
-}
-
-void LLScriptTypeCast::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- fprintf(fp, "( ");
- mType->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ") ");
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_EMIT_ASSEMBLY:
- fprintf(fp, "CAST %s->%s\n", LSCRIPTTypeNames[mRightType], LSCRIPTTypeNames[mType->mType]);
- break;
- case LSCP_TYPE:
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightType = type;
- if (!legal_casts(mType->mType, type))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- type = mType->mType;
- mReturnType = mLeftType = type;
- break;
- case LSCP_TO_STACK:
- {
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- chunk->addByte(LSCRIPTOpCodes[LOPC_CAST]);
- U8 castbyte = LSCRIPTTypeByte[mType->mType] | LSCRIPTTypeHi4Bits[mRightType];
- chunk->addByte(castbyte);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_cast(fp, mRightType, mType->mType);
- break;
- default:
- mType->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
-}
-
-S32 LLScriptTypeCast::getSize()
-{
- return 0;
-}
-
-void LLScriptVectorInitializer::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- fprintf(fp, "< ");
- mExpression1->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", ");
- mExpression2->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", ");
- mExpression3->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " >");
- break;
- case LSCP_EMIT_ASSEMBLY:
- mExpression1->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mExpression1->mReturnType != LST_FLOATINGPOINT)
- {
- fprintf(fp, "CAST %s->%s\n", LSCRIPTTypeNames[mExpression1->mReturnType], LSCRIPTTypeNames[LST_FLOATINGPOINT]);
- }
- mExpression2->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mExpression2->mReturnType != LST_FLOATINGPOINT)
- {
- fprintf(fp, "CAST %s->%s\n", LSCRIPTTypeNames[mExpression2->mReturnType], LSCRIPTTypeNames[LST_FLOATINGPOINT]);
- }
- mExpression3->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mExpression3->mReturnType != LST_FLOATINGPOINT)
- {
- fprintf(fp, "CAST %s->%s\n", LSCRIPTTypeNames[mExpression3->mReturnType], LSCRIPTTypeNames[LST_FLOATINGPOINT]);
- }
- break;
- case LSCP_TYPE:
- // vector's take floats
- mExpression1->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (!legal_assignment(LST_FLOATINGPOINT, type))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- mExpression2->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (!legal_assignment(LST_FLOATINGPOINT, type))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- mExpression3->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (!legal_assignment(LST_FLOATINGPOINT, type))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- mReturnType = type = LST_VECTOR;
- if (mNextp)
- {
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- case LSCP_TO_STACK:
- pass = LSCP_TO_STACK;
- mExpression1->recurse(fp, tabs, tabsize, LSCP_TO_STACK, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mExpression1->mReturnType != LST_FLOATINGPOINT)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_CAST]);
- U8 castbyte = LSCRIPTTypeByte[LST_FLOATINGPOINT] | LSCRIPTTypeHi4Bits[mExpression1->mReturnType];
- chunk->addByte(castbyte);
- }
- mExpression2->recurse(fp, tabs, tabsize, LSCP_TO_STACK, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mExpression2->mReturnType != LST_FLOATINGPOINT)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_CAST]);
- U8 castbyte = LSCRIPTTypeByte[LST_FLOATINGPOINT] | LSCRIPTTypeHi4Bits[mExpression2->mReturnType];
- chunk->addByte(castbyte);
- }
- mExpression3->recurse(fp, tabs, tabsize, LSCP_TO_STACK, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mExpression3->mReturnType != LST_FLOATINGPOINT)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_CAST]);
- U8 castbyte = LSCRIPTTypeByte[LST_FLOATINGPOINT] | LSCRIPTTypeHi4Bits[mExpression3->mReturnType];
- chunk->addByte(castbyte);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
-
- // Load arguments.
- mExpression1->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mExpression1->mReturnType != LST_FLOATINGPOINT)
- {
- print_cil_cast(fp, mExpression1->mReturnType, LST_FLOATINGPOINT);
- }
- mExpression2->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mExpression2->mReturnType != LST_FLOATINGPOINT)
- {
- print_cil_cast(fp, mExpression2->mReturnType, LST_FLOATINGPOINT);
- }
- mExpression3->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mExpression3->mReturnType != LST_FLOATINGPOINT)
- {
- print_cil_cast(fp, mExpression3->mReturnType, LST_FLOATINGPOINT);
- }
- // Call named ctor, which leaves new Vector on stack, so it can be saved in to local or argument just like a primitive type.
- fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Vector class [LslUserScript]LindenLab.SecondLife.LslUserScript::'CreateVector'(float32, float32, float32)\n");
- break;
- default:
- mExpression1->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mExpression2->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mExpression3->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
-}
-
-S32 LLScriptVectorInitializer::getSize()
-{
- return 0;
-}
-
-void LLScriptQuaternionInitializer::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- fprintf(fp, "< ");
- mExpression1->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", ");
- mExpression2->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", ");
- mExpression3->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", ");
- mExpression4->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " >");
- break;
- case LSCP_EMIT_ASSEMBLY:
- mExpression1->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mExpression1->mReturnType != LST_FLOATINGPOINT)
- {
- fprintf(fp, "CAST %s->%s\n", LSCRIPTTypeNames[mExpression1->mReturnType], LSCRIPTTypeNames[LST_FLOATINGPOINT]);
- }
- mExpression2->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mExpression2->mReturnType != LST_FLOATINGPOINT)
- {
- fprintf(fp, "CAST %s->%s\n", LSCRIPTTypeNames[mExpression2->mReturnType], LSCRIPTTypeNames[LST_FLOATINGPOINT]);
- }
- mExpression3->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mExpression3->mReturnType != LST_FLOATINGPOINT)
- {
- fprintf(fp, "CAST %s->%s\n", LSCRIPTTypeNames[mExpression3->mReturnType], LSCRIPTTypeNames[LST_FLOATINGPOINT]);
- }
- mExpression4->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mExpression4->mReturnType != LST_FLOATINGPOINT)
- {
- fprintf(fp, "CAST %s->%s\n", LSCRIPTTypeNames[mExpression4->mReturnType], LSCRIPTTypeNames[LST_FLOATINGPOINT]);
- }
- break;
- case LSCP_TYPE:
- // vector's take floats
- mExpression1->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (!legal_assignment(LST_FLOATINGPOINT, type))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- mExpression2->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (!legal_assignment(LST_FLOATINGPOINT, type))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- mExpression3->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (!legal_assignment(LST_FLOATINGPOINT, type))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- mExpression4->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (!legal_assignment(LST_FLOATINGPOINT, type))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- mReturnType = type = LST_QUATERNION;
- if (mNextp)
- {
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- case LSCP_TO_STACK:
- pass = LSCP_TO_STACK;
- mExpression1->recurse(fp, tabs, tabsize, LSCP_TO_STACK, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mExpression1->mReturnType != LST_FLOATINGPOINT)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_CAST]);
- U8 castbyte = LSCRIPTTypeByte[LST_FLOATINGPOINT] | LSCRIPTTypeHi4Bits[mExpression1->mReturnType];
- chunk->addByte(castbyte);
- }
- mExpression2->recurse(fp, tabs, tabsize, LSCP_TO_STACK, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mExpression2->mReturnType != LST_FLOATINGPOINT)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_CAST]);
- U8 castbyte = LSCRIPTTypeByte[LST_FLOATINGPOINT] | LSCRIPTTypeHi4Bits[mExpression2->mReturnType];
- chunk->addByte(castbyte);
- }
- mExpression3->recurse(fp, tabs, tabsize, LSCP_TO_STACK, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mExpression3->mReturnType != LST_FLOATINGPOINT)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_CAST]);
- U8 castbyte = LSCRIPTTypeByte[LST_FLOATINGPOINT] | LSCRIPTTypeHi4Bits[mExpression3->mReturnType];
- chunk->addByte(castbyte);
- }
- mExpression4->recurse(fp, tabs, tabsize, LSCP_TO_STACK, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mExpression4->mReturnType != LST_FLOATINGPOINT)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_CAST]);
- U8 castbyte = LSCRIPTTypeByte[LST_FLOATINGPOINT] | LSCRIPTTypeHi4Bits[mExpression4->mReturnType];
- chunk->addByte(castbyte);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
-
- // Load arguments.
- mExpression1->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mExpression1->mReturnType != LST_FLOATINGPOINT)
- {
- print_cil_cast(fp, mExpression1->mReturnType, LST_FLOATINGPOINT);
- }
- mExpression2->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mExpression2->mReturnType != LST_FLOATINGPOINT)
- {
- print_cil_cast(fp, mExpression2->mReturnType, LST_FLOATINGPOINT);
- }
- mExpression3->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mExpression3->mReturnType != LST_FLOATINGPOINT)
- {
- print_cil_cast(fp, mExpression3->mReturnType, LST_FLOATINGPOINT);
- }
- mExpression4->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mExpression4->mReturnType != LST_FLOATINGPOINT)
- {
- print_cil_cast(fp, mExpression4->mReturnType, LST_FLOATINGPOINT);
- }
-
- // Call named ctor, which leaves new Vector on stack, so it can be saved in to local or argument just like a primitive type.
- fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Quaternion class [LslUserScript]LindenLab.SecondLife.LslUserScript::'CreateQuaternion'(float32, float32, float32, float32)\n");
- break;
- default:
- mExpression1->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mExpression2->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mExpression3->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mExpression4->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
-}
-
-S32 LLScriptQuaternionInitializer::getSize()
-{
- return 0;
-}
-
-void LLScriptListInitializer::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- fprintf(fp, "[ ");
- mExpressionList->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " ]");
- break;
- case LSCP_EMIT_ASSEMBLY:
- count = 0;
- if (mExpressionList)
- {
- mExpressionList->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "STACKTOL %llu\n", count);
- }
- break;
- case LSCP_TYPE:
- if (mExpressionList)
- {
- mExpressionList->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mReturnType = type = LST_LIST;
- }
- mReturnType = type = LST_LIST;
- break;
- case LSCP_TO_STACK:
- {
- if (mExpressionList)
- {
- pass = LSCP_TO_STACK;
- U64 list_element_count = 0;
- mExpressionList->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, list_element_count, chunk, heap, stacksize, entry, entrycount, NULL);
- chunk->addByte(LSCRIPTOpCodes[LOPC_STACKTOL]);
- chunk->addInteger((S32)list_element_count);
-
- }
- else
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_STACKTOL]);
- chunk->addInteger(0);
- }
- break;
- }
- case LSCP_EMIT_CIL_ASSEMBLY:
- {
- // Push boxed elements on stack.
- U64 list_element_count = 0;
- if (mExpressionList)
- {
- mExpressionList->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, list_element_count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
-
- // Create list on stack.
- fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::CreateList()\n");
-
- // Call Prepend to add remaining boxed expressions.
- for(U64 i = 0; i < list_element_count; i++)
- {
- fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::Prepend(object, class [mscorlib]System.Collections.ArrayList)\n");
- }
- break;
- }
- default:
- if (mExpressionList)
- {
- mExpressionList->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
-}
-
-S32 LLScriptListInitializer::getSize()
-{
- return 0;
-}
-
-void LLScriptPostIncrement::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "++");
- break;
- case LSCP_EMIT_ASSEMBLY:
- {
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mReturnType == LST_INTEGER)
- {
- fprintf(fp, "PUSHARGI 1\n");
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "ADD integer, integer\n");
- }
- else if (mReturnType == LST_FLOATINGPOINT)
- {
- fprintf(fp, "PUSHARGF 1\n");
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "ADD float, float\n");
- }
- else
- {
- fprintf(fp, "Unexpected Type\n");
- }
- print_assignment(fp, mExpression);
- fprintf(fp, "%s\n", LSCRIPTTypePop[mReturnType]);
- }
- break;
- case LSCP_TYPE:
- if (mExpression->mType != LET_LVALUE)
- {
- gErrorToText.writeError(fp, this, LSERROR_EXPRESSION_ON_LVALUE);
- }
- else
- {
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (!legal_unary_expression(type, type, mType))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- else
- {
- mReturnType = mLeftType = type;
- }
- }
- break;
- case LSCP_TO_STACK:
- {
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mReturnType == LST_INTEGER)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHARGI]);
- chunk->addInteger(1);
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- chunk->addByte(LSCRIPTOpCodes[LOPC_ADD]);
- chunk->addByte(LSCRIPTTypeByte[LST_INTEGER] | LSCRIPTTypeHi4Bits[LST_INTEGER]);
- }
- else if (mReturnType == LST_FLOATINGPOINT)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHARGF]);
- chunk->addFloat(1.f);
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- chunk->addByte(LSCRIPTOpCodes[LOPC_ADD]);
- chunk->addByte(LSCRIPTTypeByte[LST_FLOATINGPOINT] | LSCRIPTTypeHi4Bits[LST_FLOATINGPOINT]);
- }
- store2stack(this, mExpression, chunk, mReturnType);
- switch(mReturnType)
- {
- case LST_INTEGER:
- case LST_FLOATINGPOINT:
- chunk->addByte(LSCRIPTOpCodes[LOPC_POP]);
- break;
- case LST_KEY:
- case LST_STRING:
- chunk->addByte(LSCRIPTOpCodes[LOPC_POPS]);
- break;
- case LST_LIST:
- chunk->addByte(LSCRIPTOpCodes[LOPC_POPL]);
- break;
- case LST_VECTOR:
- chunk->addByte(LSCRIPTOpCodes[LOPC_POPV]);
- break;
- case LST_QUATERNION:
- chunk->addByte(LSCRIPTOpCodes[LOPC_POPQ]);
- break;
- default:
- chunk->addByte(LSCRIPTOpCodes[LOPC_POP]);
- break;
- }
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- {
- // Push original value on to stack.
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
-
- // Load address if needed for store.
- print_cil_load_address(fp, mExpression, entry);
-
- // Load value again.
- // TODO: Work out if sideeffects can result in 2 evaluations of expression giving different values.
- // Original LSL2 uses this method, so any bugs due to side effects will probably be identical ;-)
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mReturnType == LST_INTEGER)
- {
- fprintf(fp, "ldc.i4.1\n");
- }
- else if (mReturnType == LST_FLOATINGPOINT)
- {
- fprintf(fp, "ldc.r8 1\n");
- }
- else
- {
- fprintf(fp, "Unexpected Type\n");
- }
- fprintf(fp, "add\n");
- print_cil_assignment(fp, mExpression, entry);
-
- // Pop assignment result to leave original expression result on stack.
- // TODO: Optimise away redundant pop/dup pairs.
- fprintf(fp, "pop\n");
- }
- break;
- default:
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
-}
-
-S32 LLScriptPostIncrement::getSize()
-{
- return 0;
-}
-
-void LLScriptPostDecrement::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "--");
- break;
- case LSCP_EMIT_ASSEMBLY:
- {
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mReturnType == LST_INTEGER)
- {
- fprintf(fp, "PUSHARGI 1\n");
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "SUB integer, integer\n");
- }
- else if (mReturnType == LST_FLOATINGPOINT)
- {
- fprintf(fp, "PUSHARGF 1\n");
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "SUB float, float\n");
- }
- else
- {
- fprintf(fp, "Unexpected Type\n");
- }
- print_assignment(fp, mExpression);
- fprintf(fp, "%s\n", LSCRIPTTypePop[mReturnType]);
- }
- break;
- case LSCP_TYPE:
- if (mExpression->mType != LET_LVALUE)
- {
- gErrorToText.writeError(fp, this, LSERROR_EXPRESSION_ON_LVALUE);
- }
- else
- {
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (!legal_unary_expression(type, type, mType))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- else
- {
- mReturnType = mLeftType = type;
- }
- }
- break;
- case LSCP_TO_STACK:
- {
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mReturnType == LST_INTEGER)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHARGI]);
- chunk->addInteger(1);
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- chunk->addByte(LSCRIPTOpCodes[LOPC_SUB]);
- chunk->addByte(LSCRIPTTypeByte[LST_INTEGER] | LSCRIPTTypeHi4Bits[LST_INTEGER]);
- }
- else if (mReturnType == LST_FLOATINGPOINT)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHARGF]);
- chunk->addFloat(1.f);
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- chunk->addByte(LSCRIPTOpCodes[LOPC_SUB]);
- chunk->addByte(LSCRIPTTypeByte[LST_FLOATINGPOINT] | LSCRIPTTypeHi4Bits[LST_FLOATINGPOINT]);
- }
- store2stack(this, mExpression, chunk, mReturnType);
- switch(mReturnType)
- {
- case LST_INTEGER:
- case LST_FLOATINGPOINT:
- chunk->addByte(LSCRIPTOpCodes[LOPC_POP]);
- break;
- case LST_KEY:
- case LST_STRING:
- chunk->addByte(LSCRIPTOpCodes[LOPC_POPS]);
- break;
- case LST_LIST:
- chunk->addByte(LSCRIPTOpCodes[LOPC_POPL]);
- break;
- case LST_VECTOR:
- chunk->addByte(LSCRIPTOpCodes[LOPC_POPV]);
- break;
- case LST_QUATERNION:
- chunk->addByte(LSCRIPTOpCodes[LOPC_POPQ]);
- break;
- default:
- chunk->addByte(LSCRIPTOpCodes[LOPC_POP]);
- break;
- }
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- {
- // Push original value on to stack.
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
-
- // Load address if needed for store.
- print_cil_load_address(fp, mExpression, entry);
-
- // Load value again.
- // TODO: Work out if sideeffects can result in 2 evaluations of expression giving different values.
- // Original LSL2 uses this method, so any bugs due to side effects will probably be identical ;-)
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mReturnType == LST_INTEGER)
- {
- fprintf(fp, "ldc.i4.1\n");
- }
- else if (mReturnType == LST_FLOATINGPOINT)
- {
- fprintf(fp, "ldc.r8 1\n");
- }
- else
- {
- fprintf(fp, "Unexpected Type\n");
- }
- fprintf(fp, "sub\n");
- print_cil_assignment(fp, mExpression, entry);
-
- // Pop assignment result to leave original expression result on stack.
- // TODO: Optimise away redundant pop/dup pairs.
- fprintf(fp, "pop\n");
- }
- break;
- default:
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
-}
-
-S32 LLScriptPostDecrement::getSize()
-{
- return 0;
-}
-
-// Generate arg list.
-static void print_cil_arg_list(LLFILE *fp, LLScriptArgString& args)
-{
- int i = 0;
- bool finished = (i >= args.getNumber());
- while(! finished)
- {
- print_cil_type(fp, args.getType(i));
- ++i;
- finished = (i >= args.getNumber());
- if(! finished)
- {
- fprintf(fp, ", ");
- }
- }
-}
-
-void LLScriptFunctionCall::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "( ");
- if (mExpressionList)
- mExpressionList->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )");
- break;
- case LSCP_EMIT_ASSEMBLY:
- if (mIdentifier->mScopeEntry->mType)
- fprintf(fp, "%s\n", LSCRIPTTypePush[mIdentifier->mScopeEntry->mType]);
- fprintf(fp,"PUSHE\n");
- fprintf(fp, "PUSHBP\n");
- if (mExpressionList)
- mExpressionList->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, mIdentifier->mScopeEntry, 0, NULL);
- fprintf(fp, "PUSHARGE %d\n", mIdentifier->mScopeEntry->mSize - mIdentifier->mScopeEntry->mOffset);
- fprintf(fp, "PUSHSP\n");
- fprintf(fp, "PUSHARGI %d\n", mIdentifier->mScopeEntry->mSize);
- fprintf(fp, "ADD integer, integer\n");
- fprintf(fp, "POPBP\n");
- if (mIdentifier->mScopeEntry->mIDType != LIT_LIBRARY_FUNCTION)
- {
- fprintf(fp, "CALL ");
- mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- else
- {
- fprintf(fp, "CALLLID ");
- mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", %d", (U32)mIdentifier->mScopeEntry->mLibraryNumber);
- }
- fprintf(fp, "\n");
- fprintf(fp, "POPBP\n");
- break;
- case LSCP_SCOPE_PASS1:
- if (mExpressionList)
- mExpressionList->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_SCOPE_PASS2:
- {
- LLScriptScopeEntry *entry = scope->findEntryTyped(mIdentifier->mName, LIT_FUNCTION);
- if (!entry)
- {
- gErrorToText.writeError(fp, this, LSERROR_UNDEFINED_NAME);
- }
- else
- {
- // if we did find it, make sure this identifier is associated with the correct scope entry
- mIdentifier->mScopeEntry = entry;
- }
- if (mExpressionList)
- mExpressionList->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- case LSCP_TYPE:
- if (mIdentifier->mScopeEntry)
- {
- U64 argcount = 0;
- if (mExpressionList)
- mExpressionList->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, argcount, chunk, heap, stacksize, mIdentifier->mScopeEntry, 0, NULL);
-
- if (!mIdentifier->mScopeEntry->mFunctionArgs.mString)
- {
- if (argcount)
- {
- gErrorToText.writeError(fp, this, LSERROR_FUNCTION_TYPE_ERROR);
- }
- }
- else if (argcount != strlen(mIdentifier->mScopeEntry->mFunctionArgs.mString))
- {
- gErrorToText.writeError(fp, this, LSERROR_FUNCTION_TYPE_ERROR);
- }
- }
-
- if (mIdentifier->mScopeEntry)
- type = mIdentifier->mScopeEntry->mType;
- else
- type = LST_NULL;
- mReturnType = type;
- break;
- case LSCP_TO_STACK:
- switch(mIdentifier->mScopeEntry->mType)
- {
- case LST_INTEGER:
- case LST_FLOATINGPOINT:
- case LST_STRING:
- case LST_KEY:
- case LST_LIST:
- chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHE]);
- break;
- case LST_VECTOR:
- chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHEV]);
- break;
- case LST_QUATERNION:
- chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHEQ]);
- break;
- default:
- break;
- }
- chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHE]);
- chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHBP]);
- if (mExpressionList)
- {
- // Don't let this change the count.
- U64 dummy_count = 0;
- mExpressionList->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, dummy_count, chunk, heap, stacksize, mIdentifier->mScopeEntry, 0, NULL);
- //mExpressionList->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, mIdentifier->mScopeEntry, 0, NULL);
- }
- chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHARGE]);
- chunk->addInteger(mIdentifier->mScopeEntry->mSize - mIdentifier->mScopeEntry->mOffset);
- chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHSP]);
- chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHARGI]);
- chunk->addInteger(mIdentifier->mScopeEntry->mSize);
- chunk->addByte(LSCRIPTOpCodes[LOPC_ADD]);
- chunk->addByte(LSCRIPTTypeByte[LST_INTEGER] | LSCRIPTTypeHi4Bits[LST_INTEGER]);
- chunk->addByte(LSCRIPTOpCodes[LOPC_POPBP]);
- if (mIdentifier->mScopeEntry->mIDType != LIT_LIBRARY_FUNCTION)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_CALL]);
- chunk->addInteger(mIdentifier->mScopeEntry->mCount);
- }
- else
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_CALLLIB_TWO_BYTE]);
- chunk->addU16(mIdentifier->mScopeEntry->mLibraryNumber);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- {
- bool library_call = (mIdentifier->mScopeEntry->mIDType == LIT_LIBRARY_FUNCTION);
- if(! library_call)
- {
- // Load this pointer.
- fprintf(fp, "ldarg.0\n");
- }
-
- // Load args on to stack.
- if (mExpressionList)
- {
- //mExpressionList->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry /* Needed for is_parameter calls */, 0, NULL);
- llassert(LET_FUNC_EXPRESSION_LIST == mExpressionList->mType);
- print_cil_func_expression_list((LLScriptFuncExpressionList*) mExpressionList, fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry /* Caller entry needed for is_parameter calls */, 0, NULL, mIdentifier->mScopeEntry /* Callee entry needed for argument casting */);
- }
-
- // Make call.
- if (! library_call)
- {
- fprintf(fp, "call instance ");
- }
- else
- {
- fprintf(fp, "call ");
- }
- print_cil_type(fp, mIdentifier->mScopeEntry->mType);
- fprintf(fp, " class ");
- if (library_call)
- {
- fprintf(fp, "[LslLibrary]LindenLab.SecondLife.Library::'");
- }
- else
- {
- // Prefix function name with g to distinguish from
- // event handlers.
- fprintf(fp, "%s", gScriptp->getClassName());
- fprintf(fp, "::'g");
- }
- fprintf(fp, "%s", mIdentifier->mName);
- fprintf(fp, "'(");
- print_cil_arg_list(fp, mIdentifier->mScopeEntry->mFunctionArgs);
- fprintf(fp, ")\n");
- }
- break;
- default:
- mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mExpressionList)
- mExpressionList->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
-}
-
-S32 LLScriptFunctionCall::getSize()
-{
- return 0;
-}
-
-void LLScriptPrint::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- fprintf(fp, " PRINT ( ");
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )");
- break;
- case LSCP_EMIT_ASSEMBLY:
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "PRINT %s\n", LSCRIPTTypeNames[mLeftType]);
- break;
- case LSCP_TYPE:
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftType = type;
- mReturnType = LST_NULL;
- break;
- case LSCP_TO_STACK:
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- chunk->addByte(LSCRIPTOpCodes[LOPC_PRINT]);
- chunk->addByte(LSCRIPTTypeByte[mLeftType]);
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_cast(fp, mLeftType, LST_STRING);
- fprintf(fp, "call void class [LslLibrary]LindenLab.SecondLife.Library::Print(string)");
- break;
- default:
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
-}
-
-S32 LLScriptPrint::getSize()
-{
- return 0;
-}
-
-void LLScriptConstantExpression::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- mConstant->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_TYPE:
- mConstant->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mReturnType = type;
- break;
- case LSCP_TO_STACK:
- mConstant->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- default:
- mConstant->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
-}
-
-S32 LLScriptConstantExpression::getSize()
-{
- return 0;
-}
-
-void LLScriptStatement::addStatement(LLScriptStatement *event)
-{
- if (mNextp)
- {
- event->mNextp = mNextp;
- }
- mNextp = event;
-}
-
-void LLScriptStatement::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- fprintf(fp, "Statement Base Class -- should never get here!\n");
-}
-
-S32 LLScriptStatement::getSize()
-{
- printf("Statement Base Class -- should never get here!\n");
- return 0;
-}
-
-void LLScriptStatement::gonext(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- if (mNextp)
- {
- fprintf(fp, ", ");
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- case LSCP_EMIT_ASSEMBLY:
- if (mNextp)
- {
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- default:
- if (mNextp)
- {
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- }
-}
-
-S32 LLScriptStatementSequence::getSize()
-{
- return 0;
-}
-
-void LLScriptStatementSequence::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- mFirstp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mSecondp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_EMIT_ASSEMBLY:
- mFirstp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mSecondp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_PRUNE:
- mFirstp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (prunearg)
- {
- // babbage: only warn on first dead code block found.
- if(ptype != LSPRUNE_DEAD_CODE)
- {
- gErrorToText.writeWarning(fp, this, LSWARN_DEAD_CODE);
- }
-
- // babbage: set prune type to LSPRUNE_DEAD_CODE to mask other
- // prune errors.
- ptype = LSPRUNE_DEAD_CODE;
-
- // babbage: reset prunearg, to track whether return needed at
- // end of dead code path as CIL always needs a return/throw.
- prunearg = FALSE;
- }
- mSecondp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_TYPE:
- // pass the return type into all statements so we can check returns
- {
- LSCRIPTType return_type = type;
- mFirstp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, return_type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- return_type = type;
- mSecondp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, return_type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- default:
- mFirstp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mSecondp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
-}
-
-S32 LLScriptNOOP::getSize()
-{
- return 0;
-}
-
-void LLScriptNOOP::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, ";\n");
- break;
- case LSCP_PRUNE:
- prunearg = FALSE;
- break;
- default:
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
-}
-
-void add_exit_pops(LLScriptByteCodeChunk *chunk, LLScriptScopeEntry *entry)
-{
- // remember that we need to pop in reverse order
- S32 number, i;
-
- if (entry->mLocals.mString)
- {
- number = (S32)strlen(entry->mLocals.mString);
- for (i = number - 1; i >= 0; i--)
- {
- switch(entry->mLocals.getType(i))
- {
- case LST_INTEGER:
- chunk->addByte(LSCRIPTOpCodes[LOPC_POP]);
- break;
- case LST_FLOATINGPOINT:
- chunk->addByte(LSCRIPTOpCodes[LOPC_POP]);
- break;
- case LST_STRING:
- case LST_KEY:
- chunk->addByte(LSCRIPTOpCodes[LOPC_POPS]);
- break;
- case LST_VECTOR:
- chunk->addByte(LSCRIPTOpCodes[LOPC_POPV]);
- break;
- case LST_QUATERNION:
- chunk->addByte(LSCRIPTOpCodes[LOPC_POPQ]);
- break;
- case LST_LIST:
- chunk->addByte(LSCRIPTOpCodes[LOPC_POPL]);
- break;
-
- default:
- break;
- }
- }
- }
-
- if (entry->mFunctionArgs.mString)
- {
- number = (S32)strlen(entry->mFunctionArgs.mString);
- for (i = number - 1; i >= 0; i--)
- {
- switch(entry->mFunctionArgs.getType(i))
- {
- case LST_INTEGER:
- chunk->addByte(LSCRIPTOpCodes[LOPC_POP]);
- break;
- case LST_FLOATINGPOINT:
- chunk->addByte(LSCRIPTOpCodes[LOPC_POP]);
- break;
- case LST_STRING:
- case LST_KEY:
- chunk->addByte(LSCRIPTOpCodes[LOPC_POPS]);
- break;
- case LST_VECTOR:
- chunk->addByte(LSCRIPTOpCodes[LOPC_POPV]);
- break;
- case LST_QUATERNION:
- chunk->addByte(LSCRIPTOpCodes[LOPC_POPQ]);
- break;
- case LST_LIST:
- chunk->addByte(LSCRIPTOpCodes[LOPC_POPL]);
- break;
-
- default:
- break;
- }
- }
- }
-}
-
-void print_exit_pops(LLFILE *fp, LLScriptScopeEntry *entry)
-{
- // remember that we need to pop in reverse order
- S32 number, i;
-
- if (entry->mLocals.mString)
- {
- number = (S32)strlen(entry->mLocals.mString);
- for (i = number - 1; i >= 0; i--)
- {
- fprintf(fp, "%s", LSCRIPTTypePop[entry->mLocals.getType(i)]);
- }
- }
-
- if (entry->mFunctionArgs.mString)
- {
- number = (S32)strlen(entry->mFunctionArgs.mString);
- for (i = number - 1; i >= 0; i--)
- {
- fprintf(fp, "%s", LSCRIPTTypePop[entry->mFunctionArgs.getType(i)]);
- }
- }
-}
-
-
-S32 LLScriptStateChange::getSize()
-{
- return 0;
-}
-
-void LLScriptStateChange::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "state ");
- mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ";\n");
- break;
- case LSCP_EMIT_ASSEMBLY:
- print_exit_pops(fp, entry);
- fprintf(fp, "STATE ");
- mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "\n");
- break;
- case LSCP_PRUNE:
- if ( (ptype == LSPRUNE_GLOBAL_VOIDS)
- ||(ptype == LSPRUNE_GLOBAL_NON_VOIDS))
- {
- gErrorToText.writeError(fp, this, LSERROR_STATE_CHANGE_IN_GLOBAL);
- }
- prunearg = FALSE;
- break;
- case LSCP_SCOPE_PASS2:
- {
- LLScriptScopeEntry *entry = scope->findEntryTyped(mIdentifier->mName, LIT_STATE);
- if (!entry)
- {
- gErrorToText.writeError(fp, this, LSERROR_UNDEFINED_NAME);
- }
- else
- {
- // if we did find it, make sure this identifier is associated with the correct scope entry
- mIdentifier->mScopeEntry = entry;
- }
- }
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
- add_exit_pops(chunk, entry);
- chunk->addByte(LSCRIPTOpCodes[LOPC_STATE]);
- chunk->addInteger(mIdentifier->mScopeEntry->mCount);
- }
- break;
- case LSCP_TYPE:
- mReturnType = basetype;
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- fprintf(fp, "ldarg.0\n");
- fprintf(fp, "ldstr \"%s\"\n", mIdentifier->mName);
- fprintf(fp, "call instance void class [LslUserScript]LindenLab.SecondLife.LslUserScript::ChangeState(string)\n");
- // We are doing a state change. In the LSL interpreter, this is basically a longjmp. We emulate it
- // here using a call to the ChangeState followed by a short cut return of the current method. To
- // maintain type safety we need to push an arbitrary variable of the current method's return type
- // onto the stack before returning. This will be ignored and discarded.
- print_cil_init_variable(fp, mReturnType);
- fprintf(fp, "ret\n");
- break;
- default:
- mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
-}
-
-S32 LLScriptJump::getSize()
-{
- return 0;
-}
-
-void LLScriptJump::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "jump ");
- mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ";\n");
- break;
- case LSCP_EMIT_ASSEMBLY:
- fprintf(fp, "JUMP ");
- mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "\n");
- break;
- case LSCP_PRUNE:
- prunearg = FALSE;
- break;
- case LSCP_SCOPE_PASS2:
- {
- LLScriptScopeEntry *entry = scope->findEntryTyped(mIdentifier->mName, LIT_LABEL);
- if (!entry)
- {
- gErrorToText.writeError(fp, this, LSERROR_UNDEFINED_NAME);
- }
- else
- {
- // if we did find it, make sure this identifier is associated with the correct scope entry
- mIdentifier->mScopeEntry = entry;
- }
- }
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_JUMP]);
- chunk->addBytes(LSCRIPTDataSize[LST_INTEGER]);
- chunk->addJump(mIdentifier->mName);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- fprintf(fp, "br ");
- mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "\n");
- break;
- default:
- mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
-}
-
-S32 LLScriptLabel::getSize()
-{
- return 0;
-}
-
-void LLScriptLabel::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "@");
- mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ";\n");
- break;
- case LSCP_EMIT_ASSEMBLY:
- fprintf(fp, "LABEL ");
- mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "\n");
- break;
- case LSCP_PRUNE:
- // Always clear this flag, to stop pruning after return statements. A jump
- // might start up code at this label, so we need to stop pruning.
- prunearg = FALSE;
- break;
- case LSCP_SCOPE_PASS1:
- // add labels to scope
- if (scope->checkEntry(mIdentifier->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mIdentifier->mScopeEntry = scope->addEntry(mIdentifier->mName, LIT_LABEL, LST_NULL);
- }
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
- chunk->addLabel(mIdentifier->mName);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ":\n");
- break;
- default:
- mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
-}
-
-void add_return(LLScriptByteCodeChunk *chunk, LLScriptScopeEntry *entry)
-{
- add_exit_pops(chunk, entry);
- chunk->addByte(LSCRIPTOpCodes[LOPC_RETURN]);
-}
-
-void print_return(LLFILE *fp, LLScriptScopeEntry *entry)
-{
- print_exit_pops(fp, entry);
- fprintf(fp, "RETURN\n");
-}
-
-
-S32 LLScriptReturn::getSize()
-{
- return 0;
-}
-
-void LLScriptReturn::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- if (mExpression)
- {
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "return ");
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ";\n");
- }
- else
- {
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "return;\n");
- }
- break;
- case LSCP_EMIT_ASSEMBLY:
- if (mExpression)
- {
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "%s\n", LSCRIPTTypeReturn[mType]);
- }
- print_return(fp, entry);
- break;
- case LSCP_PRUNE:
- if ( (ptype == LSPRUNE_GLOBAL_VOIDS)
- ||(ptype == LSPRUNE_EVENTS))
- {
- if (mExpression)
- {
- gErrorToText.writeError(fp, this, LSERROR_INVALID_RETURN);
- }
- }
- else if (ptype == LSPRUNE_GLOBAL_NON_VOIDS)
- {
- if (!mExpression)
- {
- gErrorToText.writeError(fp, this, LSERROR_INVALID_VOID_RETURN);
- }
- }
- prunearg = TRUE;
- case LSCP_TYPE:
- // if there is a return expression, it must be promotable to the return type of the function
- if (mExpression)
- {
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (!legal_assignment(basetype, type))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- else
- {
- mType = basetype;
- }
- }
- else if (basetype != LST_NULL)
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- break;
- case LSCP_EMIT_BYTE_CODE:
- if (mExpression)
- {
- mExpression->recurse(fp, tabs, tabsize, LSCP_TO_STACK, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- switch(mType)
- {
- case LST_INTEGER:
- case LST_FLOATINGPOINT:
- chunk->addByte(LSCRIPTOpCodes[LOPC_LOADP]);
- chunk->addInteger(-12);
- break;
- case LST_STRING:
- case LST_KEY:
- // use normal store for reference counted types
- chunk->addByte(LSCRIPTOpCodes[LOPC_LOADSP]);
- chunk->addInteger(-12);
- break;
- case LST_LIST:
- // use normal store for reference counted types
- chunk->addByte(LSCRIPTOpCodes[LOPC_LOADLP]);
- chunk->addInteger(-12);
- break;
- case LST_VECTOR:
- chunk->addByte(LSCRIPTOpCodes[LOPC_LOADVP]);
- chunk->addInteger(-20);
- break;
- case LST_QUATERNION:
- chunk->addByte(LSCRIPTOpCodes[LOPC_LOADQP]);
- chunk->addInteger(-24);
- break;
- default:
- chunk->addByte(LSCRIPTOpCodes[LOPC_LOADP]);
- chunk->addInteger(-12);
- break;
- }
- }
- add_return(chunk, entry);
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- if (mExpression)
- {
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_cast(fp, mExpression->mReturnType, mType);
- }
- fprintf(fp, "ret\n");
- break;
- default:
- if (mExpression)
- {
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
-}
-
-S32 LLScriptExpressionStatement::getSize()
-{
- return 0;
-}
-
-void LLScriptExpressionStatement::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- fdotabs(fp, tabs, tabsize);
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ";\n");
- break;
- case LSCP_EMIT_ASSEMBLY:
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mExpression->mReturnType)
- {
- fprintf(fp, "%s\n", LSCRIPTTypePop[mExpression->mReturnType]);
- }
- break;
- case LSCP_PRUNE:
- prunearg = FALSE;
- break;
- case LSCP_EMIT_BYTE_CODE:
- mExpression->recurse(fp, tabs, tabsize, LSCP_TO_STACK, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- switch(mExpression->mReturnType)
- {
- case LST_INTEGER:
- case LST_FLOATINGPOINT:
- chunk->addByte(LSCRIPTOpCodes[LOPC_POP]);
- break;
- case LST_STRING:
- case LST_KEY:
- chunk->addByte(LSCRIPTOpCodes[LOPC_POPS]);
- break;
- case LST_LIST:
- chunk->addByte(LSCRIPTOpCodes[LOPC_POPL]);
- break;
- case LST_VECTOR:
- chunk->addByte(LSCRIPTOpCodes[LOPC_POPV]);
- break;
- case LST_QUATERNION:
- chunk->addByte(LSCRIPTOpCodes[LOPC_POPQ]);
- break;
- default:
- break;
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if(mExpression->mReturnType)
- {
- fprintf(fp, "pop\n");
- }
- break;
- default:
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
-}
-
-S32 LLScriptIf::getSize()
-{
- return 0;
-}
-
-static void print_cil_if_test(LLFILE* fp, LSCRIPTType type)
-{
- switch(type)
- {
- case LST_INTEGER:
- break;
- case LST_FLOATINGPOINT:
- fprintf(fp, "ldc.r8 0\n");
- fprintf(fp, "ceq\n");
- fprintf(fp, "ldc.i4.0\n");
- fprintf(fp, "ceq\n");
- break;
- case LST_VECTOR:
- fprintf(fp, "ldc.r8 0\n");
- fprintf(fp, "ldc.r8 0\n");
- fprintf(fp, "ldc.r8 0\n");
- fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Vector class [LslUserScript]LindenLab.SecondLife.LslUserScript::'CreateVector'(float32, float32, float32)\n");
- fprintf(fp, "call bool [LslUserScript]LindenLab.SecondLife.LslUserScript::'Equals'(class [ScriptTypes]LindenLab.SecondLife.Vector, class [ScriptTypes]LindenLab.SecondLife.Vector)\n");
- fprintf(fp, "ldc.i4.0\n");
- fprintf(fp, "ceq\n");
- break;
- case LST_QUATERNION:
- fprintf(fp, "ldc.r8 0\n");
- fprintf(fp, "ldc.r8 0\n");
- fprintf(fp, "ldc.r8 0\n");
- fprintf(fp, "ldc.r8 1\n");
- fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Quaternion class [LslUserScript]LindenLab.SecondLife.LslUserScript::'CreateQuaternion'(float32, float32, float32, float32)\n");
- fprintf(fp, "call bool [LslUserScript]LindenLab.SecondLife.LslUserScript::'Equals'(class [ScriptTypes]LindenLab.SecondLife.Quaternion, class [ScriptTypes]LindenLab.SecondLife.Quaternion)\n");
- fprintf(fp, "ldc.i4.0\n");
- fprintf(fp, "ceq\n");
- break;
- case LST_KEY:
- fprintf(fp, "call bool [LslUserScript]LindenLab.SecondLife.LslUserScript::'IsNonNullUuid'(valuetype [ScriptTypes]LindenLab.SecondLife.Key)\n");
- break;
- case LST_STRING:
- fprintf(fp, "ldstr \"\"\n");
- fprintf(fp, "call bool string::op_Equality(string, string)\n");
- fprintf(fp, "ldc.i4.0\n");
- fprintf(fp, "ceq\n");
- break;
- case LST_LIST:
- fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::CreateList()\n");
- fprintf(fp, "call bool [LslUserScript]LindenLab.SecondLife.LslUserScript::Equals(class [mscorlib]System.Collections.ArrayList, class [mscorlib]System.Collections.ArrayList)\n");
- fprintf(fp, "ldc.i4.0\n");
- fprintf(fp, "ceq\n");
- break;
- default:
- break;
- }
-
-}
-
-void LLScriptIf::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "if ( ");
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )\n");
- mStatement->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_EMIT_ASSEMBLY:
- {
- S32 tjump = gTempJumpCount++;
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "JUMPNIF ##Temp Jump %d##\n", tjump);
- mStatement->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "LABEL ##Temp Jump %d##\n", tjump);
- }
- break;
- case LSCP_PRUNE:
- prunearg = FALSE;
- break;
- case LSCP_TYPE:
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (type == LST_NULL)
- {
- gErrorToText.writeError(fp, mExpression, LSERROR_TYPE_MISMATCH);
- }
- mType = type;
- mStatement->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
- char jumpname[32]; /*Flawfinder: ignore*/
- snprintf(jumpname, sizeof(jumpname),"##Temp Jump %d##", gTempJumpCount++); /* Flawfinder: ignore */
-
- mExpression->recurse(fp, tabs, tabsize, LSCP_TO_STACK, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- chunk->addByte(LSCRIPTOpCodes[LOPC_JUMPNIF]);
- chunk->addByte(LSCRIPTTypeByte[mType]);
- chunk->addBytes(LSCRIPTDataSize[LST_INTEGER]);
- chunk->addJump(jumpname);
- mStatement->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- chunk->addLabel(jumpname);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- {
- S32 tjump = gTempJumpCount++;
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_if_test(fp, mExpression->mReturnType);
- fprintf(fp, "brfalse LabelTempJump%d\n", tjump);
- mStatement->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "LabelTempJump%d:\n", tjump);
- }
- break;
- default:
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mStatement->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
-}
-
-S32 LLScriptIfElse::getSize()
-{
- return 0;
-}
-
-void LLScriptIfElse::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "if ( ");
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )\n");
- mStatement1->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "else\n");
- mStatement2->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_EMIT_ASSEMBLY:
- {
- S32 tjump1 = gTempJumpCount++;
- S32 tjump2 = gTempJumpCount++;
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "JUMPNIF ##Temp Jump %d##\n", tjump1);
- mStatement1->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "JUMP ##Temp Jump %d##\n", tjump2);
- fprintf(fp, "LABEL ##Temp Jump %d##\n", tjump1);
- mStatement2->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "LABEL ##Temp Jump %d##\n", tjump2);
- }
- break;
- case LSCP_PRUNE:
- {
- BOOL arg1 = TRUE, arg2 = TRUE;
- mStatement1->recurse(fp, tabs, tabsize, pass, ptype, arg1, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mStatement2->recurse(fp, tabs, tabsize, pass, ptype, arg2, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- prunearg = arg1 && arg2;
- }
- break;
- case LSCP_TYPE:
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (type == LST_NULL)
- {
- gErrorToText.writeError(fp, mExpression, LSERROR_TYPE_MISMATCH);
- }
- mType = type;
- mStatement1->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mStatement2->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
- char jumpname1[32]; /*Flawfinder: ignore*/
- snprintf(jumpname1, sizeof(jumpname1), "##Temp Jump %d##", gTempJumpCount++); /* Flawfinder: ignore */
- char jumpname2[32]; /*Flawfinder: ignore*/
- snprintf(jumpname2, sizeof(jumpname2), "##Temp Jump %d##", gTempJumpCount++); /* Flawfinder: ignore */
-
- mExpression->recurse(fp, tabs, tabsize, LSCP_TO_STACK, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- chunk->addByte(LSCRIPTOpCodes[LOPC_JUMPNIF]);
- chunk->addByte(LSCRIPTTypeByte[mType]);
- chunk->addBytes(LSCRIPTDataSize[LST_INTEGER]);
- chunk->addJump(jumpname1);
- mStatement1->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- chunk->addByte(LSCRIPTOpCodes[LOPC_JUMP]);
- chunk->addBytes(LSCRIPTDataSize[LST_INTEGER]);
- chunk->addJump(jumpname2);
- chunk->addLabel(jumpname1);
- mStatement2->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- chunk->addLabel(jumpname2);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- {
- S32 tjump1 = gTempJumpCount++;
- S32 tjump2 = gTempJumpCount++;
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_if_test(fp, mExpression->mReturnType);
- fprintf(fp, "brfalse LabelTempJump%d\n", tjump1);
- mStatement1->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "br LabelTempJump%d\n", tjump2);
- fprintf(fp, "LabelTempJump%d:\n", tjump1);
- mStatement2->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "LabelTempJump%d:\n", tjump2);
- }
- break;
- default:
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mStatement1->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mStatement2->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- };
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
-}
-
-S32 LLScriptFor::getSize()
-{
- return 0;
-}
-
-void LLScriptFor::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "for ( ");
- if(mSequence)
- mSequence->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " ; ");
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " ; ");
- if(mExpressionList)
- mExpressionList->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )\n");
- if(mStatement)
- mStatement->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_EMIT_ASSEMBLY:
- {
- S32 tjump1 = gTempJumpCount++;
- S32 tjump2 = gTempJumpCount++;
- if(mSequence)
- mSequence->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "LABEL ##Temp Jump %d##\n", tjump1);
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "JUMPNIF ##Temp Jump %d##\n", tjump2);
- if(mStatement)
- mStatement->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if(mExpressionList)
- mExpressionList->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "JUMP ##Temp Jump %d##\n", tjump1);
- fprintf(fp, "LABEL ##Temp Jump %d##\n", tjump2);
- }
- break;
- case LSCP_PRUNE:
- prunearg = FALSE;
- break;
- case LSCP_TYPE:
- if(mSequence)
- mSequence->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (type == LST_NULL)
- {
- gErrorToText.writeError(fp, mExpression, LSERROR_TYPE_MISMATCH);
- }
- mType = type;
- if(mExpressionList)
- mExpressionList->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if(mStatement)
- mStatement->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
- char jumpname1[32]; /*Flawfinder: ignore*/
- snprintf(jumpname1, sizeof(jumpname1), "##Temp Jump %d##", gTempJumpCount++); /* Flawfinder: ignore */
- char jumpname2[32]; /*Flawfinder: ignore*/
- snprintf(jumpname2, sizeof(jumpname2), "##Temp Jump %d##", gTempJumpCount++); /* Flawfinder: ignore */
-
- if(mSequence)
- mSequence->recurse(fp, tabs, tabsize, LSCP_TO_STACK, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- chunk->addLabel(jumpname1);
- mExpression->recurse(fp, tabs, tabsize, LSCP_TO_STACK, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- chunk->addByte(LSCRIPTOpCodes[LOPC_JUMPNIF]);
- chunk->addByte(LSCRIPTTypeByte[mType]);
- chunk->addBytes(LSCRIPTDataSize[LST_INTEGER]);
- chunk->addJump(jumpname2);
- if(mStatement)
- mStatement->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if(mExpressionList)
- mExpressionList->recurse(fp, tabs, tabsize, LSCP_TO_STACK, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- chunk->addByte(LSCRIPTOpCodes[LOPC_JUMP]);
- chunk->addBytes(LSCRIPTDataSize[LST_INTEGER]);
- chunk->addJump(jumpname1);
- chunk->addLabel(jumpname2);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- {
- S32 tjump1 = gTempJumpCount++;
- S32 tjump2 = gTempJumpCount++;
- if(mSequence)
- mSequence->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "LabelTempJump%d:\n", tjump1);
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_if_test(fp, mExpression->mReturnType);
- fprintf(fp, "brfalse LabelTempJump%d\n", tjump2);
- if(mStatement)
- mStatement->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if(mExpressionList)
- mExpressionList->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "br LabelTempJump%d\n", tjump1);
- fprintf(fp, "LabelTempJump%d:\n", tjump2);
- }
- break;
- default:
- if(mSequence)
- mSequence->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if(mExpressionList)
- mExpressionList->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if(mStatement)
- mStatement->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
-}
-
-S32 LLScriptDoWhile::getSize()
-{
- return 0;
-}
-
-void LLScriptDoWhile::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "do\n");
- mStatement->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "while( ");
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " );\n");
- break;
- case LSCP_EMIT_ASSEMBLY:
- {
- S32 tjump1 = gTempJumpCount++;
- fprintf(fp, "LABEL ##Temp Jump %d##\n", tjump1);
- mStatement->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "JUMPIF ##Temp Jump %d##\n", tjump1);
- }
- break;
- case LSCP_PRUNE:
- prunearg = FALSE;
- break;
- case LSCP_TYPE:
- mStatement->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (type == LST_NULL)
- {
- gErrorToText.writeError(fp, mExpression, LSERROR_TYPE_MISMATCH);
- }
- mType = type;
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
- char jumpname1[32]; /*Flawfinder: ignore*/
- snprintf(jumpname1, sizeof(jumpname1), "##Temp Jump %d##", gTempJumpCount++); /* Flawfinder: ignore */
-
- chunk->addLabel(jumpname1);
- mStatement->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mExpression->recurse(fp, tabs, tabsize, LSCP_TO_STACK, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- chunk->addByte(LSCRIPTOpCodes[LOPC_JUMPIF]);
- chunk->addByte(LSCRIPTTypeByte[mType]);
- chunk->addBytes(LSCRIPTDataSize[LST_INTEGER]);
- chunk->addJump(jumpname1);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- {
- S32 tjump1 = gTempJumpCount++;
- fprintf(fp, "LabelTempJump%d:\n", tjump1);
- mStatement->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_if_test(fp, mExpression->mReturnType);
- fprintf(fp, "brtrue LabelTempJump%d\n", tjump1);
- }
- break;
- default:
- mStatement->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
-}
-
-S32 LLScriptWhile::getSize()
-{
- return 0;
-}
-
-void LLScriptWhile::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "while( ");
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )\n");
- mStatement->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_EMIT_ASSEMBLY:
- {
- S32 tjump1 = gTempJumpCount++;
- S32 tjump2 = gTempJumpCount++;
- fprintf(fp, "LABEL ##Temp Jump %d##\n", tjump1);
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "JUMPNIF ##Temp Jump %d##\n", tjump2);
- mStatement->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "JUMP ##Temp Jump %d##\n", tjump1);
- fprintf(fp, "LABEL ##Temp Jump %d##\n", tjump2);
- }
- break;
- case LSCP_PRUNE:
- prunearg = FALSE;
- break;
- case LSCP_TYPE:
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (type == LST_NULL)
- {
- gErrorToText.writeError(fp, mExpression, LSERROR_TYPE_MISMATCH);
- }
- mType = type;
- mStatement->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
- char jumpname1[32]; /*Flawfinder: ignore*/
- snprintf(jumpname1, sizeof(jumpname1), "##Temp Jump %d##", gTempJumpCount++); /* Flawfinder: ignore */
- char jumpname2[32]; /*Flawfinder: ignore*/
- snprintf(jumpname2, sizeof(jumpname2), "##Temp Jump %d##", gTempJumpCount++); /* Flawfinder: ignore */
-
- chunk->addLabel(jumpname1);
- mExpression->recurse(fp, tabs, tabsize, LSCP_TO_STACK, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- chunk->addByte(LSCRIPTOpCodes[LOPC_JUMPNIF]);
- chunk->addByte(LSCRIPTTypeByte[mType]);
- chunk->addBytes(LSCRIPTDataSize[LST_INTEGER]);
- chunk->addJump(jumpname2);
- mStatement->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- chunk->addByte(LSCRIPTOpCodes[LOPC_JUMP]);
- chunk->addBytes(LSCRIPTDataSize[LST_INTEGER]);
- chunk->addJump(jumpname1);
- chunk->addLabel(jumpname2);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- {
- S32 tjump1 = gTempJumpCount++;
- S32 tjump2 = gTempJumpCount++;
- fprintf(fp, "LabelTempJump%d:\n", tjump1);
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_if_test(fp, mExpression->mReturnType);
- fprintf(fp, "brfalse LabelTempJump%d\n", tjump2);
- mStatement->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "br LabelTempJump%d\n", tjump1);
- fprintf(fp, "LabelTempJump%d:\n", tjump2);
- }
- break;
- default:
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mStatement->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
-}
-
-S32 LLScriptDeclaration::getSize()
-{
- return mType->getSize();
-}
-
-void LLScriptDeclaration::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- if (mExpression)
- {
- fdotabs(fp, tabs, tabsize);
- mType->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "\t");
- mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " = ");
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ";\n");
- }
- else
- {
- fdotabs(fp, tabs, tabsize);
- mType->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "\t");
- mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ";\n");
- }
- break;
- case LSCP_EMIT_ASSEMBLY:
- if (mExpression)
- {
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mIdentifier->mScopeEntry->mIDType == LIT_VARIABLE)
- {
- fprintf(fp, "%s%d [%s]\n", LSCRIPTTypeLocalDeclaration[mIdentifier->mScopeEntry->mType], mIdentifier->mScopeEntry->mOffset, mIdentifier->mName);
- }
- else if (mIdentifier->mScopeEntry->mIDType == LIT_GLOBAL)
- {
- gErrorToText.writeError(fp, this, LSERROR_UNDEFINED_NAME);
- }
- }
- break;
- case LSCP_PRUNE:
- prunearg = FALSE;
- break;
- case LSCP_SCOPE_PASS1:
- // Check to see if a declaration is valid here.
- if (!mAllowDeclarations)
- {
- gErrorToText.writeError(fp, this, LSERROR_NEED_NEW_SCOPE);
- }
- // add labels to scope
- else if (scope->checkEntry(mIdentifier->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- if (mExpression)
- {
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- // this needs to go after expression decent to make sure that we don't add ourselves or something silly
- // check expression if it exists
- mIdentifier->mScopeEntry = scope->addEntry(mIdentifier->mName, LIT_VARIABLE, mType->mType);
- }
- break;
- case LSCP_TYPE:
- // if there is an expression, it must be promotable to variable type
- if (mExpression && mIdentifier->mScopeEntry)
- {
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (!legal_assignment(mIdentifier->mScopeEntry->mType, type))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- }
- break;
- case LSCP_RESOURCE:
- {
- mIdentifier->mScopeEntry->mOffset = (S32)count;
- mIdentifier->mScopeEntry->mSize = mType->getSize();
- count += mIdentifier->mScopeEntry->mSize;
- // Index into locals is current number of locals. Stored in mCount member of mScopeEntry.
- mIdentifier->mScopeEntry->mCount = entry->mLocals.getNumber();
- entry->mLocals.addType(mType->mType);
- mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- case LSCP_EMIT_BYTE_CODE:
- if (mExpression)
- {
- mExpression->recurse(fp, tabs, tabsize, LSCP_TO_STACK, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mExpression->mReturnType != mIdentifier->mScopeEntry->mType)
- {
- cast2stack(chunk, mExpression->mReturnType, mIdentifier->mScopeEntry->mType);
- }
- switch(mExpression->mReturnType)
- {
- case LST_INTEGER:
- case LST_FLOATINGPOINT:
- if (mIdentifier->mScopeEntry->mIDType == LIT_VARIABLE)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_LOADP]);
- }
- break;
- case LST_STRING:
- case LST_KEY:
- if (mIdentifier->mScopeEntry->mIDType == LIT_VARIABLE)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_LOADSP]);
- }
- break;
- case LST_LIST:
- if (mIdentifier->mScopeEntry->mIDType == LIT_VARIABLE)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_LOADLP]);
- }
- break;
- case LST_VECTOR:
- if (mIdentifier->mScopeEntry->mIDType == LIT_VARIABLE)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_LOADVP]);
- }
- break;
- case LST_QUATERNION:
- if (mIdentifier->mScopeEntry->mIDType == LIT_VARIABLE)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_LOADQP]);
- }
- break;
- default:
- if (mIdentifier->mScopeEntry->mIDType == LIT_VARIABLE)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_LOADP]);
- }
- break;
- }
- if (mIdentifier->mScopeEntry->mIDType == LIT_VARIABLE)
- {
- S32 address = mIdentifier->mScopeEntry->mOffset;
- chunk->addInteger(address);
- }
- }
- else
- {
- switch(mIdentifier->mScopeEntry->mType)
- {
- case LST_INTEGER:
- case LST_FLOATINGPOINT:
- if (mIdentifier->mScopeEntry->mIDType == LIT_VARIABLE)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHARGI]);
- chunk->addInteger(0);
- chunk->addByte(LSCRIPTOpCodes[LOPC_LOADP]);
- }
- break;
- case LST_STRING:
- case LST_KEY:
- if (mIdentifier->mScopeEntry->mIDType == LIT_VARIABLE)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHARGS]);
- chunk->addBytes("", 1);
- chunk->addByte(LSCRIPTOpCodes[LOPC_LOADSP]);
- }
- break;
- case LST_LIST:
- if (mIdentifier->mScopeEntry->mIDType == LIT_VARIABLE)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_STACKTOL]);
- chunk->addInteger(0);
- chunk->addByte(LSCRIPTOpCodes[LOPC_LOADLP]);
- }
- break;
- case LST_VECTOR:
- if (mIdentifier->mScopeEntry->mIDType == LIT_VARIABLE)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHARGV]);
- chunk->addFloat(0);
- chunk->addFloat(0);
- chunk->addFloat(0);
- chunk->addByte(LSCRIPTOpCodes[LOPC_LOADVP]);
- }
- break;
- case LST_QUATERNION:
- if (mIdentifier->mScopeEntry->mIDType == LIT_VARIABLE)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHARGQ]);
- chunk->addFloat(1);
- chunk->addFloat(0);
- chunk->addFloat(0);
- chunk->addFloat(0);
- chunk->addByte(LSCRIPTOpCodes[LOPC_LOADQP]);
- }
- break;
- default:
- if (mIdentifier->mScopeEntry->mIDType == LIT_VARIABLE)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHARGI]);
- chunk->addInteger(0);
- chunk->addByte(LSCRIPTOpCodes[LOPC_LOADP]);
- }
- break;
- }
- if (mIdentifier->mScopeEntry->mIDType == LIT_VARIABLE)
- {
- S32 address = mIdentifier->mScopeEntry->mOffset;
- chunk->addInteger(address);
- }
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- if (mExpression)
- {
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_cast(fp, mExpression->mReturnType, mIdentifier->mScopeEntry->mType);
- }
- else
- {
- print_cil_init_variable(fp, mIdentifier->mScopeEntry->mType);
- }
- fprintf(fp, "stloc.s %d\n", mIdentifier->mScopeEntry->mCount);
- break;
- default:
- if (mExpression)
- {
- mType->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- else
- {
- mType->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
-}
-
-S32 LLScriptCompoundStatement::getSize()
-{
- return 0;
-}
-
-void LLScriptCompoundStatement::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- if (mStatement)
- {
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "{\n");
- mStatement->recurse(fp, tabs + 1, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "}\n");
- }
- else
- {
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "{\n");
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "}\n");
- }
- break;
- case LSCP_EMIT_ASSEMBLY:
- if (mStatement)
- {
- mStatement->recurse(fp, tabs + 1, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- case LSCP_PRUNE:
- if (mStatement)
- {
- mStatement->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- else
- {
- prunearg = FALSE;
- }
- break;
- case LSCP_SCOPE_PASS1:
- // compound statements create a new scope
- if (mStatement)
- {
- mStatementScope = new LLScriptScope(gScopeStringTable);
- mStatementScope->addParentScope(scope);
- mStatement->recurse(fp, tabs, tabsize, pass, ptype, prunearg, mStatementScope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- case LSCP_SCOPE_PASS2:
- // compound statements create a new scope
- if (mStatement)
- {
- mStatement->recurse(fp, tabs, tabsize, pass, ptype, prunearg, mStatementScope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- default:
- if (mStatement)
- {
- mStatement->recurse(fp, tabs + 1, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
-}
-
-void LLScriptEventHandler::addEvent(LLScriptEventHandler *event)
-{
- if (mNextp)
- {
- event->mNextp = mNextp;
- }
- mNextp = event;
-}
-
-void LLScriptEventHandler::gonext(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- if (mNextp)
- {
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- default:
- if (mNextp)
- {
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- }
-}
-
-S32 LLScriptEventHandler::getSize()
-{
- return mStackSpace;
-}
-
-U64 gCurrentHandler = 0;
-
-static void print_cil_local_init(LLFILE* fp, LLScriptScopeEntry* scopeEntry)
-{
- if(scopeEntry->mLocals.getNumber() > 0)
- {
- fprintf(fp, ".locals init (");
- for(int local = 0; local < scopeEntry->mLocals.getNumber(); ++local)
- {
- if(local > 0)
- {
- fprintf(fp, ", ");
- }
- print_cil_type(fp, scopeEntry->mLocals.getType(local));
- }
- fprintf(fp, ")\n");
- }
-}
-
-void LLScriptEventHandler::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- mEventp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mStatement)
- {
- mStatement->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- else
- {
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "{\n");
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "}\n");
- }
- break;
- case LSCP_EMIT_ASSEMBLY:
- mEventp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mStatement)
- {
- mStatement->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, getSize(), mScopeEntry, entrycount, NULL);
- }
- if (mbNeedTrailingReturn)
- {
- print_return(fp, mScopeEntry);
- }
- fprintf(fp, "\n");
- break;
- case LSCP_PRUNE:
- mbNeedTrailingReturn = FALSE;
- prunearg = TRUE;
- mStatement->recurse(fp, tabs, tabsize, pass, LSPRUNE_EVENTS, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (!prunearg)
- {
- // this means that we didn't end with a return statement, need to add one
- mbNeedTrailingReturn = TRUE;
- }
- break;
- case LSCP_SCOPE_PASS1:
- // create event level scope
- mEventScope = new LLScriptScope(gScopeStringTable);
- mEventScope->addParentScope(scope);
-
- // add event parameters
- mEventp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, mEventScope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
-
- mStatement->recurse(fp, tabs, tabsize, pass, ptype, prunearg, mEventScope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_SCOPE_PASS2:
- mStatement->recurse(fp, tabs, tabsize, pass, ptype, prunearg, mEventScope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_TYPE:
- mScopeEntry = new LLScriptScopeEntry("Event", LIT_HANDLER, LST_NULL);
- switch(mEventp->mType)
- {
- case LSTT_STATE_ENTRY:
- break;
- case LSTT_STATE_EXIT:
- break;
- case LSTT_TOUCH_START:
- mScopeEntry->mFunctionArgs.addType(LST_INTEGER);
- break;
- case LSTT_TOUCH:
- mScopeEntry->mFunctionArgs.addType(LST_INTEGER);
- break;
- case LSTT_TOUCH_END:
- mScopeEntry->mFunctionArgs.addType(LST_INTEGER);
- break;
- case LSTT_COLLISION_START:
- mScopeEntry->mFunctionArgs.addType(LST_INTEGER);
- break;
- case LSTT_COLLISION:
- mScopeEntry->mFunctionArgs.addType(LST_INTEGER);
- break;
- case LSTT_COLLISION_END:
- mScopeEntry->mFunctionArgs.addType(LST_INTEGER);
- break;
- case LSTT_LAND_COLLISION_START:
- mScopeEntry->mFunctionArgs.addType(LST_VECTOR);
- break;
- case LSTT_LAND_COLLISION:
- mScopeEntry->mFunctionArgs.addType(LST_VECTOR);
- break;
- case LSTT_LAND_COLLISION_END:
- mScopeEntry->mFunctionArgs.addType(LST_VECTOR);
- break;
- case LSTT_INVENTORY:
- mScopeEntry->mFunctionArgs.addType(LST_INTEGER);
- break;
- case LSTT_ATTACH:
- mScopeEntry->mFunctionArgs.addType(LST_KEY);
- break;
- case LSTT_DATASERVER:
- mScopeEntry->mFunctionArgs.addType(LST_KEY);
- mScopeEntry->mFunctionArgs.addType(LST_STRING);
- break;
- case LSTT_TIMER:
- break;
- case LSTT_MOVING_START:
- break;
- case LSTT_MOVING_END:
- break;
- case LSTT_OBJECT_REZ:
- mScopeEntry->mFunctionArgs.addType(LST_KEY);
- break;
- case LSTT_REMOTE_DATA:
- mScopeEntry->mFunctionArgs.addType(LST_INTEGER);
- mScopeEntry->mFunctionArgs.addType(LST_KEY);
- mScopeEntry->mFunctionArgs.addType(LST_KEY);
- mScopeEntry->mFunctionArgs.addType(LST_STRING);
- mScopeEntry->mFunctionArgs.addType(LST_INTEGER);
- mScopeEntry->mFunctionArgs.addType(LST_STRING);
- break;
- case LSTT_CHAT:
- mScopeEntry->mFunctionArgs.addType(LST_INTEGER);
- mScopeEntry->mFunctionArgs.addType(LST_STRING);
- mScopeEntry->mFunctionArgs.addType(LST_KEY);
- mScopeEntry->mFunctionArgs.addType(LST_STRING);
- break;
- case LSTT_SENSOR:
- mScopeEntry->mFunctionArgs.addType(LST_INTEGER);
- break;
- case LSTT_CONTROL:
- mScopeEntry->mFunctionArgs.addType(LST_KEY);
- mScopeEntry->mFunctionArgs.addType(LST_INTEGER);
- mScopeEntry->mFunctionArgs.addType(LST_INTEGER);
- break;
- case LSTT_LINK_MESSAGE:
- mScopeEntry->mFunctionArgs.addType(LST_INTEGER);
- mScopeEntry->mFunctionArgs.addType(LST_INTEGER);
- mScopeEntry->mFunctionArgs.addType(LST_STRING);
- mScopeEntry->mFunctionArgs.addType(LST_KEY);
- break;
- case LSTT_MONEY:
- mScopeEntry->mFunctionArgs.addType(LST_KEY);
- mScopeEntry->mFunctionArgs.addType(LST_INTEGER);
- break;
- case LSTT_EMAIL:
- mScopeEntry->mFunctionArgs.addType(LST_STRING);
- mScopeEntry->mFunctionArgs.addType(LST_STRING);
- mScopeEntry->mFunctionArgs.addType(LST_STRING);
- mScopeEntry->mFunctionArgs.addType(LST_STRING);
- mScopeEntry->mFunctionArgs.addType(LST_INTEGER);
- break;
- case LSTT_REZ:
- mScopeEntry->mFunctionArgs.addType(LST_INTEGER);
- break;
- case LSTT_NO_SENSOR:
- break;
- case LSTT_AT_TARGET:
- mScopeEntry->mFunctionArgs.addType(LST_INTEGER);
- mScopeEntry->mFunctionArgs.addType(LST_VECTOR);
- mScopeEntry->mFunctionArgs.addType(LST_VECTOR);
- break;
- case LSTT_NOT_AT_TARGET:
- break;
- case LSTT_AT_ROT_TARGET:
- mScopeEntry->mFunctionArgs.addType(LST_INTEGER);
- mScopeEntry->mFunctionArgs.addType(LST_QUATERNION);
- mScopeEntry->mFunctionArgs.addType(LST_QUATERNION);
- break;
- case LSTT_NOT_AT_ROT_TARGET:
- break;
- case LSTT_RTPERMISSIONS:
- mScopeEntry->mFunctionArgs.addType(LST_INTEGER);
- break;
- case LSTT_HTTP_RESPONSE:
- mScopeEntry->mFunctionArgs.addType(LST_KEY);
- mScopeEntry->mFunctionArgs.addType(LST_INTEGER);
- mScopeEntry->mFunctionArgs.addType(LST_LIST);
- mScopeEntry->mFunctionArgs.addType(LST_STRING);
- break;
- case LSTT_HTTP_REQUEST:
- mScopeEntry->mFunctionArgs.addType(LST_KEY);
- mScopeEntry->mFunctionArgs.addType(LST_STRING);
- mScopeEntry->mFunctionArgs.addType(LST_STRING);
- break;
-
- default:
- break;
- }
- mStatement->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_RESOURCE:
- // first determine resource counts for globals
- count = 0;
- mEventp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
-
- // Store offset of first local as with global functions, so locals and arguments can be distinguished with is_parameter when compiling to CIL.
- mScopeEntry->mOffset = (S32) count;
-
- if (mStatement)
- {
- entrycount = 0;
- mStatement->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, mScopeEntry, entrycount, NULL);
-
- const char *function_args = mScopeEntry->mFunctionArgs.mString;
- fprintf(fp, "Function Args: %s\n", function_args?function_args:"");
-
- const char *local_list = mScopeEntry->mLocals.mString;
- fprintf(fp, "Local List: %s\n", local_list?local_list:"");
- }
- mStackSpace = (S32)count;
- break;
- case LSCP_DETERMINE_HANDLERS:
- count |= LSCRIPTStateBitField[mEventp->mType];
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
- llassert(mEventp);
- if (!mEventp) return;
-
- // order for event handler
- // set jump table value
- S32 jumpoffset;
- jumpoffset = LSCRIPTDataSize[LST_INTEGER]*get_event_handler_jump_position(gCurrentHandler, mEventp->mType)*2;
-
- integer2bytestream(chunk->mCodeChunk, jumpoffset, chunk->mCurrentOffset);
-
- // 0 - 3: offset to actual data
- S32 offsetoffset = chunk->mCurrentOffset;
- S32 offsetdelta = 0;
- chunk->addBytes(4);
-
- // null terminated event name and null terminated parameters
- LLScriptByteCodeChunk *event = new LLScriptByteCodeChunk(FALSE);
- mEventp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, event, heap, stacksize, entry, entrycount, NULL);
- chunk->addBytes(event->mCodeChunk, event->mCurrentOffset);
- delete event;
-
- chunk->addBytes(1);
-
- // now we're at the first opcode
- offsetdelta = chunk->mCurrentOffset - offsetoffset;
- integer2bytestream(chunk->mCodeChunk, offsetoffset, offsetdelta);
-
- // get ready to compute the number of bytes of opcode
- offsetdelta = chunk->mCurrentOffset;
-
- if (mStatement)
- {
- LLScriptByteCodeChunk *statements = new LLScriptByteCodeChunk(TRUE);
- mStatement->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, statements, heap, getSize(), mScopeEntry, entrycount, NULL);
- statements->connectJumps();
- chunk->addBytes(statements->mCodeChunk, statements->mCurrentOffset);
- delete statements;
- }
- if (mbNeedTrailingReturn)
- {
- add_return(chunk, mScopeEntry);
- }
- // now stuff in the number of bytes of stack space that this routine needs
- integer2bytestream(chunk->mCodeChunk, jumpoffset, getSize());
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
-
- // Method signature prefix.
- fprintf(fp, ".method public hidebysig instance default void ");
-
- // Mangle event handler name by prefixing it with state name.
- // Allows state changing by finding handlers prefixed with new
- // state name. Prefix disambiguates functions and event handlers.
- fprintf(fp, "e");
- fprintf(fp, "%s", entry->mIdentifier);
-
- // Handler name and arguments.
- mEventp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
-
- // Method signature postfix.
- fprintf(fp, " cil managed\n");
-
- // Function header.
- fprintf(fp,"{\n");
- fprintf(fp, ".maxstack 500\n"); // TODO: Calculated stack size...
-
- // Allocate space for locals.
- print_cil_local_init(fp, mScopeEntry);
-
- if (mStatement)
- {
- // Pass scope so identifiers can determine parameter or local.
- mStatement->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, mScopeEntry, entrycount, NULL);
- }
-
- // Function footer.
- if (mbNeedTrailingReturn)
- {
- // TODO: throw exception?
- fprintf(fp, "ret\n");
- }
- fprintf(fp, "}\n");
-
- break;
- default:
- mEventp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mStatement)
- {
- mStatement->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
-}
-
-void LLScriptFunctionDec::addFunctionParameter(LLScriptFunctionDec *dec)
-{
- if (mNextp)
- {
- dec->mNextp = mNextp;
- }
- mNextp = dec;
-}
-
-void LLScriptFunctionDec::gonext(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- if (mNextp)
- {
- fprintf(fp, ", ");
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- case LSCP_EMIT_ASSEMBLY:
- if (mNextp)
- {
- fprintf(fp, ", ");
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- default:
- if (mNextp)
- {
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- }
-
-}
-
-S32 LLScriptFunctionDec::getSize()
-{
- return 0;
-}
-
-void LLScriptFunctionDec::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- fdotabs(fp, tabs, tabsize);
- mType->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " ");
- mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_EMIT_ASSEMBLY:
- mType->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " ");
- mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_SCOPE_PASS1:
- // add function names into global scope
- if (scope->checkEntry(mIdentifier->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mIdentifier->mScopeEntry = scope->addEntry(mIdentifier->mName, LIT_VARIABLE, mType->mType);
- }
- break;
- case LSCP_RESOURCE:
- {
- // we're just tryng to determine how much space the variable needs
- mIdentifier->mScopeEntry->mOffset = (S32)count;
- mIdentifier->mScopeEntry->mSize = mType->getSize();
- count += mIdentifier->mScopeEntry->mSize;
- }
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
- // return type
- char typereturn;
- if (mType)
- {
- typereturn = LSCRIPTTypeByte[mType->mType];
- }
- else
- {
- typereturn = LSCRIPTTypeByte[LST_NULL];
- }
- chunk->addBytes(&typereturn, 1);
- // name
-#ifdef LSL_INCLUDE_DEBUG_INFO
- chunk->addBytes(mIdentifier->mName, strlen(mIdentifier->mName) + 1);
-#else
- chunk->addBytes(1);
-#endif
- }
- break;
- case LSCP_BUILD_FUNCTION_ARGS:
- {
- entry->mFunctionArgs.addType(mType->mType);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- mType->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " ");
- mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if(NULL != mNextp)
- {
- fprintf(fp, ",");
- }
- break;
- default:
- mType->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
-}
-
-void LLScriptGlobalFunctions::addGlobalFunction(LLScriptGlobalFunctions *global)
-{
- if (mNextp)
- {
- global->mNextp = mNextp;
- }
- mNextp = global;
-}
-
-void LLScriptGlobalFunctions::gonext(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- if (mNextp)
- {
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- default:
- if (mNextp)
- {
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- }
-}
-
-S32 LLScriptGlobalFunctions::getSize()
-{
- return 0;
-}
-
-void LLScriptGlobalFunctions::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- fdotabs(fp, tabs, tabsize);
- if (mType)
- {
- mType->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "\t");
- }
- mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mParameters)
- {
- fprintf(fp, "( ");
- mParameters->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )\n");
- }
- else
- {
- fprintf(fp, "()\n");
- }
- if (mStatements)
- {
- fdotabs(fp, tabs, tabsize);
- mStatements->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, mIdentifier->mScopeEntry, entrycount, NULL);
- }
- else
- {
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "{\n");
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "}\n");
- }
- break;
- case LSCP_EMIT_ASSEMBLY:
- mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mParameters)
- {
- fprintf(fp, "( ");
- mParameters->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )\n");
- }
- else
- {
- fprintf(fp, "()\n");
- }
- if (mStatements)
- {
- mStatements->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, mIdentifier->mScopeEntry->mSize, mIdentifier->mScopeEntry, entrycount, NULL);
- }
- if (mbNeedTrailingReturn)
- {
- print_return(fp, mIdentifier->mScopeEntry);
- }
- fprintf(fp, "\n");
- break;
- case LSCP_PRUNE:
- mbNeedTrailingReturn = FALSE;
- if (mType)
- {
- prunearg = TRUE;
- mStatements->recurse(fp, tabs, tabsize, pass, LSPRUNE_GLOBAL_NON_VOIDS, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (!prunearg)
- {
- gErrorToText.writeError(fp, this, LSERROR_NO_RETURN);
- }
- }
- else
- {
- prunearg = TRUE;
- mStatements->recurse(fp, tabs, tabsize, pass, LSPRUNE_GLOBAL_VOIDS, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (!prunearg)
- {
- // this means that we didn't end with a return statement, need to add one
- mbNeedTrailingReturn = TRUE;
- }
- }
- break;
- case LSCP_SCOPE_PASS1:
- // add function names into global scope
- if (scope->checkEntry(mIdentifier->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- if (mType)
- {
- mIdentifier->mScopeEntry = scope->addEntry(mIdentifier->mName, LIT_FUNCTION, mType->mType);
- }
- else
- {
- mIdentifier->mScopeEntry = scope->addEntry(mIdentifier->mName, LIT_FUNCTION, LST_NULL);
- }
- }
-
- // create function level scope
- mFunctionScope = new LLScriptScope(gScopeStringTable);
- mFunctionScope->addParentScope(scope);
-
- // function parameters
- if (mParameters)
- {
- mParameters->recurse(fp, tabs, tabsize, pass, ptype, prunearg, mFunctionScope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
-
- mStatements->recurse(fp, tabs, tabsize, pass, ptype, prunearg, mFunctionScope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_SCOPE_PASS2:
- mStatements->recurse(fp, tabs, tabsize, pass, ptype, prunearg, mFunctionScope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
-
- if (mParameters)
- {
- if (mIdentifier->mScopeEntry)
- {
- mParameters->recurse(fp, tabs, tabsize, LSCP_BUILD_FUNCTION_ARGS, ptype, prunearg, mFunctionScope, type, basetype, count, chunk, heap, stacksize, mIdentifier->mScopeEntry, 0, NULL);
- }
- }
- break;
- case LSCP_TYPE:
- if (mType)
- {
- mStatements->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, mType->mType, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- else
- {
- type = LST_NULL;
- mStatements->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- case LSCP_RESOURCE:
- // first determine resource counts for globals
- count = 0;
-
- if (mParameters)
- {
- mParameters->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
-
- if (mIdentifier->mScopeEntry)
- {
- // this isn't a bug . . . Offset is used to determine how much is params vs locals
- mIdentifier->mScopeEntry->mOffset = (S32)count;
- }
-
- if (mStatements)
- {
- entrycount = 0;
- mStatements->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, mIdentifier->mScopeEntry, entrycount, NULL);
- fprintf(fp, "Function Args: %s\n", mIdentifier->mScopeEntry->mFunctionArgs.mString);
- fprintf(fp, "Local List: %s\n", mIdentifier->mScopeEntry->mLocals.mString);
- if (mIdentifier->mScopeEntry)
- {
- mIdentifier->mScopeEntry->mSize = (S32)count;
- }
- }
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
- // order for global functions
- // set jump table value
- S32 jumpoffset = LSCRIPTDataSize[LST_INTEGER]*mIdentifier->mScopeEntry->mCount + LSCRIPTDataSize[LST_INTEGER];
- integer2bytestream(chunk->mCodeChunk, jumpoffset, chunk->mCurrentOffset);
-
- // 0 - 3: offset to actual data
- S32 offsetoffset = chunk->mCurrentOffset;
- S32 offsetdelta = 0;
- chunk->addBytes(4);
-
- // null terminated function name
-#ifdef LSL_INCLUDE_DEBUG_INFO
- chunk->addBytes(mIdentifier->mName, strlen(mIdentifier->mName) + 1);
-#else
- chunk->addBytes(1);
-#endif
- // return type
- char typereturn;
- if (mType)
- {
- typereturn = LSCRIPTTypeByte[mType->mType];
- }
- else
- {
- typereturn = LSCRIPTTypeByte[LST_NULL];
- }
- chunk->addBytes(&typereturn, 1);
-
- // null terminated parameters, followed by type
- if (mParameters)
- {
- LLScriptByteCodeChunk *params = new LLScriptByteCodeChunk(FALSE);
- mParameters->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, params, heap, stacksize, entry, entrycount, NULL);
- chunk->addBytes(params->mCodeChunk, params->mCurrentOffset);
- delete params;
- }
- chunk->addBytes(1);
-
- // now we're at the first opcode
- offsetdelta = chunk->mCurrentOffset - offsetoffset;
- integer2bytestream(chunk->mCodeChunk, offsetoffset, offsetdelta);
-
- if (mStatements)
- {
- LLScriptByteCodeChunk *statements = new LLScriptByteCodeChunk(TRUE);
- mStatements->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, statements, heap, mIdentifier->mScopeEntry->mSize, mIdentifier->mScopeEntry, entrycount, NULL);
- statements->connectJumps();
- chunk->addBytes(statements->mCodeChunk, statements->mCurrentOffset);
- delete statements;
- }
- if (mbNeedTrailingReturn)
- {
- add_return(chunk, mIdentifier->mScopeEntry);
- }
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- {
- // Function header. Prefix function name with g to distinguish
- // from event handlers.
- fprintf(fp, ".method public hidebysig instance default ");
- print_cil_type(fp, mType ? mType->mType : LST_NULL);
- fprintf(fp, " 'g");
- fprintf(fp, "%s", mIdentifier->mName);
- fprintf(fp, "'");
- if (mParameters)
- {
- fprintf(fp, "( ");
- mParameters->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )");
- }
- else
- {
- fprintf(fp, "()");
- }
- fprintf(fp, " cil managed\n{\n");
- fprintf(fp, ".maxstack 500\n"); // TODO: Calculated stack size...
-
- // Allocate space for locals.
- print_cil_local_init(fp, mIdentifier->mScopeEntry);
-
- if (mStatements)
- {
- mStatements->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, mIdentifier->mScopeEntry->mSize, mIdentifier->mScopeEntry, entrycount, NULL);
- }
-
- // Function footer.
- if (mbNeedTrailingReturn)
- {
- // TODO: throw exception?
- fprintf(fp, "ret\n");
- }
- fprintf(fp, "}\n");
- fprintf(fp, "\n");
- }
- break;
- default:
- if (mType)
- {
- mType->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mParameters)
- {
- mParameters->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- if (mStatements)
- {
- mStatements->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
-}
-
-void LLScriptState::addState(LLScriptState *state)
-{
- if (mNextp)
- {
- state->mNextp = mNextp;
- }
- mNextp = state;
-}
-
-void LLScriptState::gonext(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- if (mNextp)
- {
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- default:
- if (mNextp)
- {
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- }
-}
-
-S32 LLScriptState::getSize()
-{
- return 0;
-}
-
-void LLScriptState::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- fdotabs(fp, tabs, tabsize);
- if (mType == LSSTYPE_DEFAULT)
- {
- mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "\n");
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "{\n");
- }
- else
- {
- fprintf(fp, "state ");
- mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "\n");
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "{\n");
- }
- if (mEvent)
- {
- mEvent->recurse(fp, tabs + 1, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "}\n");
- break;
- case LSCP_EMIT_ASSEMBLY:
- mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ":\n");
- if (mEvent)
- {
- fprintf(fp, "EVENTS\n");
- mEvent->recurse(fp, tabs + 1, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "\n");
- }
- break;
- case LSCP_SCOPE_PASS1:
- // add state name
- if (scope->checkEntry(mIdentifier->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mIdentifier->mScopeEntry = scope->addEntry(mIdentifier->mName, LIT_STATE, LST_NULL);
- }
- mStateScope = new LLScriptScope(gScopeStringTable);
- mStateScope->addParentScope(scope);
- // now do the events
- if (mEvent)
- {
- mEvent->recurse(fp, tabs, tabsize, pass, ptype, prunearg, mStateScope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- case LSCP_SCOPE_PASS2:
- if (mEvent)
- {
- mEvent->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- case LSCP_TYPE:
- if (mEvent)
- {
- mEvent->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
- // order for states
- // set jump table value
-
- S32 jumpoffset;
- if (LSL2_CURRENT_MAJOR_VERSION == LSL2_MAJOR_VERSION_TWO)
- {
- jumpoffset = LSCRIPTDataSize[LST_INTEGER]*3*mIdentifier->mScopeEntry->mCount + LSCRIPTDataSize[LST_INTEGER];
- }
- else
- {
- jumpoffset = LSCRIPTDataSize[LST_INTEGER]*2*mIdentifier->mScopeEntry->mCount + LSCRIPTDataSize[LST_INTEGER];
- }
- integer2bytestream(chunk->mCodeChunk, jumpoffset, chunk->mCurrentOffset);
-
- // need to figure out what handlers this state has registered
- // we'll use to count to find it
- count = 0;
-
- if (mEvent)
- {
- mEvent->recurse(fp, tabs, tabsize, LSCP_DETERMINE_HANDLERS, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- gCurrentHandler = count;
- }
-
- // add description word into chunk
- if (LSL2_CURRENT_MAJOR_VERSION == LSL2_MAJOR_VERSION_TWO)
- {
- u642bytestream(chunk->mCodeChunk, jumpoffset, gCurrentHandler);
- }
- else
- {
- integer2bytestream(chunk->mCodeChunk, jumpoffset, (S32)gCurrentHandler);
- }
-
-
- // 0 - 3: offset to event jump table
- S32 offsetoffset = chunk->mCurrentOffset;
- S32 offsetdelta = 0;
- chunk->addBytes(4);
-
- // null terminated state name
-#ifdef LSL_INCLUDE_DEBUG_INFO
- chunk->addBytes(mIdentifier->mName, strlen(mIdentifier->mName) + 1);
-#else
- chunk->addBytes(1);
-#endif
- // now we're at the jump table
- offsetdelta = chunk->mCurrentOffset - offsetoffset;
- integer2bytestream(chunk->mCodeChunk, offsetoffset, offsetdelta);
-
- // add the events themselves
- if (mEvent)
- {
- LLScriptByteCodeChunk *events = new LLScriptByteCodeChunk(FALSE);
- // make space for event jump table
- events->addBytes(LSCRIPTDataSize[LST_INTEGER]*get_number_of_event_handlers(gCurrentHandler)*2);
- mEvent->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, events, heap, stacksize, entry, entrycount, NULL);
- chunk->addBytes(events->mCodeChunk, events->mCurrentOffset);
- delete events;
- }
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- if (mEvent)
- {
- // Entry not used at this level, so pass state scope as entry parameter, to allow event handlers to do name mangling.
- mEvent->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, mIdentifier->mScopeEntry, entrycount, NULL);
- }
- break;
- default:
- if (mType == LSSTYPE_DEFAULT)
- {
- }
- else
- {
- mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- if (mEvent)
- {
- mEvent->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
-}
-
-// Converts string to a valid CIL class name and stores the result
-// in the supplied buffer, which should be at least 32 chars long.
-// If the string starts with a UUID, all characters in the UUID are included
-// in the generated name.
-void to_class_name(char* buffer, const char* string)
-{
- strcpy(buffer, "LSL-");
- strcat(buffer, string);
- char* current_char = buffer;
- while((*current_char) != 0)
- {
- if(isalnum(*current_char))
- {
- ++current_char;
- }
- else if((*current_char) == '-')
- {
- (*current_char) = '_';
- ++current_char;
- }
- else
- {
- (*current_char) = 0;
- }
- }
-}
-
-void LLScriptScript::setClassName(const char* class_name)
-{
- to_class_name(mClassName, class_name);
-}
-
-S32 LLScriptScript::getSize()
-{
- return 0;
-}
-
-LLScriptScript::LLScriptScript(LLScritpGlobalStorage *globals,
- LLScriptState *states) :
- LLScriptFilePosition(0, 0),
- mStates(states), mGlobalScope(NULL), mGlobals(NULL), mGlobalFunctions(NULL), mGodLike(FALSE)
-{
- const char DEFAULT_BYTECODE_FILENAME[] = "lscript.lso";
-
- mBytecodeDest = DEFAULT_BYTECODE_FILENAME;
- LLScriptGlobalVariable *tvar;
- LLScriptGlobalFunctions *tfunc;
- LLScritpGlobalStorage *temp;
-
- temp = globals;
- while(temp)
- {
- if (temp->mbGlobalFunction)
- {
- if (!mGlobalFunctions)
- {
- mGlobalFunctions = (LLScriptGlobalFunctions *)temp->mGlobal;
- }
- else
- {
- tfunc = mGlobalFunctions;
- while(tfunc->mNextp)
- {
- tfunc = tfunc->mNextp;
- }
- tfunc->mNextp = (LLScriptGlobalFunctions *)temp->mGlobal;
- }
- }
- else
- {
- if (!mGlobals)
- {
- mGlobals = (LLScriptGlobalVariable *)temp->mGlobal;
- }
- else
- {
- tvar = mGlobals;
- while(tvar->mNextp)
- {
- tvar = tvar->mNextp;
- }
- tvar->mNextp = (LLScriptGlobalVariable *)temp->mGlobal;
- }
- }
- temp = temp->mNextp;
- }
-
- mClassName[0] = '\0';
-}
-
-void LLScriptScript::setBytecodeDest(const char* dst_filename)
-{
- mBytecodeDest = ll_safe_string(dst_filename);
-}
-
-static void print_cil_globals(LLFILE* fp, LLScriptGlobalVariable* global)
-{
- fprintf(fp, ".field public ");
- print_cil_type(fp, global->mType->mType);
- fprintf(fp, " '%s'\n", global->mIdentifier->mName);
- if(NULL != global->mNextp)
- {
- print_cil_globals(fp, global->mNextp);
- }
-}
-
-void LLScriptScript::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
-{
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- if (mGlobals)
- {
- fdotabs(fp, tabs, tabsize);
- mGlobals->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
-
- if (mGlobalFunctions)
- {
- fdotabs(fp, tabs, tabsize);
- mGlobalFunctions->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
-
- fdotabs(fp, tabs, tabsize);
- mStates->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_PRUNE:
- if (mGlobalFunctions)
- {
- mGlobalFunctions->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- mStates->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_SCOPE_PASS1:
- {
- mGlobalScope = new LLScriptScope(gScopeStringTable);
- // zeroth, add library functions to global scope
- U16 function_index = 0;
- const char *arg;
- LLScriptScopeEntry *sentry;
- for (std::vector<LLScriptLibraryFunction>::const_iterator i = gScriptLibrary.mFunctions.begin();
- i != gScriptLibrary.mFunctions.end(); ++i)
- {
- // First, check to make sure this isn't a god only function, or that the viewer's agent is a god.
- if (!i->mGodOnly || mGodLike)
- {
- if (i->mReturnType)
- sentry = mGlobalScope->addEntry(i->mName, LIT_LIBRARY_FUNCTION, char2type(*i->mReturnType));
- else
- sentry = mGlobalScope->addEntry(i->mName, LIT_LIBRARY_FUNCTION, LST_NULL);
- sentry->mLibraryNumber = function_index;
- arg = i->mArgs;
- if (arg)
- {
- while (*arg)
- {
- sentry->mFunctionArgs.addType(char2type(*arg));
- sentry->mSize += LSCRIPTDataSize[char2type(*arg)];
- sentry->mOffset += LSCRIPTDataSize[char2type(*arg)];
- arg++;
- }
- }
- }
- function_index++;
- }
- // first go and collect all the global variables
- if (mGlobals)
- mGlobals->recurse(fp, tabs, tabsize, pass, ptype, prunearg, mGlobalScope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- // second, do the global functions
- if (mGlobalFunctions)
- mGlobalFunctions->recurse(fp, tabs, tabsize, pass, ptype, prunearg, mGlobalScope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- // now do states
- mStates->recurse(fp, tabs, tabsize, pass, ptype, prunearg, mGlobalScope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- case LSCP_SCOPE_PASS2:
- // now we're checking jumps, function calls, and state transitions
- if (mGlobalFunctions)
- mGlobalFunctions->recurse(fp, tabs, tabsize, pass, ptype, prunearg, mGlobalScope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mStates->recurse(fp, tabs, tabsize, pass, ptype, prunearg, mGlobalScope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_TYPE:
- // first we need to check global variables
- if (mGlobals)
- mGlobals->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- // now do global functions and states
- if (mGlobalFunctions)
- mGlobalFunctions->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mStates->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_RESOURCE:
- // first determine resource counts for globals
- count = 0;
- if (mGlobals)
- mGlobals->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- // now do locals
- if (mGlobalFunctions)
- mGlobalFunctions->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mStates->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_EMIT_ASSEMBLY:
-
- if (mGlobals)
- {
- fprintf(fp, "GLOBALS\n");
- fdotabs(fp, tabs, tabsize);
- mGlobals->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "\n");
- }
-
- if (mGlobalFunctions)
- {
- fprintf(fp, "GLOBAL FUNCTIONS\n");
- fdotabs(fp, tabs, tabsize);
- mGlobalFunctions->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "\n");
- }
-
- fprintf(fp, "STATES\n");
- fdotabs(fp, tabs, tabsize);
- mStates->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "\n");
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
- // first, create data structure to hold the whole shebang
- LLScriptScriptCodeChunk *code = new LLScriptScriptCodeChunk(TOP_OF_MEMORY);
-
- // ok, let's add the registers, all zeroes for now
- S32 i;
- S32 nooffset = 0;
-
- for (i = LREG_IP; i < LREG_EOF; i++)
- {
- if (i < LREG_NCE)
- code->mRegisters->addBytes(4);
- else if (LSL2_CURRENT_MAJOR_VERSION == LSL2_MAJOR_VERSION_TWO)
- code->mRegisters->addBytes(8);
- }
- // global variables
- if (mGlobals)
- mGlobals->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, code->mGlobalVariables, code->mHeap, stacksize, entry, entrycount, NULL);
-
- // put the ending heap block onto the heap
- U8 *temp;
- S32 size = lsa_create_data_block(&temp, NULL, 0);
- code->mHeap->addBytes(temp, size);
- delete [] temp;
-
- // global functions
- // make space for global function jump table
- if (mGlobalFunctions)
- {
- code->mGlobalFunctions->addBytes(LSCRIPTDataSize[LST_INTEGER]*mGlobalScope->mFunctionCount + LSCRIPTDataSize[LST_INTEGER]);
- integer2bytestream(code->mGlobalFunctions->mCodeChunk, nooffset, mGlobalScope->mFunctionCount);
- mGlobalFunctions->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, code->mGlobalFunctions, NULL, stacksize, entry, entrycount, NULL);
- }
-
-
- nooffset = 0;
- // states
- // make space for state jump/info table
- if (LSL2_CURRENT_MAJOR_VERSION == LSL2_MAJOR_VERSION_TWO)
- {
- code->mStates->addBytes(LSCRIPTDataSize[LST_INTEGER]*3*mGlobalScope->mStateCount + LSCRIPTDataSize[LST_INTEGER]);
- }
- else
- {
- code->mStates->addBytes(LSCRIPTDataSize[LST_INTEGER]*2*mGlobalScope->mStateCount + LSCRIPTDataSize[LST_INTEGER]);
- }
- integer2bytestream(code->mStates->mCodeChunk, nooffset, mGlobalScope->mStateCount);
- mStates->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, code->mStates, NULL, stacksize, entry, entrycount, NULL);
-
- // now, put it all together and spit it out
- // we need
- LLFILE* bcfp = LLFile::fopen(mBytecodeDest, "wb"); /*Flawfinder: ignore*/
-
- code->build(fp, bcfp);
- fclose(bcfp);
-
- delete code;
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- {
- LLFILE *bcfp = LLFile::fopen(mBytecodeDest, "wb");
-
- // Output dependencies.
- fprintf(bcfp, ".assembly extern mscorlib {.ver 1:0:5000:0}\n");
- fprintf(bcfp, ".assembly extern LslLibrary {.ver 0:1:0:0}\n");
- fprintf(bcfp, ".assembly extern LslUserScript {.ver 0:1:0:0}\n");
- fprintf(bcfp, ".assembly extern ScriptTypes {.ver 0:1:0:0}\n");
-
- // Output assembly name.
- fprintf(bcfp, ".assembly '%s' {.ver 0:0:0:0}\n", gScriptp->getClassName());
-
- // Output class header.
- fprintf(bcfp, ".class public auto ansi serializable beforefieldinit %s extends [LslUserScript]LindenLab.SecondLife.LslUserScript\n", gScriptp->getClassName());
- fprintf(bcfp, "{\n");
-
- // Output globals as members.
- if(NULL != mGlobals)
- {
- print_cil_globals(bcfp, mGlobals);
- }
-
- // Output ctor header.
- fprintf(bcfp, ".method public hidebysig specialname rtspecialname instance default void .ctor () cil managed\n");
- fprintf(bcfp, "{\n");
- fprintf(bcfp, ".maxstack 500\n");
-
- // Initialise globals as members in ctor.
- if (mGlobals)
- {
- fdotabs(bcfp, tabs, tabsize);
- mGlobals->recurse(bcfp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(bcfp, "\n");
- }
-
- // Output ctor footer.
- fprintf(bcfp, "ldarg.0\n");
- fprintf(bcfp, "call instance void [LslUserScript]LindenLab.SecondLife.LslUserScript::.ctor()\n");
- fprintf(bcfp, "ret\n");
- fprintf(bcfp, "}\n");
-
- // Output functions as methods.
- if (mGlobalFunctions)
- {
- fdotabs(bcfp, tabs, tabsize);
- mGlobalFunctions->recurse(bcfp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(bcfp, "\n");
- }
-
- // Output states as name mangled methods.
- fdotabs(bcfp, tabs, tabsize);
- mStates->recurse(bcfp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(bcfp, "\n");
-
- // Output class footer.
- fprintf(bcfp, "}\n");
-
- // Close file.
- fclose(bcfp);
- }
- break;
- default:
- if (mGlobals)
- mGlobals->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mGlobalFunctions)
- mGlobalFunctions->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mStates->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
-}
diff --git a/indra/lscript/lscript_compile/lscript_tree.h b/indra/lscript/lscript_compile/lscript_tree.h
deleted file mode 100755
index 047c220b17..0000000000
--- a/indra/lscript/lscript_compile/lscript_tree.h
+++ /dev/null
@@ -1,2325 +0,0 @@
-/**
- * @file lscript_tree.h
- * @brief provides the classes required to build lscript's abstract syntax tree and symbol table
- *
- * $LicenseInfo:firstyear=2002&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#ifndef LL_LSCRIPT_TREE_H
-#define LL_LSCRIPT_TREE_H
-
-#include "v3math.h"
-#include "llquaternion.h"
-#include "lscript_error.h"
-#include "lscript_typecheck.h"
-#include "lscript_byteformat.h"
-
-
-// Nota Bene: Class destructors don't delete pointed to classes because it isn't guaranteed that lex/yacc will build
-// complete data structures. Instead various chunks that are allocated are stored and deleted by allocation lists
-
-class LLScriptType : public LLScriptFilePosition
-{
-public:
- LLScriptType(S32 line, S32 col, LSCRIPTType type)
- : LLScriptFilePosition(line, col), mType(type)
- {
- }
-
- ~LLScriptType() {}
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LSCRIPTType mType;
-};
-
-// contains a literal or constant value
-class LLScriptConstant : public LLScriptFilePosition
-{
-public:
- LLScriptConstant(S32 line, S32 col, LSCRIPTType type)
- : LLScriptFilePosition(line, col), mType(type)
- {
- }
-
- virtual ~LLScriptConstant() {}
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LSCRIPTType mType;
-};
-
-class LLScriptConstantInteger : public LLScriptConstant
-{
-public:
- LLScriptConstantInteger(S32 line, S32 col, S32 value)
- : LLScriptConstant(line, col, LST_INTEGER), mValue(value)
- {
- }
-
- ~LLScriptConstantInteger() {}
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- S32 mValue;
-};
-
-class LLScriptConstantFloat : public LLScriptConstant
-{
-public:
- LLScriptConstantFloat(S32 line, S32 col, F32 value)
- : LLScriptConstant(line, col, LST_FLOATINGPOINT), mValue(value)
- {
- }
-
- ~LLScriptConstantFloat() {}
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- F32 mValue;
-};
-
-class LLScriptConstantString : public LLScriptConstant
-{
-public:
- LLScriptConstantString(S32 line, S32 col, char *value)
- : LLScriptConstant(line, col, LST_STRING), mValue(value)
- {
- }
-
- ~LLScriptConstantString()
- {
- delete [] mValue;
- mValue = NULL;
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- char *mValue;
-};
-
-// container for individual identifiers
-class LLScriptIdentifier : public LLScriptFilePosition
-{
-public:
- LLScriptIdentifier(S32 line, S32 col, char *name, LLScriptType *type = NULL)
- : LLScriptFilePosition(line, col), mName(name), mScopeEntry(NULL), mType(type)
- {
- }
-
- ~LLScriptIdentifier()
- {
- delete [] mName;
- mName = NULL;
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- char *mName;
- LLScriptScopeEntry *mScopeEntry;
- LLScriptType *mType;
-};
-
-typedef enum e_lscript_simple_assignable_type
-{
- LSSAT_NULL,
- LSSAT_IDENTIFIER,
- LSSAT_CONSTANT,
- LSSAT_VECTOR_CONSTANT,
- LSSAT_QUATERNION_CONSTANT,
- LSSAT_LIST_CONSTANT,
- LSSAT_EOF
-} LSCRIPTSimpleAssignableType;
-
-class LLScriptSimpleAssignable : public LLScriptFilePosition
-{
-public:
- LLScriptSimpleAssignable(S32 line, S32 col, LSCRIPTSimpleAssignableType type)
- : LLScriptFilePosition(line, col), mType(type), mNextp(NULL)
- {
- }
-
- void addAssignable(LLScriptSimpleAssignable *assign);
-
- virtual ~LLScriptSimpleAssignable()
- {
- // don't delete next pointer because we're going to store allocation lists and delete from those
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LSCRIPTSimpleAssignableType mType;
- LLScriptSimpleAssignable *mNextp;
-};
-
-class LLScriptSAIdentifier : public LLScriptSimpleAssignable
-{
-public:
- LLScriptSAIdentifier(S32 line, S32 col, LLScriptIdentifier *identifier)
- : LLScriptSimpleAssignable(line, col, LSSAT_IDENTIFIER), mIdentifier(identifier)
- {
- }
-
- ~LLScriptSAIdentifier()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptIdentifier *mIdentifier;
-};
-
-class LLScriptSAConstant : public LLScriptSimpleAssignable
-{
-public:
- LLScriptSAConstant(S32 line, S32 col, LLScriptConstant *constant)
- : LLScriptSimpleAssignable(line, col, LSSAT_CONSTANT), mConstant(constant)
- {
- }
-
- ~LLScriptSAConstant()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptConstant *mConstant;
-};
-
-class LLScriptSAVector : public LLScriptSimpleAssignable
-{
-public:
- LLScriptSAVector(S32 line, S32 col, LLScriptSimpleAssignable *e1,
- LLScriptSimpleAssignable *e2,
- LLScriptSimpleAssignable *e3)
- : LLScriptSimpleAssignable(line, col, LSSAT_VECTOR_CONSTANT),
- mEntry1(e1), mEntry2(e2), mEntry3(e3)
- {
- }
-
- ~LLScriptSAVector()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptSimpleAssignable *mEntry1;
- LLScriptSimpleAssignable *mEntry2;
- LLScriptSimpleAssignable *mEntry3;
-};
-
-class LLScriptSAQuaternion : public LLScriptSimpleAssignable
-{
-public:
- LLScriptSAQuaternion(S32 line, S32 col, LLScriptSimpleAssignable *e1,
- LLScriptSimpleAssignable *e2,
- LLScriptSimpleAssignable *e3,
- LLScriptSimpleAssignable *e4)
- : LLScriptSimpleAssignable(line, col, LSSAT_QUATERNION_CONSTANT),
- mEntry1(e1), mEntry2(e2), mEntry3(e3), mEntry4(e4)
- {
- }
-
- ~LLScriptSAQuaternion()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptSimpleAssignable *mEntry1;
- LLScriptSimpleAssignable *mEntry2;
- LLScriptSimpleAssignable *mEntry3;
- LLScriptSimpleAssignable *mEntry4;
-};
-
-class LLScriptSAList : public LLScriptSimpleAssignable
-{
-public:
- LLScriptSAList(S32 line, S32 col, LLScriptSimpleAssignable *elist)
- : LLScriptSimpleAssignable(line, col, LSSAT_QUATERNION_CONSTANT), mEntryList(elist)
- {
- }
-
- ~LLScriptSAList()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptSimpleAssignable *mEntryList;
-};
-
-// global variables
-class LLScriptGlobalVariable : public LLScriptFilePosition
-{
-public:
- LLScriptGlobalVariable(S32 line, S32 col, LLScriptType *type,
- LLScriptIdentifier *identifier,
- LLScriptSimpleAssignable *assignable)
- : LLScriptFilePosition(line, col), mType(type), mIdentifier(identifier), mAssignable(assignable), mNextp(NULL), mAssignableType(LST_NULL)
- {
- }
-
- void addGlobal(LLScriptGlobalVariable *global);
-
- ~LLScriptGlobalVariable()
- {
- }
-
- void gonext(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptType *mType;
- LLScriptIdentifier *mIdentifier;
- LLScriptSimpleAssignable *mAssignable;
- LLScriptGlobalVariable *mNextp;
- LSCRIPTType mAssignableType;
-};
-
-// events
-
-class LLScriptEvent : public LLScriptFilePosition
-{
-public:
- LLScriptEvent(S32 line, S32 col, LSCRIPTStateEventType type)
- : LLScriptFilePosition(line, col), mType(type)
- {
- }
-
- virtual ~LLScriptEvent()
- {
- // don't delete next pointer because we're going to store allocation lists and delete from those
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LSCRIPTStateEventType mType;
-};
-
-class LLScriptStateEntryEvent : public LLScriptEvent
-{
-public:
- LLScriptStateEntryEvent(S32 line, S32 col)
- : LLScriptEvent(line, col, LSTT_STATE_ENTRY)
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- ~LLScriptStateEntryEvent() {}
-};
-
-class LLScriptStateExitEvent : public LLScriptEvent
-{
-public:
- LLScriptStateExitEvent(S32 line, S32 col)
- : LLScriptEvent(line, col, LSTT_STATE_EXIT)
- {
- }
-
- ~LLScriptStateExitEvent() {}
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-};
-
-class LLScriptTouchStartEvent : public LLScriptEvent
-{
-public:
- LLScriptTouchStartEvent(S32 line, S32 col, LLScriptIdentifier *count)
- : LLScriptEvent(line, col, LSTT_TOUCH_START), mCount(count)
- {
- }
-
- ~LLScriptTouchStartEvent()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptIdentifier *mCount;
-};
-
-class LLScriptTouchEvent : public LLScriptEvent
-{
-public:
- LLScriptTouchEvent(S32 line, S32 col, LLScriptIdentifier *count)
- : LLScriptEvent(line, col, LSTT_TOUCH), mCount(count)
- {
- }
-
- ~LLScriptTouchEvent()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptIdentifier *mCount;
-};
-
-class LLScriptTouchEndEvent : public LLScriptEvent
-{
-public:
- LLScriptTouchEndEvent(S32 line, S32 col, LLScriptIdentifier *count)
- : LLScriptEvent(line, col, LSTT_TOUCH_END), mCount(count)
- {
- }
-
- ~LLScriptTouchEndEvent()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptIdentifier *mCount;
-};
-
-class LLScriptCollisionStartEvent : public LLScriptEvent
-{
-public:
- LLScriptCollisionStartEvent(S32 line, S32 col, LLScriptIdentifier *count)
- : LLScriptEvent(line, col, LSTT_COLLISION_START), mCount(count)
- {
- }
-
- ~LLScriptCollisionStartEvent()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptIdentifier *mCount;
-};
-
-class LLScriptCollisionEvent : public LLScriptEvent
-{
-public:
- LLScriptCollisionEvent(S32 line, S32 col, LLScriptIdentifier *count)
- : LLScriptEvent(line, col, LSTT_COLLISION), mCount(count)
- {
- }
-
- ~LLScriptCollisionEvent()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptIdentifier *mCount;
-};
-
-class LLScriptCollisionEndEvent : public LLScriptEvent
-{
-public:
- LLScriptCollisionEndEvent(S32 line, S32 col, LLScriptIdentifier *count)
- : LLScriptEvent(line, col, LSTT_COLLISION_END), mCount(count)
- {
- }
-
- ~LLScriptCollisionEndEvent()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptIdentifier *mCount;
-};
-
-class LLScriptLandCollisionStartEvent : public LLScriptEvent
-{
-public:
- LLScriptLandCollisionStartEvent(S32 line, S32 col, LLScriptIdentifier *pos)
- : LLScriptEvent(line, col, LSTT_LAND_COLLISION_START), mPosition(pos)
- {
- }
-
- ~LLScriptLandCollisionStartEvent()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptIdentifier *mPosition;
-};
-
-class LLScriptLandCollisionEvent : public LLScriptEvent
-{
-public:
- LLScriptLandCollisionEvent(S32 line, S32 col, LLScriptIdentifier *pos)
- : LLScriptEvent(line, col, LSTT_LAND_COLLISION), mPosition(pos)
- {
- }
-
- ~LLScriptLandCollisionEvent()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptIdentifier *mPosition;
-};
-
-class LLScriptLandCollisionEndEvent : public LLScriptEvent
-{
-public:
- LLScriptLandCollisionEndEvent(S32 line, S32 col, LLScriptIdentifier *pos)
- : LLScriptEvent(line, col, LSTT_LAND_COLLISION_END), mPosition(pos)
- {
- }
-
- ~LLScriptLandCollisionEndEvent()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptIdentifier *mPosition;
-};
-
-class LLScriptInventoryEvent : public LLScriptEvent
-{
-public:
- LLScriptInventoryEvent(S32 line, S32 col, LLScriptIdentifier *change)
- : LLScriptEvent(line, col, LSTT_INVENTORY), mChange(change)
- {
- }
-
- ~LLScriptInventoryEvent() {}
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptIdentifier *mChange;
-};
-
-class LLScriptAttachEvent : public LLScriptEvent
-{
-public:
- LLScriptAttachEvent(S32 line, S32 col, LLScriptIdentifier *attach)
- : LLScriptEvent(line, col, LSTT_ATTACH), mAttach(attach)
- {
- }
-
- ~LLScriptAttachEvent() {}
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptIdentifier *mAttach;
-};
-
-class LLScriptDataserverEvent : public LLScriptEvent
-{
-public:
- LLScriptDataserverEvent(S32 line, S32 col, LLScriptIdentifier *id, LLScriptIdentifier *data)
- : LLScriptEvent(line, col, LSTT_DATASERVER), mID(id), mData(data)
- {
- }
-
- ~LLScriptDataserverEvent() {}
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptIdentifier *mID;
- LLScriptIdentifier *mData;
-};
-
-class LLScriptTimerEvent : public LLScriptEvent
-{
-public:
- LLScriptTimerEvent(S32 line, S32 col)
- : LLScriptEvent(line, col, LSTT_TIMER)
- {
- }
-
- ~LLScriptTimerEvent() {}
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-};
-
-class LLScriptMovingStartEvent : public LLScriptEvent
-{
-public:
- LLScriptMovingStartEvent(S32 line, S32 col)
- : LLScriptEvent(line, col, LSTT_MOVING_START)
- {
- }
-
- ~LLScriptMovingStartEvent() {}
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-};
-
-class LLScriptMovingEndEvent : public LLScriptEvent
-{
-public:
- LLScriptMovingEndEvent(S32 line, S32 col)
- : LLScriptEvent(line, col, LSTT_MOVING_END)
- {
- }
-
- ~LLScriptMovingEndEvent() {}
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-};
-
-class LLScriptRTPEvent : public LLScriptEvent
-{
-public:
- LLScriptRTPEvent(S32 line, S32 col, LLScriptIdentifier *rtperm)
- : LLScriptEvent(line, col, LSTT_RTPERMISSIONS), mRTPermissions(rtperm)
- {
- }
-
- ~LLScriptRTPEvent() {}
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptIdentifier *mRTPermissions;
-};
-
-class LLScriptChatEvent : public LLScriptEvent
-{
-public:
- LLScriptChatEvent(S32 line, S32 col, LLScriptIdentifier *channel, LLScriptIdentifier *name, LLScriptIdentifier *id, LLScriptIdentifier *message)
- : LLScriptEvent(line, col, LSTT_CHAT), mChannel(channel), mName(name), mID(id), mMessage(message)
- {
- }
-
- ~LLScriptChatEvent()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptIdentifier *mChannel;
- LLScriptIdentifier *mName;
- LLScriptIdentifier *mID;
- LLScriptIdentifier *mMessage;
-};
-
-class LLScriptObjectRezEvent : public LLScriptEvent
-{
-public:
- LLScriptObjectRezEvent(S32 line, S32 col, LLScriptIdentifier *id)
- : LLScriptEvent(line, col, LSTT_OBJECT_REZ), mID(id)
- {
- }
-
- ~LLScriptObjectRezEvent()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptIdentifier *mID;
-};
-
-class LLScriptSensorEvent : public LLScriptEvent
-{
-public:
- LLScriptSensorEvent(S32 line, S32 col, LLScriptIdentifier *number)
- : LLScriptEvent(line, col, LSTT_SENSOR), mNumber(number)
- {
- }
-
- ~LLScriptSensorEvent()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptIdentifier *mNumber;
-};
-
-class LLScriptControlEvent : public LLScriptEvent
-{
-public:
- LLScriptControlEvent(S32 line, S32 col, LLScriptIdentifier *name, LLScriptIdentifier *levels, LLScriptIdentifier *edges)
- : LLScriptEvent(line, col, LSTT_CONTROL), mName(name), mLevels(levels), mEdges(edges)
- {
- }
-
- ~LLScriptControlEvent()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptIdentifier *mName;
- LLScriptIdentifier *mLevels;
- LLScriptIdentifier *mEdges;
-};
-
-class LLScriptLinkMessageEvent : public LLScriptEvent
-{
-public:
- LLScriptLinkMessageEvent(S32 line, S32 col, LLScriptIdentifier *sender, LLScriptIdentifier *num, LLScriptIdentifier *str, LLScriptIdentifier *id)
- : LLScriptEvent(line, col, LSTT_LINK_MESSAGE), mSender(sender), mNum(num), mStr(str), mID(id)
- {
- }
-
- ~LLScriptLinkMessageEvent()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptIdentifier *mSender;
- LLScriptIdentifier *mNum;
- LLScriptIdentifier *mStr;
- LLScriptIdentifier *mID;
-};
-
-class LLScriptRemoteEvent : public LLScriptEvent
-{
-public:
- LLScriptRemoteEvent(S32 line, S32 col, LLScriptIdentifier *type, LLScriptIdentifier *channel, LLScriptIdentifier *message_id, LLScriptIdentifier *sender, LLScriptIdentifier *int_val, LLScriptIdentifier *str_val)
- : LLScriptEvent(line, col, LSTT_REMOTE_DATA), mType(type), mChannel(channel), mMessageID(message_id), mSender(sender), mIntVal(int_val), mStrVal(str_val)
- {
- }
-
- ~LLScriptRemoteEvent()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptIdentifier *mType;
- LLScriptIdentifier *mChannel;
- LLScriptIdentifier *mMessageID;
- LLScriptIdentifier *mSender;
- LLScriptIdentifier *mIntVal;
- LLScriptIdentifier *mStrVal;
-};
-
-class LLScriptHTTPResponseEvent : public LLScriptEvent
-{
-public:
- LLScriptHTTPResponseEvent(S32 line, S32 col,
- LLScriptIdentifier *request_id,
- LLScriptIdentifier *status,
- LLScriptIdentifier *metadata,
- LLScriptIdentifier *body)
- : LLScriptEvent(line, col, LSTT_HTTP_RESPONSE),
- mRequestId(request_id), mStatus(status), mMetadata(metadata), mBody(body)
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass,
- LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope,
- LSCRIPTType &type, LSCRIPTType basetype, U64 &count,
- LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap,
- S32 stacksize, LLScriptScopeEntry *entry,
- S32 entrycount, LLScriptLibData **ldata);
-
- S32 getSize();
-
- LLScriptIdentifier *mRequestId;
- LLScriptIdentifier *mStatus;
- LLScriptIdentifier *mMetadata;
- LLScriptIdentifier *mBody;
-};
-
-class LLScriptHTTPRequestEvent : public LLScriptEvent
-{
-public:
- LLScriptHTTPRequestEvent(S32 line, S32 col,
- LLScriptIdentifier *request_id,
- LLScriptIdentifier *method,
- LLScriptIdentifier *body)
- : LLScriptEvent(line, col, LSTT_HTTP_REQUEST),
- mRequestId(request_id), mMethod(method), mBody(body)
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass,
- LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope,
- LSCRIPTType &type, LSCRIPTType basetype, U64 &count,
- LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap,
- S32 stacksize, LLScriptScopeEntry *entry,
- S32 entrycount, LLScriptLibData **ldata);
-
- S32 getSize();
-
- LLScriptIdentifier *mRequestId;
- LLScriptIdentifier *mMethod;
- LLScriptIdentifier *mBody;
-};
-
-class LLScriptRezEvent : public LLScriptEvent
-{
-public:
- LLScriptRezEvent(S32 line, S32 col, LLScriptIdentifier *start_param)
- : LLScriptEvent(line, col, LSTT_REZ), mStartParam(start_param)
- {
- }
- ~LLScriptRezEvent() {}
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptIdentifier *mStartParam;
-};
-
-class LLScriptNoSensorEvent : public LLScriptEvent
-{
-public:
- LLScriptNoSensorEvent(S32 line, S32 col)
- : LLScriptEvent(line, col, LSTT_NO_SENSOR)
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- ~LLScriptNoSensorEvent() {}
-};
-
-class LLScriptAtTarget : public LLScriptEvent
-{
-public:
- LLScriptAtTarget(S32 line, S32 col, LLScriptIdentifier *tnumber, LLScriptIdentifier *tpos, LLScriptIdentifier *ourpos)
- : LLScriptEvent(line, col, LSTT_AT_TARGET), mTargetNumber(tnumber), mTargetPosition(tpos), mOurPosition(ourpos)
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- ~LLScriptAtTarget() {}
-
- LLScriptIdentifier *mTargetNumber;
- LLScriptIdentifier *mTargetPosition;
- LLScriptIdentifier *mOurPosition;
-};
-
-class LLScriptNotAtTarget : public LLScriptEvent
-{
-public:
- LLScriptNotAtTarget(S32 line, S32 col)
- : LLScriptEvent(line, col, LSTT_NOT_AT_TARGET)
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- ~LLScriptNotAtTarget() {}
-};
-
-class LLScriptAtRotTarget : public LLScriptEvent
-{
-public:
- LLScriptAtRotTarget(S32 line, S32 col, LLScriptIdentifier *tnumber, LLScriptIdentifier *trot, LLScriptIdentifier *ourrot)
- : LLScriptEvent(line, col, LSTT_AT_ROT_TARGET), mTargetNumber(tnumber), mTargetRotation(trot), mOurRotation(ourrot)
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- ~LLScriptAtRotTarget() {}
-
- LLScriptIdentifier *mTargetNumber;
- LLScriptIdentifier *mTargetRotation;
- LLScriptIdentifier *mOurRotation;
-};
-
-class LLScriptNotAtRotTarget : public LLScriptEvent
-{
-public:
- LLScriptNotAtRotTarget(S32 line, S32 col)
- : LLScriptEvent(line, col, LSTT_NOT_AT_ROT_TARGET)
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- ~LLScriptNotAtRotTarget() {}
-};
-
-class LLScriptMoneyEvent : public LLScriptEvent
-{
-public:
- LLScriptMoneyEvent(S32 line, S32 col, LLScriptIdentifier *name, LLScriptIdentifier *amount)
- : LLScriptEvent(line, col, LSTT_MONEY), mName(name), mAmount(amount)
- {
- }
-
- ~LLScriptMoneyEvent()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptIdentifier *mName;
- LLScriptIdentifier *mAmount;
-};
-
-class LLScriptEmailEvent : public LLScriptEvent
-{
-public:
- LLScriptEmailEvent(S32 line, S32 col, LLScriptIdentifier *time, LLScriptIdentifier *address, LLScriptIdentifier *subject, LLScriptIdentifier *body, LLScriptIdentifier *number)
- : LLScriptEvent(line, col, LSTT_EMAIL), mTime(time), mAddress(address), mSubject(subject), mBody(body), mNumber(number)
- {
- }
-
- ~LLScriptEmailEvent()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptIdentifier *mTime;
- LLScriptIdentifier *mAddress;
- LLScriptIdentifier *mSubject;
- LLScriptIdentifier *mBody;
- LLScriptIdentifier *mNumber;
-};
-
-
-class LLScriptExpression : public LLScriptFilePosition
-{
-public:
- LLScriptExpression(S32 line, S32 col, LSCRIPTExpressionType type)
- : LLScriptFilePosition(line, col), mType(type), mNextp(NULL), mLeftType(LST_NULL), mRightType(LST_NULL), mReturnType(LST_NULL)
- {
- }
-
- void addExpression(LLScriptExpression *expression);
-
- virtual ~LLScriptExpression()
- {
- // don't delete next pointer because we're going to store allocation lists and delete from those
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
-
- void gonext(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LSCRIPTExpressionType mType;
- LLScriptExpression *mNextp;
- LSCRIPTType mLeftType, mRightType, mReturnType;
-
-};
-
-class LLScriptForExpressionList : public LLScriptExpression
-{
-public:
- LLScriptForExpressionList(S32 line, S32 col, LLScriptExpression *first, LLScriptExpression *second)
- : LLScriptExpression(line, col, LET_FOR_EXPRESSION_LIST), mFirstp(first), mSecondp(second)
- {
- }
-
- ~LLScriptForExpressionList()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptExpression *mFirstp;
- LLScriptExpression *mSecondp;
-};
-
-class LLScriptFuncExpressionList : public LLScriptExpression
-{
-public:
- LLScriptFuncExpressionList(S32 line, S32 col, LLScriptExpression *first, LLScriptExpression *second)
- : LLScriptExpression(line, col, LET_FUNC_EXPRESSION_LIST), mFirstp(first), mSecondp(second)
- {
- }
-
- ~LLScriptFuncExpressionList()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptExpression *mFirstp;
- LLScriptExpression *mSecondp;
-};
-
-class LLScriptListExpressionList : public LLScriptExpression
-{
-public:
- LLScriptListExpressionList(S32 line, S32 col, LLScriptExpression *first, LLScriptExpression *second)
- : LLScriptExpression(line, col, LET_LIST_EXPRESSION_LIST), mFirstp(first), mSecondp(second)
- {
- }
-
- ~LLScriptListExpressionList()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptExpression *mFirstp;
- LLScriptExpression *mSecondp;
-};
-
-class LLScriptLValue : public LLScriptExpression
-{
-public:
- LLScriptLValue(S32 line, S32 col, LLScriptIdentifier *identifier, LLScriptIdentifier *accessor)
- : LLScriptExpression(line, col, LET_LVALUE), mOffset(0), mIdentifier(identifier), mAccessor(accessor)
- {
- }
-
- ~LLScriptLValue()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- S32 mOffset;
- LLScriptIdentifier *mIdentifier;
- LLScriptIdentifier *mAccessor;
-};
-
-class LLScriptAssignment : public LLScriptExpression
-{
-public:
- LLScriptAssignment(S32 line, S32 col, LLScriptExpression *lvalue, LLScriptExpression *rightside)
- : LLScriptExpression(line, col, LET_ASSIGNMENT), mLValue(lvalue), mRightSide(rightside)
- {
- }
-
- ~LLScriptAssignment()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptExpression *mLValue;
- LLScriptExpression *mRightSide;
-};
-
-class LLScriptAddAssignment : public LLScriptExpression
-{
-public:
- LLScriptAddAssignment(S32 line, S32 col, LLScriptExpression *lvalue, LLScriptExpression *rightside)
- : LLScriptExpression(line, col, LET_ADD_ASSIGN), mLValue(lvalue), mRightSide(rightside)
- {
- }
-
- ~LLScriptAddAssignment()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptExpression *mLValue;
- LLScriptExpression *mRightSide;
-};
-
-class LLScriptSubAssignment : public LLScriptExpression
-{
-public:
- LLScriptSubAssignment(S32 line, S32 col, LLScriptExpression *lvalue, LLScriptExpression *rightside)
- : LLScriptExpression(line, col, LET_SUB_ASSIGN), mLValue(lvalue), mRightSide(rightside)
- {
- }
-
- ~LLScriptSubAssignment()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptExpression *mLValue;
- LLScriptExpression *mRightSide;
-};
-
-class LLScriptMulAssignment : public LLScriptExpression
-{
-public:
- LLScriptMulAssignment(S32 line, S32 col, LLScriptExpression *lvalue, LLScriptExpression *rightside)
- : LLScriptExpression(line, col, LET_MUL_ASSIGN), mLValue(lvalue), mRightSide(rightside)
- {
- }
-
- ~LLScriptMulAssignment()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptExpression *mLValue;
- LLScriptExpression *mRightSide;
-};
-
-class LLScriptDivAssignment : public LLScriptExpression
-{
-public:
- LLScriptDivAssignment(S32 line, S32 col, LLScriptExpression *lvalue, LLScriptExpression *rightside)
- : LLScriptExpression(line, col, LET_DIV_ASSIGN), mLValue(lvalue), mRightSide(rightside)
- {
- }
-
- ~LLScriptDivAssignment()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptExpression *mLValue;
- LLScriptExpression *mRightSide;
-};
-
-class LLScriptModAssignment : public LLScriptExpression
-{
-public:
- LLScriptModAssignment(S32 line, S32 col, LLScriptExpression *lvalue, LLScriptExpression *rightside)
- : LLScriptExpression(line, col, LET_MOD_ASSIGN), mLValue(lvalue), mRightSide(rightside)
- {
- }
-
- ~LLScriptModAssignment()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptExpression *mLValue;
- LLScriptExpression *mRightSide;
-};
-
-class LLScriptEquality : public LLScriptExpression
-{
-public:
- LLScriptEquality(S32 line, S32 col, LLScriptExpression *leftside, LLScriptExpression *rightside)
- : LLScriptExpression(line, col, LET_EQUALITY), mLeftSide(leftside), mRightSide(rightside)
- {
- }
-
- ~LLScriptEquality()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptExpression *mLeftSide;
- LLScriptExpression *mRightSide;
-};
-
-class LLScriptNotEquals : public LLScriptExpression
-{
-public:
- LLScriptNotEquals(S32 line, S32 col, LLScriptExpression *leftside, LLScriptExpression *rightside)
- : LLScriptExpression(line, col, LET_NOT_EQUALS), mLeftSide(leftside), mRightSide(rightside)
- {
- }
-
- ~LLScriptNotEquals()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptExpression *mLeftSide;
- LLScriptExpression *mRightSide;
-};
-
-class LLScriptLessEquals : public LLScriptExpression
-{
-public:
- LLScriptLessEquals(S32 line, S32 col, LLScriptExpression *leftside, LLScriptExpression *rightside)
- : LLScriptExpression(line, col, LET_LESS_EQUALS), mLeftSide(leftside), mRightSide(rightside)
- {
- }
-
- ~LLScriptLessEquals()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptExpression *mLeftSide;
- LLScriptExpression *mRightSide;
-};
-
-class LLScriptGreaterEquals : public LLScriptExpression
-{
-public:
- LLScriptGreaterEquals(S32 line, S32 col, LLScriptExpression *leftside, LLScriptExpression *rightside)
- : LLScriptExpression(line, col, LET_GREATER_EQUALS), mLeftSide(leftside), mRightSide(rightside)
- {
- }
-
- ~LLScriptGreaterEquals()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptExpression *mLeftSide;
- LLScriptExpression *mRightSide;
-};
-
-class LLScriptLessThan : public LLScriptExpression
-{
-public:
- LLScriptLessThan(S32 line, S32 col, LLScriptExpression *leftside, LLScriptExpression *rightside)
- : LLScriptExpression(line, col, LET_LESS_THAN), mLeftSide(leftside), mRightSide(rightside)
- {
- }
-
- ~LLScriptLessThan()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptExpression *mLeftSide;
- LLScriptExpression *mRightSide;
-};
-
-class LLScriptGreaterThan : public LLScriptExpression
-{
-public:
- LLScriptGreaterThan(S32 line, S32 col, LLScriptExpression *leftside, LLScriptExpression *rightside)
- : LLScriptExpression(line, col, LET_GREATER_THAN), mLeftSide(leftside), mRightSide(rightside)
- {
- }
-
- ~LLScriptGreaterThan()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptExpression *mLeftSide;
- LLScriptExpression *mRightSide;
-};
-
-class LLScriptPlus : public LLScriptExpression
-{
-public:
- LLScriptPlus(S32 line, S32 col, LLScriptExpression *leftside, LLScriptExpression *rightside)
- : LLScriptExpression(line, col, LET_PLUS), mLeftSide(leftside), mRightSide(rightside)
- {
- }
-
- ~LLScriptPlus()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptExpression *mLeftSide;
- LLScriptExpression *mRightSide;
-};
-
-class LLScriptMinus : public LLScriptExpression
-{
-public:
- LLScriptMinus(S32 line, S32 col, LLScriptExpression *leftside, LLScriptExpression *rightside)
- : LLScriptExpression(line, col, LET_MINUS), mLeftSide(leftside), mRightSide(rightside)
- {
- }
-
- ~LLScriptMinus()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptExpression *mLeftSide;
- LLScriptExpression *mRightSide;
-};
-
-class LLScriptTimes : public LLScriptExpression
-{
-public:
- LLScriptTimes(S32 line, S32 col, LLScriptExpression *leftside, LLScriptExpression *rightside)
- : LLScriptExpression(line, col, LET_TIMES), mLeftSide(leftside), mRightSide(rightside)
- {
- }
-
- ~LLScriptTimes()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptExpression *mLeftSide;
- LLScriptExpression *mRightSide;
-};
-
-class LLScriptDivide : public LLScriptExpression
-{
-public:
- LLScriptDivide(S32 line, S32 col, LLScriptExpression *leftside, LLScriptExpression *rightside)
- : LLScriptExpression(line, col, LET_DIVIDE), mLeftSide(leftside), mRightSide(rightside)
- {
- }
-
- ~LLScriptDivide()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptExpression *mLeftSide;
- LLScriptExpression *mRightSide;
-};
-
-class LLScriptMod : public LLScriptExpression
-{
-public:
- LLScriptMod(S32 line, S32 col, LLScriptExpression *leftside, LLScriptExpression *rightside)
- : LLScriptExpression(line, col, LET_MOD), mLeftSide(leftside), mRightSide(rightside)
- {
- }
-
- ~LLScriptMod()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptExpression *mLeftSide;
- LLScriptExpression *mRightSide;
-};
-
-class LLScriptBitAnd : public LLScriptExpression
-{
-public:
- LLScriptBitAnd(S32 line, S32 col, LLScriptExpression *leftside, LLScriptExpression *rightside)
- : LLScriptExpression(line, col, LET_BIT_AND), mLeftSide(leftside), mRightSide(rightside)
- {
- }
-
- ~LLScriptBitAnd()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptExpression *mLeftSide;
- LLScriptExpression *mRightSide;
-};
-
-class LLScriptBitOr : public LLScriptExpression
-{
-public:
- LLScriptBitOr(S32 line, S32 col, LLScriptExpression *leftside, LLScriptExpression *rightside)
- : LLScriptExpression(line, col, LET_BIT_OR), mLeftSide(leftside), mRightSide(rightside)
- {
- }
-
- ~LLScriptBitOr()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptExpression *mLeftSide;
- LLScriptExpression *mRightSide;
-};
-
-class LLScriptBitXor : public LLScriptExpression
-{
-public:
- LLScriptBitXor(S32 line, S32 col, LLScriptExpression *leftside, LLScriptExpression *rightside)
- : LLScriptExpression(line, col, LET_BIT_XOR), mLeftSide(leftside), mRightSide(rightside)
- {
- }
-
- ~LLScriptBitXor()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptExpression *mLeftSide;
- LLScriptExpression *mRightSide;
-};
-
-class LLScriptBooleanAnd : public LLScriptExpression
-{
-public:
- LLScriptBooleanAnd(S32 line, S32 col, LLScriptExpression *leftside, LLScriptExpression *rightside)
- : LLScriptExpression(line, col, LET_BOOLEAN_AND), mLeftSide(leftside), mRightSide(rightside)
- {
- }
-
- ~LLScriptBooleanAnd()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptExpression *mLeftSide;
- LLScriptExpression *mRightSide;
-};
-
-class LLScriptBooleanOr : public LLScriptExpression
-{
-public:
- LLScriptBooleanOr(S32 line, S32 col, LLScriptExpression *leftside, LLScriptExpression *rightside)
- : LLScriptExpression(line, col, LET_BOOLEAN_OR), mLeftSide(leftside), mRightSide(rightside)
- {
- }
-
- ~LLScriptBooleanOr()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptExpression *mLeftSide;
- LLScriptExpression *mRightSide;
-};
-
-class LLScriptShiftLeft : public LLScriptExpression
-{
-public:
- LLScriptShiftLeft(S32 line, S32 col, LLScriptExpression *leftside, LLScriptExpression *rightside)
- : LLScriptExpression(line, col, LET_SHIFT_LEFT), mLeftSide(leftside), mRightSide(rightside)
- {
- }
-
- ~LLScriptShiftLeft()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptExpression *mLeftSide;
- LLScriptExpression *mRightSide;
-};
-
-class LLScriptShiftRight : public LLScriptExpression
-{
-public:
- LLScriptShiftRight(S32 line, S32 col, LLScriptExpression *leftside, LLScriptExpression *rightside)
- : LLScriptExpression(line, col, LET_SHIFT_RIGHT), mLeftSide(leftside), mRightSide(rightside)
- {
- }
-
- ~LLScriptShiftRight()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptExpression *mLeftSide;
- LLScriptExpression *mRightSide;
-};
-
-class LLScriptParenthesis : public LLScriptExpression
-{
-public:
- LLScriptParenthesis(S32 line, S32 col, LLScriptExpression *expression)
- : LLScriptExpression(line, col, LET_PARENTHESIS), mExpression(expression)
- {
- }
-
- ~LLScriptParenthesis()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptExpression *mExpression;
-};
-
-class LLScriptUnaryMinus : public LLScriptExpression
-{
-public:
- LLScriptUnaryMinus(S32 line, S32 col, LLScriptExpression *expression)
- : LLScriptExpression(line, col, LET_UNARY_MINUS), mExpression(expression)
- {
- }
-
- ~LLScriptUnaryMinus()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptExpression *mExpression;
-};
-
-class LLScriptBooleanNot : public LLScriptExpression
-{
-public:
- LLScriptBooleanNot(S32 line, S32 col, LLScriptExpression *expression)
- : LLScriptExpression(line, col, LET_BOOLEAN_NOT), mExpression(expression)
- {
- }
-
- ~LLScriptBooleanNot()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptExpression *mExpression;
-};
-
-class LLScriptBitNot : public LLScriptExpression
-{
-public:
- LLScriptBitNot(S32 line, S32 col, LLScriptExpression *expression)
- : LLScriptExpression(line, col, LET_BIT_NOT), mExpression(expression)
- {
- }
-
- ~LLScriptBitNot()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptExpression *mExpression;
-};
-
-class LLScriptPreIncrement : public LLScriptExpression
-{
-public:
- LLScriptPreIncrement(S32 line, S32 col, LLScriptExpression *expression)
- : LLScriptExpression(line, col, LET_PRE_INCREMENT), mExpression(expression)
- {
- }
-
- ~LLScriptPreIncrement()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptExpression *mExpression;
-};
-
-class LLScriptPreDecrement : public LLScriptExpression
-{
-public:
- LLScriptPreDecrement(S32 line, S32 col, LLScriptExpression *expression)
- : LLScriptExpression(line, col, LET_PRE_DECREMENT), mExpression(expression)
- {
- }
-
- ~LLScriptPreDecrement()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptExpression *mExpression;
-};
-
-class LLScriptTypeCast : public LLScriptExpression
-{
-public:
- LLScriptTypeCast(S32 line, S32 col, LLScriptType *type, LLScriptExpression *expression)
- : LLScriptExpression(line, col, LET_CAST), mType(type), mExpression(expression)
- {
- }
-
- ~LLScriptTypeCast()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptType *mType;
- LLScriptExpression *mExpression;
-};
-
-class LLScriptVectorInitializer : public LLScriptExpression
-{
-public:
- LLScriptVectorInitializer(S32 line, S32 col, LLScriptExpression *expression1,
- LLScriptExpression *expression2,
- LLScriptExpression *expression3)
- : LLScriptExpression(line, col, LET_VECTOR_INITIALIZER),
- mExpression1(expression1),
- mExpression2(expression2),
- mExpression3(expression3)
- {
- }
-
- ~LLScriptVectorInitializer()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptExpression *mExpression1;
- LLScriptExpression *mExpression2;
- LLScriptExpression *mExpression3;
-};
-
-class LLScriptQuaternionInitializer : public LLScriptExpression
-{
-public:
- LLScriptQuaternionInitializer(S32 line, S32 col, LLScriptExpression *expression1,
- LLScriptExpression *expression2,
- LLScriptExpression *expression3,
- LLScriptExpression *expression4)
- : LLScriptExpression(line, col, LET_VECTOR_INITIALIZER),
- mExpression1(expression1),
- mExpression2(expression2),
- mExpression3(expression3),
- mExpression4(expression4)
- {
- }
-
- ~LLScriptQuaternionInitializer()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptExpression *mExpression1;
- LLScriptExpression *mExpression2;
- LLScriptExpression *mExpression3;
- LLScriptExpression *mExpression4;
-};
-
-class LLScriptListInitializer : public LLScriptExpression
-{
-public:
- LLScriptListInitializer(S32 line, S32 col, LLScriptExpression *expressionlist)
- : LLScriptExpression(line, col, LET_LIST_INITIALIZER), mExpressionList(expressionlist)
- {
- }
-
- ~LLScriptListInitializer()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptExpression *mExpressionList;
-};
-
-class LLScriptPostIncrement : public LLScriptExpression
-{
-public:
- LLScriptPostIncrement(S32 line, S32 col, LLScriptExpression *expression)
- : LLScriptExpression(line, col, LET_POST_INCREMENT), mExpression(expression)
- {
- }
-
- ~LLScriptPostIncrement()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptExpression *mExpression;
-};
-
-class LLScriptPostDecrement : public LLScriptExpression
-{
-public:
- LLScriptPostDecrement(S32 line, S32 col, LLScriptExpression *expression)
- : LLScriptExpression(line, col, LET_POST_DECREMENT), mExpression(expression)
- {
- }
-
- ~LLScriptPostDecrement()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptExpression *mExpression;
-};
-
-class LLScriptFunctionCall : public LLScriptExpression
-{
-public:
- LLScriptFunctionCall(S32 line, S32 col, LLScriptIdentifier *identifier, LLScriptExpression *expressionlist)
- : LLScriptExpression(line, col, LET_FUNCTION_CALL), mIdentifier(identifier), mExpressionList(expressionlist)
- {
- }
-
- ~LLScriptFunctionCall()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptIdentifier *mIdentifier;
- LLScriptExpression *mExpressionList;
-};
-
-class LLScriptPrint : public LLScriptExpression
-{
-public:
- LLScriptPrint(S32 line, S32 col, LLScriptExpression *expression)
- : LLScriptExpression(line, col, LET_PRINT), mExpression(expression)
- {
- }
-
- ~LLScriptPrint()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptExpression *mExpression;
-};
-
-class LLScriptConstantExpression : public LLScriptExpression
-{
-public:
- LLScriptConstantExpression(S32 line, S32 col, LLScriptConstant *constant)
- : LLScriptExpression(line, col, LET_CONSTANT), mConstant(constant)
- {
- }
-
- ~LLScriptConstantExpression()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptConstant *mConstant;
-};
-
-// statement
-typedef enum e_lscript_statement_types
-{
- LSSMT_NULL,
- LSSMT_SEQUENCE,
- LSSMT_NOOP,
- LSSMT_STATE_CHANGE,
- LSSMT_JUMP,
- LSSMT_LABEL,
- LSSMT_RETURN,
- LSSMT_EXPRESSION,
- LSSMT_IF,
- LSSMT_IF_ELSE,
- LSSMT_FOR,
- LSSMT_DO_WHILE,
- LSSMT_WHILE,
- LSSMT_DECLARATION,
- LSSMT_COMPOUND_STATEMENT,
- LSSMT_EOF
-} LSCRIPTStatementType;
-
-class LLScriptStatement : public LLScriptFilePosition
-{
-public:
- LLScriptStatement(S32 line, S32 col, LSCRIPTStatementType type)
- : LLScriptFilePosition(line, col), mType(type), mNextp(NULL), mStatementScope(NULL), mAllowDeclarations(TRUE)
- {
- }
-
- virtual ~LLScriptStatement()
- {
- delete mStatementScope;
- }
-
- void addStatement(LLScriptStatement *event);
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
-
- void gonext(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LSCRIPTStatementType mType;
- LLScriptStatement *mNextp;
- LLScriptScope *mStatementScope;
- BOOL mAllowDeclarations;
-};
-
-class LLScriptStatementSequence : public LLScriptStatement
-{
-public:
- LLScriptStatementSequence(S32 line, S32 col, LLScriptStatement *first, LLScriptStatement *second)
- : LLScriptStatement(line, col, LSSMT_SEQUENCE), mFirstp(first), mSecondp(second)
- {
- }
-
- ~LLScriptStatementSequence()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptStatement *mFirstp;
- LLScriptStatement *mSecondp;
-};
-
-class LLScriptNOOP : public LLScriptStatement
-{
-public:
- LLScriptNOOP(S32 line, S32 col)
- : LLScriptStatement(line, col, LSSMT_NOOP)
- {
- }
-
- ~LLScriptNOOP() {}
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-};
-
-class LLScriptStateChange : public LLScriptStatement
-{
-public:
- LLScriptStateChange(S32 line, S32 col, LLScriptIdentifier *identifier)
- : LLScriptStatement(line, col, LSSMT_STATE_CHANGE), mIdentifier(identifier), mReturnType(LST_NULL)
- {
- }
-
- ~LLScriptStateChange()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptIdentifier *mIdentifier;
- LSCRIPTType mReturnType;
-};
-
-class LLScriptJump : public LLScriptStatement
-{
-public:
- LLScriptJump(S32 line, S32 col, LLScriptIdentifier *identifier)
- : LLScriptStatement(line, col, LSSMT_JUMP), mIdentifier(identifier)
- {
- }
-
- ~LLScriptJump()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptIdentifier *mIdentifier;
-};
-
-class LLScriptLabel : public LLScriptStatement
-{
-public:
- LLScriptLabel(S32 line, S32 col, LLScriptIdentifier *identifier)
- : LLScriptStatement(line, col, LSSMT_LABEL), mIdentifier(identifier)
- {
- }
-
- ~LLScriptLabel()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptIdentifier *mIdentifier;
-};
-
-class LLScriptReturn : public LLScriptStatement
-{
-public:
- LLScriptReturn(S32 line, S32 col, LLScriptExpression *expression)
- : LLScriptStatement(line, col, LSSMT_RETURN), mExpression(expression), mType(LST_NULL)
- {
- }
-
- ~LLScriptReturn()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptExpression *mExpression;
- LSCRIPTType mType;
-};
-
-class LLScriptExpressionStatement : public LLScriptStatement
-{
-public:
- LLScriptExpressionStatement(S32 line, S32 col, LLScriptExpression *expression)
- : LLScriptStatement(line, col, LSSMT_EXPRESSION), mExpression(expression)
- {
- }
-
- ~LLScriptExpressionStatement()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptExpression *mExpression;
-};
-
-class LLScriptIf : public LLScriptStatement
-{
-public:
- LLScriptIf(S32 line, S32 col, LLScriptExpression *expression, LLScriptStatement *statement)
- : LLScriptStatement(line, col, LSSMT_IF), mType(LST_NULL), mExpression(expression), mStatement(statement)
- {
- }
-
- ~LLScriptIf()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LSCRIPTType mType;
- LLScriptExpression *mExpression;
- LLScriptStatement *mStatement;
-};
-
-class LLScriptIfElse : public LLScriptStatement
-{
-public:
- LLScriptIfElse(S32 line, S32 col, LLScriptExpression *expression, LLScriptStatement *statement1, LLScriptStatement *statement2)
- : LLScriptStatement(line, col, LSSMT_IF_ELSE), mExpression(expression), mStatement1(statement1), mStatement2(statement2), mType(LST_NULL)
- {
- }
-
- ~LLScriptIfElse()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptExpression *mExpression;
- LLScriptStatement *mStatement1;
- LLScriptStatement *mStatement2;
- LSCRIPTType mType;
-};
-
-class LLScriptFor : public LLScriptStatement
-{
-public:
- LLScriptFor(S32 line, S32 col, LLScriptExpression *sequence, LLScriptExpression *expression, LLScriptExpression *expressionlist, LLScriptStatement *statement)
- : LLScriptStatement(line, col, LSSMT_FOR), mSequence(sequence), mExpression(expression), mExpressionList(expressionlist), mStatement(statement), mType(LST_NULL)
- {
- }
-
- ~LLScriptFor()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptExpression *mSequence;
- LLScriptExpression *mExpression;
- LLScriptExpression *mExpressionList;
- LLScriptStatement *mStatement;
- LSCRIPTType mType;
-};
-
-class LLScriptDoWhile : public LLScriptStatement
-{
-public:
- LLScriptDoWhile(S32 line, S32 col, LLScriptStatement *statement, LLScriptExpression *expression)
- : LLScriptStatement(line, col, LSSMT_DO_WHILE), mStatement(statement), mExpression(expression), mType(LST_NULL)
- {
- }
-
- ~LLScriptDoWhile()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptStatement *mStatement;
- LLScriptExpression *mExpression;
- LSCRIPTType mType;
-};
-
-class LLScriptWhile : public LLScriptStatement
-{
-public:
- LLScriptWhile(S32 line, S32 col, LLScriptExpression *expression, LLScriptStatement *statement)
- : LLScriptStatement(line, col, LSSMT_WHILE), mExpression(expression), mStatement(statement), mType(LST_NULL)
- {
- }
-
- ~LLScriptWhile()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptExpression *mExpression;
- LLScriptStatement *mStatement;
- LSCRIPTType mType;
-};
-
-// local variables
-class LLScriptDeclaration : public LLScriptStatement
-{
-public:
- LLScriptDeclaration(S32 line, S32 col, LLScriptType *type, LLScriptIdentifier *identifier, LLScriptExpression *expression)
- : LLScriptStatement(line, col, LSSMT_DECLARATION), mType(type), mIdentifier(identifier), mExpression(expression)
- {
- }
-
- ~LLScriptDeclaration()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptType *mType;
- LLScriptIdentifier *mIdentifier;
- LLScriptExpression *mExpression;
-};
-
-class LLScriptCompoundStatement : public LLScriptStatement
-{
-public:
- LLScriptCompoundStatement(S32 line, S32 col, LLScriptStatement *statement)
- : LLScriptStatement(line, col, LSSMT_COMPOUND_STATEMENT), mStatement(statement)
- {
- }
-
- ~LLScriptCompoundStatement()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptStatement *mStatement;
-};
-
-class LLScriptEventHandler : public LLScriptFilePosition
-{
-public:
- LLScriptEventHandler(S32 line, S32 col, LLScriptEvent *event, LLScriptStatement *statement)
- : LLScriptFilePosition(line, col), mEventp(event), mStatement(statement), mNextp(NULL), mEventScope(NULL), mbNeedTrailingReturn(FALSE), mScopeEntry(NULL), mStackSpace(0)
- {
- }
-
- ~LLScriptEventHandler()
- {
- delete mEventScope;
- delete mScopeEntry;
- }
-
- void addEvent(LLScriptEventHandler *event);
-
- void gonext(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptEvent *mEventp;
- LLScriptStatement *mStatement;
- LLScriptEventHandler *mNextp;
- LLScriptScope *mEventScope;
- BOOL mbNeedTrailingReturn;
- LLScriptScopeEntry *mScopeEntry;
-
- S32 mStackSpace;
-
-};
-
-
-// global functions
-class LLScriptFunctionDec : public LLScriptFilePosition
-{
-public:
- LLScriptFunctionDec(S32 line, S32 col, LLScriptType *type, LLScriptIdentifier *identifier)
- : LLScriptFilePosition(line, col), mType(type), mIdentifier(identifier), mNextp(NULL)
- {
- }
-
- ~LLScriptFunctionDec()
- {
- }
-
- void addFunctionParameter(LLScriptFunctionDec *dec);
-
- void gonext(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptType *mType;
- LLScriptIdentifier *mIdentifier;
- LLScriptFunctionDec *mNextp;
-};
-
-class LLScriptGlobalFunctions : public LLScriptFilePosition
-{
-public:
- LLScriptGlobalFunctions(S32 line, S32 col, LLScriptType *type,
- LLScriptIdentifier *identifier,
- LLScriptFunctionDec *parameters,
- LLScriptStatement *statements)
- : LLScriptFilePosition(line, col), mType(type), mIdentifier(identifier), mParameters(parameters), mStatements(statements), mNextp(NULL), mFunctionScope(NULL), mbNeedTrailingReturn(FALSE)
- {
- }
-
- void addGlobalFunction(LLScriptGlobalFunctions *global);
-
- ~LLScriptGlobalFunctions()
- {
- delete mFunctionScope;
- }
-
- void gonext(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LLScriptType *mType;
- LLScriptIdentifier *mIdentifier;
- LLScriptFunctionDec *mParameters;
- LLScriptStatement *mStatements;
- LLScriptGlobalFunctions *mNextp;
- LLScriptScope *mFunctionScope;
- BOOL mbNeedTrailingReturn;
-
-};
-
-typedef enum e_lscript_state_type
-{
- LSSTYPE_NULL,
- LSSTYPE_DEFAULT,
- LSSTYPE_USER,
- LSSTYPE_EOF
-} LSCRIPTStateType;
-
-// info on state
-class LLScriptState : public LLScriptFilePosition
-{
-public:
- LLScriptState(S32 line, S32 col, LSCRIPTStateType type, LLScriptIdentifier *identifier, LLScriptEventHandler *event)
- : LLScriptFilePosition(line, col), mType(type), mIdentifier(identifier), mEvent(event), mNextp(NULL), mStateScope(NULL)
- {
- }
-
- void addState(LLScriptState *state);
-
- ~LLScriptState()
- {
- }
-
- void gonext(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- LSCRIPTStateType mType;
- LLScriptIdentifier *mIdentifier;
- LLScriptEventHandler *mEvent;
- LLScriptState *mNextp;
- LLScriptScope *mStateScope;
-};
-
-class LLScritpGlobalStorage : public LLScriptFilePosition
-{
-public:
-
- LLScritpGlobalStorage(LLScriptGlobalVariable *var)
- : LLScriptFilePosition(0, 0), mGlobal(var), mbGlobalFunction(FALSE), mNextp(NULL)
- {
- }
-
- LLScritpGlobalStorage(LLScriptGlobalFunctions *func)
- : LLScriptFilePosition(0, 0), mGlobal(func), mbGlobalFunction(TRUE), mNextp(NULL)
- {
- }
-
- ~LLScritpGlobalStorage()
- {
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- }
-
- S32 getSize()
- {
- return 0;
- }
-
- void addGlobal(LLScritpGlobalStorage *global)
- {
- if (mNextp)
- {
- global->mNextp = mNextp;
- }
- mNextp = global;
- }
-
- LLScriptFilePosition *mGlobal;
- BOOL mbGlobalFunction;
- LLScritpGlobalStorage *mNextp;
-};
-
-// top level container for entire script
-class LLScriptScript : public LLScriptFilePosition
-{
-public:
- LLScriptScript(LLScritpGlobalStorage *globals,
- LLScriptState *states);
-
- ~LLScriptScript()
- {
- delete mGlobalScope;
- }
-
- void recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata);
- S32 getSize();
-
- void setBytecodeDest(const char* dst_filename);
-
- void setClassName(const char* class_name);
- const char* getClassName() {return mClassName;}
-
- LLScriptState *mStates;
- LLScriptScope *mGlobalScope;
- LLScriptGlobalVariable *mGlobals;
- LLScriptGlobalFunctions *mGlobalFunctions;
- BOOL mGodLike;
-
-private:
- std::string mBytecodeDest;
- char mClassName[MAX_STRING];
-};
-
-class LLScriptAllocationManager
-{
-public:
- LLScriptAllocationManager() {}
- ~LLScriptAllocationManager()
- {
- deleteAllocations();
- }
-
- void addAllocation(LLScriptFilePosition *ptr)
- {
- mAllocationList.push_front(ptr);
- }
-
- void deleteAllocations()
- {
- delete_and_clear(mAllocationList);
- }
-
- std::list<LLScriptFilePosition*> mAllocationList;
-};
-
-extern LLScriptAllocationManager *gAllocationManager;
-extern LLScriptScript *gScriptp;
-
-#endif
diff --git a/indra/lscript/lscript_compile/lscript_typecheck.cpp b/indra/lscript/lscript_compile/lscript_typecheck.cpp
deleted file mode 100755
index c685621538..0000000000
--- a/indra/lscript/lscript_compile/lscript_typecheck.cpp
+++ /dev/null
@@ -1,586 +0,0 @@
-/**
- * @file lscript_typecheck.cpp
- * @brief typechecks script
- *
- * $LicenseInfo:firstyear=2002&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#include "linden_common.h"
-
-#include "lscript_tree.h"
-
-/*
- LScript automatic type casting
-
- LST_INTEGER -> LST_INTEGER
-
- LST_FLOATINGPOINT -> LST_FLOATINGPOINT
- LST_INTEGER -> LST_FLOATINGPOINT
-
- LST_FLOATINGPOINT -> LST_STRING
- LST_INTEGER -> LST_STRING
- LST_STRING -> LST_STRING
- LST_VECTOR -> LST_STRING
- LST_QUATERNION -> LST_STRING
- LST_LIST -> LST_STRING
-
- LST_VECTOR -> LST_VECTOR
-
- LST_QUATERNION -> LST_QUATERNION
-
- LST_FLOATINGPOINT -> LST_LIST
- LST_INTEGER -> LST_LIST
- LST_STRING -> LST_LIST
- LST_VECTOR -> LST_LIST
- LST_QUATERNION -> LST_LIST
- LST_LIST -> LST_LIST
-*/
-
-LSCRIPTType implicit_casts(LSCRIPTType left_side, LSCRIPTType right_side)
-{
- switch(left_side)
- {
- // shouldn't be doing an operation on void types
- case LST_NULL:
- switch(right_side)
- {
- case LST_NULL:
- return LST_NULL;
- default:
- return LST_UNDEFINED;
- }
- // shouldn't be doing an operation on undefined types
- case LST_UNDEFINED:
- return LST_UNDEFINED;
- // only integers can become integers
- case LST_INTEGER:
- switch(right_side)
- {
- case LST_INTEGER:
- return LST_INTEGER;
- default:
- return LST_UNDEFINED;
- }
- // only integers and floats can become floats
- case LST_FLOATINGPOINT:
- switch(right_side)
- {
- case LST_INTEGER:
- case LST_FLOATINGPOINT:
- return LST_FLOATINGPOINT;
- default:
- return LST_UNDEFINED;
- }
- // only strings and keys can become strings
- case LST_STRING:
- switch(right_side)
- {
- case LST_STRING:
- case LST_KEY:
- return LST_STRING;
- default:
- return LST_UNDEFINED;
- }
- // only strings and keys can become keys
- case LST_KEY:
- switch(right_side)
- {
- case LST_STRING:
- case LST_KEY:
- return LST_KEY;
- default:
- return LST_UNDEFINED;
- }
- // only vectors can become vectors
- case LST_VECTOR:
- switch(right_side)
- {
- case LST_VECTOR:
- return LST_VECTOR;
- default:
- return LST_UNDEFINED;
- }
- // only quaternions can become quaternions
- case LST_QUATERNION:
- switch(right_side)
- {
- case LST_QUATERNION:
- return LST_QUATERNION;
- default:
- return LST_UNDEFINED;
- }
- // only lists can become lists
- case LST_LIST:
- switch(right_side)
- {
- case LST_LIST:
- return LST_LIST;
- default:
- return LST_UNDEFINED;
- }
- default:
- return LST_UNDEFINED;
- }
-}
-
-LSCRIPTType promote(LSCRIPTType left_side, LSCRIPTType right_side)
-{
- LSCRIPTType type;
- type = implicit_casts(left_side, right_side);
- if (type != LST_UNDEFINED)
- {
- return type;
- }
- type = implicit_casts(right_side, left_side);
- if (type != LST_UNDEFINED)
- {
- return type;
- }
- return LST_UNDEFINED;
-}
-
-BOOL legal_assignment(LSCRIPTType left_side, LSCRIPTType right_side)
-{
- // this is to prevent cascading errors
- if ( (left_side == LST_UNDEFINED)
- ||(right_side == LST_UNDEFINED))
- {
- return TRUE;
- }
-
- if (implicit_casts(left_side, right_side) != LST_UNDEFINED)
- {
- return TRUE;
- }
- else
- {
- return FALSE;
- }
-}
-
-BOOL legal_casts(LSCRIPTType cast, LSCRIPTType base)
-{
- switch(base)
- {
- // shouldn't be doing an operation on void types
- case LST_NULL:
- return FALSE;
- // shouldn't be doing an operation on undefined types
- case LST_UNDEFINED:
- return FALSE;
- case LST_INTEGER:
- switch(cast)
- {
- case LST_INTEGER:
- case LST_FLOATINGPOINT:
- case LST_STRING:
- case LST_LIST:
- return TRUE;
- break;
- default:
- return FALSE;
- break;
- }
- break;
- case LST_FLOATINGPOINT:
- switch(cast)
- {
- case LST_INTEGER:
- case LST_FLOATINGPOINT:
- case LST_STRING:
- case LST_LIST:
- return TRUE;
- break;
- default:
- return FALSE;
- break;
- }
- break;
- case LST_STRING:
- switch(cast)
- {
- case LST_INTEGER:
- case LST_FLOATINGPOINT:
- case LST_STRING:
- case LST_KEY:
- case LST_VECTOR:
- case LST_QUATERNION:
- case LST_LIST:
- return TRUE;
- break;
- default:
- return FALSE;
- break;
- }
- break;
- case LST_KEY:
- switch(cast)
- {
- case LST_STRING:
- case LST_KEY:
- case LST_LIST:
- return TRUE;
- break;
- default:
- return FALSE;
- break;
- }
- break;
- case LST_VECTOR:
- switch(cast)
- {
- case LST_VECTOR:
- case LST_STRING:
- case LST_LIST:
- return TRUE;
- break;
- default:
- return FALSE;
- break;
- }
- break;
- case LST_QUATERNION:
- switch(cast)
- {
- case LST_QUATERNION:
- case LST_STRING:
- case LST_LIST:
- return TRUE;
- break;
- default:
- return FALSE;
- break;
- }
- break;
- // lists can only be cast to lists and strings
- case LST_LIST:
- switch(cast)
- {
- case LST_LIST:
- case LST_STRING:
- return TRUE;
- break;
- default:
- return FALSE;
- break;
- }
- break;
- default:
- return FALSE;
- break;
- }
-}
-
-LSCRIPTType gSupportedExpressionArray[LET_EOF][LST_EOF][LST_EOF];
-
-void init_supported_expressions(void)
-{
- S32 i, j, k;
- // zero out, then set the ones that matter
- for (i = 0; i < LET_EOF; i++)
- {
- for (j = 0; j < LST_EOF; j++)
- {
- for (k = 0; k < LST_EOF; k++)
- {
- gSupportedExpressionArray[i][j][k] = LST_NULL;
- }
- }
- }
-
- // LET_ASSIGNMENT
- gSupportedExpressionArray[LET_ASSIGNMENT][LST_INTEGER][LST_INTEGER] = LST_INTEGER;
- gSupportedExpressionArray[LET_ASSIGNMENT][LST_FLOATINGPOINT][LST_INTEGER] = LST_FLOATINGPOINT;
- gSupportedExpressionArray[LET_ASSIGNMENT][LST_INTEGER][LST_FLOATINGPOINT] = LST_FLOATINGPOINT;
- gSupportedExpressionArray[LET_ASSIGNMENT][LST_FLOATINGPOINT][LST_FLOATINGPOINT] = LST_FLOATINGPOINT;
- gSupportedExpressionArray[LET_ASSIGNMENT][LST_STRING][LST_STRING] = LST_STRING;
- gSupportedExpressionArray[LET_ASSIGNMENT][LST_KEY][LST_KEY] = LST_KEY;
- gSupportedExpressionArray[LET_ASSIGNMENT][LST_VECTOR][LST_VECTOR] = LST_VECTOR;
- gSupportedExpressionArray[LET_ASSIGNMENT][LST_QUATERNION][LST_QUATERNION] = LST_QUATERNION;
- gSupportedExpressionArray[LET_ASSIGNMENT][LST_LIST][LST_INTEGER] = LST_LIST;
- gSupportedExpressionArray[LET_ASSIGNMENT][LST_LIST][LST_FLOATINGPOINT] = LST_LIST;
- gSupportedExpressionArray[LET_ASSIGNMENT][LST_LIST][LST_STRING] = LST_LIST;
- gSupportedExpressionArray[LET_ASSIGNMENT][LST_LIST][LST_KEY] = LST_LIST;
- gSupportedExpressionArray[LET_ASSIGNMENT][LST_LIST][LST_VECTOR] = LST_LIST;
- gSupportedExpressionArray[LET_ASSIGNMENT][LST_LIST][LST_QUATERNION] = LST_LIST;
- gSupportedExpressionArray[LET_ASSIGNMENT][LST_LIST][LST_LIST] = LST_LIST;
-
- // LET_ADD_ASSIGN
- gSupportedExpressionArray[LET_ADD_ASSIGN][LST_INTEGER][LST_INTEGER] = LST_INTEGER;
- gSupportedExpressionArray[LET_ADD_ASSIGN][LST_FLOATINGPOINT][LST_INTEGER] = LST_FLOATINGPOINT;
- gSupportedExpressionArray[LET_ADD_ASSIGN][LST_FLOATINGPOINT][LST_FLOATINGPOINT] = LST_FLOATINGPOINT;
- gSupportedExpressionArray[LET_ADD_ASSIGN][LST_STRING][LST_STRING] = LST_STRING;
- gSupportedExpressionArray[LET_ADD_ASSIGN][LST_VECTOR][LST_VECTOR] = LST_VECTOR;
- gSupportedExpressionArray[LET_ADD_ASSIGN][LST_QUATERNION][LST_QUATERNION] = LST_QUATERNION;
- gSupportedExpressionArray[LET_ADD_ASSIGN][LST_LIST][LST_INTEGER] = LST_LIST;
- gSupportedExpressionArray[LET_ADD_ASSIGN][LST_LIST][LST_FLOATINGPOINT] = LST_LIST;
- gSupportedExpressionArray[LET_ADD_ASSIGN][LST_LIST][LST_STRING] = LST_LIST;
- gSupportedExpressionArray[LET_ADD_ASSIGN][LST_LIST][LST_KEY] = LST_LIST;
- gSupportedExpressionArray[LET_ADD_ASSIGN][LST_LIST][LST_VECTOR] = LST_LIST;
- gSupportedExpressionArray[LET_ADD_ASSIGN][LST_LIST][LST_QUATERNION] = LST_LIST;
- gSupportedExpressionArray[LET_ADD_ASSIGN][LST_LIST][LST_LIST] = LST_LIST;
-
- // LET_SUB_ASSIGN
- gSupportedExpressionArray[LET_SUB_ASSIGN][LST_INTEGER][LST_INTEGER] = LST_INTEGER;
- gSupportedExpressionArray[LET_SUB_ASSIGN][LST_FLOATINGPOINT][LST_INTEGER] = LST_FLOATINGPOINT;
- gSupportedExpressionArray[LET_SUB_ASSIGN][LST_FLOATINGPOINT][LST_FLOATINGPOINT] = LST_FLOATINGPOINT;
- gSupportedExpressionArray[LET_SUB_ASSIGN][LST_VECTOR][LST_VECTOR] = LST_VECTOR;
- gSupportedExpressionArray[LET_SUB_ASSIGN][LST_QUATERNION][LST_QUATERNION] = LST_QUATERNION;
-
- // LET_MUL_ASSIGN
- gSupportedExpressionArray[LET_MUL_ASSIGN][LST_INTEGER][LST_INTEGER] = LST_INTEGER;
- gSupportedExpressionArray[LET_MUL_ASSIGN][LST_FLOATINGPOINT][LST_INTEGER] = LST_FLOATINGPOINT;
- gSupportedExpressionArray[LET_MUL_ASSIGN][LST_INTEGER][LST_FLOATINGPOINT] = LST_FLOATINGPOINT;
- gSupportedExpressionArray[LET_MUL_ASSIGN][LST_FLOATINGPOINT][LST_FLOATINGPOINT] = LST_FLOATINGPOINT;
- gSupportedExpressionArray[LET_MUL_ASSIGN][LST_VECTOR][LST_INTEGER] = LST_VECTOR;
- //gSupportedExpressionArray[LET_MUL_ASSIGN][LST_INTEGER][LST_VECTOR] = LST_VECTOR;
- gSupportedExpressionArray[LET_MUL_ASSIGN][LST_VECTOR][LST_FLOATINGPOINT] = LST_VECTOR;
- //gSupportedExpressionArray[LET_MUL_ASSIGN][LST_FLOATINGPOINT][LST_VECTOR] = LST_VECTOR;
- //gSupportedExpressionArray[LET_MUL_ASSIGN][LST_VECTOR][LST_VECTOR] = LST_FLOATINGPOINT;
- gSupportedExpressionArray[LET_MUL_ASSIGN][LST_VECTOR][LST_QUATERNION] = LST_VECTOR;
- gSupportedExpressionArray[LET_MUL_ASSIGN][LST_QUATERNION][LST_QUATERNION] = LST_QUATERNION;
-
- // LET_DIV_ASSIGN
- gSupportedExpressionArray[LET_DIV_ASSIGN][LST_INTEGER][LST_INTEGER] = LST_INTEGER;
- gSupportedExpressionArray[LET_DIV_ASSIGN][LST_FLOATINGPOINT][LST_INTEGER] = LST_FLOATINGPOINT;
- gSupportedExpressionArray[LET_DIV_ASSIGN][LST_FLOATINGPOINT][LST_FLOATINGPOINT] = LST_FLOATINGPOINT;
- gSupportedExpressionArray[LET_DIV_ASSIGN][LST_VECTOR][LST_INTEGER] = LST_VECTOR;
- gSupportedExpressionArray[LET_DIV_ASSIGN][LST_VECTOR][LST_FLOATINGPOINT] = LST_VECTOR;
- gSupportedExpressionArray[LET_DIV_ASSIGN][LST_VECTOR][LST_QUATERNION] = LST_VECTOR;
- gSupportedExpressionArray[LET_DIV_ASSIGN][LST_QUATERNION][LST_QUATERNION] = LST_QUATERNION;
-
- // LET_MOD_ASSIGN
- gSupportedExpressionArray[LET_MOD_ASSIGN][LST_INTEGER][LST_INTEGER] = LST_INTEGER;
- gSupportedExpressionArray[LET_MOD_ASSIGN][LST_VECTOR][LST_VECTOR] = LST_VECTOR;
-
- // LET_EQUALITY
- gSupportedExpressionArray[LET_EQUALITY][LST_INTEGER][LST_INTEGER] = LST_INTEGER;
- gSupportedExpressionArray[LET_EQUALITY][LST_INTEGER][LST_FLOATINGPOINT] = LST_INTEGER;
- gSupportedExpressionArray[LET_EQUALITY][LST_FLOATINGPOINT][LST_INTEGER] = LST_INTEGER;
- gSupportedExpressionArray[LET_EQUALITY][LST_FLOATINGPOINT][LST_FLOATINGPOINT] = LST_INTEGER;
- gSupportedExpressionArray[LET_EQUALITY][LST_STRING][LST_STRING] = LST_INTEGER;
- gSupportedExpressionArray[LET_EQUALITY][LST_STRING][LST_KEY] = LST_INTEGER;
- gSupportedExpressionArray[LET_EQUALITY][LST_KEY][LST_STRING] = LST_INTEGER;
- gSupportedExpressionArray[LET_EQUALITY][LST_KEY][LST_KEY] = LST_INTEGER;
- gSupportedExpressionArray[LET_EQUALITY][LST_VECTOR][LST_VECTOR] = LST_INTEGER;
- gSupportedExpressionArray[LET_EQUALITY][LST_QUATERNION][LST_QUATERNION] = LST_INTEGER;
- gSupportedExpressionArray[LET_EQUALITY][LST_LIST][LST_LIST] = LST_INTEGER;
-
- // LET_NOT_EQUALS
- gSupportedExpressionArray[LET_NOT_EQUALS][LST_INTEGER][LST_INTEGER] = LST_INTEGER;
- gSupportedExpressionArray[LET_NOT_EQUALS][LST_INTEGER][LST_FLOATINGPOINT] = LST_INTEGER;
- gSupportedExpressionArray[LET_NOT_EQUALS][LST_FLOATINGPOINT][LST_INTEGER] = LST_INTEGER;
- gSupportedExpressionArray[LET_NOT_EQUALS][LST_FLOATINGPOINT][LST_FLOATINGPOINT] = LST_INTEGER;
- gSupportedExpressionArray[LET_NOT_EQUALS][LST_STRING][LST_STRING] = LST_INTEGER;
- gSupportedExpressionArray[LET_NOT_EQUALS][LST_STRING][LST_KEY] = LST_INTEGER;
- gSupportedExpressionArray[LET_NOT_EQUALS][LST_KEY][LST_STRING] = LST_INTEGER;
- gSupportedExpressionArray[LET_NOT_EQUALS][LST_KEY][LST_KEY] = LST_INTEGER;
- gSupportedExpressionArray[LET_NOT_EQUALS][LST_VECTOR][LST_VECTOR] = LST_INTEGER;
- gSupportedExpressionArray[LET_NOT_EQUALS][LST_QUATERNION][LST_QUATERNION] = LST_INTEGER;
- gSupportedExpressionArray[LET_NOT_EQUALS][LST_LIST][LST_LIST] = LST_INTEGER;
-
- // LET_LESS_EQUALS
- gSupportedExpressionArray[LET_LESS_EQUALS][LST_INTEGER][LST_INTEGER] = LST_INTEGER;
- gSupportedExpressionArray[LET_LESS_EQUALS][LST_INTEGER][LST_FLOATINGPOINT] = LST_INTEGER;
- gSupportedExpressionArray[LET_LESS_EQUALS][LST_FLOATINGPOINT][LST_INTEGER] = LST_INTEGER;
- gSupportedExpressionArray[LET_LESS_EQUALS][LST_FLOATINGPOINT][LST_FLOATINGPOINT] = LST_INTEGER;
-
- // LET_GREATER_EQUALS
- gSupportedExpressionArray[LET_GREATER_EQUALS][LST_INTEGER][LST_INTEGER] = LST_INTEGER;
- gSupportedExpressionArray[LET_GREATER_EQUALS][LST_INTEGER][LST_FLOATINGPOINT] = LST_INTEGER;
- gSupportedExpressionArray[LET_GREATER_EQUALS][LST_FLOATINGPOINT][LST_INTEGER] = LST_INTEGER;
- gSupportedExpressionArray[LET_GREATER_EQUALS][LST_FLOATINGPOINT][LST_FLOATINGPOINT] = LST_INTEGER;
-
- // LET_LESS_THAN
- gSupportedExpressionArray[LET_LESS_THAN][LST_INTEGER][LST_INTEGER] = LST_INTEGER;
- gSupportedExpressionArray[LET_LESS_THAN][LST_INTEGER][LST_FLOATINGPOINT] = LST_INTEGER;
- gSupportedExpressionArray[LET_LESS_THAN][LST_FLOATINGPOINT][LST_INTEGER] = LST_INTEGER;
- gSupportedExpressionArray[LET_LESS_THAN][LST_FLOATINGPOINT][LST_FLOATINGPOINT] = LST_INTEGER;
-
- // LET_GREATER_THAN
- gSupportedExpressionArray[LET_GREATER_THAN][LST_INTEGER][LST_INTEGER] = LST_INTEGER;
- gSupportedExpressionArray[LET_GREATER_THAN][LST_INTEGER][LST_FLOATINGPOINT] = LST_INTEGER;
- gSupportedExpressionArray[LET_GREATER_THAN][LST_FLOATINGPOINT][LST_INTEGER] = LST_INTEGER;
- gSupportedExpressionArray[LET_GREATER_THAN][LST_FLOATINGPOINT][LST_FLOATINGPOINT] = LST_INTEGER;
-
- // LET_PLUS
- gSupportedExpressionArray[LET_PLUS][LST_INTEGER][LST_INTEGER] = LST_INTEGER;
- gSupportedExpressionArray[LET_PLUS][LST_FLOATINGPOINT][LST_INTEGER] = LST_FLOATINGPOINT;
- gSupportedExpressionArray[LET_PLUS][LST_INTEGER][LST_FLOATINGPOINT] = LST_FLOATINGPOINT;
- gSupportedExpressionArray[LET_PLUS][LST_FLOATINGPOINT][LST_FLOATINGPOINT] = LST_FLOATINGPOINT;
- gSupportedExpressionArray[LET_PLUS][LST_STRING][LST_STRING] = LST_STRING;
- gSupportedExpressionArray[LET_PLUS][LST_VECTOR][LST_VECTOR] = LST_VECTOR;
- gSupportedExpressionArray[LET_PLUS][LST_QUATERNION][LST_QUATERNION] = LST_QUATERNION;
- gSupportedExpressionArray[LET_PLUS][LST_LIST][LST_INTEGER] = LST_LIST;
- gSupportedExpressionArray[LET_PLUS][LST_LIST][LST_FLOATINGPOINT] = LST_LIST;
- gSupportedExpressionArray[LET_PLUS][LST_LIST][LST_STRING] = LST_LIST;
- gSupportedExpressionArray[LET_PLUS][LST_LIST][LST_KEY] = LST_LIST;
- gSupportedExpressionArray[LET_PLUS][LST_LIST][LST_VECTOR] = LST_LIST;
- gSupportedExpressionArray[LET_PLUS][LST_LIST][LST_QUATERNION] = LST_LIST;
- gSupportedExpressionArray[LET_PLUS][LST_INTEGER][LST_LIST] = LST_LIST;
- gSupportedExpressionArray[LET_PLUS][LST_FLOATINGPOINT][LST_LIST] = LST_LIST;
- gSupportedExpressionArray[LET_PLUS][LST_STRING][LST_LIST] = LST_LIST;
- gSupportedExpressionArray[LET_PLUS][LST_KEY][LST_LIST] = LST_LIST;
- gSupportedExpressionArray[LET_PLUS][LST_VECTOR][LST_LIST] = LST_LIST;
- gSupportedExpressionArray[LET_PLUS][LST_QUATERNION][LST_LIST] = LST_LIST;
- gSupportedExpressionArray[LET_PLUS][LST_LIST][LST_LIST] = LST_LIST;
-
- // LET_MINUS
- gSupportedExpressionArray[LET_MINUS][LST_INTEGER][LST_INTEGER] = LST_INTEGER;
- gSupportedExpressionArray[LET_MINUS][LST_FLOATINGPOINT][LST_INTEGER] = LST_FLOATINGPOINT;
- gSupportedExpressionArray[LET_MINUS][LST_INTEGER][LST_FLOATINGPOINT] = LST_FLOATINGPOINT;
- gSupportedExpressionArray[LET_MINUS][LST_FLOATINGPOINT][LST_FLOATINGPOINT] = LST_FLOATINGPOINT;
- gSupportedExpressionArray[LET_MINUS][LST_VECTOR][LST_VECTOR] = LST_VECTOR;
- gSupportedExpressionArray[LET_MINUS][LST_QUATERNION][LST_QUATERNION] = LST_QUATERNION;
-
- // LET_TIMES
- gSupportedExpressionArray[LET_TIMES][LST_INTEGER][LST_INTEGER] = LST_INTEGER;
- gSupportedExpressionArray[LET_TIMES][LST_FLOATINGPOINT][LST_INTEGER] = LST_FLOATINGPOINT;
- gSupportedExpressionArray[LET_TIMES][LST_INTEGER][LST_FLOATINGPOINT] = LST_FLOATINGPOINT;
- gSupportedExpressionArray[LET_TIMES][LST_FLOATINGPOINT][LST_FLOATINGPOINT] = LST_FLOATINGPOINT;
- gSupportedExpressionArray[LET_TIMES][LST_VECTOR][LST_INTEGER] = LST_VECTOR;
- gSupportedExpressionArray[LET_TIMES][LST_INTEGER][LST_VECTOR] = LST_VECTOR;
- gSupportedExpressionArray[LET_TIMES][LST_VECTOR][LST_FLOATINGPOINT] = LST_VECTOR;
- gSupportedExpressionArray[LET_TIMES][LST_FLOATINGPOINT][LST_VECTOR] = LST_VECTOR;
- gSupportedExpressionArray[LET_TIMES][LST_VECTOR][LST_VECTOR] = LST_FLOATINGPOINT;
- gSupportedExpressionArray[LET_TIMES][LST_VECTOR][LST_QUATERNION] = LST_VECTOR;
- gSupportedExpressionArray[LET_TIMES][LST_QUATERNION][LST_QUATERNION] = LST_QUATERNION;
-
- // LET_DIVIDE
- gSupportedExpressionArray[LET_DIVIDE][LST_INTEGER][LST_INTEGER] = LST_INTEGER;
- gSupportedExpressionArray[LET_DIVIDE][LST_INTEGER][LST_FLOATINGPOINT] = LST_FLOATINGPOINT;
- gSupportedExpressionArray[LET_DIVIDE][LST_FLOATINGPOINT][LST_INTEGER] = LST_FLOATINGPOINT;
- gSupportedExpressionArray[LET_DIVIDE][LST_FLOATINGPOINT][LST_FLOATINGPOINT] = LST_FLOATINGPOINT;
- gSupportedExpressionArray[LET_DIVIDE][LST_VECTOR][LST_INTEGER] = LST_VECTOR;
- gSupportedExpressionArray[LET_DIVIDE][LST_VECTOR][LST_FLOATINGPOINT] = LST_VECTOR;
- gSupportedExpressionArray[LET_DIVIDE][LST_VECTOR][LST_QUATERNION] = LST_VECTOR;
- gSupportedExpressionArray[LET_DIVIDE][LST_QUATERNION][LST_QUATERNION] = LST_QUATERNION;
-
- // LET_MOD
- gSupportedExpressionArray[LET_MOD][LST_INTEGER][LST_INTEGER] = LST_INTEGER;
- gSupportedExpressionArray[LET_MOD][LST_VECTOR][LST_VECTOR] = LST_VECTOR;
-
- // LET_BIT_AND
- gSupportedExpressionArray[LET_BIT_AND][LST_INTEGER][LST_INTEGER] = LST_INTEGER;
-
- // LET_BIT_OR
- gSupportedExpressionArray[LET_BIT_OR][LST_INTEGER][LST_INTEGER] = LST_INTEGER;
-
- // LET_BIT_XOR
- gSupportedExpressionArray[LET_BIT_XOR][LST_INTEGER][LST_INTEGER] = LST_INTEGER;
-
- // LET_BOOLEAN_AND
- gSupportedExpressionArray[LET_BOOLEAN_AND][LST_INTEGER][LST_INTEGER] = LST_INTEGER;
-
- // LET_BOOLEAN_OR
- gSupportedExpressionArray[LET_BOOLEAN_OR][LST_INTEGER][LST_INTEGER] = LST_INTEGER;
-
- // LET_SHIFT_LEFT
- gSupportedExpressionArray[LET_SHIFT_LEFT][LST_INTEGER][LST_INTEGER] = LST_INTEGER;
-
- // LET_SHIFT_RIGHT
- gSupportedExpressionArray[LET_SHIFT_RIGHT][LST_INTEGER][LST_INTEGER] = LST_INTEGER;
-
- // LET_PARENTHESIS
- gSupportedExpressionArray[LET_PARENTHESIS][LST_INTEGER][LST_NULL] = LST_INTEGER;
- gSupportedExpressionArray[LET_PARENTHESIS][LST_FLOATINGPOINT][LST_NULL] = LST_INTEGER;
- gSupportedExpressionArray[LET_PARENTHESIS][LST_STRING][LST_NULL] = LST_INTEGER;
- gSupportedExpressionArray[LET_PARENTHESIS][LST_LIST][LST_NULL] = LST_INTEGER;
-
- // LET_UNARY_MINUS
- gSupportedExpressionArray[LET_UNARY_MINUS][LST_INTEGER][LST_NULL] = LST_INTEGER;
- gSupportedExpressionArray[LET_UNARY_MINUS][LST_FLOATINGPOINT][LST_NULL] = LST_FLOATINGPOINT;
- gSupportedExpressionArray[LET_UNARY_MINUS][LST_VECTOR][LST_NULL] = LST_VECTOR;
- gSupportedExpressionArray[LET_UNARY_MINUS][LST_QUATERNION][LST_NULL] = LST_QUATERNION;
-
- // LET_BOOLEAN_NOT
- gSupportedExpressionArray[LET_BOOLEAN_NOT][LST_INTEGER][LST_NULL] = LST_INTEGER;
-
- // LET_BIT_NOT
- gSupportedExpressionArray[LET_BIT_NOT][LST_INTEGER][LST_NULL] = LST_INTEGER;
-
- // LET_PRE_INCREMENT
- gSupportedExpressionArray[LET_PRE_INCREMENT][LST_INTEGER][LST_NULL] = LST_INTEGER;
- gSupportedExpressionArray[LET_PRE_INCREMENT][LST_FLOATINGPOINT][LST_NULL] = LST_FLOATINGPOINT;
-
- // LET_PRE_DECREMENT
- gSupportedExpressionArray[LET_PRE_DECREMENT][LST_INTEGER][LST_NULL] = LST_INTEGER;
- gSupportedExpressionArray[LET_PRE_DECREMENT][LST_FLOATINGPOINT][LST_NULL] = LST_FLOATINGPOINT;
-
- // LET_POST_INCREMENT
- gSupportedExpressionArray[LET_POST_INCREMENT][LST_INTEGER][LST_NULL] = LST_INTEGER;
- gSupportedExpressionArray[LET_POST_INCREMENT][LST_FLOATINGPOINT][LST_NULL] = LST_FLOATINGPOINT;
-
- // LET_POST_DECREMENT
- gSupportedExpressionArray[LET_POST_DECREMENT][LST_INTEGER][LST_NULL] = LST_INTEGER;
- gSupportedExpressionArray[LET_POST_DECREMENT][LST_FLOATINGPOINT][LST_NULL] = LST_FLOATINGPOINT;
-}
-
-BOOL legal_binary_expression(LSCRIPTType &result, LSCRIPTType left_side, LSCRIPTType right_side, LSCRIPTExpressionType expression)
-{
- if ( (left_side == LST_UNDEFINED)
- ||(right_side == LST_UNDEFINED))
- {
- result = LST_UNDEFINED;
- return TRUE;
- }
-
- if ( (left_side == LST_NULL)
- ||(right_side == LST_NULL))
- {
- result = LST_UNDEFINED;
- return FALSE;
- }
-
- result = gSupportedExpressionArray[expression][left_side][right_side];
- if (result)
- return TRUE;
- else
- {
- result = LST_UNDEFINED;
- return FALSE;
- }
-}
-
-BOOL legal_unary_expression(LSCRIPTType &result, LSCRIPTType left_side, LSCRIPTExpressionType expression)
-{
- if (left_side == LST_UNDEFINED)
- {
- result = LST_UNDEFINED;
- return TRUE;
- }
-
- if (left_side == LST_NULL)
- {
- result = LST_UNDEFINED;
- return FALSE;
- }
-
- result = gSupportedExpressionArray[expression][left_side][LST_NULL];
- if (result)
- return TRUE;
- else
- {
- result = LST_UNDEFINED;
- return FALSE;
- }
-}
diff --git a/indra/lscript/lscript_compile/lscript_typecheck.h b/indra/lscript/lscript_compile/lscript_typecheck.h
deleted file mode 100755
index 74f723506f..0000000000
--- a/indra/lscript/lscript_compile/lscript_typecheck.h
+++ /dev/null
@@ -1,118 +0,0 @@
-/**
- * @file lscript_typecheck.h
- * @brief typechecks script
- *
- * $LicenseInfo:firstyear=2002&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#ifndef LL_LSCRIPT_TYPECHECK_H
-#define LL_LSCRIPT_TYPECHECK_H
-
-#include "lscript_error.h"
-
-LSCRIPTType implicit_casts(LSCRIPTType left_side, LSCRIPTType right_side);
-BOOL legal_casts(LSCRIPTType cast, LSCRIPTType base);
-LSCRIPTType promote(LSCRIPTType left_side, LSCRIPTType right_side);
-BOOL legal_assignment(LSCRIPTType left_side, LSCRIPTType right_side);
-
-typedef enum e_lscript_expression_types
-{
- LET_NULL,
- LET_ASSIGNMENT,
- LET_ADD_ASSIGN,
- LET_SUB_ASSIGN,
- LET_MUL_ASSIGN,
- LET_DIV_ASSIGN,
- LET_MOD_ASSIGN,
- LET_EQUALITY,
- LET_NOT_EQUALS,
- LET_LESS_EQUALS,
- LET_GREATER_EQUALS,
- LET_LESS_THAN,
- LET_GREATER_THAN,
- LET_PLUS,
- LET_MINUS,
- LET_TIMES,
- LET_DIVIDE,
- LET_MOD,
- LET_BIT_AND,
- LET_BIT_OR,
- LET_BIT_XOR,
- LET_BOOLEAN_AND,
- LET_BOOLEAN_OR,
- LET_PARENTHESIS,
- LET_UNARY_MINUS,
- LET_BOOLEAN_NOT,
- LET_BIT_NOT,
- LET_PRE_INCREMENT,
- LET_PRE_DECREMENT,
- LET_CAST,
- LET_VECTOR_INITIALIZER,
- LET_QUATERNION_INITIALIZER,
- LET_LIST_INITIALIZER,
- LET_LVALUE,
- LET_POST_INCREMENT,
- LET_POST_DECREMENT,
- LET_FUNCTION_CALL,
- LET_CONSTANT,
- LET_FOR_EXPRESSION_LIST,
- LET_FUNC_EXPRESSION_LIST,
- LET_LIST_EXPRESSION_LIST,
- LET_PRINT,
- LET_SHIFT_LEFT,
- LET_SHIFT_RIGHT,
- LET_EOF
-} LSCRIPTExpressionType;
-
-BOOL legal_binary_expression(LSCRIPTType &result, LSCRIPTType left_side, LSCRIPTType right_side, LSCRIPTExpressionType expression);
-BOOL legal_unary_expression(LSCRIPTType &result, LSCRIPTType left_side, LSCRIPTExpressionType expression);
-
-void init_supported_expressions(void);
-
-/*
- LScript automatic type casting
-
- LST_INTEGER -> LST_INTEGER
-
- LST_FLOATINGPOINT -> LST_FLOATINGPOINT
- LST_INTEGER -> LST_FLOATINGPOINT
-
- LST_FLOATINGPOINT -> LST_STRING
- LST_INTEGER -> LST_STRING
- LST_STRING -> LST_STRING
- LST_VECTOR -> LST_STRING
- LST_QUATERNION -> LST_STRING
- LST_LIST -> LST_STRING
-
- LST_VECTOR -> LST_VECTOR
-
- LST_QUATERNION -> LST_QUATERNION
-
- LST_FLOATINGPOINT -> LST_LIST
- LST_INTEGER -> LST_LIST
- LST_STRING -> LST_LIST
- LST_VECTOR -> LST_LIST
- LST_QUATERNION -> LST_LIST
- LST_LIST -> LST_LIST
-*/
-
-#endif
diff --git a/indra/lscript/lscript_compile/windows/unistd.h b/indra/lscript/lscript_compile/windows/unistd.h
deleted file mode 100755
index 0b7e2581e3..0000000000
--- a/indra/lscript/lscript_compile/windows/unistd.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/**
- * $LicenseInfo:firstyear=2002&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-/* After all that, this file is empty. */
diff --git a/indra/lscript/lscript_execute.h b/indra/lscript/lscript_execute.h
deleted file mode 100755
index 576c2ca2b7..0000000000
--- a/indra/lscript/lscript_execute.h
+++ /dev/null
@@ -1,552 +0,0 @@
-/**
- * @file lscript_execute.h
- * @brief Classes to execute bytecode
- *
- * $LicenseInfo:firstyear=2002&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#ifndef LL_LSCRIPT_EXECUTE_H
-#define LL_LSCRIPT_EXECUTE_H
-
-#include "stdtypes.h"
-#include "lscript_byteconvert.h"
-#include "lscript_library.h"
-#include "llstl.h"
-
-class LLTimer;
-
-// Return values for run() methods
-const U32 NO_DELETE_FLAG = 0x0000;
-const U32 DELETE_FLAG = 0x0001;
-const U32 CREDIT_MONEY_FLAG = 0x0002;
-
-// list of op code execute functions
-BOOL run_noop(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_pop(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_pops(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_popl(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_popv(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_popq(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_poparg(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_popip(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_popbp(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_popsp(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_popslr(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-
-BOOL run_dup(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_dups(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_dupl(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_dupv(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_dupq(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-
-BOOL run_store(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_stores(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_storel(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_storev(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_storeq(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_storeg(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_storegs(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_storegl(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_storegv(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_storegq(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_loadp(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_loadsp(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_loadlp(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_loadvp(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_loadqp(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_loadgp(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_loadgsp(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_loadglp(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_loadgvp(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_loadgqp(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-
-BOOL run_push(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_pushs(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_pushl(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_pushv(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_pushq(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_pushg(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_pushgs(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_pushgl(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_pushgv(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_pushgq(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_puship(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_pushbp(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_pushsp(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_pushargb(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_pushargi(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_pushargf(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_pushargs(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_pushargv(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_pushargq(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_pushe(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_pushev(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_pusheq(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_pusharge(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-
-BOOL run_add(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_sub(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_mul(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_div(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_mod(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-
-BOOL run_eq(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_neq(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_leq(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_geq(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_less(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_greater(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-
-BOOL run_bitand(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_bitor(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_bitxor(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_booland(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_boolor(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-
-BOOL run_shl(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_shr(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-
-BOOL run_neg(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_bitnot(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_boolnot(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-
-BOOL run_jump(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_jumpif(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_jumpnif(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-
-BOOL run_state(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_call(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_return(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_cast(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_stacktos(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_stacktol(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-
-BOOL run_print(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-
-BOOL run_calllib(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-BOOL run_calllib_two_byte(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-
-void unknown_operation(U8 *buffer, LSCRIPTOpCodesEnum opcode);
-void integer_integer_operation(U8 *buffer, LSCRIPTOpCodesEnum opcode);
-void integer_float_operation(U8 *buffer, LSCRIPTOpCodesEnum opcode);
-void integer_vector_operation(U8 *buffer, LSCRIPTOpCodesEnum opcode);
-void float_integer_operation(U8 *buffer, LSCRIPTOpCodesEnum opcode);
-void float_float_operation(U8 *buffer, LSCRIPTOpCodesEnum opcode);
-void float_vector_operation(U8 *buffer, LSCRIPTOpCodesEnum opcode);
-void string_string_operation(U8 *buffer, LSCRIPTOpCodesEnum opcode);
-void string_key_operation(U8 *buffer, LSCRIPTOpCodesEnum opcode);
-void key_string_operation(U8 *buffer, LSCRIPTOpCodesEnum opcode);
-void key_key_operation(U8 *buffer, LSCRIPTOpCodesEnum opcode);
-void vector_integer_operation(U8 *buffer, LSCRIPTOpCodesEnum opcode);
-void vector_float_operation(U8 *buffer, LSCRIPTOpCodesEnum opcode);
-void vector_vector_operation(U8 *buffer, LSCRIPTOpCodesEnum opcode);
-void vector_quaternion_operation(U8 *buffer, LSCRIPTOpCodesEnum opcode);
-void quaternion_quaternion_operation(U8 *buffer, LSCRIPTOpCodesEnum opcode);
-
-
-void integer_list_operation(U8 *buffer, LSCRIPTOpCodesEnum opcode);
-void float_list_operation(U8 *buffer, LSCRIPTOpCodesEnum opcode);
-void string_list_operation(U8 *buffer, LSCRIPTOpCodesEnum opcode);
-void key_list_operation(U8 *buffer, LSCRIPTOpCodesEnum opcode);
-void vector_list_operation(U8 *buffer, LSCRIPTOpCodesEnum opcode);
-void quaternion_list_operation(U8 *buffer, LSCRIPTOpCodesEnum opcode);
-void list_integer_operation(U8 *buffer, LSCRIPTOpCodesEnum opcode);
-void list_float_operation(U8 *buffer, LSCRIPTOpCodesEnum opcode);
-void list_string_operation(U8 *buffer, LSCRIPTOpCodesEnum opcode);
-void list_key_operation(U8 *buffer, LSCRIPTOpCodesEnum opcode);
-void list_vector_operation(U8 *buffer, LSCRIPTOpCodesEnum opcode);
-void list_quaternion_operation(U8 *buffer, LSCRIPTOpCodesEnum opcode);
-void list_list_operation(U8 *buffer, LSCRIPTOpCodesEnum opcode);
-
-void integer_operation(U8 *buffer, LSCRIPTOpCodesEnum opcode);
-void float_operation(U8 *buffer, LSCRIPTOpCodesEnum opcode);
-void vector_operation(U8 *buffer, LSCRIPTOpCodesEnum opcode);
-void quaternion_operation(U8 *buffer, LSCRIPTOpCodesEnum opcode);
-
-class LLScriptDataCollection
-{
-public:
- LLScriptDataCollection(LSCRIPTStateEventType type, LLScriptLibData *data)
- : mType(type), mData(data)
- {
- }
- LLScriptDataCollection(U8 *src, S32 &offset)
- {
- S32 i, number;
- mType = (LSCRIPTStateEventType)bytestream2integer(src, offset);
- number = bytestream2integer(src, offset);
-
- mData = new LLScriptLibData[number];
-
- for (i = 0; i < number; i++)
- {
- mData[i].set(src, offset);
- }
-
- }
-
- ~LLScriptDataCollection()
- {
- delete [] mData;
- mData = NULL;
- }
-
- S32 getSavedSize()
- {
- S32 size = 0;
- // mTyoe
- size += 4;
- // number of entries
- size += 4;
-
- S32 i = 0;
- do
- {
- size += mData[i].getSavedSize();;
- }
- while (mData[i++].mType != LST_NULL);
- return size;
- }
-
- S32 write2bytestream(U8 *dest)
- {
- S32 offset = 0;
- // mTyoe
- integer2bytestream(dest, offset, mType);
- // count number of entries
- S32 number = 0;
- while (mData[number++].mType != LST_NULL)
- ;
- integer2bytestream(dest, offset, number);
-
- // now the entries themselves
- number = 0;
- do
- {
- offset += mData[number].write2bytestream(dest + offset);
- }
- while (mData[number++].mType != LST_NULL);
- return offset;
- }
-
-
- LSCRIPTStateEventType mType;
- LLScriptLibData *mData;
-};
-const S32 MAX_EVENTS_IN_QUEUE = 64;
-
-class LLScriptEventData
-{
-public:
- LLScriptEventData() {}
- LLScriptEventData(U8 *src, S32 &offset)
- {
- S32 i, number = bytestream2integer(src, offset);
- for (i = 0; i < number; i++)
- {
- mEventDataList.push_front(new LLScriptDataCollection(src, offset));
- }
- }
-
- void set(U8 *src, S32 &offset)
- {
- S32 i, number = bytestream2integer(src, offset);
- for (i = 0; i < number; i++)
- {
- mEventDataList.push_front(new LLScriptDataCollection(src, offset));
- }
- }
-
- ~LLScriptEventData()
- {
- delete_and_clear(mEventDataList);
- }
-
- void addEventData(LLScriptDataCollection *data)
- {
- if (mEventDataList.size() < MAX_EVENTS_IN_QUEUE)
- mEventDataList.push_back(data);
- else
- delete data;
- }
- LLScriptDataCollection *getNextEvent(LSCRIPTStateEventType type)
- {
- for (std::list<LLScriptDataCollection*>::iterator it = mEventDataList.begin(), end_it = mEventDataList.end();
- it != end_it;
- ++it)
- {
- LLScriptDataCollection* temp = *it;
- if (temp->mType == type)
- {
- mEventDataList.erase(it);
- return temp;
- }
- }
- return NULL;
- }
- LLScriptDataCollection *getNextEvent()
- {
- LLScriptDataCollection *temp;
- temp = mEventDataList.front();
- if (temp)
- {
- mEventDataList.pop_front();
- return temp;
- }
- return NULL;
- }
- void removeEventType(LSCRIPTStateEventType type)
- {
- for (std::list<LLScriptDataCollection*>::iterator it = mEventDataList.begin(), end_it = mEventDataList.end();
- it != end_it;
- ++it)
- {
- if ((*it)->mType == type)
- {
- delete *it;
- mEventDataList.erase(it);
- }
- }
- }
-
- S32 getSavedSize()
- {
- S32 size = 0;
- // number in linked list
- size += 4;
- for (std::list<LLScriptDataCollection*>::iterator it = mEventDataList.begin(), end_it = mEventDataList.end();
- it != end_it;
- ++it)
- {
- size += (*it)->getSavedSize();
- }
- return size;
- }
-
- S32 write2bytestream(U8 *dest)
- {
- S32 offset = 0;
- // number in linked list
- S32 number = mEventDataList.size();
- integer2bytestream(dest, offset, number);
- for (std::list<LLScriptDataCollection*>::iterator it = mEventDataList.begin(), end_it = mEventDataList.end();
- it != end_it;
- ++it)
- {
- offset += (*it)->write2bytestream(dest + offset);
- }
- return offset;
- }
-
- std::list<LLScriptDataCollection*> mEventDataList;
-};
-
-class LLScriptExecute
-{
-public:
- LLScriptExecute();
- virtual ~LLScriptExecute() = 0;
- virtual S32 getVersion() const = 0;
- virtual void deleteAllEvents() = 0;
- virtual void addEvent(LLScriptDataCollection* event) = 0;
- virtual U32 getEventCount() = 0;
- virtual void removeEventType(LSCRIPTStateEventType event_type) = 0;
- virtual S32 getFaults() = 0;
- virtual void setFault(LSCRIPTRunTimeFaults fault) = 0;
- virtual U32 getFreeMemory() = 0;
- virtual S32 getParameter() = 0;
- virtual void setParameter(S32 value) = 0;
- virtual F32 getSleep() const = 0;
- virtual void setSleep(F32 value) = 0;
- virtual F32 getEnergy() const = 0;
- virtual void setEnergy(F32 value) = 0;
- virtual U64 getCurrentEvents() = 0;
- virtual void setCurrentEvents(U64 value) = 0;
- virtual U64 getEventHandlers() = 0;
- virtual void setEventHandlers(U64 value) = 0;
- virtual U64 getCurrentHandler() = 0;
- virtual void setCurrentHandler(U64 value) = 0;
- virtual BOOL isFinished() const = 0;
- virtual BOOL isStateChangePending() const = 0;
- virtual S32 writeState(U8 **dest, U32 header_size, U32 footer_size) = 0; // Allocate memory for header, state and footer return size of state.
- virtual U32 getEventsSavedSize() = 0; // Returns 0 if events are written with state.
- virtual S32 writeEvents(U8 *dest) = 0; // Must write and return exactly the number of bytes returned by getEventsSavedSize.
- virtual void readEvents(U8* src, S32& offset) = 0;
- virtual S32 readState(U8 *src) = 0; // Returns number of bytes read.
- virtual void reset();
- virtual const U8* getBytecode() const = 0;
- virtual U32 getBytecodeSize() const = 0;
- virtual bool isMono() const = 0;
- virtual void error() {;} // Processing that must be performed when error flag is set and so run is not called.
-
- virtual U32 getUsedMemory() = 0;
-
- // Run current event handler for a maximum of time_slice seconds.
- // Updates current handler and current events registers.
- virtual void resumeEventHandler(BOOL b_print, const LLUUID &id, F32 time_slice) = 0;
-
- // Run handler for event for a maximum of time_slice seconds.
- // Updates current handler and current events registers.
- virtual void callEventHandler(LSCRIPTStateEventType event, const LLUUID &id, F32 time_slice) = 0;;
-
- // Run handler for next queued event for maximum of time_slice seconds.
- // Updates current handler and current events registers.
- // Removes processed event from queue.
- virtual void callNextQueuedEventHandler(U64 event_register, const LLUUID &id, F32 time_slice) = 0;
-
- // Run handler for event for a maximum of time_slice seconds.
- // Updates current handler and current events registers.
- // Removes processed event from queue.
- virtual void callQueuedEventHandler(LSCRIPTStateEventType event, const LLUUID &id, F32 time_slice) = 0;
-
- // Switch to next state.
- // Returns new set of handled events.
- virtual U64 nextState() = 0;
-
- // Returns time taken.
- virtual F32 runQuanta(BOOL b_print, const LLUUID &id,
- const char **errorstr,
- F32 quanta,
- U32& events_processed, LLTimer& timer);
-
- // NOTE: babbage: this must be used on occasions where another script may already be executing. Only 2 levels of nesting are allowed.
- // Provided to support bizarre detach behaviour only. Do not use.
- virtual F32 runNested(BOOL b_print, const LLUUID &id,
- const char **errorstr,
- F32 quanta,
- U32& events_processed, LLTimer& timer);
-
- // Run smallest possible amount of code: an instruction for LSL2, a segment
- // between save tests for Mono
- void runInstructions(BOOL b_print, const LLUUID &id,
- const char **errorstr,
- U32& events_processed,
- F32 quanta);
-
- bool isYieldDue() const;
-
- void setReset(BOOL b) {mReset = b;}
- BOOL getReset() const { return mReset; }
-
- // Called when the script is scheduled to be run from newsim/LLScriptData
- virtual void startRunning() = 0;
-
- // Called when the script is scheduled to be stopped from newsim/LLScriptData
- virtual void stopRunning() = 0;
-
- // A timer is regularly checked to see if script takes too long, but we
- // don't do it every opcode due to performance hits.
- static void setTimerCheckSkip( S32 value ) { sTimerCheckSkip = value; }
- static S32 getTimerCheckSkip() { return sTimerCheckSkip; }
-
-private:
-
- BOOL mReset;
-
- static S32 sTimerCheckSkip; // Number of times to skip the timer check for performance reasons
-};
-
-class LLScriptExecuteLSL2 : public LLScriptExecute
-{
-public:
- LLScriptExecuteLSL2(LLFILE *fp);
- LLScriptExecuteLSL2(const U8* bytecode, U32 bytecode_size);
- virtual ~LLScriptExecuteLSL2();
-
- virtual S32 getVersion() const {return get_register(mBuffer, LREG_VN);}
- virtual void deleteAllEvents() {delete_and_clear(mEventData.mEventDataList);}
- virtual void addEvent(LLScriptDataCollection* event);
- virtual U32 getEventCount() {return mEventData.mEventDataList.size();}
- virtual void removeEventType(LSCRIPTStateEventType event_type);
- virtual S32 getFaults() {return get_register(mBuffer, LREG_FR);}
- virtual void setFault(LSCRIPTRunTimeFaults fault) {set_fault(mBuffer, fault);}
- virtual U32 getFreeMemory();
- virtual S32 getParameter();
- virtual void setParameter(S32 value);
- virtual F32 getSleep() const;
- virtual void setSleep(F32 value);
- virtual F32 getEnergy() const;
- virtual void setEnergy(F32 value);
- virtual U64 getCurrentEvents() {return get_event_register(mBuffer, LREG_CE, getMajorVersion());}
- virtual void setCurrentEvents(U64 value) {return set_event_register(mBuffer, LREG_CE, value, getMajorVersion());}
- virtual U64 getEventHandlers() {return get_event_register(mBuffer, LREG_ER, getMajorVersion());}
- virtual void setEventHandlers(U64 value) {set_event_register(mBuffer, LREG_ER, value, getMajorVersion());}
- virtual U64 getCurrentHandler();
- virtual void setCurrentHandler(U64 value) {return set_event_register(mBuffer, LREG_IE, value, getMajorVersion());}
- virtual BOOL isFinished() const {return get_register(mBuffer, LREG_IP) == 0;}
- virtual BOOL isStateChangePending() const {return get_register(mBuffer, LREG_CS) != get_register(mBuffer, LREG_NS);}
- virtual S32 writeState(U8 **dest, U32 header_size, U32 footer_size); // Not including Events.
- virtual U32 getEventsSavedSize() {return mEventData.getSavedSize();}
- virtual S32 writeEvents(U8 *dest) {return mEventData.write2bytestream(dest);}
- virtual void readEvents(U8* src, S32& offset) {mEventData.set(src, offset);}
- virtual S32 writeBytecode(U8 **dest);
- virtual S32 readState(U8 *src);
- virtual void reset();
- virtual const U8* getBytecode() const {return mBytecode;}
- virtual U32 getBytecodeSize() const {return mBytecodeSize;}
- virtual bool isMono() const {return false;}
- virtual U32 getUsedMemory();
- // Run current event handler for a maximum of time_slice seconds.
- // Updates current handler and current events registers.
- virtual void resumeEventHandler(BOOL b_print, const LLUUID &id, F32 time_slice);
-
- // Run handler for event for a maximum of time_slice seconds.
- // Updates current handler and current events registers.
- virtual void callEventHandler(LSCRIPTStateEventType event, const LLUUID &id, F32 time_slice);
-
- // Run handler for next queued event for maximum of time_slice seconds.
- // Updates current handler and current events registers.
- // Removes processed event from queue.
- virtual void callNextQueuedEventHandler(U64 event_register, const LLUUID &id, F32 time_slice);
-
- // Run handler for event for a maximum of time_slice seconds.
- // Updates current handler and current events registers.
- // Removes processed event from queue.
- virtual void callQueuedEventHandler(LSCRIPTStateEventType event, const LLUUID &id, F32 time_slice);
-
- // Switch to next state.
- // Returns new set of handled events.
- virtual U64 nextState();
-
- void init();
-
- BOOL (*mExecuteFuncs[0x100])(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id);
-
- U32 mInstructionCount;
- U8 *mBuffer;
- LLScriptEventData mEventData;
- U8* mBytecode; // Initial state and bytecode.
- U32 mBytecodeSize;
-
-private:
- S32 getMajorVersion() const;
- void recordBoundaryError( const LLUUID &id );
- void setStateEventOpcoodeStartSafely( S32 state, LSCRIPTStateEventType event, const LLUUID &id );
-
- // Called when the script is scheduled to be run from newsim/LLScriptData
- virtual void startRunning();
-
- // Called when the script is scheduled to be stopped from newsim/LLScriptData
- virtual void stopRunning();
-};
-
-#endif
diff --git a/indra/lscript/lscript_execute/CMakeLists.txt b/indra/lscript/lscript_execute/CMakeLists.txt
deleted file mode 100755
index 49605982a8..0000000000
--- a/indra/lscript/lscript_execute/CMakeLists.txt
+++ /dev/null
@@ -1,43 +0,0 @@
-# -*- cmake -*-
-
-include(00-Common)
-include(LLCommon)
-include(LLMath)
-include(LScript)
-
-include_directories(
- ${LLCOMMON_INCLUDE_DIRS}
- ${LLMATH_INCLUDE_DIRS}
- ${LSCRIPT_INCLUDE_DIRS}
- )
-include_directories(SYSTEM
- ${LLCOMMON_SYSTEM_INCLUDE_DIRS}
- )
-
-set(lscript_execute_SOURCE_FILES
- llscriptresource.cpp
- llscriptresourceconsumer.cpp
- llscriptresourcepool.cpp
- lscript_execute.cpp
- lscript_heapruntime.cpp
- lscript_readlso.cpp
- )
-
-set(lscript_execute_HEADER_FILES
- CMakeLists.txt
-
- ../llscriptresource.h
- ../llscriptresourceconsumer.h
- ../llscriptresourcepool.h
- ../lscript_execute.h
- ../lscript_rt_interface.h
- lscript_heapruntime.h
- lscript_readlso.h
- )
-
-set_source_files_properties(${lscript_execute_HEADER_FILES}
- PROPERTIES HEADER_FILE_ONLY TRUE)
-
-list(APPEND lscript_execute_SOURCE_FILES ${lscript_execute_HEADER_FILES})
-
-add_library (lscript_execute ${lscript_execute_SOURCE_FILES})
diff --git a/indra/lscript/lscript_execute/llscriptresource.cpp b/indra/lscript/lscript_execute/llscriptresource.cpp
deleted file mode 100755
index 2c6811b226..0000000000
--- a/indra/lscript/lscript_execute/llscriptresource.cpp
+++ /dev/null
@@ -1,93 +0,0 @@
-/**
- * @file llscriptresource.cpp
- * @brief LLScriptResource class implementation for managing limited resources
- *
- * $LicenseInfo:firstyear=2008&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#include "linden_common.h"
-
-#include "llscriptresource.h"
-#include "llerror.h"
-
-LLScriptResource::LLScriptResource()
-: mTotal(0),
- mUsed(0)
-{
-}
-
-bool LLScriptResource::request(S32 amount /* = 1 */)
-{
- if (mUsed + amount <= mTotal)
- {
- mUsed += amount;
- return true;
- }
-
- return false;
-}
-
-bool LLScriptResource::release(S32 amount /* = 1 */)
-{
- if (mUsed >= amount)
- {
- mUsed -= amount;
- return true;
- }
-
- return false;
-}
-
-S32 LLScriptResource::getAvailable() const
-{
- if (mUsed > mTotal)
- {
- // It is possible after a parcel ownership change for more than total to be used
- // In this case the user of this class just wants to know
- // whether or not they can use a resource
- return 0;
- }
- return (mTotal - mUsed);
-}
-
-void LLScriptResource::setTotal(S32 amount)
-{
- // This may cause this resource to be over spent
- // such that more are in use than total allowed
- // Until those resources are released getAvailable will return 0.
- mTotal = amount;
-}
-
-S32 LLScriptResource::getTotal() const
-{
- return mTotal;
-}
-
-S32 LLScriptResource::getUsed() const
-{
- return mUsed;
-}
-
-bool LLScriptResource::isOverLimit() const
-{
- return (mUsed > mTotal);
-}
diff --git a/indra/lscript/lscript_execute/llscriptresourceconsumer.cpp b/indra/lscript/lscript_execute/llscriptresourceconsumer.cpp
deleted file mode 100755
index 0ce5eb7dab..0000000000
--- a/indra/lscript/lscript_execute/llscriptresourceconsumer.cpp
+++ /dev/null
@@ -1,106 +0,0 @@
-/**
- * @file llscriptresourceconsumer.cpp
- * @brief An interface for a script resource consumer.
- *
- * $LicenseInfo:firstyear=2008&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#include "llscriptresourceconsumer.h"
-
-#include "llscriptresourcepool.h"
-
-LLScriptResourceConsumer::LLScriptResourceConsumer()
- : mScriptResourcePool(&LLScriptResourcePool::null)
-{ }
-
-// Get the resource pool this consumer is currently using.
-// virtual
-LLScriptResourcePool& LLScriptResourceConsumer::getScriptResourcePool()
-{
- return *mScriptResourcePool;
-}
-
-// Get the resource pool this consumer is currently using.
-// virtual
-const LLScriptResourcePool& LLScriptResourceConsumer::getScriptResourcePool() const
-{
- return *mScriptResourcePool;
-}
-
-// virtual
-void LLScriptResourceConsumer::setScriptResourcePool(LLScriptResourcePool& new_pool)
-{
- mScriptResourcePool = &new_pool;
-}
-
-bool LLScriptResourceConsumer::switchScriptResourcePools(LLScriptResourcePool& new_pool)
-{
- if (&new_pool == &LLScriptResourcePool::null)
- {
- LL_WARNS() << "New pool is null" << LL_ENDL;
- }
-
- if (isInPool(new_pool))
- {
- return true;
- }
-
- if (!canUseScriptResourcePool(new_pool))
- {
- return false;
- }
-
- S32 used_urls = getUsedPublicURLs();
-
- getScriptResourcePool().getPublicURLResource().release( used_urls );
- setScriptResourcePool(new_pool);
- getScriptResourcePool().getPublicURLResource().request( used_urls );
-
- return true;
-}
-
-bool LLScriptResourceConsumer::canUseScriptResourcePool(const LLScriptResourcePool& resource_pool)
-{
- if (isInPool(resource_pool))
- {
- return true;
- }
-
- if (resource_pool.getPublicURLResource().getAvailable() < getUsedPublicURLs())
- {
- return false;
- }
-
- return true;
-}
-
-bool LLScriptResourceConsumer::isInPool(const LLScriptResourcePool& resource_pool)
-{
- const LLScriptResourcePool& current_pool = getScriptResourcePool();
- if ( &resource_pool == &current_pool )
- {
- // This consumer is already in this pool
- return true;
- }
- return false;
-}
-
diff --git a/indra/lscript/lscript_execute/llscriptresourcepool.cpp b/indra/lscript/lscript_execute/llscriptresourcepool.cpp
deleted file mode 100755
index 6bdc2bbd48..0000000000
--- a/indra/lscript/lscript_execute/llscriptresourcepool.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- * @file llscriptresourcepool.cpp
- * @brief Collection of limited script resources
- *
- * $LicenseInfo:firstyear=2008&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#include "llscriptresourcepool.h"
-
-LLScriptResourcePool LLScriptResourcePool::null;
-
-LLScriptResourcePool::LLScriptResourcePool()
-{
-
-}
-
-LLScriptResource& LLScriptResourcePool::getPublicURLResource()
-{
- return mLSLPublicURLs;
-}
-
-const LLScriptResource& LLScriptResourcePool::getPublicURLResource() const
-{
- return mLSLPublicURLs;
-}
diff --git a/indra/lscript/lscript_execute/lscript_execute.cpp b/indra/lscript/lscript_execute/lscript_execute.cpp
deleted file mode 100755
index 5eb7ffc5a9..0000000000
--- a/indra/lscript/lscript_execute/lscript_execute.cpp
+++ /dev/null
@@ -1,4318 +0,0 @@
-/**
- * @file lscript_execute.cpp
- * @brief classes to execute bytecode
- *
- * $LicenseInfo:firstyear=2002&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#include "linden_common.h"
-
-#include <algorithm>
-#include <sstream>
-
-#include "lscript_execute.h"
-#include "lltimer.h"
-#include "lscript_readlso.h"
-#include "lscript_library.h"
-#include "lscript_heapruntime.h"
-#include "lscript_alloc.h"
-
-
-// Static
-const S32 DEFAULT_SCRIPT_TIMER_CHECK_SKIP = 4;
-S32 LLScriptExecute::sTimerCheckSkip = DEFAULT_SCRIPT_TIMER_CHECK_SKIP;
-
-void (*binary_operations[LST_EOF][LST_EOF])(U8 *buffer, LSCRIPTOpCodesEnum opcode);
-void (*unary_operations[LST_EOF])(U8 *buffer, LSCRIPTOpCodesEnum opcode);
-
-const char* LSCRIPTRunTimeFaultStrings[LSRF_EOF] = /*Flawfinder: ignore*/
-{
- "Invalid", // LSRF_INVALID,
- "Math Error", // LSRF_MATH,
- "Stack-Heap Collision", // LSRF_STACK_HEAP_COLLISION,
- "Bounds Check Error", // LSRF_BOUND_CHECK_ERROR,
- "Heap Error", // LSRF_HEAP_ERROR,
- "Version Mismatch", // LSRF_VERSION_MISMATCH,
- "Missing Inventory", // LSRF_MISSING_INVENTORY,
- "Hit Sandbox Limit", // LSRF_SANDBOX,
- "Chat Overrun", // LSRF_CHAT_OVERRUN,
- "Too Many Listens", // LSRF_TOO_MANY_LISTENS,
- "Lists may not contain lists", // LSRF_NESTING_LISTS,
- "CLI Exception" // LSRF_CLI
-};
-
-void LLScriptExecuteLSL2::startRunning() {}
-void LLScriptExecuteLSL2::stopRunning() {}
-
-const char* URL_REQUEST_GRANTED = "URL_REQUEST_GRANTED";
-const char* URL_REQUEST_DENIED = "URL_REQUEST_DENIED";
-
-// HTTP Requests to LSL scripts will time out after 25 seconds.
-const U64 LSL_HTTP_REQUEST_TIMEOUT_USEC = 25 * USEC_PER_SEC;
-
-LLScriptExecuteLSL2::LLScriptExecuteLSL2(LLFILE *fp)
-{
- U8 sizearray[4];
- size_t filesize;
- S32 pos = 0;
- if (fread(&sizearray, 1, 4, fp) != 4)
- {
- LL_WARNS() << "Short read" << LL_ENDL;
- filesize = 0;
- } else {
- filesize = bytestream2integer(sizearray, pos);
- }
- mBuffer = new U8[filesize];
- fseek(fp, 0, SEEK_SET);
- if (fread(mBuffer, 1, filesize, fp) != filesize)
- {
- LL_WARNS() << "Short read" << LL_ENDL;
- }
- fclose(fp);
-
- init();
-}
-
-LLScriptExecuteLSL2::LLScriptExecuteLSL2(const U8* bytecode, U32 bytecode_size)
-{
- mBuffer = new U8[TOP_OF_MEMORY];
- memset(mBuffer + bytecode_size, 0, TOP_OF_MEMORY - bytecode_size);
- S32 src_offset = 0;
- S32 dest_offset = 0;
- bytestream2bytestream(mBuffer, dest_offset, bytecode, src_offset, bytecode_size);
- mBytecodeSize = bytecode_size;
- mBytecode = new U8[mBytecodeSize];
- memcpy(mBytecode, bytecode, mBytecodeSize);
- init();
-}
-
-LLScriptExecute::~LLScriptExecute() {}
-LLScriptExecuteLSL2::~LLScriptExecuteLSL2()
-{
- delete[] mBuffer;
- delete[] mBytecode;
-}
-
-void LLScriptExecuteLSL2::init()
-{
- S32 i, j;
-
- mInstructionCount = 0;
-
- for (i = 0; i < 256; i++)
- {
- mExecuteFuncs[i] = run_noop;
- }
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_NOOP]] = run_noop;
-
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_POP]] = run_pop;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_POPS]] = run_pops;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_POPL]] = run_popl;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_POPV]] = run_popv;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_POPQ]] = run_popq;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_POPARG]] = run_poparg;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_POPIP]] = run_popip;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_POPBP]] = run_popbp;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_POPSP]] = run_popsp;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_POPSLR]] = run_popslr;
-
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_DUP]] = run_dup;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_DUPS]] = run_dups;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_DUPL]] = run_dupl;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_DUPV]] = run_dupv;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_DUPQ]] = run_dupq;
-
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_STORE]] = run_store;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_STORES]] = run_stores;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_STOREL]] = run_storel;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_STOREV]] = run_storev;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_STOREQ]] = run_storeq;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_STOREG]] = run_storeg;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_STOREGL]] = run_storegl;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_STOREGS]] = run_storegs;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_STOREGV]] = run_storegv;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_STOREGQ]] = run_storegq;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_LOADP]] = run_loadp;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_LOADSP]] = run_loadsp;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_LOADLP]] = run_loadlp;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_LOADVP]] = run_loadvp;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_LOADQP]] = run_loadqp;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_LOADGP]] = run_loadgp;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_LOADGSP]] = run_loadgsp;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_LOADGLP]] = run_loadglp;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_LOADGVP]] = run_loadgvp;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_LOADGQP]] = run_loadgqp;
-
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_PUSH]] = run_push;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_PUSHS]] = run_pushs;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_PUSHL]] = run_pushl;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_PUSHV]] = run_pushv;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_PUSHQ]] = run_pushq;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_PUSHG]] = run_pushg;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_PUSHGS]] = run_pushgs;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_PUSHGL]] = run_pushgl;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_PUSHGV]] = run_pushgv;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_PUSHGQ]] = run_pushgq;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_PUSHIP]] = run_puship;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_PUSHSP]] = run_pushsp;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_PUSHBP]] = run_pushbp;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_PUSHARGB]] = run_pushargb;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_PUSHARGI]] = run_pushargi;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_PUSHARGF]] = run_pushargf;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_PUSHARGS]] = run_pushargs;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_PUSHARGV]] = run_pushargv;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_PUSHARGQ]] = run_pushargq;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_PUSHE]] = run_pushe;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_PUSHEV]] = run_pushev;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_PUSHEQ]] = run_pusheq;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_PUSHARGE]] = run_pusharge;
-
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_ADD]] = run_add;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_SUB]] = run_sub;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_MUL]] = run_mul;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_DIV]] = run_div;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_MOD]] = run_mod;
-
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_EQ]] = run_eq;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_NEQ]] = run_neq;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_LEQ]] = run_leq;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_GEQ]] = run_geq;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_LESS]] = run_less;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_GREATER]] = run_greater;
-
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_BITAND]] = run_bitand;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_BITOR]] = run_bitor;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_BITXOR]] = run_bitxor;
-
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_BOOLAND]] = run_booland;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_BOOLOR]] = run_boolor;
-
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_SHL]] = run_shl;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_SHR]] = run_shr;
-
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_NEG]] = run_neg;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_BITNOT]] = run_bitnot;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_BOOLNOT]] = run_boolnot;
-
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_JUMP]] = run_jump;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_JUMPIF]] = run_jumpif;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_JUMPNIF]] = run_jumpnif;
-
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_STATE]] = run_state;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_CALL]] = run_call;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_RETURN]] = run_return;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_CAST]] = run_cast;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_STACKTOS]] = run_stacktos;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_STACKTOL]] = run_stacktol;
-
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_PRINT]] = run_print;
-
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_CALLLIB]] = run_calllib;
- mExecuteFuncs[LSCRIPTOpCodes[LOPC_CALLLIB_TWO_BYTE]] = run_calllib_two_byte;
-
- for (i = 0; i < LST_EOF; i++)
- {
- for (j = 0; j < LST_EOF; j++)
- {
- binary_operations[i][j] = unknown_operation;
- }
- }
-
- binary_operations[LST_INTEGER][LST_INTEGER] = integer_integer_operation;
- binary_operations[LST_INTEGER][LST_FLOATINGPOINT] = integer_float_operation;
- binary_operations[LST_INTEGER][LST_VECTOR] = integer_vector_operation;
-
- binary_operations[LST_FLOATINGPOINT][LST_INTEGER] = float_integer_operation;
- binary_operations[LST_FLOATINGPOINT][LST_FLOATINGPOINT] = float_float_operation;
- binary_operations[LST_FLOATINGPOINT][LST_VECTOR] = float_vector_operation;
-
- binary_operations[LST_STRING][LST_STRING] = string_string_operation;
- binary_operations[LST_STRING][LST_KEY] = string_key_operation;
-
- binary_operations[LST_KEY][LST_STRING] = key_string_operation;
- binary_operations[LST_KEY][LST_KEY] = key_key_operation;
-
- binary_operations[LST_VECTOR][LST_INTEGER] = vector_integer_operation;
- binary_operations[LST_VECTOR][LST_FLOATINGPOINT] = vector_float_operation;
- binary_operations[LST_VECTOR][LST_VECTOR] = vector_vector_operation;
- binary_operations[LST_VECTOR][LST_QUATERNION] = vector_quaternion_operation;
-
- binary_operations[LST_QUATERNION][LST_QUATERNION] = quaternion_quaternion_operation;
-
- binary_operations[LST_INTEGER][LST_LIST] = integer_list_operation;
- binary_operations[LST_FLOATINGPOINT][LST_LIST] = float_list_operation;
- binary_operations[LST_STRING][LST_LIST] = string_list_operation;
- binary_operations[LST_KEY][LST_LIST] = key_list_operation;
- binary_operations[LST_VECTOR][LST_LIST] = vector_list_operation;
- binary_operations[LST_QUATERNION][LST_LIST] = quaternion_list_operation;
- binary_operations[LST_LIST][LST_INTEGER] = list_integer_operation;
- binary_operations[LST_LIST][LST_FLOATINGPOINT] = list_float_operation;
- binary_operations[LST_LIST][LST_STRING] = list_string_operation;
- binary_operations[LST_LIST][LST_KEY] = list_key_operation;
- binary_operations[LST_LIST][LST_VECTOR] = list_vector_operation;
- binary_operations[LST_LIST][LST_QUATERNION] = list_quaternion_operation;
- binary_operations[LST_LIST][LST_LIST] = list_list_operation;
-
- for (i = 0; i < LST_EOF; i++)
- {
- unary_operations[i] = unknown_operation;
- }
-
- unary_operations[LST_INTEGER] = integer_operation;
- unary_operations[LST_FLOATINGPOINT] = float_operation;
- unary_operations[LST_VECTOR] = vector_operation;
- unary_operations[LST_QUATERNION] = quaternion_operation;
-
-}
-
-
-// Utility routine for when there's a boundary error parsing bytecode
-void LLScriptExecuteLSL2::recordBoundaryError( const LLUUID &id )
-{
- set_fault(mBuffer, LSRF_BOUND_CHECK_ERROR);
- LL_WARNS() << "Script boundary error for ID " << id << LL_ENDL;
-}
-
-
-// set IP to the event handler with some error checking
-void LLScriptExecuteLSL2::setStateEventOpcoodeStartSafely( S32 state, LSCRIPTStateEventType event, const LLUUID &id )
-{
- S32 opcode_start = get_state_event_opcoode_start( mBuffer, state, event );
- if ( opcode_start == -1 )
- {
- recordBoundaryError( id );
- }
- else
- {
- set_ip( mBuffer, opcode_start );
- }
-}
-
-
-
-
-S32 lscript_push_variable(LLScriptLibData *data, U8 *buffer);
-
-void LLScriptExecuteLSL2::resumeEventHandler(BOOL b_print, const LLUUID &id, F32 time_slice)
-{
- // call opcode run function pointer with buffer and IP
- mInstructionCount++;
- S32 value = get_register(mBuffer, LREG_IP);
- S32 tvalue = value;
- S32 opcode = safe_instruction_bytestream2byte(mBuffer, tvalue);
- mExecuteFuncs[opcode](mBuffer, value, b_print, id);
- set_ip(mBuffer, value);
- add_register_fp(mBuffer, LREG_ESR, -0.1f);
- // lsa_print_heap(mBuffer);
-
- if (b_print)
- {
- lsa_print_heap(mBuffer);
- printf("ip: 0x%X\n", get_register(mBuffer, LREG_IP));
- printf("sp: 0x%X\n", get_register(mBuffer, LREG_SP));
- printf("bp: 0x%X\n", get_register(mBuffer, LREG_BP));
- printf("hr: 0x%X\n", get_register(mBuffer, LREG_HR));
- printf("hp: 0x%X\n", get_register(mBuffer, LREG_HP));
- }
-
- // NOTE: Babbage: all mExecuteFuncs return false.
-}
-
-void LLScriptExecuteLSL2::callEventHandler(LSCRIPTStateEventType event, const LLUUID &id, F32 time_slice)
-{
- S32 major_version = getMajorVersion();
- // push a zero to be popped
- lscript_push(mBuffer, 0);
- // push sp as current bp
- S32 sp = get_register(mBuffer, LREG_SP);
- lscript_push(mBuffer, sp);
-
- // Update current handler and current events registers.
- set_event_register(mBuffer, LREG_IE, LSCRIPTStateBitField[event], major_version);
- U64 current_events = get_event_register(mBuffer, LREG_CE, major_version);
- current_events &= ~LSCRIPTStateBitField[event];
- set_event_register(mBuffer, LREG_CE, current_events, major_version);
-
- // now, push any additional stack space
- U32 current_state = get_register(mBuffer, LREG_CS);
- S32 additional_size = get_event_stack_size(mBuffer, current_state, event);
- lscript_pusharge(mBuffer, additional_size);
-
- // now set the bp correctly
- sp = get_register(mBuffer, LREG_SP);
- sp += additional_size;
- set_bp(mBuffer, sp);
-
- // set IP to the function
- S32 opcode_start = get_state_event_opcoode_start(mBuffer, current_state, event);
- set_ip(mBuffer, opcode_start);
-}
-
-//void callStateExitHandler()
-//{
-// // push a zero to be popped
-// lscript_push(mBuffer, 0);
-// // push sp as current bp
-// S32 sp = get_register(mBuffer, LREG_SP);
-// lscript_push(mBuffer, sp);
-//
-// // now, push any additional stack space
-// S32 additional_size = get_event_stack_size(mBuffer, current_state, LSTT_STATE_EXIT);
-// lscript_pusharge(mBuffer, additional_size);
-//
-// sp = get_register(mBuffer, LREG_SP);
-// sp += additional_size;
-// set_bp(mBuffer, sp);
-//
-// // set IP to the event handler
-// S32 opcode_start = get_state_event_opcoode_start(mBuffer, current_state, LSTT_STATE_EXIT);
-// set_ip(mBuffer, opcode_start);
-//}
-//
-//void callStateEntryHandler()
-//{
-// // push a zero to be popped
-// lscript_push(mBuffer, 0);
-// // push sp as current bp
-// S32 sp = get_register(mBuffer, LREG_SP);
-// lscript_push(mBuffer, sp);
-//
-// event = return_first_event((S32)LSCRIPTStateBitField[LSTT_STATE_ENTRY]);
-// set_event_register(mBuffer, LREG_IE, LSCRIPTStateBitField[event], major_version);
-// current_events &= ~LSCRIPTStateBitField[event];
-// set_event_register(mBuffer, LREG_CE, current_events, major_version);
-//
-// // now, push any additional stack space
-// S32 additional_size = get_event_stack_size(mBuffer, current_state, event) - size;
-// lscript_pusharge(mBuffer, additional_size);
-//
-// // now set the bp correctly
-// sp = get_register(mBuffer, LREG_SP);
-// sp += additional_size + size;
-// set_bp(mBuffer, sp);
-// // set IP to the function
-// S32 opcode_start = get_state_event_opcoode_start(mBuffer, current_state, event);
-// set_ip(mBuffer, opcode_start);
-//}
-
-void LLScriptExecuteLSL2::callQueuedEventHandler(LSCRIPTStateEventType event, const LLUUID &id, F32 time_slice)
-{
- S32 major_version = getMajorVersion();
-
- for (std::list<LLScriptDataCollection*>::iterator it = mEventData.mEventDataList.begin(), end_it = mEventData.mEventDataList.end();
- it != end_it;
- ++it)
- {
- LLScriptDataCollection* eventdata = *it;
-
- if (eventdata->mType == event)
- {
- // push a zero to be popped
- lscript_push(mBuffer, 0);
- // push sp as current bp
- S32 sp = get_register(mBuffer, LREG_SP);
- lscript_push(mBuffer, sp);
-
- // Update current handler and current events registers.
- set_event_register(mBuffer, LREG_IE, LSCRIPTStateBitField[event], major_version);
- U64 current_events = get_event_register(mBuffer, LREG_CE, major_version);
- current_events &= ~LSCRIPTStateBitField[event];
- set_event_register(mBuffer, LREG_CE, current_events, major_version);
-
- // push any arguments that need to be pushed onto the stack
- // last piece of data will be type LST_NULL
- LLScriptLibData *data = eventdata->mData;
- U32 size = 0;
- while (data->mType)
- {
- size += lscript_push_variable(data, mBuffer);
- data++;
- }
- // now, push any additional stack space
- U32 current_state = get_register(mBuffer, LREG_CS);
- S32 additional_size = get_event_stack_size(mBuffer, current_state, event) - size;
- lscript_pusharge(mBuffer, additional_size);
-
- // now set the bp correctly
- sp = get_register(mBuffer, LREG_SP);
- sp += additional_size + size;
- set_bp(mBuffer, sp);
-
- // set IP to the function
- S32 opcode_start = get_state_event_opcoode_start(mBuffer, current_state, event);
- set_ip(mBuffer, opcode_start);
-
- delete *it;
- mEventData.mEventDataList.erase(it);
- break;
- }
- }
-}
-
-void LLScriptExecuteLSL2::callNextQueuedEventHandler(U64 event_register, const LLUUID &id, F32 time_slice)
-{
- S32 major_version = getMajorVersion();
- LLScriptDataCollection* eventdata = mEventData.getNextEvent();
- if (eventdata)
- {
- LSCRIPTStateEventType event = eventdata->mType;
-
- // make sure that we can actually handle this one
- if (LSCRIPTStateBitField[event] & event_register)
- {
- // push a zero to be popped
- lscript_push(mBuffer, 0);
- // push sp as current bp
- S32 sp = get_register(mBuffer, LREG_SP);
- lscript_push(mBuffer, sp);
-
- // Update current handler and current events registers.
- set_event_register(mBuffer, LREG_IE, LSCRIPTStateBitField[event], major_version);
- U64 current_events = get_event_register(mBuffer, LREG_CE, major_version);
- current_events &= ~LSCRIPTStateBitField[event];
- set_event_register(mBuffer, LREG_CE, current_events, major_version);
-
- // push any arguments that need to be pushed onto the stack
- // last piece of data will be type LST_NULL
- LLScriptLibData *data = eventdata->mData;
- U32 size = 0;
- while (data->mType)
- {
- size += lscript_push_variable(data, mBuffer);
- data++;
- }
-
- // now, push any additional stack space
- U32 current_state = get_register(mBuffer, LREG_CS);
- S32 additional_size = get_event_stack_size(mBuffer, current_state, event) - size;
- lscript_pusharge(mBuffer, additional_size);
-
- // now set the bp correctly
- sp = get_register(mBuffer, LREG_SP);
- sp += additional_size + size;
- set_bp(mBuffer, sp);
-
- // set IP to the function
- S32 opcode_start = get_state_event_opcoode_start(mBuffer, current_state, event);
- set_ip(mBuffer, opcode_start);
- }
- else
- {
- LL_WARNS() << "Somehow got an event that we're not registered for!" << LL_ENDL;
- }
- delete eventdata;
- }
-}
-
-U64 LLScriptExecuteLSL2::nextState()
-{
- // copy NS to CS
- S32 next_state = get_register(mBuffer, LREG_NS);
- set_register(mBuffer, LREG_CS, next_state);
-
- // copy new state's handled events into ER (SR + CS*4 + 4)
- return get_handled_events(mBuffer, next_state);
-}
-
-//virtual
-void LLScriptExecuteLSL2::addEvent(LLScriptDataCollection* event)
-{
- mEventData.addEventData(event);
-}
-
-//virtual
-void LLScriptExecuteLSL2::removeEventType(LSCRIPTStateEventType event_type)
-{
- mEventData.removeEventType(event_type);
-}
-
-//virtual
-F32 LLScriptExecuteLSL2::getSleep() const
-{
- return get_register_fp(mBuffer, LREG_SLR);
-}
-
-//virtual
-void LLScriptExecuteLSL2::setSleep(F32 value)
-{
- set_register_fp(mBuffer, LREG_SLR, value);
-}
-
-//virtual
-U64 LLScriptExecuteLSL2::getCurrentHandler()
-{
- return get_event_register(mBuffer, LREG_IE, getMajorVersion());
-}
-
-//virtual
-F32 LLScriptExecuteLSL2::getEnergy() const
-{
- return get_register_fp(mBuffer, LREG_ESR);
-}
-
-//virtual
-void LLScriptExecuteLSL2::setEnergy(F32 value)
-{
- set_register_fp(mBuffer, LREG_ESR, value);
-}
-
-//virtual
-U32 LLScriptExecuteLSL2::getFreeMemory()
-{
- return get_register(mBuffer, LREG_SP) - get_register(mBuffer, LREG_HP);
-}
-
-//virtual
-S32 LLScriptExecuteLSL2::getParameter()
-{
- return get_register(mBuffer, LREG_PR);
-}
-
-//virtual
-void LLScriptExecuteLSL2::setParameter(S32 value)
-{
- set_register(mBuffer, LREG_PR, value);
-}
-
-
-S32 LLScriptExecuteLSL2::writeState(U8 **dest, U32 header_size, U32 footer_size)
-{
- // data format:
- // 4 bytes of size of Registers, Name and Description, and Global Variables
- // Registers, Name and Description, and Global Variables data
- // 4 bytes of size of Heap
- // Heap data
- // 4 bytes of stack size
- // Stack data
-
- S32 registers_size = get_register(mBuffer, LREG_GFR);
-
- if (get_register(mBuffer, LREG_HP) > TOP_OF_MEMORY)
- reset_hp_to_safe_spot(mBuffer);
-
- S32 heap_size = get_register(mBuffer, LREG_HP) - get_register(mBuffer, LREG_HR);
- S32 stack_size = get_register(mBuffer, LREG_TM) - get_register(mBuffer, LREG_SP);
- S32 total_size = registers_size + LSCRIPTDataSize[LST_INTEGER] +
- heap_size + LSCRIPTDataSize[LST_INTEGER] +
- stack_size + LSCRIPTDataSize[LST_INTEGER];
-
- // actually allocate data
- delete[] *dest;
- *dest = new U8[header_size + total_size + footer_size];
- memset(*dest, 0, header_size + total_size + footer_size);
- S32 dest_offset = header_size;
- S32 src_offset = 0;
-
- // registers
- integer2bytestream(*dest, dest_offset, registers_size);
-
- // LL_INFOS() << "Writing CE: " << getCurrentEvents() << LL_ENDL;
- bytestream2bytestream(*dest, dest_offset, mBuffer, src_offset, registers_size);
-
- // heap
- integer2bytestream(*dest, dest_offset, heap_size);
-
- src_offset = get_register(mBuffer, LREG_HR);
- bytestream2bytestream(*dest, dest_offset, mBuffer, src_offset, heap_size);
-
- // stack
- integer2bytestream(*dest, dest_offset, stack_size);
-
- src_offset = get_register(mBuffer, LREG_SP);
- bytestream2bytestream(*dest, dest_offset, mBuffer, src_offset, stack_size);
-
- return total_size;
-}
-
-S32 LLScriptExecuteLSL2::writeBytecode(U8 **dest)
-{
- // data format:
- // registers through top of heap
- // Heap data
- S32 total_size = get_register(mBuffer, LREG_HP);
-
- // actually allocate data
- delete [] *dest;
- *dest = new U8[total_size];
- S32 dest_offset = 0;
- S32 src_offset = 0;
-
- bytestream2bytestream(*dest, dest_offset, mBuffer, src_offset, total_size);
-
- return total_size;
-}
-
-S32 LLScriptExecuteLSL2::readState(U8 *src)
-{
- // first, blitz heap and stack
- S32 hr = get_register(mBuffer, LREG_HR);
- S32 tm = get_register(mBuffer, LREG_TM);
- memset(mBuffer + hr, 0, tm - hr);
-
- S32 src_offset = 0;
- S32 dest_offset = 0;
- S32 size;
-
- // read register size
- size = bytestream2integer(src, src_offset);
-
- // copy data into register area
- bytestream2bytestream(mBuffer, dest_offset, src, src_offset, size);
-// LL_INFOS() << "Read CE: " << getCurrentEvents() << LL_ENDL;
- if (get_register(mBuffer, LREG_TM) != TOP_OF_MEMORY)
- {
- LL_WARNS() << "Invalid state. Top of memory register does not match"
- << " constant." << LL_ENDL;
- reset_hp_to_safe_spot(mBuffer);
- return -1;
- }
-
- // read heap size
- size = bytestream2integer(src, src_offset);
-
- // set dest offset
- dest_offset = get_register(mBuffer, LREG_HR);
-
- if (dest_offset + size > TOP_OF_MEMORY)
- {
- reset_hp_to_safe_spot(mBuffer);
- return -1;
- }
-
- // copy data into heap area
- bytestream2bytestream(mBuffer, dest_offset, src, src_offset, size);
-
- // read stack size
- size = bytestream2integer(src, src_offset);
-
- // set dest offset
- dest_offset = get_register(mBuffer, LREG_SP);
-
- if (dest_offset + size > TOP_OF_MEMORY)
- {
- reset_hp_to_safe_spot(mBuffer);
- return -1;
- }
-
- // copy data into heap area
- bytestream2bytestream(mBuffer, dest_offset, src, src_offset, size);
-
- // Return offset to first byte after read data.
- return src_offset;
-}
-
-void LLScriptExecuteLSL2::reset()
-{
- LLScriptExecute::reset();
-
- const U8 *src = getBytecode();
- S32 size = getBytecodeSize();
-
- if (!src)
- return;
-
- // first, blitz heap and stack
- S32 hr = get_register(mBuffer, LREG_HR);
- S32 tm = get_register(mBuffer, LREG_TM);
- memset(mBuffer + hr, 0, tm - hr);
-
- S32 dest_offset = 0;
- S32 src_offset = 0;
-
- bytestream2bytestream(mBuffer, dest_offset, src, src_offset, size);
-}
-
-S32 LLScriptExecuteLSL2::getMajorVersion() const
-{
- S32 version = getVersion();
- S32 major_version = 0;
- if (version == LSL2_VERSION1_END_NUMBER){
- major_version = 1;
- }
- else if (version == LSL2_VERSION_NUMBER)
- {
- major_version = 2;
- }
- return major_version;
-}
-
-U32 LLScriptExecuteLSL2::getUsedMemory()
-{
- return getBytecodeSize();
-}
-
-LLScriptExecute::LLScriptExecute() :
- mReset(FALSE)
-{
-}
-
-void LLScriptExecute::reset()
-{
- mReset = FALSE;
-}
-
-bool LLScriptExecute::isYieldDue() const
-{
- if(mReset)
- {
- return true;
- }
-
- if(getSleep() > 0.f)
- {
- return true;
- }
-
- if(isFinished())
- {
- return true;
- }
-
- // State changes can occur within a single time slice,
- // but LLScriptData's clean up is required. Yield here
- // to allow LLScriptData to perform cleanup and then call
- // runQuanta again.
- if(isStateChangePending())
- {
- return true;
- }
-
- return false;
-}
-
-// Run smallest number of instructions possible:
-// a single instruction for LSL2, a segment between save tests for Mono
-void LLScriptExecute::runInstructions(BOOL b_print, const LLUUID &id,
- const char **errorstr,
- U32& events_processed,
- F32 quanta)
-{
- // is there a fault?
- // if yes, print out message and exit
- S32 value = getVersion();
- if ( (value != LSL2_VERSION1_END_NUMBER) && (value != LSL2_VERSION_NUMBER) )
- {
- setFault(LSRF_VERSION_MISMATCH);
- }
- value = getFaults();
- if (value > LSRF_INVALID && value < LSRF_EOF)
- {
- if (b_print)
- {
- printf("Error!\n");
- }
- *errorstr = LSCRIPTRunTimeFaultStrings[value];
- return;
- }
- else
- {
- *errorstr = NULL;
- }
-
- if (! isFinished())
- {
- resumeEventHandler(b_print, id, quanta);
- return;
- }
- else
- {
- // make sure that IE is zero
- setCurrentHandler(0);
-
- // if no, we're in a state and waiting for an event
- U64 current_events = getCurrentEvents();
- U64 event_register = getEventHandlers();
-
- // check NS to see if need to switch states (NS != CS)
- if (isStateChangePending())
- {
- // ok, blow away any pending events
- deleteAllEvents();
-
- // if yes, check state exit flag is set
- if (current_events & LSCRIPTStateBitField[LSTT_STATE_EXIT])
- {
- // if yes, clear state exit flag
- setCurrentHandler(LSCRIPTStateBitField[LSTT_STATE_EXIT]);
- current_events &= ~LSCRIPTStateBitField[LSTT_STATE_EXIT];
- setCurrentEvents(current_events);
-
- // check state exit event handler
- // if there is a handler, call it
- if (event_register & LSCRIPTStateBitField[LSTT_STATE_EXIT])
- {
- ++events_processed;
- callEventHandler(LSTT_STATE_EXIT, id, quanta);
- return;
- }
- }
-
- // if no handler or no state exit flag switch to new state
- // set state entry flag and clear other CE flags
- current_events = LSCRIPTStateBitField[LSTT_STATE_ENTRY];
- setCurrentEvents(current_events);
-
- U64 handled_events = nextState();
- setEventHandlers(handled_events);
- }
-
- // try to get next event from stack
- BOOL b_done = FALSE;
- LSCRIPTStateEventType event = LSTT_NULL;
-
- current_events = getCurrentEvents();
- event_register = getEventHandlers();
-
- // first, check to see if state_entry or onrez are raised and handled
- if ((current_events & LSCRIPTStateBitField[LSTT_STATE_ENTRY])
- &&(current_events & event_register))
- {
- ++events_processed;
- callEventHandler(LSTT_STATE_ENTRY, id, quanta);
- b_done = TRUE;
- }
- else if ((current_events & LSCRIPTStateBitField[LSTT_REZ])
- &&(current_events & event_register))
- {
- ++events_processed;
- callQueuedEventHandler(LSTT_REZ, id, quanta);
- b_done = TRUE;
- }
-
- if (!b_done)
- {
- // Call handler for next queued event.
- if(getEventCount() > 0)
- {
- ++events_processed;
- callNextQueuedEventHandler(event_register, id, quanta);
- }
- else
- {
- // if no data waiting, do it the old way:
- U64 handled_current = current_events & event_register;
- if (handled_current)
- {
- event = return_first_event((S32)handled_current);
- ++events_processed;
- callEventHandler(event, id, quanta);
- }
- }
- b_done = TRUE;
- }
- }
-}
-
-// Run for a single timeslice, or until a yield or state transition is due
-F32 LLScriptExecute::runQuanta(BOOL b_print, const LLUUID &id, const char **errorstr, F32 quanta, U32& events_processed, LLTimer& timer)
-{
- S32 timer_checks = 0;
- F32 inloop = 0;
-
- // Loop while not finished, yield not due and time remaining
- // NOTE: Default implementation does not do adaptive timer skipping
- // to preserve current LSL behaviour and not break scripts that rely
- // on current execution speed.
- while(true)
- {
- runInstructions(b_print, id, errorstr,
- events_processed, quanta);
-
- if(isYieldDue())
- {
- break;
- }
- else if(timer_checks++ >= LLScriptExecute::sTimerCheckSkip)
- {
- inloop = timer.getElapsedTimeF32();
- if(inloop > quanta)
- {
- break;
- }
- timer_checks = 0;
- }
- }
- if (inloop == 0.0f)
- {
- inloop = timer.getElapsedTimeF32();
- }
- return inloop;
-}
-
-F32 LLScriptExecute::runNested(BOOL b_print, const LLUUID &id, const char **errorstr, F32 quanta, U32& events_processed, LLTimer& timer)
-{
- return LLScriptExecute::runQuanta(b_print, id, errorstr, quanta, events_processed, timer);
-}
-
-BOOL run_noop(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tNOOP\n", offset);
- offset++;
- return FALSE;
-}
-
-BOOL run_pop(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tPOP\n", offset);
- offset++;
- lscript_poparg(buffer, LSCRIPTDataSize[LST_INTEGER]);
- return FALSE;
-}
-
-BOOL run_pops(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tPOPS\n", offset);
- offset++;
- S32 address = lscript_pop_int(buffer);
- if (address)
- lsa_decrease_ref_count(buffer, address);
- return FALSE;
-}
-
-BOOL run_popl(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tPOPL\n", offset);
- offset++;
- S32 address = lscript_pop_int(buffer);
- if (address)
- lsa_decrease_ref_count(buffer, address);
- return FALSE;
-}
-
-BOOL run_popv(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tPOPV\n", offset);
- offset++;
- lscript_poparg(buffer, LSCRIPTDataSize[LST_VECTOR]);
- return FALSE;
-}
-
-BOOL run_popq(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tPOPQ\n", offset);
- offset++;
- lscript_poparg(buffer, LSCRIPTDataSize[LST_QUATERNION]);
- return FALSE;
-}
-
-BOOL run_poparg(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tPOPARG ", offset);
- offset++;
- S32 arg = safe_instruction_bytestream2integer(buffer, offset);
- if (b_print)
- printf("%d\n", arg);
- lscript_poparg(buffer, arg);
- return FALSE;
-}
-
-BOOL run_popip(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tPOPIP\n", offset);
- offset++;
- offset = lscript_pop_int(buffer);
- return FALSE;
-}
-
-BOOL run_popbp(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tPOPBP\n", offset);
- offset++;
- S32 bp = lscript_pop_int(buffer);
- set_bp(buffer, bp);
- return FALSE;
-}
-
-BOOL run_popsp(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tPOPSP\n", offset);
- offset++;
- S32 sp = lscript_pop_int(buffer);
- set_sp(buffer, sp);
- return FALSE;
-}
-
-BOOL run_popslr(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tPOPSLR\n", offset);
- offset++;
- S32 slr = lscript_pop_int(buffer);
- set_register(buffer, LREG_SLR, slr);
- return FALSE;
-}
-
-BOOL run_dup(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tDUP\n", offset);
- offset++;
- S32 sp = get_register(buffer, LREG_SP);
- S32 value = bytestream2integer(buffer, sp);
- lscript_push(buffer, value);
- return FALSE;
-}
-
-BOOL run_dups(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tDUPS\n", offset);
- offset++;
- S32 sp = get_register(buffer, LREG_SP);
- S32 value = bytestream2integer(buffer, sp);
- lscript_push(buffer, value);
- lsa_increase_ref_count(buffer, value);
- return FALSE;
-}
-
-BOOL run_dupl(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tDUPL\n", offset);
- offset++;
- S32 sp = get_register(buffer, LREG_SP);
- S32 value = bytestream2integer(buffer, sp);
- lscript_push(buffer, value);
- lsa_increase_ref_count(buffer, value);
- return FALSE;
-}
-
-BOOL run_dupv(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tDUPV\n", offset);
- offset++;
- S32 sp = get_register(buffer, LREG_SP);
- LLVector3 value;
- bytestream2vector(value, buffer, sp);
- lscript_push(buffer, value);
- return FALSE;
-}
-
-BOOL run_dupq(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tDUPV\n", offset);
- offset++;
- S32 sp = get_register(buffer, LREG_SP);
- LLQuaternion value;
- bytestream2quaternion(value, buffer, sp);
- lscript_push(buffer, value);
- return FALSE;
-}
-
-BOOL run_store(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tSTORE ", offset);
- offset++;
- S32 arg = safe_instruction_bytestream2integer(buffer, offset);
- if (b_print)
- printf("0x%X\n", arg);
- S32 sp = get_register(buffer, LREG_SP);
- S32 value = bytestream2integer(buffer, sp);
- lscript_local_store(buffer, arg, value);
- return FALSE;
-}
-
-BOOL run_stores(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tSTORES ", offset);
- offset++;
- S32 arg = safe_instruction_bytestream2integer(buffer, offset);
- if (b_print)
- printf("0x%X\n", arg);
- S32 sp = get_register(buffer, LREG_SP);
- S32 value = bytestream2integer(buffer, sp);
-
- S32 address = lscript_local_get(buffer, arg);
-
- lscript_local_store(buffer, arg, value);
- lsa_increase_ref_count(buffer, value);
- if (address)
- lsa_decrease_ref_count(buffer, address);
- return FALSE;
-}
-
-BOOL run_storel(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tSTOREL ", offset);
- offset++;
- S32 arg = safe_instruction_bytestream2integer(buffer, offset);
- if (b_print)
- printf("0x%X\n", arg);
- S32 sp = get_register(buffer, LREG_SP);
- S32 value = bytestream2integer(buffer, sp);
-
- S32 address = lscript_local_get(buffer, arg);
-
- lscript_local_store(buffer, arg, value);
- lsa_increase_ref_count(buffer, value);
- if (address)
- lsa_decrease_ref_count(buffer, address);
- return FALSE;
-}
-
-BOOL run_storev(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tSTOREV ", offset);
- offset++;
- S32 arg = safe_instruction_bytestream2integer(buffer, offset);
- if (b_print)
- printf("0x%X\n", arg);
- LLVector3 value;
- S32 sp = get_register(buffer, LREG_SP);
- bytestream2vector(value, buffer, sp);
- lscript_local_store(buffer, arg, value);
- return FALSE;
-}
-
-BOOL run_storeq(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tSTOREQ ", offset);
- offset++;
- S32 arg = safe_instruction_bytestream2integer(buffer, offset);
- if (b_print)
- printf("0x%X\n", arg);
- LLQuaternion value;
- S32 sp = get_register(buffer, LREG_SP);
- bytestream2quaternion(value, buffer, sp);
- lscript_local_store(buffer, arg, value);
- return FALSE;
-}
-
-BOOL run_storeg(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tSTOREG ", offset);
- offset++;
- S32 arg = safe_instruction_bytestream2integer(buffer, offset);
- if (b_print)
- printf("0x%X\n", arg);
- S32 sp = get_register(buffer, LREG_SP);
- S32 value = bytestream2integer(buffer, sp);
- lscript_global_store(buffer, arg, value);
- return FALSE;
-}
-
-BOOL run_storegs(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tSTOREGS ", offset);
- offset++;
- S32 arg = safe_instruction_bytestream2integer(buffer, offset);
- if (b_print)
- printf("0x%X\n", arg);
- S32 sp = get_register(buffer, LREG_SP);
- S32 value = bytestream2integer(buffer, sp);
-
- S32 address = lscript_global_get(buffer, arg);
-
- lscript_global_store(buffer, arg, value);
-
- lsa_increase_ref_count(buffer, value);
- if (address)
- lsa_decrease_ref_count(buffer, address);
- return FALSE;
-}
-
-BOOL run_storegl(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tSTOREGL ", offset);
- offset++;
- S32 arg = safe_instruction_bytestream2integer(buffer, offset);
- if (b_print)
- printf("0x%X\n", arg);
- S32 sp = get_register(buffer, LREG_SP);
- S32 value = bytestream2integer(buffer, sp);
-
- S32 address = lscript_global_get(buffer, arg);
-
- lscript_global_store(buffer, arg, value);
-
- lsa_increase_ref_count(buffer, value);
- if (address)
- lsa_decrease_ref_count(buffer, address);
- return FALSE;
-}
-
-BOOL run_storegv(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tSTOREGV ", offset);
- offset++;
- S32 arg = safe_instruction_bytestream2integer(buffer, offset);
- if (b_print)
- printf("0x%X\n", arg);
- LLVector3 value;
- S32 sp = get_register(buffer, LREG_SP);
- bytestream2vector(value, buffer, sp);
- lscript_global_store(buffer, arg, value);
- return FALSE;
-}
-
-BOOL run_storegq(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tSTOREGQ ", offset);
- offset++;
- S32 arg = safe_instruction_bytestream2integer(buffer, offset);
- if (b_print)
- printf("0x%X\n", arg);
- LLQuaternion value;
- S32 sp = get_register(buffer, LREG_SP);
- bytestream2quaternion(value, buffer, sp);
- lscript_global_store(buffer, arg, value);
- return FALSE;
-}
-
-BOOL run_loadp(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tSTOREP ", offset);
- offset++;
- S32 arg = safe_instruction_bytestream2integer(buffer, offset);
- if (b_print)
- printf("0x%X\n", arg);
- S32 value = lscript_pop_int(buffer);
- lscript_local_store(buffer, arg, value);
- return FALSE;
-}
-
-BOOL run_loadsp(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tSTORESP ", offset);
- offset++;
- S32 arg = safe_instruction_bytestream2integer(buffer, offset);
- if (b_print)
- printf("0x%X\n", arg);
- S32 value = lscript_pop_int(buffer);
-
- S32 address = lscript_local_get(buffer, arg);
- if (address)
- lsa_decrease_ref_count(buffer, address);
-
- lscript_local_store(buffer, arg, value);
- return FALSE;
-}
-
-BOOL run_loadlp(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tSTORELP ", offset);
- offset++;
- S32 arg = safe_instruction_bytestream2integer(buffer, offset);
- if (b_print)
- printf("0x%X\n", arg);
- S32 value = lscript_pop_int(buffer);
-
- S32 address = lscript_local_get(buffer, arg);
- if (address)
- lsa_decrease_ref_count(buffer, address);
-
- lscript_local_store(buffer, arg, value);
- return FALSE;
-}
-
-BOOL run_loadvp(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tSTOREVP ", offset);
- offset++;
- S32 arg = safe_instruction_bytestream2integer(buffer, offset);
- if (b_print)
- printf("0x%X\n", arg);
- LLVector3 value;
- lscript_pop_vector(buffer, value);
- lscript_local_store(buffer, arg, value);
- return FALSE;
-}
-
-BOOL run_loadqp(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tSTOREQP ", offset);
- offset++;
- S32 arg = safe_instruction_bytestream2integer(buffer, offset);
- if (b_print)
- printf("0x%X\n", arg);
- LLQuaternion value;
- lscript_pop_quaternion(buffer, value);
- lscript_local_store(buffer, arg, value);
- return FALSE;
-}
-
-BOOL run_loadgp(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tSTOREGP ", offset);
- offset++;
- S32 arg = safe_instruction_bytestream2integer(buffer, offset);
- if (b_print)
- printf("0x%X\n", arg);
- S32 value = lscript_pop_int(buffer);
- lscript_global_store(buffer, arg, value);
- return FALSE;
-}
-
-BOOL run_loadgsp(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tSTOREGSP ", offset);
- offset++;
- S32 arg = safe_instruction_bytestream2integer(buffer, offset);
- if (b_print)
- printf("%d\n", arg);
- S32 value = lscript_pop_int(buffer);
-
- S32 address = lscript_global_get(buffer, arg);
- if (address)
- lsa_decrease_ref_count(buffer, address);
-
- lscript_global_store(buffer, arg, value);
- return FALSE;
-}
-
-BOOL run_loadglp(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tSTOREGLP ", offset);
- offset++;
- S32 arg = safe_instruction_bytestream2integer(buffer, offset);
- if (b_print)
- printf("0x%X\n", arg);
- S32 value = lscript_pop_int(buffer);
-
- S32 address = lscript_global_get(buffer, arg);
- if (address)
- lsa_decrease_ref_count(buffer, address);
-
- lscript_global_store(buffer, arg, value);
- return FALSE;
-}
-
-BOOL run_loadgvp(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tSTOREGVP ", offset);
- offset++;
- S32 arg = safe_instruction_bytestream2integer(buffer, offset);
- if (b_print)
- printf("0x%X\n", arg);
- LLVector3 value;
- lscript_pop_vector(buffer, value);
- lscript_global_store(buffer, arg, value);
- return FALSE;
-}
-
-BOOL run_loadgqp(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tSTOREGQP ", offset);
- offset++;
- S32 arg = safe_instruction_bytestream2integer(buffer, offset);
- if (b_print)
- printf("0x%X\n", arg);
- LLQuaternion value;
- lscript_pop_quaternion(buffer, value);
- lscript_global_store(buffer, arg, value);
- return FALSE;
-}
-
-BOOL run_push(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tPUSH ", offset);
- offset++;
- S32 arg = safe_instruction_bytestream2integer(buffer, offset);
- if (b_print)
- printf("0x%X\n", arg);
- S32 value = lscript_local_get(buffer, arg);
- lscript_push(buffer, value);
- return FALSE;
-}
-
-BOOL run_pushs(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tPUSHS ", offset);
- offset++;
- S32 arg = safe_instruction_bytestream2integer(buffer, offset);
- if (b_print)
- printf("0x%X\n", arg);
- S32 value = lscript_local_get(buffer, arg);
- lscript_push(buffer, value);
- lsa_increase_ref_count(buffer, value);
- return FALSE;
-}
-
-BOOL run_pushl(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tPUSHL ", offset);
- offset++;
- S32 arg = safe_instruction_bytestream2integer(buffer, offset);
- if (b_print)
- printf("0x%X\n", arg);
- S32 value = lscript_local_get(buffer, arg);
- lscript_push(buffer, value);
- lsa_increase_ref_count(buffer, value);
- return FALSE;
-}
-
-BOOL run_pushv(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tPUSHV ", offset);
- offset++;
- S32 arg = safe_instruction_bytestream2integer(buffer, offset);
- if (b_print)
- printf("0x%X\n", arg);
- LLVector3 value;
- lscript_local_get(buffer, arg, value);
- lscript_push(buffer, value);
- return FALSE;
-}
-
-BOOL run_pushq(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tPUSHQ ", offset);
- offset++;
- S32 arg = safe_instruction_bytestream2integer(buffer, offset);
- if (b_print)
- printf("0x%X\n", arg);
- LLQuaternion value;
- lscript_local_get(buffer, arg, value);
- lscript_push(buffer, value);
- return FALSE;
-}
-
-BOOL run_pushg(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tPUSHG ", offset);
- offset++;
- S32 arg = safe_instruction_bytestream2integer(buffer, offset);
- if (b_print)
- printf("0x%X\n", arg);
- S32 value = lscript_global_get(buffer, arg);
- lscript_push(buffer, value);
- return FALSE;
-}
-
-BOOL run_pushgs(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tPUSHGS ", offset);
- offset++;
- S32 arg = safe_instruction_bytestream2integer(buffer, offset);
- if (b_print)
- printf("0x%X\n", arg);
- S32 value = lscript_global_get(buffer, arg);
- lscript_push(buffer, value);
- lsa_increase_ref_count(buffer, value);
- return FALSE;
-}
-
-BOOL run_pushgl(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tPUSHGL ", offset);
- offset++;
- S32 arg = safe_instruction_bytestream2integer(buffer, offset);
- if (b_print)
- printf("0x%X\n", arg);
- S32 value = lscript_global_get(buffer, arg);
- lscript_push(buffer, value);
- lsa_increase_ref_count(buffer, value);
- return FALSE;
-}
-
-BOOL run_pushgv(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tPUSHGV ", offset);
- offset++;
- S32 arg = safe_instruction_bytestream2integer(buffer, offset);
- if (b_print)
- printf("0x%X\n", arg);
- LLVector3 value;
- lscript_global_get(buffer, arg, value);
- lscript_push(buffer, value);
- return FALSE;
-}
-
-BOOL run_pushgq(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tPUSHGQ ", offset);
- offset++;
- S32 arg = safe_instruction_bytestream2integer(buffer, offset);
- if (b_print)
- printf("0x%X\n", arg);
- LLQuaternion value;
- lscript_global_get(buffer, arg, value);
- lscript_push(buffer, value);
- return FALSE;
-}
-
-BOOL run_puship(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tPUSHIP\n", offset);
- offset++;
- lscript_push(buffer, offset);
- return FALSE;
-}
-
-BOOL run_pushbp(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tPUSHBP\n", offset);
- offset++;
- lscript_push(buffer, get_register(buffer, LREG_BP));
- return FALSE;
-}
-
-BOOL run_pushsp(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tPUSHSP\n", offset);
- offset++;
- lscript_push(buffer, get_register(buffer, LREG_SP));
- return FALSE;
-}
-
-BOOL run_pushargb(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tPUSHGARGB ", offset);
- offset++;
- U8 arg = safe_instruction_bytestream2byte(buffer, offset);
- if (b_print)
- printf("%d\n", (U32)arg);
- lscript_push(buffer, arg);
- return FALSE;
-}
-
-BOOL run_pushargi(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tPUSHARGI ", offset);
- offset++;
- S32 arg = safe_instruction_bytestream2integer(buffer, offset);
- if (b_print)
- printf("%d\n", arg);
- lscript_push(buffer, arg);
- return FALSE;
-}
-
-BOOL run_pushargf(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tPUSHARGF ", offset);
- offset++;
- F32 arg = safe_instruction_bytestream2float(buffer, offset);
- if (b_print)
- printf("%f\n", arg);
- lscript_push(buffer, arg);
- return FALSE;
-}
-
-BOOL run_pushargs(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tPUSHARGS ", offset);
- S32 toffset = offset;
- safe_instruction_bytestream_count_char(buffer, toffset);
- S32 size = toffset - offset;
- char *arg = new char[size];
- offset++;
- safe_instruction_bytestream2char(arg, buffer, offset, size);
- if (b_print)
- printf("%s\n", arg);
- S32 address = lsa_heap_add_data(buffer, new LLScriptLibData(arg), get_max_heap_size(buffer), TRUE);
- lscript_push(buffer, address);
- delete [] arg;
- return FALSE;
-}
-
-BOOL run_pushargv(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tPUSHARGV ", offset);
- offset++;
- LLVector3 arg;
- safe_instruction_bytestream2vector(arg, buffer, offset);
- if (b_print)
- printf("< %f, %f, %f >\n", arg.mV[VX], arg.mV[VY], arg.mV[VZ]);
- lscript_push(buffer, arg);
- return FALSE;
-}
-BOOL run_pushargq(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tPUSHARGQ ", offset);
- offset++;
- LLQuaternion arg;
- safe_instruction_bytestream2quaternion(arg, buffer, offset);
- if (b_print)
- printf("< %f, %f, %f, %f >\n", arg.mQ[VX], arg.mQ[VY], arg.mQ[VZ], arg.mQ[VS]);
- lscript_push(buffer, arg);
- return FALSE;
-}
-BOOL run_pushe(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tPUSHE\n", offset);
- offset++;
- lscript_pusharge(buffer, LSCRIPTDataSize[LST_INTEGER]);
- return FALSE;
-}
-BOOL run_pushev(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tPUSHEV\n", offset);
- offset++;
- lscript_pusharge(buffer, LSCRIPTDataSize[LST_VECTOR]);
- return FALSE;
-}
-BOOL run_pusheq(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tPUSHEQ\n", offset);
- offset++;
- lscript_pusharge(buffer, LSCRIPTDataSize[LST_QUATERNION]);
- return FALSE;
-}
-BOOL run_pusharge(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tPUSHARGE ", offset);
- offset++;
- S32 arg = safe_instruction_bytestream2integer(buffer, offset);
- if (b_print)
- printf("%d\n", arg);
- lscript_pusharge(buffer, arg);
- return FALSE;
-}
-
-void print_type(U8 type)
-{
- if (type == LSCRIPTTypeByte[LST_INTEGER])
- {
- printf("integer");
- }
- else if (type == LSCRIPTTypeByte[LST_FLOATINGPOINT])
- {
- printf("float");
- }
- else if (type == LSCRIPTTypeByte[LST_STRING])
- {
- printf("string");
- }
- else if (type == LSCRIPTTypeByte[LST_KEY])
- {
- printf("key");
- }
- else if (type == LSCRIPTTypeByte[LST_VECTOR])
- {
- printf("vector");
- }
- else if (type == LSCRIPTTypeByte[LST_QUATERNION])
- {
- printf("quaternion");
- }
- else if (type == LSCRIPTTypeByte[LST_LIST])
- {
- printf("list");
- }
-}
-
-void unknown_operation(U8 *buffer, LSCRIPTOpCodesEnum opcode)
-{
- printf("Unknown arithmetic operation!\n");
-}
-
-void integer_integer_operation(U8 *buffer, LSCRIPTOpCodesEnum opcode)
-{
- S32 lside = lscript_pop_int(buffer);
- S32 rside = lscript_pop_int(buffer);
- S32 result = 0;
-
- switch(opcode)
- {
- case LOPC_ADD:
- result = lside + rside;
- break;
- case LOPC_SUB:
- result = lside - rside;
- break;
- case LOPC_MUL:
- result = lside * rside;
- break;
- case LOPC_DIV:
- if (rside){
- if( ( rside == -1 ) || ( rside == (S32) 0xffffffff ) )// division by -1 can have funny results: multiplication is OK: SL-31252
- {
- result = -1 * lside;
- }
- else
- {
- result = lside / rside;
- }
- }
- else
- set_fault(buffer, LSRF_MATH);
- break;
- case LOPC_MOD:
- if (rside)
- {
- if (rside == -1 || rside == 1 ) // mod(1) = mod(-1) = 0: SL-31252
- {
- result = 0;
- }
- else
- {
- result = lside % rside;
- }
- }
- else
- set_fault(buffer, LSRF_MATH);
- break;
- case LOPC_EQ:
- result = (lside == rside);
- break;
- case LOPC_NEQ:
- result = (lside != rside);
- break;
- case LOPC_LEQ:
- result = (lside <= rside);
- break;
- case LOPC_GEQ:
- result = (lside >= rside);
- break;
- case LOPC_LESS:
- result = (lside < rside);
- break;
- case LOPC_GREATER:
- result = (lside > rside);
- break;
- case LOPC_BITAND:
- result = (lside & rside);
- break;
- case LOPC_BITOR:
- result = (lside | rside);
- break;
- case LOPC_BITXOR:
- result = (lside ^ rside);
- break;
- case LOPC_BOOLAND:
- result = (lside && rside);
- break;
- case LOPC_BOOLOR:
- result = (lside || rside);
- break;
- case LOPC_SHL:
- result = (lside << rside);
- break;
- case LOPC_SHR:
- result = (lside >> rside);
- break;
- default:
- break;
- }
- lscript_push(buffer, result);
-}
-
-void integer_float_operation(U8 *buffer, LSCRIPTOpCodesEnum opcode)
-{
- S32 lside = lscript_pop_int(buffer);
- F32 rside = lscript_pop_float(buffer);
- S32 resulti = 0;
- F32 resultf = 0;
-
- switch(opcode)
- {
- case LOPC_ADD:
- resultf = lside + rside;
- lscript_push(buffer, resultf);
- break;
- case LOPC_SUB:
- resultf = lside - rside;
- lscript_push(buffer, resultf);
- break;
- case LOPC_MUL:
- resultf = lside * rside;
- lscript_push(buffer, resultf);
- break;
- case LOPC_DIV:
- if (rside)
- resultf = lside / rside;
- else
- set_fault(buffer, LSRF_MATH);
- lscript_push(buffer, resultf);
- break;
- case LOPC_EQ:
- resulti = (lside == rside);
- lscript_push(buffer, resulti);
- break;
- case LOPC_NEQ:
- resulti = (lside != rside);
- lscript_push(buffer, resulti);
- break;
- case LOPC_LEQ:
- resulti = (lside <= rside);
- lscript_push(buffer, resulti);
- break;
- case LOPC_GEQ:
- resulti = (lside >= rside);
- lscript_push(buffer, resulti);
- break;
- case LOPC_LESS:
- resulti = (lside < rside);
- lscript_push(buffer, resulti);
- break;
- case LOPC_GREATER:
- resulti = (lside > rside);
- lscript_push(buffer, resulti);
- break;
- default:
- break;
- }
-}
-
-void integer_vector_operation(U8 *buffer, LSCRIPTOpCodesEnum opcode)
-{
- S32 lside = lscript_pop_int(buffer);
- LLVector3 rside;
- lscript_pop_vector(buffer, rside);
-
- switch(opcode)
- {
- case LOPC_MUL:
- rside *= (F32)lside;
- lscript_push(buffer, rside);
- break;
- default:
- break;
- }
-}
-
-void float_integer_operation(U8 *buffer, LSCRIPTOpCodesEnum opcode)
-{
- F32 lside = lscript_pop_float(buffer);
- S32 rside = lscript_pop_int(buffer);
- S32 resulti = 0;
- F32 resultf = 0;
-
- switch(opcode)
- {
- case LOPC_ADD:
- resultf = lside + rside;
- lscript_push(buffer, resultf);
- break;
- case LOPC_SUB:
- resultf = lside - rside;
- lscript_push(buffer, resultf);
- break;
- case LOPC_MUL:
- resultf = lside * rside;
- lscript_push(buffer, resultf);
- break;
- case LOPC_DIV:
- if (rside)
- resultf = lside / rside;
- else
- set_fault(buffer, LSRF_MATH);
- lscript_push(buffer, resultf);
- break;
- case LOPC_EQ:
- resulti = (lside == rside);
- lscript_push(buffer, resulti);
- break;
- case LOPC_NEQ:
- resulti = (lside != rside);
- lscript_push(buffer, resulti);
- break;
- case LOPC_LEQ:
- resulti = (lside <= rside);
- lscript_push(buffer, resulti);
- break;
- case LOPC_GEQ:
- resulti = (lside >= rside);
- lscript_push(buffer, resulti);
- break;
- case LOPC_LESS:
- resulti = (lside < rside);
- lscript_push(buffer, resulti);
- break;
- case LOPC_GREATER:
- resulti = (lside > rside);
- lscript_push(buffer, resulti);
- break;
- default:
- break;
- }
-}
-
-void float_float_operation(U8 *buffer, LSCRIPTOpCodesEnum opcode)
-{
- F32 lside = lscript_pop_float(buffer);
- F32 rside = lscript_pop_float(buffer);
- F32 resultf = 0;
- S32 resulti = 0;
-
- switch(opcode)
- {
- case LOPC_ADD:
- resultf = lside + rside;
- lscript_push(buffer, resultf);
- break;
- case LOPC_SUB:
- resultf = lside - rside;
- lscript_push(buffer, resultf);
- break;
- case LOPC_MUL:
- resultf = lside * rside;
- lscript_push(buffer, resultf);
- break;
- case LOPC_DIV:
- if (rside)
- resultf = lside / rside;
- else
- set_fault(buffer, LSRF_MATH);
- lscript_push(buffer, resultf);
- break;
- case LOPC_EQ:
- resulti = (lside == rside);
- lscript_push(buffer, resulti);
- break;
- case LOPC_NEQ:
- resulti = (lside != rside);
- lscript_push(buffer, resulti);
- break;
- case LOPC_LEQ:
- resulti = (lside <= rside);
- lscript_push(buffer, resulti);
- break;
- case LOPC_GEQ:
- resulti = (lside >= rside);
- lscript_push(buffer, resulti);
- break;
- case LOPC_LESS:
- resulti = (lside < rside);
- lscript_push(buffer, resulti);
- break;
- case LOPC_GREATER:
- resulti = (lside > rside);
- lscript_push(buffer, resulti);
- break;
- default:
- break;
- }
-}
-
-void float_vector_operation(U8 *buffer, LSCRIPTOpCodesEnum opcode)
-{
- F32 lside = lscript_pop_float(buffer);
- LLVector3 rside;
- lscript_pop_vector(buffer, rside);
-
- switch(opcode)
- {
- case LOPC_MUL:
- rside *= lside;
- lscript_push(buffer, rside);
- break;
- default:
- break;
- }
-}
-
-void string_string_operation(U8 *buffer, LSCRIPTOpCodesEnum opcode)
-{
- S32 lside = lscript_pop_int(buffer);
- S32 rside = lscript_pop_int(buffer);
- S32 resulti;
- S32 address;
-
- switch(opcode)
- {
- case LOPC_ADD:
- address = lsa_cat_strings(buffer, lside, rside, get_max_heap_size(buffer));
- lscript_push(buffer, address);
- break;
- case LOPC_EQ:
- resulti = !lsa_cmp_strings(buffer, lside, rside);
- lscript_push(buffer, resulti);
- break;
- case LOPC_NEQ:
- resulti = lsa_cmp_strings(buffer, lside, rside);
- lscript_push(buffer, resulti);
- break;
- default:
- break;
- }
-}
-
-void string_key_operation(U8 *buffer, LSCRIPTOpCodesEnum opcode)
-{
- S32 lside = lscript_pop_int(buffer);
- S32 rside = lscript_pop_int(buffer);
- S32 resulti;
-
- switch(opcode)
- {
- case LOPC_NEQ:
- resulti = lsa_cmp_strings(buffer, lside, rside);
- lscript_push(buffer, resulti);
- break;
- case LOPC_EQ:
- resulti = !lsa_cmp_strings(buffer, lside, rside);
- lscript_push(buffer, resulti);
- break;
- default:
- break;
- }
-}
-
-void key_string_operation(U8 *buffer, LSCRIPTOpCodesEnum opcode)
-{
- S32 lside = lscript_pop_int(buffer);
- S32 rside = lscript_pop_int(buffer);
- S32 resulti;
-
- switch(opcode)
- {
- case LOPC_NEQ:
- resulti = lsa_cmp_strings(buffer, lside, rside);
- lscript_push(buffer, resulti);
- break;
- case LOPC_EQ:
- resulti = !lsa_cmp_strings(buffer, lside, rside);
- lscript_push(buffer, resulti);
- break;
- default:
- break;
- }
-}
-
-void key_key_operation(U8 *buffer, LSCRIPTOpCodesEnum opcode)
-{
- S32 lside = lscript_pop_int(buffer);
- S32 rside = lscript_pop_int(buffer);
- S32 resulti;
-
- switch(opcode)
- {
- case LOPC_EQ:
- resulti = !lsa_cmp_strings(buffer, lside, rside);
- lscript_push(buffer, resulti);
- break;
- case LOPC_NEQ:
- resulti = lsa_cmp_strings(buffer, lside, rside);
- lscript_push(buffer, resulti);
- break;
- default:
- break;
- }
-}
-
-void vector_integer_operation(U8 *buffer, LSCRIPTOpCodesEnum opcode)
-{
- LLVector3 lside;
- lscript_pop_vector(buffer, lside);
- S32 rside = lscript_pop_int(buffer);
-
- switch(opcode)
- {
- case LOPC_MUL:
- lside *= (F32)rside;
- lscript_push(buffer, lside);
- break;
- case LOPC_DIV:
- if (rside)
- lside *= (1.f/rside);
- else
- set_fault(buffer, LSRF_MATH);
- lscript_push(buffer, lside);
- break;
- default:
- break;
- }
-}
-
-void vector_float_operation(U8 *buffer, LSCRIPTOpCodesEnum opcode)
-{
- LLVector3 lside;
- lscript_pop_vector(buffer, lside);
- F32 rside = lscript_pop_float(buffer);
-
- switch(opcode)
- {
- case LOPC_MUL:
- lside *= rside;
- lscript_push(buffer, lside);
- break;
- case LOPC_DIV:
- if (rside)
- lside *= (1.f/rside);
- else
- set_fault(buffer, LSRF_MATH);
- lscript_push(buffer, lside);
- break;
- default:
- break;
- }
-}
-
-void vector_vector_operation(U8 *buffer, LSCRIPTOpCodesEnum opcode)
-{
- LLVector3 lside;
- lscript_pop_vector(buffer, lside);
- LLVector3 rside;
- lscript_pop_vector(buffer, rside);
- S32 resulti = 0;
- F32 resultf = 0.f;
-
- switch(opcode)
- {
- case LOPC_ADD:
- lside += rside;
- lscript_push(buffer, lside);
- break;
- case LOPC_SUB:
- lside -= rside;
- lscript_push(buffer, lside);
- break;
- case LOPC_MUL:
- resultf = lside * rside;
- lscript_push(buffer, resultf);
- break;
- case LOPC_MOD:
- lside = lside % rside;
- lscript_push(buffer, lside);
- break;
- case LOPC_EQ:
- resulti = (lside == rside);
- lscript_push(buffer, resulti);
- break;
- case LOPC_NEQ:
- resulti = (lside != rside);
- lscript_push(buffer, resulti);
- break;
- default:
- break;
- }
-}
-
-void vector_quaternion_operation(U8 *buffer, LSCRIPTOpCodesEnum opcode)
-{
- LLVector3 lside;
- lscript_pop_vector(buffer, lside);
- LLQuaternion rside;
- lscript_pop_quaternion(buffer, rside);
-
- switch(opcode)
- {
- case LOPC_MUL:
- lside = lside * rside;
- lscript_push(buffer, lside);
- break;
- case LOPC_DIV:
- lside = lside * rside.conjQuat();
- lscript_push(buffer, lside);
- break;
- default:
- break;
- }
-}
-
-void quaternion_quaternion_operation(U8 *buffer, LSCRIPTOpCodesEnum opcode)
-{
- LLQuaternion lside;
- lscript_pop_quaternion(buffer, lside);
- LLQuaternion rside;
- lscript_pop_quaternion(buffer, rside);
- S32 resulti = 0;
-
- switch(opcode)
- {
- case LOPC_ADD:
- lside = lside + rside;
- lscript_push(buffer, lside);
- break;
- case LOPC_SUB:
- lside = lside - rside;
- lscript_push(buffer, lside);
- break;
- case LOPC_MUL:
- lside *= rside;
- lscript_push(buffer, lside);
- break;
- case LOPC_DIV:
- lside = lside * rside.conjQuat();
- lscript_push(buffer, lside);
- break;
- case LOPC_EQ:
- resulti = (lside == rside);
- lscript_push(buffer, resulti);
- break;
- case LOPC_NEQ:
- resulti = (lside != rside);
- lscript_push(buffer, resulti);
- break;
- default:
- break;
- }
-}
-
-void integer_list_operation(U8 *buffer, LSCRIPTOpCodesEnum opcode)
-{
- S32 lside = lscript_pop_int(buffer);
- S32 rside = lscript_pop_int(buffer);
- S32 address;
-
- switch(opcode)
- {
- case LOPC_ADD:
- {
- LLScriptLibData *list = new LLScriptLibData;
- list->mType = LST_LIST;
- list->mListp = new LLScriptLibData(lside);
- address = lsa_preadd_lists(buffer, list, rside, get_max_heap_size(buffer));
- lscript_push(buffer, address);
- list->mListp = NULL;
- delete list;
- }
- break;
- default:
- break;
- }
-}
-
-void float_list_operation(U8 *buffer, LSCRIPTOpCodesEnum opcode)
-{
- F32 lside = lscript_pop_float(buffer);
- S32 rside = lscript_pop_int(buffer);
- S32 address;
-
- switch(opcode)
- {
- case LOPC_ADD:
- {
- LLScriptLibData *list = new LLScriptLibData;
- list->mType = LST_LIST;
- list->mListp = new LLScriptLibData(lside);
- address = lsa_preadd_lists(buffer, list, rside, get_max_heap_size(buffer));
- lscript_push(buffer, address);
- list->mListp = NULL;
- delete list;
- }
- break;
- default:
- break;
- }
-}
-
-void string_list_operation(U8 *buffer, LSCRIPTOpCodesEnum opcode)
-{
- S32 lside = lscript_pop_int(buffer);
- S32 rside = lscript_pop_int(buffer);
- S32 address;
-
- switch(opcode)
- {
- case LOPC_ADD:
- {
- LLScriptLibData *string = lsa_get_data(buffer, lside, TRUE);
- LLScriptLibData *list = new LLScriptLibData;
- list->mType = LST_LIST;
- list->mListp = string;
- address = lsa_preadd_lists(buffer, list, rside, get_max_heap_size(buffer));
- lscript_push(buffer, address);
- list->mListp = NULL;
- delete list;
- }
- break;
- default:
- break;
- }
-}
-
-void key_list_operation(U8 *buffer, LSCRIPTOpCodesEnum opcode)
-{
- S32 lside = lscript_pop_int(buffer);
- S32 rside = lscript_pop_int(buffer);
- S32 address;
-
- switch(opcode)
- {
- case LOPC_ADD:
- {
- LLScriptLibData *key = lsa_get_data(buffer, lside, TRUE);
- // need to convert key to key, since it comes out like a string
- if (key->mType == LST_STRING)
- {
- key->mKey = key->mString;
- key->mString = NULL;
- key->mType = LST_KEY;
- }
- LLScriptLibData *list = new LLScriptLibData;
- list->mType = LST_LIST;
- list->mListp = key;
- address = lsa_preadd_lists(buffer, list, rside, get_max_heap_size(buffer));
- lscript_push(buffer, address);
- list->mListp = NULL;
- delete list;
- }
- break;
- default:
- break;
- }
-}
-
-void vector_list_operation(U8 *buffer, LSCRIPTOpCodesEnum opcode)
-{
- LLVector3 lside;
- lscript_pop_vector(buffer, lside);
- S32 rside = lscript_pop_int(buffer);
- S32 address;
-
- switch(opcode)
- {
- case LOPC_ADD:
- {
- LLScriptLibData *list = new LLScriptLibData;
- list->mType = LST_LIST;
- list->mListp = new LLScriptLibData(lside);
- address = lsa_preadd_lists(buffer, list, rside, get_max_heap_size(buffer));
- lscript_push(buffer, address);
- list->mListp = NULL;
- delete list;
- }
- break;
- default:
- break;
- }
-}
-
-void quaternion_list_operation(U8 *buffer, LSCRIPTOpCodesEnum opcode)
-{
- LLQuaternion lside;
- lscript_pop_quaternion(buffer, lside);
- S32 rside = lscript_pop_int(buffer);
- S32 address;
-
- switch(opcode)
- {
- case LOPC_ADD:
- {
- LLScriptLibData *list = new LLScriptLibData;
- list->mType = LST_LIST;
- list->mListp = new LLScriptLibData(lside);
- address = lsa_preadd_lists(buffer, list, rside, get_max_heap_size(buffer));
- lscript_push(buffer, address);
- list->mListp = NULL;
- delete list;
- }
- break;
- default:
- break;
- }
-}
-
-void list_integer_operation(U8 *buffer, LSCRIPTOpCodesEnum opcode)
-{
- S32 lside = lscript_pop_int(buffer);
- S32 rside = lscript_pop_int(buffer);
- S32 address;
-
- switch(opcode)
- {
- case LOPC_ADD:
- {
- LLScriptLibData *list = new LLScriptLibData;
- list->mType = LST_LIST;
- list->mListp = new LLScriptLibData(rside);
- address = lsa_postadd_lists(buffer, lside, list, get_max_heap_size(buffer));
- list->mListp = NULL;
- delete list;
- lscript_push(buffer, address);
- }
- break;
- default:
- break;
- }
-}
-
-void list_float_operation(U8 *buffer, LSCRIPTOpCodesEnum opcode)
-{
- S32 lside = lscript_pop_int(buffer);
- F32 rside = lscript_pop_float(buffer);
- S32 address;
-
- switch(opcode)
- {
- case LOPC_ADD:
- {
- LLScriptLibData *list = new LLScriptLibData;
- list->mType = LST_LIST;
- list->mListp = new LLScriptLibData(rside);
- address = lsa_postadd_lists(buffer, lside, list, get_max_heap_size(buffer));
- list->mListp = NULL;
- delete list;
- lscript_push(buffer, address);
- }
- break;
- default:
- break;
- }
-}
-
-void list_string_operation(U8 *buffer, LSCRIPTOpCodesEnum opcode)
-{
- S32 lside = lscript_pop_int(buffer);
- S32 rside = lscript_pop_int(buffer);
- S32 address;
-
- switch(opcode)
- {
- case LOPC_ADD:
- {
- LLScriptLibData *string = lsa_get_data(buffer, rside, TRUE);
- LLScriptLibData *list = new LLScriptLibData;
- list->mType = LST_LIST;
- list->mListp = string;
- address = lsa_postadd_lists(buffer, lside, list, get_max_heap_size(buffer));
- list->mListp = NULL;
- delete list;
- lscript_push(buffer, address);
- }
- break;
- default:
- break;
- }
-}
-
-void list_key_operation(U8 *buffer, LSCRIPTOpCodesEnum opcode)
-{
- S32 lside = lscript_pop_int(buffer);
- S32 rside = lscript_pop_int(buffer);
- S32 address;
-
- switch(opcode)
- {
- case LOPC_ADD:
- {
- LLScriptLibData *key = lsa_get_data(buffer, rside, TRUE);
- // need to convert key to key, since it comes out like a string
- if (key->mType == LST_STRING)
- {
- key->mKey = key->mString;
- key->mString = NULL;
- key->mType = LST_KEY;
- }
- LLScriptLibData *list = new LLScriptLibData;
- list->mType = LST_LIST;
- list->mListp = key;
- address = lsa_postadd_lists(buffer, lside, list, get_max_heap_size(buffer));
- list->mListp = NULL;
- delete list;
- lscript_push(buffer, address);
- }
- break;
- default:
- break;
- }
-}
-
-void list_vector_operation(U8 *buffer, LSCRIPTOpCodesEnum opcode)
-{
- S32 lside = lscript_pop_int(buffer);
- LLVector3 rside;
- lscript_pop_vector(buffer, rside);
- S32 address;
-
- switch(opcode)
- {
- case LOPC_ADD:
- {
- LLScriptLibData *list = new LLScriptLibData;
- list->mType = LST_LIST;
- list->mListp = new LLScriptLibData(rside);
- address = lsa_postadd_lists(buffer, lside, list, get_max_heap_size(buffer));
- list->mListp = NULL;
- delete list;
- lscript_push(buffer, address);
- }
- break;
- default:
- break;
- }
-}
-
-void list_quaternion_operation(U8 *buffer, LSCRIPTOpCodesEnum opcode)
-{
- S32 lside = lscript_pop_int(buffer);
- LLQuaternion rside;
- lscript_pop_quaternion(buffer, rside);
- S32 address;
-
- switch(opcode)
- {
- case LOPC_ADD:
- {
- LLScriptLibData *list = new LLScriptLibData;
- list->mType = LST_LIST;
- list->mListp = new LLScriptLibData(rside);
- address = lsa_postadd_lists(buffer, lside, list, get_max_heap_size(buffer));
- list->mListp = NULL;
- delete list;
- lscript_push(buffer, address);
- }
- break;
- default:
- break;
- }
-}
-
-void list_list_operation(U8 *buffer, LSCRIPTOpCodesEnum opcode)
-{
- S32 lside = lscript_pop_int(buffer);
- S32 rside = lscript_pop_int(buffer);
- S32 resulti;
- S32 address;
-
- switch(opcode)
- {
- case LOPC_ADD:
- address = lsa_cat_lists(buffer, lside, rside, get_max_heap_size(buffer));
- lscript_push(buffer, address);
- break;
- case LOPC_EQ:
- resulti = !lsa_cmp_lists(buffer, lside, rside);
- lscript_push(buffer, resulti);
- break;
- case LOPC_NEQ:
- resulti = lsa_cmp_lists(buffer, lside, rside);
- lscript_push(buffer, resulti);
- break;
- default:
- break;
- }
-}
-
-static U8 safe_op_index(U8 index)
-{
- if(index >= LST_EOF)
- {
- // Operations on LST_NULL will always be unknown_operation.
- index = LST_NULL;
- }
- return index;
-}
-
-BOOL run_add(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tADD ", offset);
- offset++;
- U8 arg = safe_instruction_bytestream2byte(buffer, offset);
- U8 arg1 = safe_op_index(arg >> 4);
- U8 arg2 = safe_op_index(arg & 0xf);
- if (b_print)
- {
- print_type(arg1);
- printf(", ");
- print_type(arg2);
- printf("\n");
- }
- binary_operations[arg1][arg2](buffer, LOPC_ADD);
- return FALSE;
-}
-
-BOOL run_sub(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tSUB ", offset);
- offset++;
- U8 arg = safe_instruction_bytestream2byte(buffer, offset);
- U8 arg1 = safe_op_index(arg >> 4);
- U8 arg2 = safe_op_index(arg & 0xf);
- if (b_print)
- {
- print_type(arg1);
- printf(", ");
- print_type(arg2);
- printf("\n");
- }
- binary_operations[arg1][arg2](buffer, LOPC_SUB);
- return FALSE;
-}
-BOOL run_mul(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tMUL ", offset);
- offset++;
- U8 arg = safe_instruction_bytestream2byte(buffer, offset);
- U8 arg1 = safe_op_index(arg >> 4);
- U8 arg2 = safe_op_index(arg & 0xf);
- if (b_print)
- {
- print_type(arg1);
- printf(", ");
- print_type(arg2);
- printf("\n");
- }
- binary_operations[arg1][arg2](buffer, LOPC_MUL);
- return FALSE;
-}
-BOOL run_div(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tDIV ", offset);
- offset++;
- U8 arg = safe_instruction_bytestream2byte(buffer, offset);
- U8 arg1 = safe_op_index(arg >> 4);
- U8 arg2 = safe_op_index(arg & 0xf);
- if (b_print)
- {
- print_type(arg1);
- printf(", ");
- print_type(arg2);
- printf("\n");
- }
- binary_operations[arg1][arg2](buffer, LOPC_DIV);
- return FALSE;
-}
-BOOL run_mod(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tMOD ", offset);
- offset++;
- U8 arg = safe_instruction_bytestream2byte(buffer, offset);
- U8 arg1 = safe_op_index(arg >> 4);
- U8 arg2 = safe_op_index(arg & 0xf);
- if (b_print)
- {
- print_type(arg1);
- printf(", ");
- print_type(arg2);
- printf("\n");
- }
- binary_operations[arg1][arg2](buffer, LOPC_MOD);
- return FALSE;
-}
-
-BOOL run_eq(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tEQ ", offset);
- offset++;
- U8 arg = safe_instruction_bytestream2byte(buffer, offset);
- U8 arg1 = safe_op_index(arg >> 4);
- U8 arg2 = safe_op_index(arg & 0xf);
- if (b_print)
- {
- print_type(arg1);
- printf(", ");
- print_type(arg2);
- printf("\n");
- }
- binary_operations[arg1][arg2](buffer, LOPC_EQ);
- return FALSE;
-}
-BOOL run_neq(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tNEQ ", offset);
- offset++;
- U8 arg = safe_instruction_bytestream2byte(buffer, offset);
- U8 arg1 = safe_op_index(arg >> 4);
- U8 arg2 = safe_op_index(arg & 0xf);
- if (b_print)
- {
- print_type(arg1);
- printf(", ");
- print_type(arg2);
- printf("\n");
- }
- binary_operations[arg1][arg2](buffer, LOPC_NEQ);
- return FALSE;
-}
-BOOL run_leq(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tLEQ ", offset);
- offset++;
- U8 arg = safe_instruction_bytestream2byte(buffer, offset);
- U8 arg1 = safe_op_index(arg >> 4);
- U8 arg2 = safe_op_index(arg & 0xf);
- if (b_print)
- {
- print_type(arg1);
- printf(", ");
- print_type(arg2);
- printf("\n");
- }
- binary_operations[arg1][arg2](buffer, LOPC_LEQ);
- return FALSE;
-}
-BOOL run_geq(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tGEQ ", offset);
- offset++;
- U8 arg = safe_instruction_bytestream2byte(buffer, offset);
- U8 arg1 = safe_op_index(arg >> 4);
- U8 arg2 = safe_op_index(arg & 0xf);
- if (b_print)
- {
- print_type(arg1);
- printf(", ");
- print_type(arg2);
- printf("\n");
- }
- binary_operations[arg1][arg2](buffer, LOPC_GEQ);
- return FALSE;
-}
-BOOL run_less(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tLESS ", offset);
- offset++;
- U8 arg = safe_instruction_bytestream2byte(buffer, offset);
- U8 arg1 = safe_op_index(arg >> 4);
- U8 arg2 = safe_op_index(arg & 0xf);
- if (b_print)
- {
- print_type(arg1);
- printf(", ");
- print_type(arg2);
- printf("\n");
- }
- binary_operations[arg1][arg2](buffer, LOPC_LESS);
- return FALSE;
-}
-BOOL run_greater(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tGREATER ", offset);
- offset++;
- U8 arg = safe_instruction_bytestream2byte(buffer, offset);
- U8 arg1 = safe_op_index(arg >> 4);
- U8 arg2 = safe_op_index(arg & 0xf);
- if (b_print)
- {
- print_type(arg1);
- printf(", ");
- print_type(arg2);
- printf("\n");
- }
- binary_operations[arg1][arg2](buffer, LOPC_GREATER);
- return FALSE;
-}
-
-BOOL run_bitand(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tBITAND\n", offset);
- offset++;
- binary_operations[LST_INTEGER][LST_INTEGER](buffer, LOPC_BITAND);
- return FALSE;
-}
-BOOL run_bitor(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tBITOR\n", offset);
- offset++;
- binary_operations[LST_INTEGER][LST_INTEGER](buffer, LOPC_BITOR);
- return FALSE;
-}
-BOOL run_bitxor(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tBITXOR\n", offset);
- offset++;
- binary_operations[LST_INTEGER][LST_INTEGER](buffer, LOPC_BITXOR);
- return FALSE;
-}
-BOOL run_booland(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tBOOLAND\n", offset);
- offset++;
- binary_operations[LST_INTEGER][LST_INTEGER](buffer, LOPC_BOOLAND);
- return FALSE;
-}
-BOOL run_boolor(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tBOOLOR\n", offset);
- offset++;
- binary_operations[LST_INTEGER][LST_INTEGER](buffer, LOPC_BOOLOR);
- return FALSE;
-}
-
-BOOL run_shl(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tSHL\n", offset);
- offset++;
- binary_operations[LST_INTEGER][LST_INTEGER](buffer, LOPC_SHL);
- return FALSE;
-}
-BOOL run_shr(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tSHR\n", offset);
- offset++;
- binary_operations[LST_INTEGER][LST_INTEGER](buffer, LOPC_SHR);
- return FALSE;
-}
-
-void integer_operation(U8 *buffer, LSCRIPTOpCodesEnum opcode)
-{
- S32 lside = lscript_pop_int(buffer);
- S32 result = 0;
-
- switch(opcode)
- {
- case LOPC_NEG:
- result = -lside;
- break;
- case LOPC_BITNOT:
- result = ~lside;
- break;
- case LOPC_BOOLNOT:
- result = !lside;
- break;
- default:
- break;
- }
- lscript_push(buffer, result);
-}
-
-void float_operation(U8 *buffer, LSCRIPTOpCodesEnum opcode)
-{
- F32 lside = lscript_pop_float(buffer);
- F32 result = 0;
-
- switch(opcode)
- {
- case LOPC_NEG:
- result = -lside;
- lscript_push(buffer, result);
- break;
- default:
- break;
- }
-}
-
-void vector_operation(U8 *buffer, LSCRIPTOpCodesEnum opcode)
-{
- LLVector3 lside;
- lscript_pop_vector(buffer, lside);
- LLVector3 result;
-
- switch(opcode)
- {
- case LOPC_NEG:
- result = -lside;
- lscript_push(buffer, result);
- break;
- default:
- break;
- }
-}
-
-void quaternion_operation(U8 *buffer, LSCRIPTOpCodesEnum opcode)
-{
- LLQuaternion lside;
- lscript_pop_quaternion(buffer, lside);
- LLQuaternion result;
-
- switch(opcode)
- {
- case LOPC_NEG:
- result = -lside;
- lscript_push(buffer, result);
- break;
- default:
- break;
- }
-}
-
-BOOL run_neg(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tNEG ", offset);
- offset++;
- U8 arg = safe_op_index(safe_instruction_bytestream2byte(buffer, offset));
- if (b_print)
- {
- print_type(arg);
- printf("\n");
- }
- unary_operations[arg](buffer, LOPC_NEG);
- return FALSE;
-}
-
-BOOL run_bitnot(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tBITNOT\n", offset);
- offset++;
- unary_operations[LST_INTEGER](buffer, LOPC_BITNOT);
- return FALSE;
-}
-
-BOOL run_boolnot(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tBOOLNOT\n", offset);
- offset++;
- unary_operations[LST_INTEGER](buffer, LOPC_BOOLNOT);
- return FALSE;
-}
-
-BOOL run_jump(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tJUMP ", offset);
- offset++;
- S32 arg = safe_instruction_bytestream2integer(buffer, offset);
- if (b_print)
- printf("%d\n", arg);
- offset += arg;
- return FALSE;
-}
-
-BOOL run_jumpif(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tJUMPIF ", offset);
- offset++;
- U8 type = safe_instruction_bytestream2byte(buffer, offset);
- if (b_print)
- {
- print_type(type);
- printf(", ");
- }
- S32 arg = safe_instruction_bytestream2integer(buffer, offset);
- if (b_print)
- printf("%d\n", arg);
-
- if (type == LST_INTEGER)
- {
- S32 test = lscript_pop_int(buffer);
- if (test)
- {
- offset += arg;
- }
- }
- else if (type == LST_FLOATINGPOINT)
- {
- F32 test = lscript_pop_float(buffer);
- if (test)
- {
- offset += arg;
- }
- }
- else if (type == LST_VECTOR)
- {
- LLVector3 test;
- lscript_pop_vector(buffer, test);
- if (!test.isExactlyZero())
- {
- offset += arg;
- }
- }
- else if (type == LST_QUATERNION)
- {
- LLQuaternion test;
- lscript_pop_quaternion(buffer, test);
- if (!test.isIdentity())
- {
- offset += arg;
- }
- }
- else if (type == LST_STRING)
- {
- S32 base_address = lscript_pop_int(buffer);
- // this bit of nastiness is to get around that code paths to
- // local variables can result in lack of initialization and
- // function clean up of ref counts isn't based on scope (a
- // mistake, I know)
- S32 address = base_address + get_register(buffer, LREG_HR) - 1;
- if (address)
- {
- S32 string = address;
- string += SIZEOF_SCRIPT_ALLOC_ENTRY;
- if (safe_heap_check_address(buffer, string, 1))
- {
- S32 toffset = string;
- safe_heap_bytestream_count_char(buffer, toffset);
- S32 size = toffset - string;
- char *sdata = new char[size];
- bytestream2char(sdata, buffer, string, size);
- if (strlen(sdata)) /*Flawfinder: ignore*/
- {
- offset += arg;
- }
- delete [] sdata;
- }
- lsa_decrease_ref_count(buffer, base_address);
- }
- }
- else if (type == LST_KEY)
- {
- S32 base_address = lscript_pop_int(buffer);
- // this bit of nastiness is to get around that code paths to
- // local variables can result in lack of initialization and
- // function clean up of ref counts isn't based on scope (a
- // mistake, I know)
- S32 address = base_address + get_register(buffer, LREG_HR) - 1;
- if (address)
- {
- S32 string = address;
- string += SIZEOF_SCRIPT_ALLOC_ENTRY;
- if (safe_heap_check_address(buffer, string, 1))
- {
- S32 toffset = string;
- safe_heap_bytestream_count_char(buffer, toffset);
- S32 size = toffset - string;
- char *sdata = new char[size];
- bytestream2char(sdata, buffer, string, size);
- if (strlen(sdata)) /*Flawfinder: ignore*/
- {
- LLUUID id;
- if (id.set(sdata) && id.notNull())
- offset += arg;
- }
- delete [] sdata;
- }
- lsa_decrease_ref_count(buffer, base_address);
- }
- }
- else if (type == LST_LIST)
- {
- S32 base_address = lscript_pop_int(buffer);
- S32 address = base_address + get_register(buffer, LREG_HR) - 1;
- if (address)
- {
- if (safe_heap_check_address(buffer, address + SIZEOF_SCRIPT_ALLOC_ENTRY, 1))
- {
- LLScriptLibData *list = lsa_get_list_ptr(buffer, base_address, TRUE);
- if (list && list->getListLength())
- {
- offset += arg;
- }
- delete list;
- }
- }
- }
- return FALSE;
-}
-
-BOOL run_jumpnif(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tJUMPNIF ", offset);
- offset++;
- U8 type = safe_instruction_bytestream2byte(buffer, offset);
- if (b_print)
- {
- print_type(type);
- printf(", ");
- }
- S32 arg = safe_instruction_bytestream2integer(buffer, offset);
- if (b_print)
- printf("%d\n", arg);
-
- if (type == LST_INTEGER)
- {
- S32 test = lscript_pop_int(buffer);
- if (!test)
- {
- offset += arg;
- }
- }
- else if (type == LST_FLOATINGPOINT)
- {
- F32 test = lscript_pop_float(buffer);
- if (!test)
- {
- offset += arg;
- }
- }
- else if (type == LST_VECTOR)
- {
- LLVector3 test;
- lscript_pop_vector(buffer, test);
- if (test.isExactlyZero())
- {
- offset += arg;
- }
- }
- else if (type == LST_QUATERNION)
- {
- LLQuaternion test;
- lscript_pop_quaternion(buffer, test);
- if (test.isIdentity())
- {
- offset += arg;
- }
- }
- else if (type == LST_STRING)
- {
- S32 base_address = lscript_pop_int(buffer);
- // this bit of nastiness is to get around that code paths to
- // local variables can result in lack of initialization and
- // function clean up of ref counts isn't based on scope (a
- // mistake, I know)
- S32 address = base_address + get_register(buffer, LREG_HR) - 1;
- if (address)
- {
- S32 string = address;
- string += SIZEOF_SCRIPT_ALLOC_ENTRY;
- if (safe_heap_check_address(buffer, string, 1))
- {
- S32 toffset = string;
- safe_heap_bytestream_count_char(buffer, toffset);
- S32 size = toffset - string;
- char *sdata = new char[size];
- bytestream2char(sdata, buffer, string, size);
- if (!strlen(sdata)) /*Flawfinder: ignore*/
- {
- offset += arg;
- }
- delete [] sdata;
- }
- lsa_decrease_ref_count(buffer, base_address);
- }
- }
- else if (type == LST_KEY)
- {
- S32 base_address = lscript_pop_int(buffer);
- // this bit of nastiness is to get around that code paths to
- // local variables can result in lack of initialization and
- // function clean up of ref counts isn't based on scope (a
- // mistake, I know)
- S32 address = base_address + get_register(buffer, LREG_HR) - 1;
- if (address)
- {
- S32 string = address;
- string += SIZEOF_SCRIPT_ALLOC_ENTRY;
- if (safe_heap_check_address(buffer, string, 1))
- {
- S32 toffset = string;
- safe_heap_bytestream_count_char(buffer, toffset);
- S32 size = toffset - string;
- char *sdata = new char[size];
- bytestream2char(sdata, buffer, string, size);
- if (strlen(sdata)) /*Flawfinder: ignore*/
- {
- LLUUID id;
- if (!id.set(sdata) || id.isNull())
- offset += arg;
- }
- else
- {
- offset += arg;
- }
- delete [] sdata;
- }
- lsa_decrease_ref_count(buffer, base_address);
- }
- }
- else if (type == LST_LIST)
- {
- S32 base_address = lscript_pop_int(buffer);
- // this bit of nastiness is to get around that code paths to
- // local variables can result in lack of initialization and
- // function clean up of ref counts isn't based on scope (a
- // mistake, I know)
- S32 address = base_address + get_register(buffer, LREG_HR) - 1;
- if (address)
- {
- if (safe_heap_check_address(buffer, address + SIZEOF_SCRIPT_ALLOC_ENTRY, 1))
- {
- LLScriptLibData *list = lsa_get_list_ptr(buffer, base_address, TRUE);
- if (!list || !list->getListLength())
- {
- offset += arg;
- }
- delete list;
- }
- }
- }
- return FALSE;
-}
-
-BOOL run_state(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tSTATE ", offset);
- offset++;
- S32 state = safe_instruction_bytestream2integer(buffer, offset);
- if (b_print)
- printf("%d\n", state);
-
- S32 bp = lscript_pop_int(buffer);
- set_bp(buffer, bp);
-
- offset = lscript_pop_int(buffer);
-
- S32 major_version = 0;
- S32 value = get_register(buffer, LREG_VN);
- if (value == LSL2_VERSION1_END_NUMBER)
- {
- major_version = 1;
- }
- else if (value == LSL2_VERSION_NUMBER)
- {
- major_version = 2;
- }
-
- S32 current_state = get_register(buffer, LREG_CS);
- if (state != current_state)
- {
- U64 ce = get_event_register(buffer, LREG_CE, major_version);
- ce |= LSCRIPTStateBitField[LSTT_STATE_EXIT];
- set_event_register(buffer, LREG_CE, ce, major_version);
- }
- set_register(buffer, LREG_NS, state);
- return FALSE;
-}
-
-BOOL run_call(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tCALL ", offset);
- offset++;
- S32 func = safe_instruction_bytestream2integer(buffer, offset);
- if (b_print)
- printf("%d\n", func);
-
- lscript_local_store(buffer, -8, offset);
-
- S32 minimum = get_register(buffer, LREG_GFR);
- S32 maximum = get_register(buffer, LREG_SR);
- S32 lookup = minimum + func*4 + 4;
- S32 function;
-
- if ( (lookup >= minimum)
- &&(lookup < maximum))
- {
- function = bytestream2integer(buffer, lookup) + minimum;
- if ( (lookup >= minimum)
- &&(lookup < maximum))
- {
- offset = function;
- offset += bytestream2integer(buffer, function);
- }
- else
- {
- set_fault(buffer, LSRF_BOUND_CHECK_ERROR);
- }
- }
- else
- {
- set_fault(buffer, LSRF_BOUND_CHECK_ERROR);
- }
- return FALSE;
-}
-
-BOOL run_return(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tRETURN\n", offset);
- offset++;
-
- // SEC-53: babbage: broken instructions may allow inbalanced pushes and
- // pops which can cause caller BP and return IP to be corrupted, so restore
- // SP from BP before popping caller BP and IP.
- S32 bp = get_register(buffer, LREG_BP);
- set_sp(buffer, bp);
-
- bp = lscript_pop_int(buffer);
- set_bp(buffer, bp);
- offset = lscript_pop_int(buffer);
- return FALSE;
-}
-
-
-
-BOOL run_cast(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- char caststr[1024]; /*Flawfinder: ignore*/
- if (b_print)
- printf("[0x%X]\tCAST ", offset);
- offset++;
- U8 arg = safe_instruction_bytestream2byte(buffer, offset);
- U8 from = arg >> 4;
- U8 to = arg & 0xf;
- if (b_print)
- {
- print_type(from);
- printf(", ");
- print_type(to);
- printf("\n");
- }
-
- switch(from)
- {
- case LST_INTEGER:
- {
- switch(to)
- {
- case LST_INTEGER:
- break;
- case LST_FLOATINGPOINT:
- {
- S32 source = lscript_pop_int(buffer);
- F32 dest = (F32)source;
- lscript_push(buffer, dest);
- }
- break;
- case LST_STRING:
- {
- S32 address, source = lscript_pop_int(buffer);
- snprintf(caststr, sizeof(caststr), "%d", source); /* Flawfinder: ignore */
- address = lsa_heap_add_data(buffer, new LLScriptLibData(caststr), get_max_heap_size(buffer), TRUE);
- lscript_push(buffer, address);
- }
- break;
- case LST_LIST:
- {
- S32 address, source = lscript_pop_int(buffer);
- LLScriptLibData *list = new LLScriptLibData;
- list->mType = LST_LIST;
- list->mListp = new LLScriptLibData(source);
- address = lsa_heap_add_data(buffer, list, get_max_heap_size(buffer), TRUE);
- lscript_push(buffer, address);
- }
- break;
- default:
- break;
- }
- }
- break;
- case LST_FLOATINGPOINT:
- {
- switch(to)
- {
- case LST_INTEGER:
- {
- F32 source = lscript_pop_float(buffer);
- S32 dest = (S32)source;
- lscript_push(buffer, dest);
- }
- break;
- case LST_FLOATINGPOINT:
- break;
- case LST_STRING:
- {
- S32 address;
- F32 source = lscript_pop_float(buffer);
- snprintf(caststr, sizeof(caststr), "%f", source); /* Flawfinder: ignore */
- address = lsa_heap_add_data(buffer, new LLScriptLibData(caststr), get_max_heap_size(buffer), TRUE);
- lscript_push(buffer, address);
- }
- break;
- case LST_LIST:
- {
- S32 address;
- F32 source = lscript_pop_float(buffer);
- LLScriptLibData *list = new LLScriptLibData;
- list->mType = LST_LIST;
- list->mListp = new LLScriptLibData(source);
- address = lsa_heap_add_data(buffer, list, get_max_heap_size(buffer), TRUE);
- lscript_push(buffer, address);
- }
- break;
- default:
- break;
- }
- }
- break;
- case LST_STRING:
- {
- switch(to)
- {
- case LST_INTEGER:
- {
- S32 base_address = lscript_pop_int(buffer);
- // this bit of nastiness is to get around that code paths to local variables can result in lack of initialization
- // and function clean up of ref counts isn't based on scope (a mistake, I know)
- S32 address = base_address + get_register(buffer, LREG_HR) - 1;
- if (address)
- {
- S32 string = address;
- string += SIZEOF_SCRIPT_ALLOC_ENTRY;
- if (safe_heap_check_address(buffer, string, 1))
- {
- S32 toffset = string;
- safe_heap_bytestream_count_char(buffer, toffset);
- S32 size = toffset - string;
- char *arg = new char[size];
- bytestream2char(arg, buffer, string, size);
- // S32 length = strlen(arg);
- S32 dest;
- S32 base;
-
- // Check to see if this is a hexidecimal number.
- if ( (arg[0] == '0') &&
- (arg[1] == 'x' || arg[1] == 'X') )
- {
- // Let strtoul do a hex conversion.
- base = 16;
- }
- else
- {
- // Force base-10, so octal is never used.
- base = 10;
- }
-
- dest = strtoul(arg, NULL, base);
-
- lscript_push(buffer, dest);
- delete [] arg;
- }
- lsa_decrease_ref_count(buffer, base_address);
- }
- }
- break;
- case LST_FLOATINGPOINT:
- {
- S32 base_address = lscript_pop_int(buffer);
- // this bit of nastiness is to get around that code paths to local variables can result in lack of initialization
- // and function clean up of ref counts isn't based on scope (a mistake, I know)
- S32 address = base_address + get_register(buffer, LREG_HR) - 1;
- if (address)
- {
- S32 string = address;
- string += SIZEOF_SCRIPT_ALLOC_ENTRY;
- if (safe_heap_check_address(buffer, string, 1))
- {
- S32 toffset = string;
- safe_heap_bytestream_count_char(buffer, toffset);
- S32 size = toffset - string;
- char *arg = new char[size];
- bytestream2char(arg, buffer, string, size);
- F32 dest = (F32)atof(arg);
-
-
- lscript_push(buffer, dest);
- delete [] arg;
- }
- lsa_decrease_ref_count(buffer, base_address);
- }
- }
- break;
- case LST_STRING:
- break;
- case LST_LIST:
- {
- S32 saddress = lscript_pop_int(buffer);
- LLScriptLibData *string = lsa_get_data(buffer, saddress, TRUE);
- LLScriptLibData *list = new LLScriptLibData;
- list->mType = LST_LIST;
- list->mListp = string;
- S32 address = lsa_heap_add_data(buffer, list, get_max_heap_size(buffer), TRUE);
- lscript_push(buffer, address);
- }
- break;
- case LST_VECTOR:
- {
- S32 base_address = lscript_pop_int(buffer);
- // this bit of nastiness is to get around that code paths to local variables can result in lack of initialization
- // and function clean up of ref counts isn't based on scope (a mistake, I know)
- S32 address = base_address + get_register(buffer, LREG_HR) - 1;
- if (address)
- {
- S32 string = address;
- string += SIZEOF_SCRIPT_ALLOC_ENTRY;
- if (safe_heap_check_address(buffer, string, 1))
- {
- S32 toffset = string;
- safe_heap_bytestream_count_char(buffer, toffset);
- S32 size = toffset - string;
- char *arg = new char[size];
- bytestream2char(arg, buffer, string, size);
- LLVector3 vec;
- S32 num = sscanf(arg, "<%f, %f, %f>", &vec.mV[VX], &vec.mV[VY], &vec.mV[VZ]);
- if (num != 3)
- {
- vec = LLVector3::zero;
- }
- lscript_push(buffer, vec);
- delete [] arg;
- }
- lsa_decrease_ref_count(buffer, base_address);
- }
- }
- break;
- case LST_QUATERNION:
- {
- S32 base_address = lscript_pop_int(buffer);
- // this bit of nastiness is to get around that code paths to local variables can result in lack of initialization
- // and function clean up of ref counts isn't based on scope (a mistake, I know)
- S32 address = base_address + get_register(buffer, LREG_HR) - 1;
- if (address)
- {
- S32 string = address;
- string += SIZEOF_SCRIPT_ALLOC_ENTRY;
- if (safe_heap_check_address(buffer, string, 1))
- {
- S32 toffset = string;
- safe_heap_bytestream_count_char(buffer, toffset);
- S32 size = toffset - string;
- char *arg = new char[size];
- bytestream2char(arg, buffer, string, size);
- LLQuaternion quat;
- S32 num = sscanf(arg, "<%f, %f, %f, %f>", &quat.mQ[VX], &quat.mQ[VY], &quat.mQ[VZ], &quat.mQ[VW]);
- if (num != 4)
- {
- quat = LLQuaternion::DEFAULT;
-
- }
- lscript_push(buffer, quat);
- delete [] arg;
- }
- lsa_decrease_ref_count(buffer, base_address);
- }
- }
- break;
- default:
- break;
- }
- }
- break;
- case LST_KEY:
- {
- switch(to)
- {
- case LST_KEY:
- break;
- case LST_STRING:
- break;
- case LST_LIST:
- {
- S32 saddress = lscript_pop_int(buffer);
- LLScriptLibData *string = lsa_get_data(buffer, saddress, TRUE);
- LLScriptLibData *list = new LLScriptLibData;
- list->mType = LST_LIST;
- list->mListp = string;
- S32 address = lsa_heap_add_data(buffer, list, get_max_heap_size(buffer), TRUE);
- lscript_push(buffer, address);
- }
- break;
- default:
- break;
- }
- }
- break;
- case LST_VECTOR:
- {
- switch(to)
- {
- case LST_VECTOR:
- break;
- case LST_STRING:
- {
- S32 address;
- LLVector3 source;
- lscript_pop_vector(buffer, source);
- snprintf(caststr, sizeof(caststr), "<%5.5f, %5.5f, %5.5f>", source.mV[VX], source.mV[VY], source.mV[VZ]); /* Flawfinder: ignore */
- address = lsa_heap_add_data(buffer, new LLScriptLibData(caststr), get_max_heap_size(buffer), TRUE);
- lscript_push(buffer, address);
- }
- break;
- case LST_LIST:
- {
- S32 address;
- LLVector3 source;
- lscript_pop_vector(buffer, source);
- LLScriptLibData *list = new LLScriptLibData;
- list->mType = LST_LIST;
- list->mListp = new LLScriptLibData(source);
- address = lsa_heap_add_data(buffer, list, get_max_heap_size(buffer), TRUE);
- lscript_push(buffer, address);
- }
- break;
- default:
- break;
- }
- }
- break;
- case LST_QUATERNION:
- {
- switch(to)
- {
- case LST_QUATERNION:
- break;
- case LST_STRING:
- {
- S32 address;
- LLQuaternion source;
- lscript_pop_quaternion(buffer, source);
- snprintf(caststr, sizeof(caststr), "<%5.5f, %5.5f, %5.5f, %5.5f>", source.mQ[VX], source.mQ[VY], source.mQ[VZ], source.mQ[VS]); /* Flawfinder: ignore */
- address = lsa_heap_add_data(buffer, new LLScriptLibData(caststr), get_max_heap_size(buffer), TRUE);
- lscript_push(buffer, address);
- }
- break;
- case LST_LIST:
- {
- S32 address;
- LLQuaternion source;
- lscript_pop_quaternion(buffer, source);
- LLScriptLibData *list = new LLScriptLibData;
- list->mType = LST_LIST;
- list->mListp = new LLScriptLibData(source);
- address = lsa_heap_add_data(buffer, list, get_max_heap_size(buffer), TRUE);
- lscript_push(buffer, address);
- }
- break;
- default:
- break;
- }
- }
- break;
- case LST_LIST:
- {
- switch(to)
- {
- case LST_LIST:
- break;
- case LST_STRING:
- {
- S32 address = lscript_pop_int(buffer);
- LLScriptLibData *list = lsa_get_data(buffer, address, TRUE);
- LLScriptLibData *list_root = list;
-
- std::ostringstream dest;
- while (list)
- {
- list->print(dest, FALSE);
- list = list->mListp;
- }
- delete list_root;
- char *tmp = strdup(dest.str().c_str());
- LLScriptLibData *string = new LLScriptLibData(tmp);
- free(tmp);
- tmp = NULL;
- S32 destaddress = lsa_heap_add_data(buffer, string, get_max_heap_size(buffer), TRUE);
- lscript_push(buffer, destaddress);
- }
- break;
- default:
- break;
- }
- }
- break;
- default:
- break;
- }
- return FALSE;
-}
-
-BOOL run_stacktos(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- offset++;
- S32 length = lscript_pop_int(buffer);
- S32 i;
- char *arg = new char[length];
- S32 fault;
- for (i = 0; i < length; i++)
- {
- fault = get_register(buffer, LREG_FR);
- if (fault)
- break;
-
- arg[length - i - 1] = lscript_pop_char(buffer);
- }
- S32 address = lsa_heap_add_data(buffer, new LLScriptLibData(arg), get_max_heap_size(buffer), TRUE);
- lscript_push(buffer, address);
- delete [] arg;
- return FALSE;
-}
-
-void lscript_stacktol_pop_variable(LLScriptLibData *data, U8 *buffer, char type)
-{
- S32 address, string;
- S32 base_address;
-
- switch(type)
- {
- case LST_INTEGER:
- data->mType = LST_INTEGER;
- data->mInteger = lscript_pop_int(buffer);
- break;
- case LST_FLOATINGPOINT:
- data->mType = LST_FLOATINGPOINT;
- data->mFP = lscript_pop_float(buffer);
- break;
- case LST_KEY:
- data->mType = LST_KEY;
-
- base_address = lscript_pop_int(buffer);
- // this bit of nastiness is to get around that code paths to local variables can result in lack of initialization
- // and function clean up of ref counts isn't based on scope (a mistake, I know)
- address = base_address + get_register(buffer, LREG_HR) - 1;
-
- if (address)
- {
- string = address + SIZEOF_SCRIPT_ALLOC_ENTRY;
- if (safe_heap_check_address(buffer, string, 1))
- {
- S32 toffset = string;
- safe_heap_bytestream_count_char(buffer, toffset);
- S32 size = toffset - string;
- data->mKey = new char[size];
- bytestream2char(data->mKey, buffer, string, size);
- }
- lsa_decrease_ref_count(buffer, base_address);
- }
- else
- {
- data->mKey = new char[1];
- data->mKey[0] = 0;
- }
- break;
- case LST_STRING:
- data->mType = LST_STRING;
-
- base_address = lscript_pop_int(buffer);
- // this bit of nastiness is to get around that code paths to local variables can result in lack of initialization
- // and function clean up of ref counts isn't based on scope (a mistake, I know)
- address = base_address + get_register(buffer, LREG_HR) - 1;
-
- if (address)
- {
- string = address + SIZEOF_SCRIPT_ALLOC_ENTRY;
- if (safe_heap_check_address(buffer, string, 1))
- {
- S32 toffset = string;
- safe_heap_bytestream_count_char(buffer, toffset);
- S32 size = toffset - string;
- data->mString = new char[size];
- bytestream2char(data->mString, buffer, string, size);
- }
- lsa_decrease_ref_count(buffer, base_address);
- }
- else
- {
- data->mString = new char[1];
- data->mString[0] = 0;
- }
- break;
- case LST_VECTOR:
- data->mType = LST_VECTOR;
- lscript_pop_vector(buffer, data->mVec);
- break;
- case LST_QUATERNION:
- data->mType = LST_QUATERNION;
- lscript_pop_quaternion(buffer, data->mQuat);
- break;
- case LST_LIST:
- data->mType = LST_LIST;
- address = lscript_pop_int(buffer);
- data->mListp = lsa_get_data(buffer, address, TRUE);
- break;
- }
-}
-
-BOOL run_stacktol(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- offset++;
- S32 length = safe_instruction_bytestream2integer(buffer, offset);
- S32 i;
- S32 fault;
-
- S8 type;
-
- LLScriptLibData *data = new LLScriptLibData, *tail;
- data->mType = LST_LIST;
-
- for (i = 0; i < length; i++)
- {
- fault = get_register(buffer, LREG_FR);
- if (fault)
- break;
-
- type = lscript_pop_char(buffer);
-
- tail = new LLScriptLibData;
-
- lscript_stacktol_pop_variable(tail, buffer, type);
-
- tail->mListp = data->mListp;
- data->mListp = tail;
- }
- S32 address = lsa_heap_add_data(buffer,data, get_max_heap_size(buffer), TRUE);
- lscript_push(buffer, address);
- return FALSE;
-}
-
-BOOL run_print(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- if (b_print)
- printf("[0x%X]\tPRINT ", offset);
- offset++;
- U8 type = safe_instruction_bytestream2byte(buffer, offset);
- if (b_print)
- {
- print_type(type);
- printf("\n");
- }
- switch(type)
- {
- case LST_INTEGER:
- {
- S32 source = lscript_pop_int(buffer);
- printf("%d\n", source);
- }
- break;
- case LST_FLOATINGPOINT:
- {
- F32 source = lscript_pop_float(buffer);
- printf("%f\n", source);
- }
- break;
- case LST_STRING:
- {
- S32 base_address = lscript_pop_int(buffer);
- // this bit of nastiness is to get around that code paths to local variables can result in lack of initialization
- // and function clean up of ref counts isn't based on scope (a mistake, I know)
- S32 address = base_address + get_register(buffer, LREG_HR) - 1;
-
- if (address)
- {
- S32 string = address;
- string += SIZEOF_SCRIPT_ALLOC_ENTRY;
- if (safe_heap_check_address(buffer, string, 1))
- {
- S32 toffset = string;
- safe_heap_bytestream_count_char(buffer, toffset);
- S32 size = toffset - string;
- char *arg = new char[size];
- bytestream2char(arg, buffer, string, size);
- printf("%s\n", arg);
- delete [] arg;
- }
- lsa_decrease_ref_count(buffer, base_address);
- }
- }
- break;
- case LST_VECTOR:
- {
- LLVector3 source;
- lscript_pop_vector(buffer, source);
- printf("< %f, %f, %f >\n", source.mV[VX], source.mV[VY], source.mV[VZ]);
- }
- break;
- case LST_QUATERNION:
- {
- LLQuaternion source;
- lscript_pop_quaternion(buffer, source);
- printf("< %f, %f, %f, %f >\n", source.mQ[VX], source.mQ[VY], source.mQ[VZ], source.mQ[VS]);
- }
- break;
- case LST_LIST:
- {
- S32 base_address = lscript_pop_int(buffer);
- LLScriptLibData *data = lsa_get_data(buffer, base_address, TRUE);
- LLScriptLibData *print = data;
-
- printf("list\n");
-
- while (print)
- {
- switch(print->mType)
- {
- case LST_INTEGER:
- {
- printf("%d\n", print->mInteger);
- }
- break;
- case LST_FLOATINGPOINT:
- {
- printf("%f\n", print->mFP);
- }
- break;
- case LST_STRING:
- {
- printf("%s\n", print->mString);
- }
- break;
- case LST_KEY:
- {
- printf("%s\n", print->mKey);
- }
- break;
- case LST_VECTOR:
- {
- printf("< %f, %f, %f >\n", print->mVec.mV[VX], print->mVec.mV[VY], print->mVec.mV[VZ]);
- }
- break;
- case LST_QUATERNION:
- {
- printf("< %f, %f, %f, %f >\n", print->mQuat.mQ[VX], print->mQuat.mQ[VY], print->mQuat.mQ[VZ], print->mQuat.mQ[VS]);
- }
- break;
- default:
- break;
- }
- print = print->mListp;
- }
- delete data;
- }
- break;
- default:
- break;
- }
- return FALSE;
-}
-
-
-void lscript_run(const std::string& filename, BOOL b_debug)
-{
- LLTimer timer;
-
- const char *error;
- LLScriptExecuteLSL2 *execute = NULL;
-
- if (filename.empty())
- {
- LL_ERRS() << "filename is NULL" << LL_ENDL;
- // Just reporting error is likely not enough. Need
- // to check how to abort or error out gracefully
- // from this function. XXXTBD
- }
- LLFILE* file = LLFile::fopen(filename, "r"); /* Flawfinder: ignore */
- if(file)
- {
- execute = new LLScriptExecuteLSL2(file);
- fclose(file);
- }
- if (execute)
- {
- timer.reset();
- F32 time_slice = 3600.0f; // 1 hr.
- U32 events_processed = 0;
-
- do {
- LLTimer timer2;
- execute->runQuanta(b_debug, LLUUID::null, &error,
- time_slice, events_processed, timer2);
- } while (!execute->isFinished());
-
- F32 time = timer.getElapsedTimeF32();
- F32 ips = execute->mInstructionCount / time;
- LL_INFOS() << execute->mInstructionCount << " instructions in " << time << " seconds" << LL_ENDL;
- LL_INFOS() << ips/1000 << "K instructions per second" << LL_ENDL;
- printf("ip: 0x%X\n", get_register(execute->mBuffer, LREG_IP));
- printf("sp: 0x%X\n", get_register(execute->mBuffer, LREG_SP));
- printf("bp: 0x%X\n", get_register(execute->mBuffer, LREG_BP));
- printf("hr: 0x%X\n", get_register(execute->mBuffer, LREG_HR));
- printf("hp: 0x%X\n", get_register(execute->mBuffer, LREG_HP));
- delete execute;
- fclose(file);
- }
-}
-
-void lscript_pop_variable(LLScriptLibData *data, U8 *buffer, char type)
-{
- S32 address, string;
- S32 base_address;
-
- switch(type)
- {
- case 'i':
- data->mType = LST_INTEGER;
- data->mInteger = lscript_pop_int(buffer);
- break;
- case 'f':
- data->mType = LST_FLOATINGPOINT;
- data->mFP = lscript_pop_float(buffer);
- break;
- case 'k':
- data->mType = LST_KEY;
- data->mKey = NULL;
-
- base_address = lscript_pop_int(buffer);
- // this bit of nastiness is to get around that code paths to local variables can result in lack of initialization
- // and function clean up of ref counts isn't based on scope (a mistake, I know)
- address = base_address + get_register(buffer, LREG_HR) - 1;
-
- if (address)
- {
- string = address + SIZEOF_SCRIPT_ALLOC_ENTRY;
- if (safe_heap_check_address(buffer, string, 1))
- {
- S32 toffset = string;
- safe_heap_bytestream_count_char(buffer, toffset);
- S32 size = toffset - string;
- data->mKey = new char[size];
- bytestream2char(data->mKey, buffer, string, size);
- }
- lsa_decrease_ref_count(buffer, base_address);
- }
- if (data->mKey == NULL)
- {
- data->mKey = new char[1];
- data->mKey[0] = 0;
- }
- break;
- case 's':
- data->mType = LST_STRING;
- data->mString = NULL;
-
- base_address = lscript_pop_int(buffer);
- // this bit of nastiness is to get around that code paths to local variables can result in lack of initialization
- // and function clean up of ref counts isn't based on scope (a mistake, I know)
- address = base_address + get_register(buffer, LREG_HR) - 1;
-
- if (address)
- {
- string = address + SIZEOF_SCRIPT_ALLOC_ENTRY;
- if (safe_heap_check_address(buffer, string, 1))
- {
- S32 toffset = string;
- safe_heap_bytestream_count_char(buffer, toffset);
- S32 size = toffset - string;
- data->mString = new char[size];
- bytestream2char(data->mString, buffer, string, size);
- }
- lsa_decrease_ref_count(buffer, base_address);
- }
- if (data->mString == NULL)
- {
- data->mString = new char[1];
- data->mString[0] = 0;
- }
- break;
- case 'l':
- {
- S32 base_address = lscript_pop_int(buffer);
- data->mType = LST_LIST;
- data->mListp = lsa_get_list_ptr(buffer, base_address, TRUE);
- }
- break;
- case 'v':
- data->mType = LST_VECTOR;
- lscript_pop_vector(buffer, data->mVec);
- break;
- case 'q':
- data->mType = LST_QUATERNION;
- lscript_pop_quaternion(buffer, data->mQuat);
- break;
- }
-}
-
-void lscript_push_return_variable(LLScriptLibData *data, U8 *buffer)
-{
- S32 address;
- switch(data->mType)
- {
- case LST_INTEGER:
- lscript_local_store(buffer, -12, data->mInteger);
- break;
- case LST_FLOATINGPOINT:
- lscript_local_store(buffer, -12, data->mFP);
- break;
- case LST_KEY:
- address = lsa_heap_add_data(buffer, data, get_max_heap_size(buffer), FALSE);
- lscript_local_store(buffer, -12, address);
- break;
- case LST_STRING:
- address = lsa_heap_add_data(buffer, data, get_max_heap_size(buffer), FALSE);
- lscript_local_store(buffer, -12, address);
- break;
- case LST_LIST:
- address = lsa_heap_add_data(buffer, data, get_max_heap_size(buffer), FALSE);
- lscript_local_store(buffer, -12, address);
- break;
- case LST_VECTOR:
- lscript_local_store(buffer, -20, data->mVec);
- break;
- case LST_QUATERNION:
- lscript_local_store(buffer, -24, data->mQuat);
- break;
- default:
- break;
- }
-}
-
-S32 lscript_push_variable(LLScriptLibData *data, U8 *buffer)
-{
- S32 address;
- switch(data->mType)
- {
- case LST_INTEGER:
- lscript_push(buffer, data->mInteger);
- break;
- case LST_FLOATINGPOINT:
- lscript_push(buffer, data->mFP);
- return 4;
- break;
- case LST_KEY:
- address = lsa_heap_add_data(buffer, data, get_max_heap_size(buffer), FALSE);
- lscript_push(buffer, address);
- return 4;
- break;
- case LST_STRING:
- address = lsa_heap_add_data(buffer, data, get_max_heap_size(buffer), FALSE);
- lscript_push(buffer, address);
- return 4;
- break;
- case LST_LIST:
- address = lsa_heap_add_data(buffer, data, get_max_heap_size(buffer), FALSE);
- lscript_push(buffer, address);
- return 4;
- break;
- case LST_VECTOR:
- lscript_push(buffer, data->mVec);
- return 12;
- break;
- case LST_QUATERNION:
- lscript_push(buffer, data->mQuat);
- return 16;
- break;
- default:
- break;
- }
- return 4;
-}
-
-
-// Shared code for run_calllib() and run_calllib_two_byte()
-BOOL run_calllib_common(U8 *buffer, S32 &offset, const LLUUID &id, U16 arg)
-{
- if (arg >= gScriptLibrary.mFunctions.size())
- {
- set_fault(buffer, LSRF_BOUND_CHECK_ERROR);
- return FALSE;
- }
- LLScriptLibraryFunction const & function = gScriptLibrary.mFunctions[arg];
-
- // pull out the arguments and the return values
- LLScriptLibData *arguments = NULL;
- LLScriptLibData *returnvalue = NULL;
-
- S32 i, number;
-
- if (function.mReturnType)
- {
- returnvalue = new LLScriptLibData;
- }
-
- if (function.mArgs)
- {
- number = (S32)strlen(function.mArgs); //Flawfinder: ignore
- arguments = new LLScriptLibData[number];
- }
- else
- {
- number = 0;
- }
-
- for (i = number - 1; i >= 0; i--)
- {
- lscript_pop_variable(&arguments[i], buffer, function.mArgs[i]);
- }
-
- // Actually execute the function call
- function.mExecFunc(returnvalue, arguments, id);
-
- add_register_fp(buffer, LREG_ESR, -(function.mEnergyUse));
- add_register_fp(buffer, LREG_SLR, function.mSleepTime);
-
- if (returnvalue)
- {
- returnvalue->mType = char2type(*function.mReturnType);
- lscript_push_return_variable(returnvalue, buffer);
- }
-
- delete [] arguments;
- delete returnvalue;
-
- // reset the BP after calling the library files
- S32 bp = lscript_pop_int(buffer);
- set_bp(buffer, bp);
-
- // pop off the spot for the instruction pointer
- lscript_poparg(buffer, 4);
- return FALSE;
-}
-
-
-BOOL run_calllib(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- offset++;
- U16 arg = (U16) safe_instruction_bytestream2byte(buffer, offset);
- if (b_print &&
- arg < gScriptLibrary.mFunctions.size())
- {
- printf("[0x%X]\tCALLLIB ", offset);
- LLScriptLibraryFunction const & function = gScriptLibrary.mFunctions[arg];
- printf("%d (%s)\n", (U32)arg, function.mName);
- //printf("%s\n", function.mDesc);
- }
- return run_calllib_common(buffer, offset, id, arg);
-}
-
-BOOL run_calllib_two_byte(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
-{
- offset++;
- U16 arg = safe_instruction_bytestream2u16(buffer, offset);
- if (b_print &&
- arg < gScriptLibrary.mFunctions.size())
- {
- printf("[0x%X]\tCALLLIB ", (offset-1));
- LLScriptLibraryFunction const & function = gScriptLibrary.mFunctions[arg];
- printf("%d (%s)\n", (U32)arg, function.mName);
- //printf("%s\n", function.mDesc);
- }
- return run_calllib_common(buffer, offset, id, arg);
-}
diff --git a/indra/lscript/lscript_execute/lscript_heapruntime.cpp b/indra/lscript/lscript_execute/lscript_heapruntime.cpp
deleted file mode 100755
index 749857753d..0000000000
--- a/indra/lscript/lscript_execute/lscript_heapruntime.cpp
+++ /dev/null
@@ -1,519 +0,0 @@
-/**
- * @file lscript_heapruntime.cpp
- * @brief classes to manage script heap at runtime
- *
- * $LicenseInfo:firstyear=2002&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#if 0
-
-#include "linden_common.h"
-
-#include "lscript_heapruntime.h"
-#include "lscript_execute.h"
-
-
-/*
- String Heap Format
- Byte Description
- 0x0 - 0xnn Single byte string including null terminator
-
- List Heap Format
- Byte Description
- 0x0 Next Entry Type
- 0: End of list
- 1: Integer
- 2: Floating point
- 3: String
- 4: Vector
- 5: Quaternion
- 6: List
- 0x1 - 0x4 Integer, Floating Point, String Address, List Address
- or
- 0x1 - 0xd Vector
- or
- 0x1 - 0x11 Quaternion
- . . .
-
- Heap Block Format
- Byte Description
- 0x0 - 0x3 Offset to Next Block
- 0x4 - 0x7 Object Reference Count
- 0x8 Block Type
- 0: Empty
- 3: String
- 6: List
- 0x9 - 0xM Object Data
-
- Heap Management
-
- Adding Data
-
- 1) Set last empty spot to zero.
- 2) Go to start of the heap (HR).
- 3) Get next 4 bytes of offset.
- 4) If zero, we've reached the end of used memory. If empty spot is zero go to step 9. Otherwise set base offset to 0 and go to step 9.
- 5) Skip 4 bytes.
- 6) Get next 1 byte of entry type.
- 7) If zero, this spot is empty. If empty spot is zero, set empty spot to this address and go to step 9. Otherwise, coalesce with last empty spot and then go to step 9.
- 8) Skip forward by offset and go to step 3.
- 9) If the spot is empty, check to see if the size needed == offset - 9.
- 10) If it does, let's drop our data into this spot. Set reference count to 1. Set entry type appropriately and copy the data in.
- 11) If size needed < offset - 9 then we can stick in data and add in an empty block.
- 12) Otherwise, we need to keep looking. Go to step 3.
-
- Increasing reference counts
-
- Decreasing reference counts
- 1) Set entry type to 0.
- 2) If offset is non-zero and the next entry is empty, coalesce. Go to step 2.
-
- What increases reference count:
- Initial creation sets reference count to 1.
- Storing the reference increases reference count by 1.
- Pushing the reference increases reference count by 1.
- Duplicating the reference increases reference count by 1.
-
- What decreases the reference count:
- Popping the reference decreases reference count by 1.
- */
-
-
-LLScriptHeapRunTime::LLScriptHeapRunTime()
-: mLastEmpty(0), mBuffer(NULL), mCurrentPosition(0), mStackPointer(0), mHeapRegister(0), mbPrint(FALSE)
-{
-}
-
-LLScriptHeapRunTime::~LLScriptHeapRunTime()
-{
-}
-
-S32 LLScriptHeapRunTime::addData(char *string)
-{
- if (!mBuffer)
- return 0;
-
- S32 size = strlen(string) + 1;
- S32 block_offset = findOpenBlock(size + HEAP_BLOCK_HEADER_SIZE);
-
- if (mCurrentPosition)
- {
- S32 offset = mCurrentPosition;
- if (offset + block_offset + HEAP_BLOCK_HEADER_SIZE + LSCRIPTDataSize[LST_INTEGER] >= mStackPointer)
- {
- set_fault(mBuffer, LSRF_STACK_HEAP_COLLISION);
- return 0;
- }
- // cool, we've found a spot!
- // set offset
- integer2bytestream(mBuffer, offset, block_offset);
- // set reference count
- integer2bytestream(mBuffer, offset, 1);
- // set type
- *(mBuffer + offset++) = LSCRIPTTypeByte[LST_STRING];
- // plug in data
- char2bytestream(mBuffer, offset, string);
- if (mbPrint)
- printf("0x%X created ref count %d\n", mCurrentPosition - mHeapRegister, 1);
-
- // now, zero out next offset to prevent "trouble"
- // offset = mCurrentPosition + size + HEAP_BLOCK_HEADER_SIZE;
- // integer2bytestream(mBuffer, offset, 0);
- }
- return mCurrentPosition;
-}
-
-S32 LLScriptHeapRunTime::addData(U8 *list)
-{
- if (!mBuffer)
- return 0;
- return 0;
-}
-
-S32 LLScriptHeapRunTime::catStrings(S32 address1, S32 address2)
-{
- if (!mBuffer)
- return 0;
-
- S32 dataaddress1 = address1 + 2*LSCRIPTDataSize[LST_INTEGER] + 1;
- S32 dataaddress2 = address2 + 2*LSCRIPTDataSize[LST_INTEGER] + 1;
-
- S32 toffset1 = dataaddress1;
- safe_heap_bytestream_count_char(mBuffer, toffset1);
-
- S32 toffset2 = dataaddress2;
- safe_heap_bytestream_count_char(mBuffer, toffset2);
-
- // calculate new string size
- S32 size1 = toffset1 - dataaddress1;
- S32 size2 = toffset2 - dataaddress2;
- S32 newbuffer = size1 + size2 - 1;
-
- char *temp = new char[newbuffer];
-
- // get the strings
- bytestream2char(temp, mBuffer, dataaddress1);
- bytestream2char(temp + size1 - 1, mBuffer, dataaddress2);
-
- decreaseRefCount(address1);
- decreaseRefCount(address2);
-
- S32 retaddress = addData(temp);
-
- return retaddress;
-}
-
-S32 LLScriptHeapRunTime::cmpStrings(S32 address1, S32 address2)
-{
- if (!mBuffer)
- return 0;
-
- S32 dataaddress1 = address1 + 2*LSCRIPTDataSize[LST_INTEGER] + 1;
- S32 dataaddress2 = address2 + 2*LSCRIPTDataSize[LST_INTEGER] + 1;
-
- S32 toffset1 = dataaddress1;
- safe_heap_bytestream_count_char(mBuffer, toffset1);
-
- S32 toffset2 = dataaddress2;
- safe_heap_bytestream_count_char(mBuffer, toffset2);
-
- // calculate new string size
- S32 size1 = toffset1 - dataaddress1;
- S32 size2 = toffset2 - dataaddress2;
-
- if (size1 != size2)
- {
- return llmin(size1, size2);
- }
- else
- {
- return strncmp((char *)(mBuffer + dataaddress1), (char *)(mBuffer + dataaddress2), size1);
- }
-}
-
-void LLScriptHeapRunTime::removeData(S32 address)
-{
- if (!mBuffer)
- return;
-
- S32 toffset = address;
- // read past offset (relying on function side effect
- bytestream2integer(mBuffer, toffset);
-
- // make sure that reference count is 0
- integer2bytestream(mBuffer, toffset, 0);
- // show the block as empty
- *(mBuffer + toffset) = 0;
-
- // now, clean up the heap
- S32 clean = mHeapRegister;
- S32 tclean;
- S32 clean_offset;
-
- S32 nclean;
- S32 tnclean;
- S32 next_offset;
-
- U8 type;
- U8 ntype;
-
- for(;;)
- {
- tclean = clean;
- clean_offset = bytestream2integer(mBuffer, tclean);
- // is this block, empty?
- tclean += LSCRIPTDataSize[LST_INTEGER];
- type = *(mBuffer + tclean);
-
- if (!clean_offset)
- {
- if (!type)
- {
- // we're done! if our block is empty, we can pull in the HP and zero out our offset
- set_register(mBuffer, LREG_HP, clean);
- }
- return;
- }
-
-
- if (!type)
- {
- // if we're empty, try to coalesce with the next one
- nclean = clean + clean_offset;
- tnclean = nclean;
- next_offset = bytestream2integer(mBuffer, tnclean);
- tnclean += LSCRIPTDataSize[LST_INTEGER];
- ntype = *(mBuffer + tnclean);
-
- if (!next_offset)
- {
- // we're done! if our block is empty, we can pull in the HP and zero out our offset
- tclean = clean;
- integer2bytestream(mBuffer, tclean, 0);
- set_register(mBuffer, LREG_HP, clean);
- return;
- }
-
- if (!ntype)
- {
- // hooray! we can coalesce
- tclean = clean;
- integer2bytestream(mBuffer, tclean, clean_offset + next_offset);
- // don't skip forward so that we can keep coalescing on next pass through the loop
- }
- else
- {
- clean += clean_offset;
- }
- }
- else
- {
- // if not, move on to the next block
- clean += clean_offset;
- }
- }
-}
-
-void LLScriptHeapRunTime::coalesce(S32 address1, S32 address2)
-{
- // we need to bump the base offset by the second block's
- S32 toffset = address1;
- S32 offset1 = bytestream2integer(mBuffer, toffset);
- offset1 += bytestream2integer(mBuffer, address2);
-
- integer2bytestream(mBuffer, address1, offset1);
-}
-
-void LLScriptHeapRunTime::split(S32 address1, S32 size)
-{
- S32 toffset = address1;
- S32 oldoffset = bytestream2integer(mBuffer, toffset);
-
- // add new offset and zero out reference count and block used
- S32 newoffset = oldoffset - size;
- S32 newblockpos = address1 + size;
-
- // set new offset
- integer2bytestream(mBuffer, newblockpos, newoffset);
- // zero out reference count
- integer2bytestream(mBuffer, newblockpos, 0);
- // mark as empty
- *(mBuffer + newblockpos) = 0;
-
- // now, change the offset of the original block
- integer2bytestream(mBuffer, address1, size + HEAP_BLOCK_HEADER_SIZE);
-}
-
-/*
-
- For reference count changes, strings are easy. For lists, we'll need to go through the lists reducing
- the reference counts for any included strings and lists
-
- */
-
-void LLScriptHeapRunTime::increaseRefCount(S32 address)
-{
- if (!mBuffer)
- return;
-
- if (!address)
- {
- // unused temp string entry
- return;
- }
-
- // get current reference count
- S32 toffset = address + 4;
- S32 count = bytestream2integer(mBuffer, toffset);
-
- count++;
-
- if (mbPrint)
- printf("0x%X inc ref count %d\n", address - mHeapRegister, count);
-
- // see which type it is
- U8 type = *(mBuffer + toffset);
-
- if (type == LSCRIPTTypeByte[LST_STRING])
- {
- toffset = address + 4;
- integer2bytestream(mBuffer, toffset, count);
- }
- // TO DO: put list stuff here!
- else
- {
- set_fault(mBuffer, LSRF_HEAP_ERROR);
- }
-}
-
-void LLScriptHeapRunTime::decreaseRefCount(S32 address)
-{
- if (!mBuffer)
- return;
-
- if (!address)
- {
- // unused temp string entry
- return;
- }
-
- // get offset
- S32 toffset = address;
- // read past offset (rely on function side effect)
- bytestream2integer(mBuffer, toffset);
-
- // get current reference count
- S32 count = bytestream2integer(mBuffer, toffset);
-
- // see which type it is
- U8 type = *(mBuffer + toffset);
-
- if (type == LSCRIPTTypeByte[LST_STRING])
- {
- count--;
-
- if (mbPrint)
- printf("0x%X dec ref count %d\n", address - mHeapRegister, count);
-
- toffset = address + 4;
- integer2bytestream(mBuffer, toffset, count);
- if (!count)
- {
- // we can blow this one away
- removeData(address);
- }
- }
- // TO DO: put list stuff here!
- else
- {
- set_fault(mBuffer, LSRF_HEAP_ERROR);
- }
-}
-
-// if we're going to assign a variable, we need to decrement the reference count of what we were pointing at (if anything)
-void LLScriptHeapRunTime::releaseLocal(S32 address)
-{
- S32 hr = get_register(mBuffer, LREG_HR);
- address = lscript_local_get(mBuffer, address);
- if ( (address >= hr)
- &&(address < hr + get_register(mBuffer, LREG_HP)))
- {
- decreaseRefCount(address);
- }
-}
-
-void LLScriptHeapRunTime::releaseGlobal(S32 address)
-{
- // NOTA BENE: Global strings are referenced relative to the HR while local strings aren't
- S32 hr = get_register(mBuffer, LREG_HR);
- address = lscript_global_get(mBuffer, address) + hr;
- if ( (address >= hr)
- &&(address < hr + get_register(mBuffer, LREG_HP)))
- {
- decreaseRefCount(address);
- }
-}
-
-
-// we know the following function has "unreachable code"
-// don't remind us every friggin' time we compile. . .
-
-#if defined(_MSC_VER)
-# pragma warning(disable: 4702) // unreachable code
-#endif
-
-S32 LLScriptHeapRunTime::findOpenBlock(S32 size)
-{
- S32 offset;
- S32 toffset;
- U8 blocktype;
-
- while(1)
- {
- if (mCurrentPosition + size >= mStackPointer)
- {
- set_fault(mBuffer, LSRF_STACK_HEAP_COLLISION);
- mCurrentPosition = 0;
- }
-
- toffset = mCurrentPosition;
- offset = bytestream2integer(mBuffer, toffset);
- if (!offset)
- {
- // we've reached the end of Heap, return this location if we'll fit
- // do we need to coalesce with last empty space?
- if (mLastEmpty)
- {
- // ok, that everything from mLastEmpty to us is empty, so we don't need a block
- // zero out the last empty's offset and return it
- mCurrentPosition = mLastEmpty;
- integer2bytestream(mBuffer, mLastEmpty, 0);
- mLastEmpty = 0;
- }
- // now, zero out next offset to prevent "trouble"
- offset = mCurrentPosition + size;
- integer2bytestream(mBuffer, offset, 0);
-
- // set HP to appropriate value
- set_register(mBuffer, LREG_HP, mCurrentPosition + size);
- return size;
- }
-
- // ok, is this slot empty?
- toffset += LSCRIPTDataSize[LST_INTEGER];
-
- blocktype = *(mBuffer + toffset++);
-
- if (!blocktype)
- {
- // Empty block, do we need to coalesce?
- if (mLastEmpty)
- {
- coalesce(mLastEmpty, mCurrentPosition);
- mCurrentPosition = mLastEmpty;
- toffset = mCurrentPosition;
- offset = bytestream2integer(mBuffer, toffset);
- }
-
- // do we fit in this block?
- if (offset >= size)
- {
- // do we need to split the block? (only split if splitting will leave > HEAP_BLOCK_SPLIT_THRESHOLD bytes of free space)
- if (offset - HEAP_BLOCK_SPLIT_THRESHOLD >= size)
- {
- split(mCurrentPosition, size);
- return size;
- }
- else
- return offset;
- }
- }
- // nothing found, keep looking
- mCurrentPosition += offset;
- }
- // fake return to prevent warnings
- mCurrentPosition = 0;
- return 0;
-}
-
-LLScriptHeapRunTime gRunTime;
-#endif
diff --git a/indra/lscript/lscript_execute/lscript_heapruntime.h b/indra/lscript/lscript_execute/lscript_heapruntime.h
deleted file mode 100755
index 0e924a2036..0000000000
--- a/indra/lscript/lscript_execute/lscript_heapruntime.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * @file lscript_heapruntime.h
- * @brief classes to manage script heap at runtime
- *
- * $LicenseInfo:firstyear=2002&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#if 0
-
-#ifndef LL_LSCRIPT_HEAPRUNTIME_H
-#define LL_LSCRIPT_HEAPRUNTIME_H
-
-#include "lscript_byteconvert.h"
-
-
-const S32 HEAP_BLOCK_HEADER_SIZE = 9;
-const S32 HEAP_BLOCK_SPLIT_THRESHOLD = 16;
-
-
-#endif
-#endif
diff --git a/indra/lscript/lscript_execute/lscript_readlso.cpp b/indra/lscript/lscript_execute/lscript_readlso.cpp
deleted file mode 100755
index abcb28e998..0000000000
--- a/indra/lscript/lscript_execute/lscript_readlso.cpp
+++ /dev/null
@@ -1,1585 +0,0 @@
-/**
- * @file lscript_readlso.cpp
- * @brief classes to read lso file
- *
- * $LicenseInfo:firstyear=2002&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#include "linden_common.h"
-
-#include "lscript_readlso.h"
-#include "lscript_library.h"
-#include "lscript_alloc.h"
-
-LLScriptLSOParse::LLScriptLSOParse(LLFILE *fp)
-{
- U8 sizearray[4];
- size_t filesize;
- S32 pos = 0;
- if (fread(&sizearray, 1, 4, fp) != 4)
- {
- LL_WARNS() << "Short read" << LL_ENDL;
- filesize = 0;
- } else {
- filesize = bytestream2integer(sizearray, pos);
- }
- mRawData = new U8[filesize];
- fseek(fp, 0, SEEK_SET);
- if (fread(mRawData, 1, filesize, fp) != filesize)
- {
- LL_WARNS() << "Short read" << LL_ENDL;
- }
-
- initOpCodePrinting();
-}
-
-LLScriptLSOParse::LLScriptLSOParse(U8 *buffer)
-{
- mRawData = buffer;
- initOpCodePrinting();
-}
-
-LLScriptLSOParse::~LLScriptLSOParse()
-{
- delete [] mRawData;
-}
-
-void LLScriptLSOParse::printData(LLFILE *fp)
-{
-
-
-
- printNameDesc(fp);
-
- printRegisters(fp);
-
- printGlobals(fp);
-
- printGlobalFunctions(fp);
-
- printStates(fp);
-
- printHeap(fp);
-}
-
-void LLScriptLSOParse::printNameDesc(LLFILE *fp)
-{
- fprintf(fp, "=============================\n\n");
-}
-
-S32 gMajorVersion = 0;
-
-void LLScriptLSOParse::printRegisters(LLFILE *fp)
-{
- // print out registers first
- S32 i;
-
- fprintf(fp, "=============================\n");
- fprintf(fp, "Registers\n");
- fprintf(fp, "=============================\n");
- S32 version = get_register(mRawData, LREG_VN);
- if (version == LSL2_VERSION1_END_NUMBER)
- {
- gMajorVersion = LSL2_MAJOR_VERSION_ONE;
- }
- else if (version == LSL2_VERSION_NUMBER)
- {
- gMajorVersion = LSL2_MAJOR_VERSION_TWO;
- }
- for (i = LREG_IP; i < LREG_EOF; i++)
- {
- if (i < LREG_NCE)
- {
- fprintf(fp, "%s: 0x%X\n", gLSCRIPTRegisterNames[i], get_register(mRawData, (LSCRIPTRegisters)i));
- }
- else if (gMajorVersion == LSL2_MAJOR_VERSION_TWO)
- {
- U64 data = get_register_u64(mRawData, (LSCRIPTRegisters)i);
- fprintf(fp, "%s: 0x%X%X\n", gLSCRIPTRegisterNames[i], (U32)(data>>32), (U32)(data & 0xFFFFFFFF));
- }
- }
- fprintf(fp, "=============================\n\n");
-}
-
-void LLScriptLSOParse::printGlobals(LLFILE *fp)
-{
- // print out registers first
- S32 varoffset;
- S32 ivalue;
- F32 fpvalue;
- LLVector3 vvalue;
- LLQuaternion qvalue;
- char name[256]; /*Flawfinder: ignore*/
- U8 type;
-
- S32 global_v_offset = get_register(mRawData, LREG_GVR);
- S32 global_f_offset = get_register(mRawData, LREG_GFR);
-
- fprintf(fp, "=============================\n");
- fprintf(fp, "[0x%X] Global Variables\n", global_v_offset);
- fprintf(fp, "=============================\n");
-
-
- while (global_v_offset < global_f_offset)
- {
-
- // get offset to skip past name
- varoffset = global_v_offset;
- bytestream2integer(mRawData, global_v_offset);
- // get typeexport
- type = *(mRawData + global_v_offset++);
-
- // set name
- bytestream2char(name, mRawData, global_v_offset, sizeof(name));
-
- switch(type)
- {
- case LST_INTEGER:
- ivalue = bytestream2integer(mRawData, global_v_offset);
- fprintf(fp, "[0x%X] integer %s = %d\n", varoffset, name, ivalue);
- break;
- case LST_FLOATINGPOINT:
- fpvalue = bytestream2float(mRawData, global_v_offset);
- fprintf(fp, "[0x%X] integer %s = %f\n", varoffset, name, fpvalue);
- break;
- case LST_STRING:
- ivalue = bytestream2integer(mRawData, global_v_offset);
- fprintf(fp, "[0x%X] string %s = 0x%X\n", varoffset, name, ivalue + get_register(mRawData, LREG_HR) - 1);
- break;
- case LST_KEY:
- ivalue = bytestream2integer(mRawData, global_v_offset);
- fprintf(fp, "[0x%X] key %s = 0x%X\n", varoffset, name, ivalue + get_register(mRawData, LREG_HR) - 1);
- break;
- case LST_VECTOR:
- bytestream2vector(vvalue, mRawData, global_v_offset);
- fprintf(fp, "[0x%X] vector %s = < %f, %f, %f >\n", varoffset, name, vvalue.mV[VX], vvalue.mV[VY], vvalue.mV[VZ]);
- break;
- case LST_QUATERNION:
- bytestream2quaternion(qvalue, mRawData, global_v_offset);
- fprintf(fp, "[0x%X] quaternion %s = < %f, %f, %f, %f >\n", varoffset, name, qvalue.mQ[VX], qvalue.mQ[VY], qvalue.mQ[VZ], qvalue.mQ[VS]);
- break;
- case LST_LIST:
- ivalue = bytestream2integer(mRawData, global_v_offset);
- fprintf(fp, "[0x%X] list %s = 0x%X\n", varoffset, name, ivalue + get_register(mRawData, LREG_HR) - 1);
- break;
- default:
- break;
- }
- }
-
- fprintf(fp, "=============================\n\n");
-}
-
-void LLScriptLSOParse::printGlobalFunctions(LLFILE *fp)
-{
- // print out registers first
- S32 i, offset;
-// LLVector3 vvalue; unused
-// LLQuaternion qvalue; unused
- char name[256]; /*Flawfinder: ignore*/
- U8 type;
-
- offset = get_register(mRawData, LREG_GFR);
- S32 start_of_state = get_register(mRawData, LREG_SR);
- if (start_of_state == offset)
- return;
-
- S32 global_f_offset = get_register(mRawData, LREG_GFR);
-
- fprintf(fp, "=============================\n");
- fprintf(fp, "[0x%X] Global Functions\n", global_f_offset);
- fprintf(fp, "=============================\n");
-
-
- S32 num_functions = bytestream2integer(mRawData, offset);
- S32 orig_function_offset;
- S32 function_offset;
- S32 next_function_offset = 0;
- S32 function_number = 0;
- S32 opcode_start;
- S32 opcode_end;
-
- for (i = 0; i < num_functions; i++)
- {
- // jump to function
- // if this is the first function
- if (i == 0)
- {
- if (i < num_functions - 1)
- {
- function_offset = bytestream2integer(mRawData, offset);
- next_function_offset = bytestream2integer(mRawData, offset);
- function_offset += global_f_offset;
- opcode_end = next_function_offset + global_f_offset;
- }
- else
- {
- function_offset = bytestream2integer(mRawData, offset);
- function_offset += global_f_offset;
- opcode_end = get_register(mRawData, LREG_SR);
- }
- }
- else if (i < num_functions - 1)
- {
- function_offset = next_function_offset;
- next_function_offset = bytestream2integer(mRawData, offset);
- function_offset += global_f_offset;
- opcode_end = next_function_offset + global_f_offset;
- }
- else
- {
- function_offset = next_function_offset;
- function_offset += global_f_offset;
- opcode_end = get_register(mRawData, LREG_SR);
- }
- orig_function_offset = function_offset;
- // where do the opcodes start
- opcode_start = bytestream2integer(mRawData, function_offset);
- opcode_start += orig_function_offset;
- bytestream2char(name, mRawData, function_offset, sizeof(name));
- // get return type
- type = *(mRawData + function_offset++);
- fprintf(fp, "[Function #%d] [0x%X] %s\n", function_number, orig_function_offset, name);
- fprintf(fp, "\tReturn Type: %s\n", LSCRIPTTypeNames[type]);
- type = *(mRawData + function_offset++);
- S32 pcount = 0;
- while (type)
- {
- bytestream2char(name, mRawData, function_offset, sizeof(name));
- fprintf(fp, "\tParameter #%d: %s %s\n", pcount++, LSCRIPTTypeNames[type], name);
- type = *(mRawData + function_offset++);
- }
- fprintf(fp, "\t\tOpCodes: 0x%X - 0x%X\n", opcode_start, opcode_end);
- printOpCodeRange(fp, opcode_start, opcode_end, 2);
- function_number++;
- }
-
- fprintf(fp, "=============================\n\n");
-}
-
-void LLScriptLSOParse::printStates(LLFILE *fp)
-{
- // print out registers first
- S32 i, offset;
- U32 j, k;
-// LLVector3 vvalue; unused
-// LLQuaternion qvalue; unused
- char name[256]; /*Flawfinder: ignore*/
-
- S32 state_offset = get_register(mRawData, LREG_SR);
-
- fprintf(fp, "=============================\n");
- fprintf(fp, "[0x%X] States\n", state_offset);
- fprintf(fp, "=============================\n");
-
- offset = state_offset;
- S32 num_states = bytestream2integer(mRawData, offset);
- S32 state_info_offset;
- S32 event_jump_table;
- U64 event_handlers;
- S32 event_offset;
- S32 original_event_offset;
- S32 opcode_start;
- S32 worst_case_opcode_end;
- S32 opcode_end;
- S32 stack_size;
- S32 read_ahead;
- S32 first_jump = 0;
-
- for (i = 0; i < num_states; i++)
- {
- state_info_offset = bytestream2integer(mRawData, offset);
- if (gMajorVersion == LSL2_MAJOR_VERSION_TWO)
- event_handlers = bytestream2u64(mRawData, offset);
- else
- event_handlers = bytestream2integer(mRawData, offset);
- if (!first_jump)
- {
- first_jump = state_info_offset;
- }
- read_ahead = offset;
- if (offset < first_jump + state_offset)
- {
- worst_case_opcode_end = bytestream2integer(mRawData, read_ahead) + state_offset;
- }
- else
- {
- worst_case_opcode_end = get_register(mRawData, LREG_HR);
- }
- state_info_offset += state_offset;
- fprintf(fp, "[0x%X] ", state_info_offset);
- state_info_offset += LSCRIPTDataSize[LST_INTEGER];
- bytestream2char(name, mRawData, state_info_offset, sizeof(name));
- fprintf(fp, "%s\n", name);
-
- event_jump_table = state_info_offset;
-
- // run run through the handlers
- for (j = LSTT_STATE_BEGIN; j < LSTT_STATE_END; j++)
- {
- if (event_handlers & LSCRIPTStateBitField[j])
- {
- event_offset = bytestream2integer(mRawData, state_info_offset);
- stack_size = bytestream2integer(mRawData, state_info_offset);
-
- read_ahead = event_jump_table;
-
- S32 temp_end;
-
- opcode_end = worst_case_opcode_end;
- (void)opcode_end;
-
- for (k = LSTT_STATE_BEGIN; k < LSTT_STATE_END; k++)
- {
- if (event_handlers & LSCRIPTStateBitField[k])
- {
- temp_end = bytestream2integer(mRawData, read_ahead);
- bytestream2integer(mRawData, read_ahead);
- if ( (temp_end < opcode_end)
- &&(temp_end > event_offset))
- {
- opcode_end = temp_end;
- }
- }
- }
-
- if (event_offset)
- {
- event_offset += event_jump_table;
- if (opcode_end < worst_case_opcode_end)
- opcode_end += event_jump_table;
- original_event_offset = event_offset;
-
- fprintf(fp, "\t[0x%X] ", event_offset);
-
- opcode_start = bytestream2integer(mRawData, event_offset);
- opcode_start += original_event_offset;
-
- switch(j)
- {
- case LSTT_STATE_ENTRY: // LSTT_STATE_ENTRY
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "%s\n", name);
- break;
- case LSTT_STATE_EXIT: // LSTT_STATE_EXIT
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "%s\n", name);
- break;
- case LSTT_TOUCH_START: // LSTT_TOUCH_START
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "%s\n", name);
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "\t\tkey %s\n", name);
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "\t\tvector %s\n", name);
- break;
- case LSTT_TOUCH: // LSTT_TOUCH
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "%s\n", name);
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "\t\tkey %s\n", name);
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "\t\tvector %s\n", name);
- break;
- case LSTT_TOUCH_END: // LSTT_TOUCH_END
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "%s\n", name);
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "\t\tkey %s\n", name);
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "\t\tvector %s\n", name);
- break;
- case LSTT_COLLISION_START: // LSTT_COLLISION_START
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "%s\n", name);
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "\t\tkey %s\n", name);
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "\t\tvector %s\n", name);
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "\t\tvector %s\n", name);
- break;
- case LSTT_COLLISION: // LSTT_COLLISION
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "%s\n", name);
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "\t\tkey %s\n", name);
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "\t\tvector %s\n", name);
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "\t\tvector %s\n", name);
- break;
- case LSTT_COLLISION_END: // LSTT_COLLISION_END
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "%s\n", name);
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "\t\tkey %s\n", name);
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "\t\tvector %s\n", name);
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "\t\tvector %s\n", name);
- break;
- case LSTT_LAND_COLLISION_START: // LSTT_LAND_COLLISION_START
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "%s\n", name);
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "\t\tvector %s\n", name);
- break;
- case LSTT_LAND_COLLISION: // LSTT_LAND_COLLISION
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "%s\n", name);
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "\t\tvector %s\n", name);
- break;
- case LSTT_LAND_COLLISION_END: // LSTT_LAND_COLLISION_END
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "%s\n", name);
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "\t\tvector %s\n", name);
- break;
- case LSTT_INVENTORY: // LSTT_INVENTORY
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "%s\n", name);
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "\t\tinteger %s\n", name);
- break;
- case LSTT_ATTACH: // LSTT_ATTACH
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "%s\n", name);
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "\t\tkey %s\n", name);
- break;
- case LSTT_DATASERVER: // LSTT_DATASERVER
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "%s\n", name);
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "\t\tkey %s\n", name);
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "\t\tstring %s\n", name);
- break;
- case LSTT_TIMER: // LSTT_TIMER
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "%s\n", name);
- break;
- case LSTT_MOVING_START: // LSTT_MOVING_START
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "%s\n", name);
- break;
- case LSTT_MOVING_END: // LSTT_MOVING_END
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "%s\n", name);
- break;
- case LSTT_CHAT: // LSTT_CHAT
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "%s\n", name);
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "\t\tinteger %s\n", name);
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "\t\tkey %s\n", name);
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "\t\tstring %s\n", name);
- break;
- case LSTT_OBJECT_REZ: // LSTT_OBJECT_REZ
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "%s\n", name);
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "\t\tkey %s\n", name);
- break;
- case LSTT_REMOTE_DATA: // LSTT_REMOTE_DATA
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "%s\n", name);
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "\t\tinteger %s\n", name);
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "\t\tkey %s\n", name);
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "\t\tinteger %s\n", name);
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "\t\tstring %s\n", name);
- break;
- case LSTT_REZ: // LSTT_REZ
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "%s\n", name);
- break;
- case LSTT_SENSOR: // LSTT_SENSOR
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "%s\n", name);
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "\t\tinteger %s\n", name);
- break;
- case LSTT_NO_SENSOR: // LSTT_NO_SENSOR
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "%s\n", name);
- break;
- case LSTT_CONTROL: // LSTT_CONTROL
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "%s\n", name);
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "\t\tkey %s\n", name);
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "\t\tinteger %s\n", name);
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "\t\tinteger %s\n", name);
- break;
- case LSTT_LINK_MESSAGE: // LSTT_LINK_MESSAGE
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "%s\n", name);
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "\t\tinteger %s\n", name);
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "\t\tstring %s\n", name);
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "\t\tkey %s\n", name);
- break;
- case LSTT_MONEY: // LSTT_MONEY
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "%s\n", name);
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "\t\tkey %s\n", name);
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "\t\tinteger %s\n", name);
- break;
- case LSTT_EMAIL: // LSTT_EMAIL
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "%s\n", name);
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "\t\tstring %s\n", name);
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "\t\tstring %s\n", name);
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "\t\tstring %s\n", name);
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "\t\tinteger %s\n", name);
- break;
- case LSTT_AT_TARGET: // LSTT_AT_TARGET
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "%s\n", name);
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "\t\tinteger %s\n", name);
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "\t\tvector %s\n", name);
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "\t\tvector %s\n", name);
- break;
- case LSTT_NOT_AT_TARGET: // LSTT_NOT_AT_TARGET
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "%s\n", name);
- break;
- case LSTT_AT_ROT_TARGET: // LSTT_AT_ROT_TARGET
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "%s\n", name);
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "\t\tinteger %s\n", name);
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "\t\tquaternion %s\n", name);
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "\t\tquaternion %s\n", name);
- break;
- case LSTT_NOT_AT_ROT_TARGET: // LSTT_NOT_AT_TARGET
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "%s\n", name);
- break;
- case LSTT_RTPERMISSIONS: // LSTT_RTPERMISSIONS
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "%s\n", name);
- fprintf(fp, "\t\tinteger %s\n", name);
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- break;
- case LSTT_HTTP_RESPONSE: // LSTT_REMOTE_DATA ?!?!?!
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "%s\n", name);
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "\t\tkey %s\n", name);
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "\t\tinteger %s\n", name);
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "\t\tlist %s\n", name);
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "\t\tstring %s\n", name);
- break;
- case LSTT_HTTP_REQUEST: // LSTT_HTTP_REQUEST
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "%s\n", name);
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "\t\tkey %s\n", name);
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "\t\tstring %s\n", name);
- bytestream2char(name, mRawData, event_offset, sizeof(name));
- fprintf(fp, "\t\tstring %s\n", name);
- break;
- default:
- break;
- }
- fprintf(fp, "\t\tStack Size: %d\n", stack_size);
- fprintf(fp, "\t\t\tOpCodes: 0x%X - 0x%X\n", opcode_start, opcode_end);
- printOpCodeRange(fp, opcode_start, opcode_end, 3);
- }
- }
- }
- }
- fprintf(fp, "=============================\n\n");
-}
-
-void LLScriptLSOParse::printHeap(LLFILE *fp)
-{
- // print out registers first
-
- S32 heap_offset = get_register(mRawData, LREG_HR);
- S32 heap_pointer = get_register(mRawData, LREG_HP);
- fprintf(fp, "=============================\n");
- fprintf(fp, "[0x%X - 0x%X] Heap\n", heap_offset, heap_pointer);
- fprintf(fp, "=============================\n");
-
- lsa_fprint_heap(mRawData, fp);
-
- fprintf(fp, "=============================\n\n");
-}
-
-void lso_print_tabs(LLFILE *fp, S32 tabs)
-{
- S32 i;
- for (i = 0; i < tabs; i++)
- {
- fprintf(fp, "\t");
- }
-}
-
-void LLScriptLSOParse::printOpCodes(LLFILE *fp, S32 &offset, S32 tabs)
-{
- U8 opcode = *(mRawData + offset);
- mPrintOpCodes[opcode](fp, mRawData, offset, tabs);
-}
-
-void LLScriptLSOParse::printOpCodeRange(LLFILE *fp, S32 start, S32 end, S32 tabs)
-{
- while (start < end)
- {
- printOpCodes(fp, start, tabs);
- }
-}
-
-void LLScriptLSOParse::initOpCodePrinting()
-{
- S32 i;
- for (i = 0; i < 256; i++)
- {
- mPrintOpCodes[i] = print_noop;
- }
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_NOOP]] = print_noop;
-
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_POP]] = print_pop;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_POPS]] = print_pops;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_POPL]] = print_popl;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_POPV]] = print_popv;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_POPQ]] = print_popq;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_POPARG]] = print_poparg;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_POPIP]] = print_popip;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_POPBP]] = print_popbp;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_POPSP]] = print_popsp;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_POPSLR]] = print_popslr;
-
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_DUP]] = print_dup;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_DUPS]] = print_dups;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_DUPL]] = print_dupl;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_DUPV]] = print_dupv;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_DUPQ]] = print_dupq;
-
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_STORE]] = print_store;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_STORES]] = print_stores;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_STOREL]] = print_storel;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_STOREV]] = print_storev;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_STOREQ]] = print_storeq;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_STOREG]] = print_storeg;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_STOREGS]] = print_storegs;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_STOREGL]] = print_storegl;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_STOREGV]] = print_storegv;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_STOREGQ]] = print_storegq;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_LOADP]] = print_loadp;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_LOADSP]] = print_loadsp;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_LOADLP]] = print_loadlp;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_LOADVP]] = print_loadvp;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_LOADQP]] = print_loadqp;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_LOADGP]] = print_loadgp;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_LOADGSP]] = print_loadgsp;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_LOADGLP]] = print_loadglp;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_LOADGVP]] = print_loadgvp;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_LOADGQP]] = print_loadgqp;
-
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSH]] = print_push;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHS]] = print_pushs;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHL]] = print_pushl;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHV]] = print_pushv;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHQ]] = print_pushq;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHG]] = print_pushg;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHGS]] = print_pushgs;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHGL]] = print_pushgl;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHGV]] = print_pushgv;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHGQ]] = print_pushgq;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHIP]] = print_puship;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHSP]] = print_pushsp;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHBP]] = print_pushbp;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHARGB]] = print_pushargb;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHARGI]] = print_pushargi;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHARGF]] = print_pushargf;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHARGS]] = print_pushargs;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHARGV]] = print_pushargv;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHARGQ]] = print_pushargq;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHE]] = print_pushe;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHEV]] = print_pushev;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHEQ]] = print_pusheq;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHARGE]] = print_pusharge;
-
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_ADD]] = print_add;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_SUB]] = print_sub;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_MUL]] = print_mul;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_DIV]] = print_div;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_MOD]] = print_mod;
-
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_EQ]] = print_eq;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_NEQ]] = print_neq;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_LEQ]] = print_leq;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_GEQ]] = print_geq;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_LESS]] = print_less;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_GREATER]] = print_greater;
-
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_BITAND]] = print_bitand;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_BITOR]] = print_bitor;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_BITXOR]] = print_bitxor;
-
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_BOOLAND]] = print_booland;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_BOOLOR]] = print_boolor;
-
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_SHL]] = print_shl;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_SHR]] = print_shr;
-
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_NEG]] = print_neg;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_BITNOT]] = print_bitnot;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_BOOLNOT]] = print_boolnot;
-
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_JUMP]] = print_jump;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_JUMPIF]] = print_jumpif;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_JUMPNIF]] = print_jumpnif;
-
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_STATE]] = print_state;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_CALL]] = print_call;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_RETURN]] = print_return;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_CAST]] = print_cast;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_STACKTOS]] = print_stacktos;
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_STACKTOL]] = print_stacktol;
-
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_PRINT]] = print_print;
-
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_CALLLIB]] = print_calllib;
-
- mPrintOpCodes[LSCRIPTOpCodes[LOPC_CALLLIB_TWO_BYTE]] = print_calllib_two_byte;
-}
-
-void print_noop(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tNOOP\n", offset++);
-}
-
-void print_pop(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tPOP\n", offset++);
-}
-
-void print_pops(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tPOPS\n", offset++);
-}
-
-void print_popl(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tPOPL\n", offset++);
-}
-
-void print_popv(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tPOPV\n", offset++);
-}
-
-void print_popq(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tPOPQ\n", offset++);
-}
-
-void print_poparg(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- S32 arg;
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tPOPARG ", offset++);
- arg = bytestream2integer(buffer, offset);
- fprintf(fp, "%d\n", arg);
-}
-
-void print_popip(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tPOPIP\n", offset++);
-}
-
-void print_popbp(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tPOPBP\n", offset++);
-}
-
-void print_popsp(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tPOPSP\n", offset++);
-}
-
-void print_popslr(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tPOPSLR\n", offset++);
-}
-
-void print_dup(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tDUP\n", offset++);
-}
-
-void print_dups(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tDUPS\n", offset++);
-}
-
-void print_dupl(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tDUPL\n", offset++);
-}
-
-void print_dupv(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tDUPV\n", offset++);
-}
-
-void print_dupq(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tDUPQ\n", offset++);
-}
-
-void print_store(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- S32 arg;
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tSTORE $BP + ", offset++);
- arg = bytestream2integer(buffer, offset);
- fprintf(fp, "%d\n", arg);
-}
-
-void print_stores(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- S32 arg;
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tSTORES $BP + ", offset++);
- arg = bytestream2integer(buffer, offset);
- fprintf(fp, "%d\n", arg);
-}
-
-void print_storel(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- S32 arg;
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tSTOREL $BP + ", offset++);
- arg = bytestream2integer(buffer, offset);
- fprintf(fp, "%d\n", arg);
-}
-
-void print_storev(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- S32 arg;
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tSTOREV $BP + ", offset++);
- arg = bytestream2integer(buffer, offset);
- fprintf(fp, "%d\n", arg);
-}
-
-void print_storeq(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- S32 arg;
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tSTOREQ $BP + ", offset++);
- arg = bytestream2integer(buffer, offset);
- fprintf(fp, "%d\n", arg);
-}
-
-void print_storeg(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- S32 arg;
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tSTOREG ", offset++);
- arg = bytestream2integer(buffer, offset);
- fprintf(fp, "%d\n", arg + get_register(buffer, LREG_GVR));
-}
-
-void print_storegs(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- S32 arg;
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tSTOREGS ", offset++);
- arg = bytestream2integer(buffer, offset);
- fprintf(fp, "%d\n", arg + get_register(buffer, LREG_GVR));
-}
-
-void print_storegl(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- S32 arg;
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tSTOREGL ", offset++);
- arg = bytestream2integer(buffer, offset);
- fprintf(fp, "%d\n", arg + get_register(buffer, LREG_GVR));
-}
-
-void print_storegv(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- S32 arg;
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tSTOREGV ", offset++);
- arg = bytestream2integer(buffer, offset);
- fprintf(fp, "%d\n", arg + get_register(buffer, LREG_GVR));
-}
-
-void print_storegq(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- S32 arg;
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tSTOREGQ ", offset++);
- arg = bytestream2integer(buffer, offset);
- fprintf(fp, "%d\n", arg + get_register(buffer, LREG_GVR));
-}
-
-void print_loadp(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- S32 arg;
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tSTOREP $BP + ", offset++);
- arg = bytestream2integer(buffer, offset);
- fprintf(fp, "%d\n", arg);
-}
-
-void print_loadsp(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- S32 arg;
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tSTOREPS $BP + ", offset++);
- arg = bytestream2integer(buffer, offset);
- fprintf(fp, "%d\n", arg);
-}
-
-void print_loadlp(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- S32 arg;
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tSTOREPL $BP + ", offset++);
- arg = bytestream2integer(buffer, offset);
- fprintf(fp, "%d\n", arg);
-}
-
-void print_loadvp(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- S32 arg;
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tSTOREVP $BP + ", offset++);
- arg = bytestream2integer(buffer, offset);
- fprintf(fp, "%d\n", arg);
-}
-
-void print_loadqp(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- S32 arg;
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tSTOREQP $BP + ", offset++);
- arg = bytestream2integer(buffer, offset);
- fprintf(fp, "%d\n", arg);
-}
-
-void print_loadgp(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- S32 arg;
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tSTOREGP ", offset++);
- arg = bytestream2integer(buffer, offset);
- fprintf(fp, "%d\n", arg + get_register(buffer, LREG_GVR));
-}
-
-void print_loadgsp(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- S32 arg;
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tSTOREGSP ", offset++);
- arg = bytestream2integer(buffer, offset);
- fprintf(fp, "%d\n", arg + get_register(buffer, LREG_GVR));
-}
-
-void print_loadglp(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- S32 arg;
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tSTOREGLP ", offset++);
- arg = bytestream2integer(buffer, offset);
- fprintf(fp, "%d\n", arg + get_register(buffer, LREG_GVR));
-}
-
-void print_loadgvp(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- S32 arg;
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tSTOREGVP ", offset++);
- arg = bytestream2integer(buffer, offset);
- fprintf(fp, "%d\n", arg + get_register(buffer, LREG_GVR));
-}
-
-void print_loadgqp(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- S32 arg;
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tSTOREGQP ", offset++);
- arg = bytestream2integer(buffer, offset);
- fprintf(fp, "%d\n", arg + get_register(buffer, LREG_GVR));
-}
-
-void print_push(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- S32 arg;
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tPUSH $BP + ", offset++);
- arg = bytestream2integer(buffer, offset);
- fprintf(fp, "%d\n", arg);
-}
-
-void print_pushs(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- S32 arg;
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tPUSHS $BP + ", offset++);
- arg = bytestream2integer(buffer, offset);
- fprintf(fp, "%d\n", arg);
-}
-
-void print_pushl(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- S32 arg;
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tPUSHL $BP + ", offset++);
- arg = bytestream2integer(buffer, offset);
- fprintf(fp, "%d\n", arg);
-}
-
-void print_pushv(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- S32 arg;
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tPUSHV $BP + ", offset++);
- arg = bytestream2integer(buffer, offset);
- fprintf(fp, "%d\n", arg);
-}
-
-void print_pushq(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- S32 arg;
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tPUSHQ $BP + ", offset++);
- arg = bytestream2integer(buffer, offset);
- fprintf(fp, "%d\n", arg);
-}
-
-void print_pushg(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- S32 arg;
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tPUSHG ", offset++);
- arg = bytestream2integer(buffer, offset);
- fprintf(fp, "0x%X\n", arg + get_register(buffer, LREG_GVR));
-}
-
-void print_pushgs(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- S32 arg;
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tPUSHGS ", offset++);
- arg = bytestream2integer(buffer, offset);
- fprintf(fp, "0x%X\n", arg + get_register(buffer, LREG_GVR));
-}
-
-void print_pushgl(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- S32 arg;
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tPUSHGL ", offset++);
- arg = bytestream2integer(buffer, offset);
- fprintf(fp, "0x%X\n", arg + get_register(buffer, LREG_GVR));
-}
-
-void print_pushgv(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- S32 arg;
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tPUSHGV ", offset++);
- arg = bytestream2integer(buffer, offset);
- fprintf(fp, "0x%X\n", arg + get_register(buffer, LREG_GVR));
-}
-
-void print_pushgq(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- S32 arg;
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tPUSHGQ ", offset++);
- arg = bytestream2integer(buffer, offset);
- fprintf(fp, "0x%X\n", arg + get_register(buffer, LREG_GVR));
-}
-
-void print_puship(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tPUSHIP\n", offset++);
-}
-
-void print_pushbp(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tPUSHBP\n", offset++);
-}
-
-void print_pushsp(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tPUSHSP\n", offset++);
-}
-
-void print_pushargb(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- U8 arg;
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tPUSHARGB ", offset++);
- arg = *(buffer + offset++);
- fprintf(fp, "%d\n", (U32)arg);
-}
-
-void print_pushargi(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- S32 arg;
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tPUSHARGI ", offset++);
- arg = bytestream2integer(buffer, offset);
- fprintf(fp, "%d\n", arg);
-}
-
-void print_pushargf(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- F32 arg;
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tPUSHARGF ", offset++);
- arg = bytestream2float(buffer, offset);
- fprintf(fp, "%f\n", arg);
-}
-
-void print_pushargs(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- char arg[1024]; /*Flawfinder: ignore*/
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tPUSHARGS ", offset++);
- bytestream2char(arg, buffer, offset, sizeof(arg));
- fprintf(fp, "%s\n", arg);
-}
-
-void print_pushargv(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- LLVector3 arg;
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tPUSHARGV ", offset++);
- bytestream2vector(arg, buffer, offset);
- fprintf(fp, "< %f, %f, %f >\n", arg.mV[VX], arg.mV[VY], arg.mV[VZ]);
-}
-
-void print_pushargq(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- LLQuaternion arg;
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tPUSHARGV ", offset++);
- bytestream2quaternion(arg, buffer, offset);
- fprintf(fp, "< %f, %f, %f, %f >\n", arg.mQ[VX], arg.mQ[VY], arg.mQ[VZ], arg.mQ[VS]);
-}
-
-void print_pushe(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tPUSHE\n", offset++);
-}
-
-void print_pushev(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tPUSHEV\n", offset++);
-}
-
-void print_pusheq(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tPUSHEQ\n", offset++);
-}
-
-void print_pusharge(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- S32 arg;
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tPUSHARGE ", offset++);
- arg = bytestream2integer(buffer, offset);
- fprintf(fp, "%d\n", arg);
-}
-
-
-void print_add(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- U8 types;
- U8 type1;
- U8 type2;
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tADD ", offset++);
- types = *(buffer + offset++);
- type1 = types >> 4;
- type2 = types & 0xf;
- fprintf(fp, "%s, %s\n", LSCRIPTTypeNames[type1], LSCRIPTTypeNames[type2]);
-}
-
-void print_sub(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- U8 types;
- U8 type1;
- U8 type2;
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tSUB ", offset++);
- types = *(buffer + offset++);
- type1 = types >> 4;
- type2 = types & 0xf;
- fprintf(fp, "%s, %s\n", LSCRIPTTypeNames[type1], LSCRIPTTypeNames[type2]);
-}
-
-void print_mul(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- U8 types;
- U8 type1;
- U8 type2;
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tMUL ", offset++);
- types = *(buffer + offset++);
- type1 = types >> 4;
- type2 = types & 0xf;
- fprintf(fp, "%s, %s\n", LSCRIPTTypeNames[type1], LSCRIPTTypeNames[type2]);
-}
-
-void print_div(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- U8 types;
- U8 type1;
- U8 type2;
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tDIV ", offset++);
- types = *(buffer + offset++);
- type1 = types >> 4;
- type2 = types & 0xf;
- fprintf(fp, "%s, %s\n", LSCRIPTTypeNames[type1], LSCRIPTTypeNames[type2]);
-}
-
-void print_mod(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- U8 types;
- U8 type1;
- U8 type2;
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tMOD ", offset++);
- types = *(buffer + offset++);
- type1 = types >> 4;
- type2 = types & 0xf;
- fprintf(fp, "%s, %s\n", LSCRIPTTypeNames[type1], LSCRIPTTypeNames[type2]);
-}
-
-void print_eq(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- U8 types;
- U8 type1;
- U8 type2;
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tEQ ", offset++);
- types = *(buffer + offset++);
- type1 = types >> 4;
- type2 = types & 0xf;
- fprintf(fp, "%s, %s\n", LSCRIPTTypeNames[type1], LSCRIPTTypeNames[type2]);
-}
-
-void print_neq(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- U8 types;
- U8 type1;
- U8 type2;
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tNEQ ", offset++);
- types = *(buffer + offset++);
- type1 = types >> 4;
- type2 = types & 0xf;
- fprintf(fp, "%s, %s\n", LSCRIPTTypeNames[type1], LSCRIPTTypeNames[type2]);
-}
-
-void print_leq(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- U8 types;
- U8 type1;
- U8 type2;
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tLEQ ", offset++);
- types = *(buffer + offset++);
- type1 = types >> 4;
- type2 = types & 0xf;
- fprintf(fp, "%s, %s\n", LSCRIPTTypeNames[type1], LSCRIPTTypeNames[type2]);
-}
-
-void print_geq(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- U8 types;
- U8 type1;
- U8 type2;
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tGEQ ", offset++);
- types = *(buffer + offset++);
- type1 = types >> 4;
- type2 = types & 0xf;
- fprintf(fp, "%s, %s\n", LSCRIPTTypeNames[type1], LSCRIPTTypeNames[type2]);
-}
-
-void print_less(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- U8 types;
- U8 type1;
- U8 type2;
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tLESS ", offset++);
- types = *(buffer + offset++);
- type1 = types >> 4;
- type2 = types & 0xf;
- fprintf(fp, "%s, %s\n", LSCRIPTTypeNames[type1], LSCRIPTTypeNames[type2]);
-}
-
-void print_greater(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- U8 types;
- U8 type1;
- U8 type2;
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tGREATER ", offset++);
- types = *(buffer + offset++);
- type1 = types >> 4;
- type2 = types & 0xf;
- fprintf(fp, "%s, %s\n", LSCRIPTTypeNames[type1], LSCRIPTTypeNames[type2]);
-}
-
-
-void print_bitand(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tBITAND\n", offset++);
-}
-
-void print_bitor(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tBITOR\n", offset++);
-}
-
-void print_bitxor(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tBITXOR\n", offset++);
-}
-
-void print_booland(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tBOOLAND\n", offset++);
-}
-
-void print_boolor(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tBOOLOR\n", offset++);
-}
-
-void print_shl(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tSHL\n", offset++);
-}
-
-void print_shr(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tSHR\n", offset++);
-}
-
-
-void print_neg(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- U8 type;
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tNEG ", offset++);
- type = *(buffer + offset++);
- fprintf(fp, "%s\n", LSCRIPTTypeNames[type]);
-}
-
-void print_bitnot(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tBITNOT\n", offset++);
-}
-
-void print_boolnot(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tBOOLNOT\n", offset++);
-}
-
-void print_jump(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- S32 arg;
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tJUMP ", offset++);
- arg = bytestream2integer(buffer, offset);
- fprintf(fp, "%d\n", arg);
-}
-
-void print_jumpif(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- S32 arg;
- U8 type;
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tJUMPIF ", offset++);
- type = *(buffer + offset++);
- arg = bytestream2integer(buffer, offset);
- fprintf(fp, "%s, %d\n", LSCRIPTTypeNames[type], arg);
-}
-
-void print_jumpnif(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- S32 arg;
- U8 type;
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tJUMPNIF ", offset++);
- type = *(buffer + offset++);
- arg = bytestream2integer(buffer, offset);
- fprintf(fp, "%s, %d\n", LSCRIPTTypeNames[type], arg);
-}
-
-void print_state(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- S32 arg;
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tSTATE ", offset++);
- arg = bytestream2integer(buffer, offset);
- fprintf(fp, "%d\n", arg);
-}
-
-void print_call(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- S32 arg;
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tCALL ", offset++);
- arg = bytestream2integer(buffer, offset);
- fprintf(fp, "%d\n", arg);
-}
-
-void print_return(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tRETURN\n", offset++);
-}
-
-void print_cast(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- U8 types;
- U8 type1;
- U8 type2;
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tCAST ", offset++);
- types = *(buffer + offset++);
- type1 = types >> 4;
- type2 = types & 0xf;
- fprintf(fp, "%s, %s\n", LSCRIPTTypeNames[type1], LSCRIPTTypeNames[type2]);
-}
-
-void print_stacktos(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- S32 arg;
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tSTACKTOS ", offset++);
- arg = bytestream2integer(buffer, offset);
- fprintf(fp, "%d\n", arg);
-}
-
-void print_stacktol(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- S32 arg;
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tSTACKTOL ", offset++);
- arg = bytestream2integer(buffer, offset);
- fprintf(fp, "%d\n", arg);
-}
-
-void print_print(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tPRINT ", offset++);
- U8 type = *(buffer + offset++);
- fprintf(fp, "%s\n", LSCRIPTTypeNames[type]);
-}
-
-void print_calllib(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- U8 arg;
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tCALLLIB ", offset++);
- arg = *(buffer + offset++);
- fprintf(fp, "%d (%s)\n", (U32)arg, gScriptLibrary.mFunctions[arg].mName);
-}
-
-
-void print_calllib_two_byte(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
-{
- U16 arg;
- lso_print_tabs(fp, tabs);
- fprintf(fp, "[0x%X]\tCALLLIB_TWO_BYTE ", offset++);
- arg = bytestream2u16(buffer, offset);
- fprintf(fp, "%d (%s)\n", (U32)arg, gScriptLibrary.mFunctions[arg].mName);
-}
-
diff --git a/indra/lscript/lscript_execute/lscript_readlso.h b/indra/lscript/lscript_execute/lscript_readlso.h
deleted file mode 100755
index f3b2b66746..0000000000
--- a/indra/lscript/lscript_execute/lscript_readlso.h
+++ /dev/null
@@ -1,164 +0,0 @@
-/**
- * @file lscript_readlso.h
- * @brief classes to read lso file
- *
- * $LicenseInfo:firstyear=2002&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#ifndef LL_LSCRIPT_READLSO_H
-#define LL_LSCRIPT_READLSO_H
-
-#include "lscript_byteconvert.h"
-
-// list of op code print functions
-void print_noop(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_pop(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_pops(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_popl(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_popv(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_popq(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_poparg(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_popip(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_popbp(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_popsp(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_popslr(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-
-void print_dup(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_dups(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_dupl(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_dupv(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_dupq(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-
-void print_store(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_stores(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_storel(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_storev(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_storeq(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_storeg(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_storegs(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_storegl(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_storegv(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_storegq(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_loadp(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_loadsp(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_loadlp(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_loadvp(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_loadqp(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_loadgp(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_loadgsp(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_loadglp(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_loadgvp(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_loadgqp(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-
-void print_push(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_pushl(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_pushs(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_pushv(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_pushq(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_pushg(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_pushgl(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_pushgs(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_pushgv(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_pushgq(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_puship(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_pushbp(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_pushsp(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_pushargb(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_pushargi(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_pushargf(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_pushargs(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_pushargv(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_pushargq(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_pushe(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_pushev(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_pusheq(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_pusharge(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-
-void print_add(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_sub(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_mul(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_div(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_mod(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-
-void print_eq(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_neq(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_leq(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_geq(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_less(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_greater(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-
-void print_bitand(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_bitor(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_bitxor(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_booland(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_boolor(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-
-void print_shl(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_shr(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-
-void print_neg(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_bitnot(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_boolnot(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-
-void print_jump(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_jumpif(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_jumpnif(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-
-void print_state(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_call(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_return(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_cast(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_stacktos(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_stacktol(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-
-void print_print(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-
-void print_calllib(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-void print_calllib_two_byte(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-
-class LLScriptLSOParse
-{
-public:
- LLScriptLSOParse(LLFILE *fp);
- LLScriptLSOParse(U8 *buffer);
- ~LLScriptLSOParse();
-
- void initOpCodePrinting();
-
- void printData(LLFILE *fp);
- void printNameDesc(LLFILE *fp);
- void printRegisters(LLFILE *fp);
- void printGlobals(LLFILE *fp);
- void printGlobalFunctions(LLFILE *fp);
- void printStates(LLFILE *fp);
- void printHeap(LLFILE *fp);
- void printOpCodes(LLFILE *fp, S32 &offset, S32 tabs);
- void printOpCodeRange(LLFILE *fp, S32 start, S32 end, S32 tabs);
-
- U8 *mRawData;
- void (*mPrintOpCodes[0x100])(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs);
-};
-
-
-void lso_print_tabs(LLFILE *fp, S32 tabs);
-
-#endif
diff --git a/indra/lscript/lscript_export.h b/indra/lscript/lscript_export.h
deleted file mode 100755
index 2043dd4558..0000000000
--- a/indra/lscript/lscript_export.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * @file lscript_export.h
- * @brief Export interface class
- *
- * $LicenseInfo:firstyear=2002&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#ifndef LL_LSCRIPT_EXPORT_H
-#define LL_LSCRIPT_EXPORT_H
-
-#include "lscript_library.h"
-
-
-
-#endif
diff --git a/indra/lscript/lscript_http.h b/indra/lscript/lscript_http.h
deleted file mode 100755
index c6f2325995..0000000000
--- a/indra/lscript/lscript_http.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * @file lscript_http.h
- * @brief LSL HTTP keys
- *
- * $LicenseInfo:firstyear=2006&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-// Keys used in LSL HTTP function <key,value> pair lists.
-
-#ifndef LSCRIPT_HTTP_H
-#define LSCRIPT_HTTP_H
-
-enum LLScriptHTTPRequestParameterKey
-{
- HTTP_METHOD,
- HTTP_MIMETYPE,
- HTTP_BODY_MAXLENGTH,
- HTTP_VERIFY_CERT
-};
-
-enum LLScriptHTTPResponseMetadataKey
-{
- HTTP_BODY_TRUNCATED
-};
-
-#endif
diff --git a/indra/lscript/lscript_library.h b/indra/lscript/lscript_library.h
deleted file mode 100755
index f3dbb09196..0000000000
--- a/indra/lscript/lscript_library.h
+++ /dev/null
@@ -1,427 +0,0 @@
-/**
- * @file lscript_library.h
- * @brief External library interface
- *
- * $LicenseInfo:firstyear=2002&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#ifndef LL_LSCRIPT_LIBRARY_H
-#define LL_LSCRIPT_LIBRARY_H
-
-#include "lscript_byteformat.h"
-#include "v3math.h"
-#include "llquaternion.h"
-#include "lluuid.h"
-#include "lscript_byteconvert.h"
-
-class LLScriptLibData;
-
-class LLScriptLibraryFunction
-{
-public:
- LLScriptLibraryFunction(F32 eu, F32 st, void (*exec_func)(LLScriptLibData *, LLScriptLibData *, const LLUUID &), const char *name, const char *ret_type, const char *args, BOOL god_only = FALSE);
- ~LLScriptLibraryFunction();
-
- F32 mEnergyUse;
- F32 mSleepTime;
- void (*mExecFunc)(LLScriptLibData *, LLScriptLibData *, const LLUUID &);
- const char *mName;
- const char *mReturnType;
- const char *mArgs;
- BOOL mGodOnly;
-};
-
-class LLScriptLibrary
-{
-public:
- LLScriptLibrary();
- ~LLScriptLibrary();
-
- void init();
-
- void addFunction(F32 eu, F32 st, void (*exec_func)(LLScriptLibData *, LLScriptLibData *, const LLUUID &), const char *name, const char *ret_type, const char *args, BOOL god_only = FALSE);
- void assignExec(const char *name, void (*exec_func)(LLScriptLibData *, LLScriptLibData *, const LLUUID &));
-
- std::vector<LLScriptLibraryFunction> mFunctions;
-};
-
-
-
-class LLScriptLibData
-{
-public:
- // TODO: Change this to a union
- LSCRIPTType mType;
- S32 mInteger;
- F32 mFP;
- char *mKey;
- char *mString;
- LLVector3 mVec;
- LLQuaternion mQuat;
- LLScriptLibData *mListp;
-
- friend bool operator<=(const LLScriptLibData &a, const LLScriptLibData &b)
- {
- if (a.mType == b.mType)
- {
- if (a.mType == LST_INTEGER)
- {
- return a.mInteger <= b.mInteger;
- }
- if (a.mType == LST_FLOATINGPOINT)
- {
- return a.mFP <= b.mFP;
- }
- if (a.mType == LST_STRING)
- {
- return strcmp(a.mString, b.mString) <= 0;
- }
- if (a.mType == LST_KEY)
- {
- return strcmp(a.mKey, b.mKey) <= 0;
- }
- if (a.mType == LST_VECTOR)
- {
- return a.mVec.magVecSquared() <= b.mVec.magVecSquared();
- }
- }
- return TRUE;
- }
-
- friend bool operator==(const LLScriptLibData &a, const LLScriptLibData &b)
- {
- if (a.mType == b.mType)
- {
- if (a.mType == LST_INTEGER)
- {
- return a.mInteger == b.mInteger;
- }
- if (a.mType == LST_FLOATINGPOINT)
- {
- return a.mFP == b.mFP;
- }
- if (a.mType == LST_STRING)
- {
- return !strcmp(a.mString, b.mString);
- }
- if (a.mType == LST_KEY)
- {
- return !strcmp(a.mKey, b.mKey);
- }
- if (a.mType == LST_VECTOR)
- {
- return a.mVec == b.mVec;
- }
- if (a.mType == LST_QUATERNION)
- {
- return a.mQuat == b.mQuat;
- }
- }
- return FALSE;
- }
-
- S32 getListLength() const
- {
- const LLScriptLibData *data = this;
- S32 retval = 0;
- while (data->mListp)
- {
- retval++;
- data = data->mListp;
- }
- return retval;
- }
-
- BOOL checkForMultipleLists()
- {
- LLScriptLibData *data = this;
- while (data->mListp)
- {
- data = data->mListp;
- if (data->mType == LST_LIST)
- return TRUE;
- }
- return FALSE;
- }
-
- S32 getSavedSize()
- {
- S32 size = 0;
- // mType
- size += 4;
-
- switch(mType)
- {
- case LST_INTEGER:
- size += 4;
- break;
- case LST_FLOATINGPOINT:
- size += 4;
- break;
- case LST_KEY:
- size += (S32)strlen(mKey) + 1; /*Flawfinder: ignore*/
- break;
- case LST_STRING:
- size += (S32)strlen(mString) + 1; /*Flawfinder: ignore*/
- break;
- case LST_LIST:
- break;
- case LST_VECTOR:
- size += 12;
- break;
- case LST_QUATERNION:
- size += 16;
- break;
- default:
- break;
- }
- return size;
- }
-
- S32 write2bytestream(U8 *dest)
- {
- S32 offset = 0;
- integer2bytestream(dest, offset, mType);
- switch(mType)
- {
- case LST_INTEGER:
- integer2bytestream(dest, offset, mInteger);
- break;
- case LST_FLOATINGPOINT:
- float2bytestream(dest, offset, mFP);
- break;
- case LST_KEY:
- char2bytestream(dest, offset, mKey);
- break;
- case LST_STRING:
- char2bytestream(dest, offset, mString);
- break;
- case LST_LIST:
- break;
- case LST_VECTOR:
- vector2bytestream(dest, offset, mVec);
- break;
- case LST_QUATERNION:
- quaternion2bytestream(dest, offset, mQuat);
- break;
- default:
- break;
- }
- return offset;
- }
-
- LLScriptLibData() : mType(LST_NULL), mInteger(0), mFP(0.f), mKey(NULL), mString(NULL), mVec(), mQuat(), mListp(NULL)
- {
- }
-
- LLScriptLibData(const LLScriptLibData &data) : mType(data.mType), mInteger(data.mInteger), mFP(data.mFP), mKey(NULL), mString(NULL), mVec(data.mVec), mQuat(data.mQuat), mListp(NULL)
- {
- if (data.mKey)
- {
- mKey = new char[strlen(data.mKey) + 1]; /* Flawfinder: ignore */
- if (mKey == NULL)
- {
- LL_ERRS() << "Memory Allocation Failed" << LL_ENDL;
- return;
- }
- strcpy(mKey, data.mKey); /* Flawfinder: ignore */
- }
- if (data.mString)
- {
- mString = new char[strlen(data.mString) + 1]; /* Flawfinder: ignore */
- if (mString == NULL)
- {
- LL_ERRS() << "Memory Allocation Failed" << LL_ENDL;
- return;
- }
- strcpy(mString, data.mString); /* Flawfinder: ignore */
- }
- }
-
- LLScriptLibData(U8 *src, S32 &offset) : mListp(NULL)
- {
- static char temp[TOP_OF_MEMORY]; /* Flawfinder: ignore */
- mType = (LSCRIPTType)bytestream2integer(src, offset);
- switch(mType)
- {
- case LST_INTEGER:
- mInteger = bytestream2integer(src, offset);
- break;
- case LST_FLOATINGPOINT:
- mFP = bytestream2float(src, offset);
- break;
- case LST_KEY:
- {
- bytestream2char(temp, src, offset, sizeof(temp));
- mKey = new char[strlen(temp) + 1]; /* Flawfinder: ignore */
- if (mKey == NULL)
- {
- LL_ERRS() << "Memory Allocation Failed" << LL_ENDL;
- return;
- }
- strcpy(mKey, temp); /* Flawfinder: ignore */
- }
- break;
- case LST_STRING:
- {
- bytestream2char(temp, src, offset, sizeof(temp));
- mString = new char[strlen(temp) + 1]; /* Flawfinder: ignore */
- if (mString == NULL)
- {
- LL_ERRS() << "Memory Allocation Failed" << LL_ENDL;
- return;
- }
- strcpy(mString, temp); /* Flawfinder: ignore */
- }
- break;
- case LST_LIST:
- break;
- case LST_VECTOR:
- bytestream2vector(mVec, src, offset);
- break;
- case LST_QUATERNION:
- bytestream2quaternion(mQuat, src, offset);
- break;
- default:
- break;
- }
- }
-
- void set(U8 *src, S32 &offset)
- {
- static char temp[TOP_OF_MEMORY]; /* Flawfinder: ignore */
- mType = (LSCRIPTType)bytestream2integer(src, offset);
- switch(mType)
- {
- case LST_INTEGER:
- mInteger = bytestream2integer(src, offset);
- break;
- case LST_FLOATINGPOINT:
- mFP = bytestream2float(src, offset);
- break;
- case LST_KEY:
- {
- bytestream2char(temp, src, offset, sizeof(temp));
- mKey = new char[strlen(temp) + 1]; /* Flawfinder: ignore */
- if (mKey == NULL)
- {
- LL_ERRS() << "Memory Allocation Failed" << LL_ENDL;
- return;
- }
- strcpy(mKey, temp); /* Flawfinder: ignore */
- }
- break;
- case LST_STRING:
- {
- bytestream2char(temp, src, offset, sizeof(temp));
- mString = new char[strlen(temp) + 1]; /* Flawfinder: ignore */
- if (mString == NULL)
- {
- LL_ERRS() << "Memory Allocation Failed" << LL_ENDL;
- return;
- }
- strcpy(mString, temp); /* Flawfinder: ignore */
- }
- break;
- case LST_LIST:
- break;
- case LST_VECTOR:
- bytestream2vector(mVec, src, offset);
- break;
- case LST_QUATERNION:
- bytestream2quaternion(mQuat, src, offset);
- break;
- default:
- break;
- }
- }
-
- void print(std::ostream &s, BOOL b_prepend_comma);
- void print_separator(std::ostream& ostr, BOOL b_prepend_sep, char* sep);
-
- void setFromCSV(const char *src)
- {
- mType = LST_STRING;
- mString = new char[strlen(src) + 1]; /* Flawfinder: ignore */
- if (mString == NULL)
- {
- LL_ERRS() << "Memory Allocation Failed" << LL_ENDL;
- return;
- }
- strcpy(mString, src); /* Flawfinder: ignore */
- }
-
- LLScriptLibData(S32 integer) : mType(LST_INTEGER), mInteger(integer), mFP(0.f), mKey(NULL), mString(NULL), mVec(), mQuat(), mListp(NULL)
- {
- }
-
- LLScriptLibData(F32 fp) : mType(LST_FLOATINGPOINT), mInteger(0), mFP(fp), mKey(NULL), mString(NULL), mVec(), mQuat(), mListp(NULL)
- {
- }
-
- LLScriptLibData(const LLUUID &id) : mType(LST_KEY), mInteger(0), mFP(0.f), mKey(NULL), mString(NULL), mVec(), mQuat(), mListp(NULL)
- {
- std::string idstr;
- id.toString(idstr);
- mKey = new char[idstr.length()+1];
- LLStringUtil::copy(mKey,idstr.c_str(),idstr.length()+1);
- }
-
- LLScriptLibData(const char *string) : mType(LST_STRING), mInteger(0), mFP(0.f), mKey(NULL), mString(NULL), mVec(), mQuat(), mListp(NULL)
- {
- if (!string)
- {
- mString = new char[1];
- mString[0] = 0;
- }
- else
- {
- mString = new char[strlen(string) + 1]; /* Flawfinder: ignore */
- if (mString == NULL)
- {
- LL_ERRS() << "Memory Allocation Failed" << LL_ENDL;
- return;
- }
- strcpy(mString, string); /* Flawfinder: ignore */
- }
- }
-
- LLScriptLibData(const LLVector3 &vec) : mType(LST_VECTOR), mInteger(0), mFP(0.f), mKey(NULL), mString(NULL), mVec(vec), mQuat(), mListp(NULL)
- {
- }
-
- LLScriptLibData(const LLQuaternion &quat) : mType(LST_QUATERNION), mInteger(0), mFP(0.f), mKey(NULL), mString(NULL), mVec(), mQuat(quat), mListp(NULL)
- {
- }
-
- ~LLScriptLibData()
- {
- delete mListp;
- delete [] mKey;
- delete [] mString;
- }
-
-};
-
-extern LLScriptLibrary gScriptLibrary;
-
-#endif
diff --git a/indra/lscript/lscript_library/CMakeLists.txt b/indra/lscript/lscript_library/CMakeLists.txt
deleted file mode 100755
index 5af850c41b..0000000000
--- a/indra/lscript/lscript_library/CMakeLists.txt
+++ /dev/null
@@ -1,35 +0,0 @@
-# -*- cmake -*-
-
-include(00-Common)
-include(LLCommon)
-include(LLMath)
-include(LScript)
-
-set(lscript_library_SOURCE_FILES
- lscript_alloc.cpp
- lscript_export.cpp
- lscript_library.cpp
- )
-
-set(lscript_library_HEADER_FILES
- CMakeLists.txt
-
- ../lscript_library.h
- ../lscript_export.h
- )
-
-set_source_files_properties(${lscript_library_HEADER_FILES}
- PROPERTIES HEADER_FILE_ONLY TRUE)
-
-list(APPEND lscript_library_SOURCE_FILES ${lscript_library_HEADER_FILES})
-
-include_directories(
- ${LLCOMMON_INCLUDE_DIRS}
- ${LLMATH_INCLUDE_DIRS}
- ${LSCRIPT_INCLUDE_DIRS}
- )
-include_directories(SYSTEM
- ${LLCOMMON_SYSTEM_INCLUDE_DIRS}
- )
-
-add_library (lscript_library ${lscript_library_SOURCE_FILES})
diff --git a/indra/lscript/lscript_library/lscript_alloc.cpp b/indra/lscript/lscript_library/lscript_alloc.cpp
deleted file mode 100755
index 62ba029e8a..0000000000
--- a/indra/lscript/lscript_library/lscript_alloc.cpp
+++ /dev/null
@@ -1,1136 +0,0 @@
-/**
- * @file lscript_alloc.cpp
- * @brief general heap management for scripting system
- *
- * $LicenseInfo:firstyear=2002&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-// #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 "linden_common.h"
-#include "lscript_alloc.h"
-#include "llrand.h"
-
-// 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 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
-
-void reset_hp_to_safe_spot(const U8 *buffer)
-{
- set_register((U8 *)buffer, LREG_HP, TOP_OF_MEMORY);
-}
-
-// create a heap from the HR to TM
-BOOL lsa_create_heap(U8 *heap_start, S32 size)
-{
- LLScriptAllocEntry entry(size, LST_NULL);
-
- S32 position = 0;
-
- alloc_entry2bytestream(heap_start, position, entry);
-
- return TRUE;
-}
-
-S32 lsa_heap_top(U8 *heap_start, S32 maxtop)
-{
- S32 offset = 0;
- LLScriptAllocEntry entry;
- bytestream2alloc_entry(entry, heap_start, offset);
-
- while (offset + entry.mSize < maxtop)
- {
- offset += entry.mSize;
- bytestream2alloc_entry(entry, heap_start, offset);
- }
- return offset + entry.mSize;
-}
-
-
-// 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)
-{
- if (get_register(buffer, LREG_FR))
- return 1;
- LLScriptAllocEntry entry, nextentry;
- S32 hr = get_register(buffer, LREG_HR);
- S32 hp = get_register(buffer, LREG_HP);
- S32 current_offset, next_offset, offset = hr;
- S32 size = 0;
-
- switch(data->mType)
- {
- case LST_INTEGER:
- size = 4;
- break;
- case LST_FLOATINGPOINT:
- size = 4;
- break;
- case LST_KEY:
- // NOTE: babbage: defensive as some library calls set data to NULL
- size = data->mKey ? (S32)strlen(data->mKey) + 1 : 1; /*Flawfinder: ignore*/
- break;
- case LST_STRING:
- // NOTE: babbage: defensive as some library calls set data to NULL
- size = data->mString ? (S32)strlen(data->mString) + 1 : 1; /*Flawfinder: ignore*/
- break;
- case LST_LIST:
- // list data 4 bytes of number of entries followed by number of pointer
- size = 4 + 4*data->getListLength();
- if (data->checkForMultipleLists())
- {
- set_fault(buffer, LSRF_NESTING_LISTS);
- }
- break;
- case LST_VECTOR:
- size = 12;
- break;
- case LST_QUATERNION:
- size = 16;
- break;
- default:
- break;
- }
-
- current_offset = offset;
- bytestream2alloc_entry(entry, buffer, offset);
-
- do
- {
- hp = get_register(buffer, LREG_HP);
- if (!entry.mType)
- {
- if (entry.mSize >= size + SIZEOF_SCRIPT_ALLOC_ENTRY + 4)
- {
- offset = current_offset;
- lsa_split_block(buffer, offset, size, entry);
- entry.mType = data->mType;
- entry.mSize = size;
- entry.mReferenceCount = 1;
- offset = current_offset;
- alloc_entry2bytestream(buffer, offset, entry);
- lsa_insert_data(buffer, offset, data, entry, heapsize);
- hp = get_register(buffer, LREG_HP);
- S32 new_hp = current_offset + size + 2*SIZEOF_SCRIPT_ALLOC_ENTRY;
- if (new_hp >= hr + heapsize)
- {
- break;
- }
- if (new_hp > hp)
- {
- set_register(buffer, LREG_HP, new_hp);
- hp = get_register(buffer, LREG_HP);
- }
- if (b_delete)
- delete data;
- // this bit of nastiness is to get around that code paths to local variables can result in lack of initialization
- // and function clean up of ref counts isn't based on scope (a mistake, I know)
- if (current_offset <= hp)
- return current_offset - hr + 1;
- else
- return hp - hr + 1;
- }
- else if (entry.mSize >= size)
- {
- entry.mType = data->mType;
- entry.mReferenceCount = 1;
- offset = current_offset;
- alloc_entry2bytestream(buffer, offset, entry);
- lsa_insert_data(buffer, offset, data, entry, heapsize);
- hp = get_register(buffer, LREG_HP);
- if (b_delete)
- delete data;
- // this bit of nastiness is to get around that code paths to local variables can result in lack of initialization
- // and function clean up of ref counts isn't based on scope (a mistake, I know)
- return current_offset - hr + 1;
- }
- }
- offset += entry.mSize;
- if (offset < hr + heapsize)
- {
- next_offset = offset;
- bytestream2alloc_entry(nextentry, buffer, offset);
- if (!nextentry.mType && !entry.mType)
- {
- entry.mSize += nextentry.mSize + SIZEOF_SCRIPT_ALLOC_ENTRY;
- offset = current_offset;
- alloc_entry2bytestream(buffer, offset, entry);
- }
- else
- {
- current_offset = next_offset;
- entry = nextentry;
- }
-
- // this works whether we are bumping out or coming in
- S32 new_hp = current_offset + size + 2*SIZEOF_SCRIPT_ALLOC_ENTRY;
-
- // make sure we aren't about to be stupid
- if (new_hp >= hr + heapsize)
- {
- break;
- }
- if (new_hp > hp)
- {
- set_register(buffer, LREG_HP, new_hp);
- hp = get_register(buffer, LREG_HP);
- }
- }
- else
- {
- break;
- }
- } while (1);
- set_fault(buffer, LSRF_STACK_HEAP_COLLISION);
- reset_hp_to_safe_spot(buffer);
- if (b_delete)
- delete data;
- return 0;
-}
-
-// 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)
-{
- if (get_register(buffer, LREG_FR))
- return;
- LLScriptAllocEntry newentry;
-
- newentry.mSize = entry.mSize - SIZEOF_SCRIPT_ALLOC_ENTRY - size;
- entry.mSize -= newentry.mSize + SIZEOF_SCRIPT_ALLOC_ENTRY;
-
- alloc_entry2bytestream(buffer, offset, entry);
- S32 orig_offset = offset + size;
- alloc_entry2bytestream(buffer, orig_offset, newentry);
-}
-
-// 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
-// save length of list
-// for each list entry
-// insert data
-// return address
-
-void lsa_insert_data(U8 *buffer, S32 &offset, LLScriptLibData *data, LLScriptAllocEntry &entry, S32 heapsize)
-{
- if (get_register(buffer, LREG_FR))
- return;
- if (data->mType != LST_LIST)
- {
- switch(data->mType)
- {
- case LST_INTEGER:
- integer2bytestream(buffer, offset, data->mInteger);
- break;
- case LST_FLOATINGPOINT:
- float2bytestream(buffer, offset, data->mFP);
- break;
- case LST_KEY:
- char2bytestream(buffer, offset, data->mKey ? data->mKey : "");
- break;
- case LST_STRING:
- char2bytestream(buffer, offset, data->mString ? data->mString : "");
- break;
- case LST_VECTOR:
- vector2bytestream(buffer, offset, data->mVec);
- break;
- case LST_QUATERNION:
- quaternion2bytestream(buffer, offset, data->mQuat);
- break;
- default:
- break;
- }
- }
- else
- {
- // store length of list
- integer2bytestream(buffer, offset, data->getListLength());
- data = data->mListp;
- while(data)
- {
- // store entry and then store address if valid
- S32 address = lsa_heap_add_data(buffer, data, heapsize, FALSE);
- integer2bytestream(buffer, offset, address);
- data = data->mListp;
- }
- }
-}
-
-S32 lsa_create_data_block(U8 **buffer, LLScriptLibData *data, S32 base_offset)
-{
- S32 offset = 0;
- S32 size = 0;
-
- LLScriptAllocEntry entry;
-
- if (!data)
- {
- entry.mType = LST_NULL;
- entry.mReferenceCount = 0;
- entry.mSize = MAX_HEAP_SIZE;
- size = SIZEOF_SCRIPT_ALLOC_ENTRY;
- *buffer = new U8[size];
- alloc_entry2bytestream(*buffer, offset, entry);
- return size;
- }
-
- entry.mType = data->mType;
- entry.mReferenceCount = 1;
-
- if (data->mType != LST_LIST)
- {
- if ( (data->mType != LST_STRING)
- &&(data->mType != LST_KEY))
- {
- size = LSCRIPTDataSize[data->mType];
- }
- else
- {
- if (data->mType == LST_STRING)
- {
- if (data->mString)
- {
- size = (S32)strlen(data->mString) + 1; /*Flawfinder: ignore*/
- }
- else
- {
- size = 1;
- }
- }
- if (data->mType == LST_KEY)
- {
- if (data->mKey)
- {
- size = (S32)strlen(data->mKey) + 1; /*Flawfinder: ignore*/
- }
- else
- {
- size = 1;
- }
- }
- }
- entry.mSize = size;
- size += SIZEOF_SCRIPT_ALLOC_ENTRY;
- *buffer = new U8[size];
- alloc_entry2bytestream(*buffer, offset, entry);
-
- switch(data->mType)
- {
- case LST_INTEGER:
- integer2bytestream(*buffer, offset, data->mInteger);
- break;
- case LST_FLOATINGPOINT:
- float2bytestream(*buffer, offset, data->mFP);
- break;
- case LST_KEY:
- if (data->mKey)
- char2bytestream(*buffer, offset, data->mKey);
- else
- byte2bytestream(*buffer, offset, 0);
- break;
- case LST_STRING:
- if (data->mString)
- char2bytestream(*buffer, offset, data->mString);
- else
- byte2bytestream(*buffer, offset, 0);
- break;
- case LST_VECTOR:
- vector2bytestream(*buffer, offset, data->mVec);
- break;
- case LST_QUATERNION:
- quaternion2bytestream(*buffer, offset, data->mQuat);
- break;
- default:
- break;
- }
- }
- else
- {
- U8 *listbuf;
- S32 length = data->getListLength();
- size = 4 * length + 4;
- entry.mSize = size;
-
- size += SIZEOF_SCRIPT_ALLOC_ENTRY;
- *buffer = new U8[size];
-
- alloc_entry2bytestream(*buffer, offset, entry);
- // store length of list
- integer2bytestream(*buffer, offset, length);
- data = data->mListp;
- while(data)
- {
- // this bit of nastiness is to get around that code paths to local variables can result in lack of initialization
- // and function clean up of ref counts isn't based on scope (a mistake, I know)
- integer2bytestream(*buffer, offset, size + base_offset + 1);
-
- S32 listsize = lsa_create_data_block(&listbuf, data, base_offset + size);
- if (listsize)
- {
- U8 *tbuff = new U8[size + listsize];
- if (tbuff == NULL)
- {
- LL_ERRS() << "Memory Allocation Failed" << LL_ENDL;
- }
- memcpy(tbuff, *buffer, size); /*Flawfinder: ignore*/
- memcpy(tbuff + size, listbuf, listsize); /*Flawfinder: ignore*/
- size += listsize;
- delete [] *buffer;
- delete [] listbuf;
- *buffer = tbuff;
- }
- data = data->mListp;
- }
- }
- return size;
-}
-
-// increase reference count
-// increase reference count by 1
-
-void lsa_increase_ref_count(U8 *buffer, S32 offset)
-{
- if (get_register(buffer, LREG_FR))
- return;
- // this bit of nastiness is to get around that code paths to local variables can result in lack of initialization
- // and function clean up of ref counts isn't based on scope (a mistake, I know)
- offset += get_register(buffer, LREG_HR) - 1;
- if ( (offset < get_register(buffer, LREG_HR))
- ||(offset >= get_register(buffer, LREG_HP)))
- {
- set_fault(buffer, LSRF_BOUND_CHECK_ERROR);
- return;
- }
- S32 orig_offset = offset;
- LLScriptAllocEntry entry;
- bytestream2alloc_entry(entry, buffer, offset);
-
- entry.mReferenceCount++;
-
- alloc_entry2bytestream(buffer, orig_offset, entry);
-}
-
-// 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)
-{
- if (get_register(buffer, LREG_FR))
- return;
- // this bit of nastiness is to get around that code paths to local variables can result in lack of initialization
- // and function clean up of ref counts isn't based on scope (a mistake, I know)
- offset += get_register(buffer, LREG_HR) - 1;
- if ( (offset < get_register(buffer, LREG_HR))
- ||(offset >= get_register(buffer, LREG_HP)))
- {
- set_fault(buffer, LSRF_BOUND_CHECK_ERROR);
- return;
- }
- S32 orig_offset = offset;
- LLScriptAllocEntry entry;
- bytestream2alloc_entry(entry, buffer, offset);
-
- entry.mReferenceCount--;
-
- if (entry.mReferenceCount < 0)
- {
- entry.mReferenceCount = 0;
- set_fault(buffer, LSRF_HEAP_ERROR);
- }
- else if (!entry.mReferenceCount)
- {
- if (entry.mType == LST_LIST)
- {
- S32 i, num = bytestream2integer(buffer, offset);
- for (i = 0; i < num; i++)
- {
- S32 list_offset = bytestream2integer(buffer, offset);
- lsa_decrease_ref_count(buffer, list_offset);
- }
- }
- entry.mType = LST_NULL;
- }
-
- alloc_entry2bytestream(buffer, orig_offset, entry);
-}
-
-char gLSAStringRead[TOP_OF_MEMORY]; /*Flawfinder: ignore*/
-
-
-LLScriptLibData *lsa_get_data(U8 *buffer, S32 &offset, BOOL b_dec_ref)
-{
- if (get_register(buffer, LREG_FR))
- return (new LLScriptLibData);
- S32 orig_offset = offset;
- // this bit of nastiness is to get around that code paths to local variables can result in lack of initialization
- // and function clean up of ref counts isn't based on scope (a mistake, I know)
- offset += get_register(buffer, LREG_HR) - 1;
- if ( (offset < get_register(buffer, LREG_HR))
- ||(offset >= get_register(buffer, LREG_HP)))
- {
- set_fault(buffer, LSRF_BOUND_CHECK_ERROR);
- return (new LLScriptLibData);
- }
- LLScriptAllocEntry entry;
- bytestream2alloc_entry(entry, buffer, offset);
-
- LLScriptLibData *retval = new LLScriptLibData;
-
- if (!entry.mType)
- {
- set_fault(buffer, LSRF_HEAP_ERROR);
- return retval;
- }
-
- retval->mType = (LSCRIPTType)entry.mType;
- if (entry.mType != LST_LIST)
- {
- switch(entry.mType)
- {
- case LST_INTEGER:
- retval->mInteger = bytestream2integer(buffer, offset);
- break;
- case LST_FLOATINGPOINT:
- retval->mFP = bytestream2float(buffer, offset);
- break;
- case LST_KEY:
- bytestream2char(gLSAStringRead, buffer, offset, sizeof(gLSAStringRead)); // global sring buffer? for real? :(
- retval->mKey = new char[strlen(gLSAStringRead) + 1]; /*Flawfinder: ignore*/
- strcpy(retval->mKey, gLSAStringRead); /*Flawfinder: ignore*/
- break;
- case LST_STRING:
- bytestream2char(gLSAStringRead, buffer, offset, sizeof(gLSAStringRead));
- retval->mString = new char[strlen(gLSAStringRead) + 1]; /*Flawfinder: ignore*/
- strcpy(retval->mString, gLSAStringRead); /*Flawfinder: ignore*/
- break;
- case LST_VECTOR:
- bytestream2vector(retval->mVec, buffer, offset);
- break;
- case LST_QUATERNION:
- bytestream2quaternion(retval->mQuat, buffer, offset);
- break;
- default:
- break;
- }
- }
- else
- {
- // get length of list
- S32 i, length = bytestream2integer(buffer, offset);
- LLScriptLibData *tip = retval;
-
- for (i = 0; i < length; i++)
- {
- S32 address = bytestream2integer(buffer, offset);
- tip->mListp = lsa_get_data(buffer, address, FALSE);
- tip = tip->mListp;
- }
- }
- if (retval->checkForMultipleLists())
- {
- set_fault(buffer, LSRF_NESTING_LISTS);
- }
- if (b_dec_ref)
- {
- lsa_decrease_ref_count(buffer, orig_offset);
- }
- return retval;
-}
-
-LLScriptLibData *lsa_get_list_ptr(U8 *buffer, S32 &offset, BOOL b_dec_ref)
-{
- if (get_register(buffer, LREG_FR))
- return (new LLScriptLibData);
- S32 orig_offset = offset;
- // this bit of nastiness is to get around that code paths to local variables can result in lack of initialization
- // and function clean up of ref counts isn't based on scope (a mistake, I know)
- offset += get_register(buffer, LREG_HR) - 1;
- if ( (offset < get_register(buffer, LREG_HR))
- ||(offset >= get_register(buffer, LREG_HP)))
- {
- set_fault(buffer, LSRF_BOUND_CHECK_ERROR);
- return (new LLScriptLibData);
- }
- LLScriptAllocEntry entry;
- bytestream2alloc_entry(entry, buffer, offset);
-
- if (!entry.mType)
- {
- set_fault(buffer, LSRF_HEAP_ERROR);
- return NULL;
- }
-
- LLScriptLibData base, *tip = &base;
-
- if (entry.mType != LST_LIST)
- {
- return NULL;
- }
- else
- {
- // get length of list
- S32 i, length = bytestream2integer(buffer, offset);
-
- for (i = 0; i < length; i++)
- {
- S32 address = bytestream2integer(buffer, offset);
- tip->mListp = lsa_get_data(buffer, address, FALSE);
- tip = tip->mListp;
- }
- }
- if (b_dec_ref)
- {
- lsa_decrease_ref_count(buffer, orig_offset);
- }
- tip = base.mListp;
- base.mListp = NULL;
- return tip;
-}
-
-S32 lsa_cat_strings(U8 *buffer, S32 offset1, S32 offset2, S32 heapsize)
-{
- if (get_register(buffer, LREG_FR))
- return 0;
- LLScriptLibData *string1;
- LLScriptLibData *string2;
- if (offset1 != offset2)
- {
- string1 = lsa_get_data(buffer, offset1, TRUE);
- string2 = lsa_get_data(buffer, offset2, TRUE);
- }
- else
- {
- string1 = lsa_get_data(buffer, offset1, TRUE);
- string2 = lsa_get_data(buffer, offset2, TRUE);
- }
-
- if ( (!string1)
- ||(!string2))
- {
- set_fault(buffer, LSRF_HEAP_ERROR);
- delete string1;
- delete string2;
- return 0;
- }
-
- char *test1 = NULL, *test2 = NULL;
-
- if (string1->mType == LST_STRING)
- {
- test1 = string1->mString;
- }
- else if (string1->mType == LST_KEY)
- {
- test1 = string1->mKey;
- }
- if (string2->mType == LST_STRING)
- {
- test2 = string2->mString;
- }
- else if (string2->mType == LST_KEY)
- {
- test2 = string2->mKey;
- }
-
- if ( (!test1)
- ||(!test2))
- {
- set_fault(buffer, LSRF_HEAP_ERROR);
- delete string1;
- delete string2;
- return 0;
- }
-
- S32 size = (S32)strlen(test1) + (S32)strlen(test2) + 1; /*Flawfinder: ignore*/
-
- LLScriptLibData *string3 = new LLScriptLibData;
- string3->mType = LST_STRING;
- string3->mString = new char[size];
- strcpy(string3->mString, test1); /*Flawfinder: ignore*/
- strcat(string3->mString, test2); /*Flawfinder: ignore*/
-
- delete string1;
- delete string2;
-
- return lsa_heap_add_data(buffer, string3, heapsize, TRUE);
-}
-
-S32 lsa_cmp_strings(U8 *buffer, S32 offset1, S32 offset2)
-{
- if (get_register(buffer, LREG_FR))
- return 0;
- LLScriptLibData *string1;
- LLScriptLibData *string2;
-
- string1 = lsa_get_data(buffer, offset1, TRUE);
- string2 = lsa_get_data(buffer, offset2, TRUE);
-
- if ( (!string1)
- ||(!string2))
- {
- set_fault(buffer, LSRF_HEAP_ERROR);
- delete string1;
- delete string2;
- return 0;
- }
-
- char *test1 = NULL, *test2 = NULL;
-
- if (string1->mType == LST_STRING)
- {
- test1 = string1->mString;
- }
- else if (string1->mType == LST_KEY)
- {
- test1 = string1->mKey;
- }
- if (string2->mType == LST_STRING)
- {
- test2 = string2->mString;
- }
- else if (string2->mType == LST_KEY)
- {
- test2 = string2->mKey;
- }
-
- if ( (!test1)
- ||(!test2))
- {
- set_fault(buffer, LSRF_HEAP_ERROR);
- delete string1;
- delete string2;
- return 0;
- }
- S32 retval = strcmp(test1, test2);
-
- delete string1;
- delete string2;
-
- return retval;
-}
-
-void lsa_print_heap(U8 *buffer)
-{
- S32 offset = get_register(buffer, LREG_HR);
- S32 readoffset;
- S32 ivalue;
- F32 fpvalue;
- LLVector3 vvalue;
- LLQuaternion qvalue;
- char string[4096]; /*Flawfinder: ignore*/
-
- LLScriptAllocEntry entry;
-
- bytestream2alloc_entry(entry, buffer, offset);
-
- printf("HP: [0x%X]\n", get_register(buffer, LREG_HP));
- printf("==========\n");
-
- while (offset + entry.mSize < MAX_HEAP_SIZE)
- {
- printf("[0x%X] ", offset);
- printf("%s ", LSCRIPTTypeNames[entry.mType]);
- printf("Ref Count: %d ", entry.mReferenceCount);
- printf("Size: %d = ", entry.mSize);
-
- readoffset = offset;
-
- switch(entry.mType)
- {
- case LST_INTEGER:
- ivalue = bytestream2integer(buffer, readoffset);
- printf("%d\n", ivalue);
- break;
- case LST_FLOATINGPOINT:
- fpvalue = bytestream2float(buffer, readoffset);
- printf("%f\n", fpvalue);
- break;
- case LST_STRING:
- bytestream2char(string, buffer, readoffset, sizeof(string));
- printf("%s\n", string);
- break;
- case LST_KEY:
- bytestream2char(string, buffer, readoffset, sizeof(string));
- printf("%s\n", string);
- break;
- case LST_VECTOR:
- bytestream2vector(vvalue, buffer, readoffset);
- printf("< %f, %f, %f >\n", vvalue.mV[VX], vvalue.mV[VY], vvalue.mV[VZ]);
- break;
- case LST_QUATERNION:
- bytestream2quaternion(qvalue, buffer, readoffset);
- printf("< %f, %f, %f, %f >\n", qvalue.mQ[VX], qvalue.mQ[VY], qvalue.mQ[VZ], qvalue.mQ[VS]);
- break;
- case LST_LIST:
- ivalue = bytestream2integer(buffer, readoffset);
- printf("%d\n", ivalue);
- break;
- default:
- printf("\n");
- break;
- }
- offset += entry.mSize;
- bytestream2alloc_entry(entry, buffer, offset);
- }
- printf("[0x%X] ", offset);
- printf("%s ", LSCRIPTTypeNames[entry.mType]);
- printf("Ref Count: %d ", entry.mReferenceCount);
- printf("Size: %d\n", entry.mSize);
- printf("==========\n");
-}
-
-void lsa_fprint_heap(U8 *buffer, LLFILE *fp)
-{
- S32 offset = get_register(buffer, LREG_HR);
- S32 readoffset;
- S32 ivalue;
- F32 fpvalue;
- LLVector3 vvalue;
- LLQuaternion qvalue;
- char string[4096]; /*Flawfinder: ignore*/
-
- LLScriptAllocEntry entry;
-
- bytestream2alloc_entry(entry, buffer, offset);
-
- while (offset + entry.mSize < MAX_HEAP_SIZE)
- {
- fprintf(fp, "[0x%X] ", offset);
- fprintf(fp, "%s ", LSCRIPTTypeNames[entry.mType]);
- fprintf(fp, "Ref Count: %d ", entry.mReferenceCount);
- fprintf(fp, "Size: %d = ", entry.mSize);
-
- readoffset = offset;
-
- switch(entry.mType)
- {
- case LST_INTEGER:
- ivalue = bytestream2integer(buffer, readoffset);
- fprintf(fp, "%d\n", ivalue);
- break;
- case LST_FLOATINGPOINT:
- fpvalue = bytestream2float(buffer, readoffset);
- fprintf(fp, "%f\n", fpvalue);
- break;
- case LST_STRING:
- bytestream2char(string, buffer, readoffset, sizeof(string));
- fprintf(fp, "%s\n", string);
- break;
- case LST_KEY:
- bytestream2char(string, buffer, readoffset, sizeof(string));
- fprintf(fp, "%s\n", string);
- break;
- case LST_VECTOR:
- bytestream2vector(vvalue, buffer, readoffset);
- fprintf(fp, "< %f, %f, %f >\n", vvalue.mV[VX], vvalue.mV[VY], vvalue.mV[VZ]);
- break;
- case LST_QUATERNION:
- bytestream2quaternion(qvalue, buffer, readoffset);
- fprintf(fp, "< %f, %f, %f, %f >\n", qvalue.mQ[VX], qvalue.mQ[VY], qvalue.mQ[VZ], qvalue.mQ[VS]);
- break;
- case LST_LIST:
- ivalue = bytestream2integer(buffer, readoffset);
- fprintf(fp, "%d\n", ivalue);
- break;
- default:
- fprintf(fp, "\n");
- break;
- }
- offset += entry.mSize;
- bytestream2alloc_entry(entry, buffer, offset);
- }
- fprintf(fp, "[0x%X] ", offset);
- fprintf(fp, "%s ", LSCRIPTTypeNames[entry.mType]);
- fprintf(fp, "Ref Count: %d ", entry.mReferenceCount);
- fprintf(fp, "Size: %d", entry.mSize);
- fprintf(fp, "\n");
-}
-
-S32 lsa_cat_lists(U8 *buffer, S32 offset1, S32 offset2, S32 heapsize)
-{
- if (get_register(buffer, LREG_FR))
- return 0;
- LLScriptLibData *list1;
- LLScriptLibData *list2;
- if (offset1 != offset2)
- {
- list1 = lsa_get_data(buffer, offset1, TRUE);
- list2 = lsa_get_data(buffer, offset2, TRUE);
- }
- else
- {
- list1 = lsa_get_data(buffer, offset1, TRUE);
- list2 = lsa_get_data(buffer, offset2, TRUE);
- }
-
- if ( (!list1)
- ||(!list2))
- {
- set_fault(buffer, LSRF_HEAP_ERROR);
- delete list1;
- delete list2;
- return 0;
- }
-
- if ( (list1->mType != LST_LIST)
- ||(list2->mType != LST_LIST))
- {
- set_fault(buffer, LSRF_HEAP_ERROR);
- delete list1;
- delete list2;
- return 0;
- }
-
- LLScriptLibData *runner = list1;
-
- while (runner->mListp)
- {
- runner = runner->mListp;
- }
-
- runner->mListp = list2->mListp;
-
- list2->mListp = NULL;
-
- delete list2;
-
- return lsa_heap_add_data(buffer, list1, heapsize, TRUE);
-}
-
-
-S32 lsa_cmp_lists(U8 *buffer, S32 offset1, S32 offset2)
-{
- if (get_register(buffer, LREG_FR))
- return 0;
- LLScriptLibData *list1;
- LLScriptLibData *list2;
- if (offset1 != offset2)
- {
- list1 = lsa_get_data(buffer, offset1, TRUE);
- list2 = lsa_get_data(buffer, offset2, TRUE);
- }
- else
- {
- list1 = lsa_get_data(buffer, offset1, FALSE);
- list2 = lsa_get_data(buffer, offset2, TRUE);
- }
-
- if ( (!list1)
- ||(!list2))
- {
- set_fault(buffer, LSRF_HEAP_ERROR);
- delete list1;
- delete list2;
- return 0;
- }
-
- if ( (list1->mType != LST_LIST)
- ||(list2->mType != LST_LIST))
- {
- set_fault(buffer, LSRF_HEAP_ERROR);
- delete list1;
- delete list2;
- return 0;
- }
-
- S32 length1 = list1->getListLength();
- S32 length2 = list2->getListLength();
- delete list1;
- delete list2;
- return length1 - length2;
-}
-
-
-S32 lsa_preadd_lists(U8 *buffer, LLScriptLibData *data, S32 offset2, S32 heapsize)
-{
- if (get_register(buffer, LREG_FR))
- return 0;
- LLScriptLibData *list2 = lsa_get_data(buffer, offset2, TRUE);
-
- if (!list2)
- {
- set_fault(buffer, LSRF_HEAP_ERROR);
- delete list2;
- return 0;
- }
-
- if (list2->mType != LST_LIST)
- {
- set_fault(buffer, LSRF_HEAP_ERROR);
- delete list2;
- return 0;
- }
-
- LLScriptLibData *runner = data->mListp;
-
- while (runner->mListp)
- {
- runner = runner->mListp;
- }
-
-
- runner->mListp = list2->mListp;
- list2->mListp = data->mListp;
-
- return lsa_heap_add_data(buffer, list2, heapsize, TRUE);
-}
-
-
-S32 lsa_postadd_lists(U8 *buffer, S32 offset1, LLScriptLibData *data, S32 heapsize)
-{
- if (get_register(buffer, LREG_FR))
- return 0;
- LLScriptLibData *list1 = lsa_get_data(buffer, offset1, TRUE);
-
- if (!list1)
- {
- set_fault(buffer, LSRF_HEAP_ERROR);
- delete list1;
- return 0;
- }
-
- if (list1->mType != LST_LIST)
- {
- set_fault(buffer, LSRF_HEAP_ERROR);
- delete list1;
- return 0;
- }
-
- LLScriptLibData *runner = list1;
-
- while (runner->mListp)
- {
- runner = runner->mListp;
- }
-
- runner->mListp = data->mListp;
-
- return lsa_heap_add_data(buffer, list1, heapsize, TRUE);
-}
-
-
-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;
- }
- S32 buckets = number / stride;
-
- // Copy everything into a special vector for sorting;
- std::vector<LLScriptLibData*> sort_array;
- sort_array.reserve(number);
- LLScriptLibData* temp = src->mListp;
- while(temp)
- {
- sort_array.push_back(temp);
- temp = temp->mListp;
- }
-
- // We cannot simply call random_shuffle or similar algorithm since
- // we need to obey the stride. So, we iterate over what we have
- // and swap each with a random other segment.
- S32 index = 0;
- S32 ii = 0;
- for(; ii < number; ii += stride)
- {
- index = ll_rand(buckets) * stride;
- for(S32 jj = 0; jj < stride; ++jj)
- {
- std::swap(sort_array[ii + jj], sort_array[index + jj]);
- }
- }
-
- // copy the pointers back out
- ii = 1;
- temp = sort_array[0];
- while (ii < number)
- {
- temp->mListp = sort_array[ii++];
- temp = temp->mListp;
- }
- temp->mListp = NULL;
-
- src->mListp = NULL;
-
- LLScriptLibData* ret_value = sort_array[0];
- return ret_value;
-}
diff --git a/indra/lscript/lscript_library/lscript_export.cpp b/indra/lscript/lscript_library/lscript_export.cpp
deleted file mode 100755
index 0ed85e3686..0000000000
--- a/indra/lscript/lscript_library/lscript_export.cpp
+++ /dev/null
@@ -1,26 +0,0 @@
-/**
- * @file lscript_export.cpp
- * @brief export interface class
- *
- * $LicenseInfo:firstyear=2002&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
diff --git a/indra/lscript/lscript_library/lscript_library.cpp b/indra/lscript/lscript_library/lscript_library.cpp
deleted file mode 100755
index 84ce94eead..0000000000
--- a/indra/lscript/lscript_library/lscript_library.cpp
+++ /dev/null
@@ -1,582 +0,0 @@
-/**
- * @file lscript_library.cpp
- * @brief external library interface
- *
- * $LicenseInfo:firstyear=2002&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-
-// ## ## ### ######## ## ## #### ## ## ###### #### ####
-// ## ## ## ## ## ## ## ### ## ## ### ## ## ## #### ####
-// ## ## ## ## ## ## ## #### ## ## #### ## ## #### ####
-// ## ## ## ## ## ######## ## ## ## ## ## ## ## ## #### ## ##
-// ## ## ## ######### ## ## ## #### ## ## #### ## ##
-// ## ## ## ## ## ## ## ## ### ## ## ### ## ## #### ####
-// ### ### ## ## ## ## ## ## #### ## ## ###### #### ####
-//
-// When adding functions, they <b>MUST</b> be appended to the end of
-// the init() method. The init() associates the name with a number,
-// which is then serialized into the bytecode. Inserting a new
-// function in the middle will lead to many sim crashes. Phoenix 2006-04-10.
-
-#include "linden_common.h"
-
-#include "lscript_library.h"
-
-LLScriptLibrary::LLScriptLibrary()
-{
- init();
-}
-
-LLScriptLibrary::~LLScriptLibrary()
-{
-}
-
-void dummy_func(LLScriptLibData *retval, LLScriptLibData *args, const LLUUID &id)
-{
-}
-
-void LLScriptLibrary::init()
-{
- // IF YOU ADD NEW SCRIPT CALLS, YOU MUST PUT THEM AT THE END OF THIS LIST.
- // Otherwise the bytecode numbers for each call will be wrong, and all
- // existing scripts will crash.
-
- // energy, sleep, dummy_func, name, return type, parameters, gods-only
- addFunction(10.f, 0.f, dummy_func, "llSin", "f", "f");
- addFunction(10.f, 0.f, dummy_func, "llCos", "f", "f");
- addFunction(10.f, 0.f, dummy_func, "llTan", "f", "f");
- addFunction(10.f, 0.f, dummy_func, "llAtan2", "f", "ff");
- addFunction(10.f, 0.f, dummy_func, "llSqrt", "f", "f");
- addFunction(10.f, 0.f, dummy_func, "llPow", "f", "ff");
- addFunction(10.f, 0.f, dummy_func, "llAbs", "i", "i");
- addFunction(10.f, 0.f, dummy_func, "llFabs", "f", "f");
- addFunction(10.f, 0.f, dummy_func, "llFrand", "f", "f");
- addFunction(10.f, 0.f, dummy_func, "llFloor", "i", "f");
- addFunction(10.f, 0.f, dummy_func, "llCeil", "i", "f");
- addFunction(10.f, 0.f, dummy_func, "llRound", "i", "f");
- addFunction(10.f, 0.f, dummy_func, "llVecMag", "f", "v");
- addFunction(10.f, 0.f, dummy_func, "llVecNorm", "v", "v");
- addFunction(10.f, 0.f, dummy_func, "llVecDist", "f", "vv");
- addFunction(10.f, 0.f, dummy_func, "llRot2Euler", "v", "q");
- addFunction(10.f, 0.f, dummy_func, "llEuler2Rot", "q", "v");
- addFunction(10.f, 0.f, dummy_func, "llAxes2Rot", "q", "vvv");
- addFunction(10.f, 0.f, dummy_func, "llRot2Fwd", "v", "q");
- addFunction(10.f, 0.f, dummy_func, "llRot2Left", "v", "q");
- addFunction(10.f, 0.f, dummy_func, "llRot2Up", "v", "q");
- addFunction(10.f, 0.f, dummy_func, "llRotBetween", "q", "vv");
- addFunction(10.f, 0.f, dummy_func, "llWhisper", NULL, "is");
- addFunction(10.f, 0.f, dummy_func, "llSay", NULL, "is");
- addFunction(10.f, 0.f, dummy_func, "llShout", NULL, "is");
- addFunction(10.f, 0.f, dummy_func, "llListen", "i", "isks");
- addFunction(10.f, 0.f, dummy_func, "llListenControl", NULL, "ii");
- addFunction(10.f, 0.f, dummy_func, "llListenRemove", NULL, "i");
- addFunction(10.f, 0.f, dummy_func, "llSensor", NULL, "skiff");
- addFunction(10.f, 0.f, dummy_func, "llSensorRepeat", NULL, "skifff");
- addFunction(10.f, 0.f, dummy_func, "llSensorRemove", NULL, NULL);
- addFunction(10.f, 0.f, dummy_func, "llDetectedName", "s", "i");
- addFunction(10.f, 0.f, dummy_func, "llDetectedKey", "k", "i");
- addFunction(10.f, 0.f, dummy_func, "llDetectedOwner", "k", "i");
- addFunction(10.f, 0.f, dummy_func, "llDetectedType", "i", "i");
- addFunction(10.f, 0.f, dummy_func, "llDetectedPos", "v", "i");
- addFunction(10.f, 0.f, dummy_func, "llDetectedVel", "v", "i");
- addFunction(10.f, 0.f, dummy_func, "llDetectedGrab", "v", "i");
- addFunction(10.f, 0.f, dummy_func, "llDetectedRot", "q", "i");
- addFunction(10.f, 0.f, dummy_func, "llDetectedGroup", "i", "i");
- addFunction(10.f, 0.f, dummy_func, "llDetectedLinkNumber", "i", "i");
- addFunction(0.f, 0.f, dummy_func, "llDie", NULL, NULL);
- addFunction(10.f, 0.f, dummy_func, "llGround", "f", "v");
- addFunction(10.f, 0.f, dummy_func, "llCloud", "f", "v");
- addFunction(10.f, 0.f, dummy_func, "llWind", "v", "v");
- addFunction(10.f, 0.f, dummy_func, "llSetStatus", NULL, "ii");
- addFunction(10.f, 0.f, dummy_func, "llGetStatus", "i", "i");
- addFunction(10.f, 0.f, dummy_func, "llSetScale", NULL, "v");
- addFunction(10.f, 0.f, dummy_func, "llGetScale", "v", NULL);
- addFunction(10.f, 0.f, dummy_func, "llSetColor", NULL, "vi");
- addFunction(10.f, 0.f, dummy_func, "llGetAlpha", "f", "i");
- addFunction(10.f, 0.f, dummy_func, "llSetAlpha", NULL, "fi");
- addFunction(10.f, 0.f, dummy_func, "llGetColor", "v", "i");
- addFunction(10.f, 0.2f, dummy_func, "llSetTexture", NULL, "si");
- addFunction(10.f, 0.2f, dummy_func, "llScaleTexture", NULL, "ffi");
- addFunction(10.f, 0.2f, dummy_func, "llOffsetTexture", NULL, "ffi");
- addFunction(10.f, 0.2f, dummy_func, "llRotateTexture", NULL, "fi");
- addFunction(10.f, 0.f, dummy_func, "llGetTexture", "s", "i");
- addFunction(10.f, 0.2f, dummy_func, "llSetPos", NULL, "v");
- addFunction(10.f, 0.f, dummy_func, "llGetPos", "v", NULL);
- addFunction(10.f, 0.f, dummy_func, "llGetLocalPos", "v", NULL);
- addFunction(10.f, 0.2f, dummy_func, "llSetRot", NULL, "q");
- addFunction(10.f, 0.f, dummy_func, "llGetRot", "q", NULL);
- addFunction(10.f, 0.f, dummy_func, "llGetLocalRot", "q", NULL);
- addFunction(10.f, 0.f, dummy_func, "llSetForce", NULL, "vi");
- addFunction(10.f, 0.f, dummy_func, "llGetForce", "v", NULL);
- addFunction(10.f, 0.f, dummy_func, "llTarget", "i", "vf");
- addFunction(10.f, 0.f, dummy_func, "llTargetRemove", NULL, "i");
- addFunction(10.f, 0.f, dummy_func, "llRotTarget", "i", "qf");
- addFunction(10.f, 0.f, dummy_func, "llRotTargetRemove", NULL, "i");
- addFunction(10.f, 0.f, dummy_func, "llMoveToTarget", NULL, "vf");
- addFunction(10.f, 0.f, dummy_func, "llStopMoveToTarget", NULL, NULL);
- addFunction(10.f, 0.f, dummy_func, "llApplyImpulse", NULL, "vi");
- addFunction(10.f, 0.f, dummy_func, "llApplyRotationalImpulse", NULL, "vi");
- addFunction(10.f, 0.f, dummy_func, "llSetTorque", NULL, "vi");
- addFunction(10.f, 0.f, dummy_func, "llGetTorque", "v", NULL);
- addFunction(10.f, 0.f, dummy_func, "llSetForceAndTorque", NULL, "vvi");
- addFunction(10.f, 0.f, dummy_func, "llGetVel", "v", NULL);
- addFunction(10.f, 0.f, dummy_func, "llGetAccel", "v", NULL);
- addFunction(10.f, 0.f, dummy_func, "llGetOmega", "v", NULL);
- addFunction(10.f, 0.f, dummy_func, "llGetTimeOfDay", "f", "");
- addFunction(10.f, 0.f, dummy_func, "llGetWallclock", "f", "");
- addFunction(10.f, 0.f, dummy_func, "llGetTime", "f", NULL);
- addFunction(10.f, 0.f, dummy_func, "llResetTime", NULL, NULL);
- addFunction(10.f, 0.f, dummy_func, "llGetAndResetTime", "f", NULL);
- addFunction(10.f, 0.f, dummy_func, "llSound", NULL, "sfii");
- addFunction(10.f, 0.f, dummy_func, "llPlaySound", NULL, "sf");
- addFunction(10.f, 0.f, dummy_func, "llLoopSound", NULL, "sf");
- addFunction(10.f, 0.f, dummy_func, "llLoopSoundMaster", NULL, "sf");
- addFunction(10.f, 0.f, dummy_func, "llLoopSoundSlave", NULL, "sf");
- addFunction(10.f, 0.f, dummy_func, "llPlaySoundSlave", NULL, "sf");
- addFunction(10.f, 0.f, dummy_func, "llTriggerSound", NULL, "sf");
- addFunction(10.f, 0.f, dummy_func, "llStopSound", NULL, "");
- addFunction(10.f, 1.f, dummy_func, "llPreloadSound", NULL, "s");
- addFunction(10.f, 0.f, dummy_func, "llGetSubString", "s", "sii");
- addFunction(10.f, 0.f, dummy_func, "llDeleteSubString", "s", "sii");
- addFunction(10.f, 0.f, dummy_func, "llInsertString", "s", "sis");
- addFunction(10.f, 0.f, dummy_func, "llToUpper", "s", "s");
- addFunction(10.f, 0.f, dummy_func, "llToLower", "s", "s");
- addFunction(10.f, 0.f, dummy_func, "llGiveMoney", "i", "ki");
- addFunction(10.f, 0.1f, dummy_func, "llMakeExplosion", NULL, "iffffsv");
- addFunction(10.f, 0.1f, dummy_func, "llMakeFountain", NULL, "iffffisvf");
- addFunction(10.f, 0.1f, dummy_func, "llMakeSmoke", NULL, "iffffsv");
- addFunction(10.f, 0.1f, dummy_func, "llMakeFire", NULL, "iffffsv");
- addFunction(200.f, 0.1f, dummy_func, "llRezObject", NULL, "svvqi");
- addFunction(10.f, 0.f, dummy_func, "llLookAt", NULL, "vff");
- addFunction(10.f, 0.f, dummy_func, "llStopLookAt", NULL, NULL);
- addFunction(10.f, 0.f, dummy_func, "llSetTimerEvent", NULL, "f");
- addFunction(0.f, 0.f, dummy_func, "llSleep", NULL, "f");
- addFunction(10.f, 0.f, dummy_func, "llGetMass", "f", NULL);
- addFunction(10.f, 0.f, dummy_func, "llCollisionFilter", NULL, "ski");
- addFunction(10.f, 0.f, dummy_func, "llTakeControls", NULL, "iii");
- addFunction(10.f, 0.f, dummy_func, "llReleaseControls", NULL, NULL);
- addFunction(10.f, 0.f, dummy_func, "llAttachToAvatar", NULL, "i");
- addFunction(10.f, 0.f, dummy_func, "llDetachFromAvatar", NULL, NULL);
- addFunction(10.f, 0.f, dummy_func, "llTakeCamera", NULL, "k");
- addFunction(10.f, 0.f, dummy_func, "llReleaseCamera", NULL, "k");
- addFunction(10.f, 0.f, dummy_func, "llGetOwner", "k", NULL);
- addFunction(10.f, 2.f, dummy_func, "llInstantMessage", NULL, "ks");
- addFunction(10.f, 20.f, dummy_func, "llEmail", NULL, "sss");
- addFunction(10.f, 0.f, dummy_func, "llGetNextEmail", NULL, "ss");
- addFunction(10.f, 0.f, dummy_func, "llGetKey", "k", NULL);
- addFunction(10.f, 0.f, dummy_func, "llSetBuoyancy", NULL, "f");
- addFunction(10.f, 0.f, dummy_func, "llSetHoverHeight", NULL, "fif");
- addFunction(10.f, 0.f, dummy_func, "llStopHover", NULL, NULL);
- addFunction(10.f, 0.f, dummy_func, "llMinEventDelay", NULL, "f");
- addFunction(10.f, 0.f, dummy_func, "llSoundPreload", NULL, "s");
- addFunction(10.f, 0.f, dummy_func, "llRotLookAt", NULL, "qff");
- addFunction(10.f, 0.f, dummy_func, "llStringLength", "i", "s");
- addFunction(10.f, 0.f, dummy_func, "llStartAnimation", NULL, "s");
- addFunction(10.f, 0.f, dummy_func, "llStopAnimation", NULL, "s");
- addFunction(10.f, 0.f, dummy_func, "llPointAt", NULL, "v");
- addFunction(10.f, 0.f, dummy_func, "llStopPointAt", NULL, NULL);
- addFunction(10.f, 0.f, dummy_func, "llTargetOmega", NULL, "vff");
- addFunction(10.f, 0.f, dummy_func, "llGetStartParameter", "i", NULL);
- addFunction(10.f, 0.f, dummy_func, "llGodLikeRezObject", NULL, "kv", TRUE);
- addFunction(10.f, 0.f, dummy_func, "llRequestPermissions", NULL, "ki");
- addFunction(10.f, 0.f, dummy_func, "llGetPermissionsKey", "k", NULL);
- addFunction(10.f, 0.f, dummy_func, "llGetPermissions", "i", NULL);
- addFunction(10.f, 0.f, dummy_func, "llGetLinkNumber", "i", NULL);
- addFunction(10.f, 0.f, dummy_func, "llSetLinkColor", NULL, "ivi");
- addFunction(10.f, 1.f, dummy_func, "llCreateLink", NULL, "ki");
- addFunction(10.f, 0.f, dummy_func, "llBreakLink", NULL, "i");
- addFunction(10.f, 0.f, dummy_func, "llBreakAllLinks", NULL, NULL);
- addFunction(10.f, 0.f, dummy_func, "llGetLinkKey", "k", "i");
- addFunction(10.f, 0.f, dummy_func, "llGetLinkName", "s", "i");
- addFunction(10.f, 0.f, dummy_func, "llGetInventoryNumber", "i", "i");
- addFunction(10.f, 0.f, dummy_func, "llGetInventoryName", "s", "ii");
- addFunction(10.f, 0.f, dummy_func, "llSetScriptState", NULL, "si");
- addFunction(10.f, 0.f, dummy_func, "llGetEnergy", "f", NULL);
- addFunction(10.f, 0.f, dummy_func, "llGiveInventory", NULL, "ks");
- addFunction(10.f, 0.f, dummy_func, "llRemoveInventory", NULL, "s");
- addFunction(10.f, 0.f, dummy_func, "llSetText", NULL, "svf");
- addFunction(10.f, 0.f, dummy_func, "llWater", "f", "v");
- addFunction(10.f, 0.f, dummy_func, "llPassTouches", NULL, "i");
- addFunction(10.f, 0.1f, dummy_func, "llRequestAgentData", "k", "ki");
- addFunction(10.f, 1.f, dummy_func, "llRequestInventoryData", "k", "s");
- addFunction(10.f, 0.f, dummy_func, "llSetDamage", NULL, "f");
- addFunction(100.f, 5.f, dummy_func, "llTeleportAgentHome", NULL, "k");
- addFunction(10.f, 0.f, dummy_func, "llModifyLand", NULL, "ii");
- addFunction(10.f, 0.f, dummy_func, "llCollisionSound", NULL, "sf");
- addFunction(10.f, 0.f, dummy_func, "llCollisionSprite", NULL, "s");
- addFunction(10.f, 0.f, dummy_func, "llGetAnimation", "s", "k");
- addFunction(10.f, 0.f, dummy_func, "llResetScript", NULL, NULL);
- addFunction(10.f, 0.f, dummy_func, "llMessageLinked", NULL, "iisk");
- addFunction(10.f, 0.f, dummy_func, "llPushObject", NULL, "kvvi");
- addFunction(10.f, 0.f, dummy_func, "llPassCollisions", NULL, "i");
- addFunction(10.f, 0.f, dummy_func, "llGetScriptName", "s", NULL);
- addFunction(10.f, 0.f, dummy_func, "llGetNumberOfSides", "i", NULL);
- addFunction(10.f, 0.f, dummy_func, "llAxisAngle2Rot", "q", "vf");
- addFunction(10.f, 0.f, dummy_func, "llRot2Axis", "v", "q");
- addFunction(10.f, 0.f, dummy_func, "llRot2Angle", "f", "q");
- addFunction(10.f, 0.f, dummy_func, "llAcos", "f", "f");
- addFunction(10.f, 0.f, dummy_func, "llAsin", "f", "f");
- addFunction(10.f, 0.f, dummy_func, "llAngleBetween", "f", "qq");
- addFunction(10.f, 0.f, dummy_func, "llGetInventoryKey", "k", "s");
- addFunction(10.f, 0.f, dummy_func, "llAllowInventoryDrop", NULL, "i");
- addFunction(10.f, 0.f, dummy_func, "llGetSunDirection", "v", NULL);
- addFunction(10.f, 0.f, dummy_func, "llGetTextureOffset", "v", "i");
- addFunction(10.f, 0.f, dummy_func, "llGetTextureScale", "v", "i");
- addFunction(10.f, 0.f, dummy_func, "llGetTextureRot", "f", "i");
- addFunction(10.f, 0.f, dummy_func, "llSubStringIndex", "i", "ss");
- addFunction(10.f, 0.f, dummy_func, "llGetOwnerKey", "k", "k");
- addFunction(10.f, 0.f, dummy_func, "llGetCenterOfMass", "v", NULL);
- addFunction(10.f, 0.f, dummy_func, "llListSort", "l", "lii");
- addFunction(10.f, 0.f, dummy_func, "llGetListLength", "i", "l");
- addFunction(10.f, 0.f, dummy_func, "llList2Integer", "i", "li");
- addFunction(10.f, 0.f, dummy_func, "llList2Float", "f", "li");
- addFunction(10.f, 0.f, dummy_func, "llList2String", "s", "li");
- addFunction(10.f, 0.f, dummy_func, "llList2Key", "k", "li");
- addFunction(10.f, 0.f, dummy_func, "llList2Vector", "v", "li");
- addFunction(10.f, 0.f, dummy_func, "llList2Rot", "q", "li");
- addFunction(10.f, 0.f, dummy_func, "llList2List", "l", "lii");
- addFunction(10.f, 0.f, dummy_func, "llDeleteSubList", "l", "lii");
- addFunction(10.f, 0.f, dummy_func, "llGetListEntryType", "i", "li");
- addFunction(10.f, 0.f, dummy_func, "llList2CSV", "s", "l");
- addFunction(10.f, 0.f, dummy_func, "llCSV2List", "l", "s");
- addFunction(10.f, 0.f, dummy_func, "llListRandomize", "l", "li");
- addFunction(10.f, 0.f, dummy_func, "llList2ListStrided", "l", "liii");
- addFunction(10.f, 0.f, dummy_func, "llGetRegionCorner", "v", NULL);
- addFunction(10.f, 0.f, dummy_func, "llListInsertList", "l", "lli");
- addFunction(10.f, 0.f, dummy_func, "llListFindList", "i", "ll");
- addFunction(10.f, 0.f, dummy_func, "llGetObjectName", "s", NULL);
- addFunction(10.f, 0.f, dummy_func, "llSetObjectName", NULL, "s");
- addFunction(10.f, 0.f, dummy_func, "llGetDate", "s", NULL);
- addFunction(10.f, 0.f, dummy_func, "llEdgeOfWorld", "i", "vv");
- addFunction(10.f, 0.f, dummy_func, "llGetAgentInfo", "i", "k");
- addFunction(10.f, 0.1f, dummy_func, "llAdjustSoundVolume", NULL, "f");
- addFunction(10.f, 0.f, dummy_func, "llSetSoundQueueing", NULL, "i");
- addFunction(10.f, 0.f, dummy_func, "llSetSoundRadius", NULL, "f");
- addFunction(10.f, 0.f, dummy_func, "llKey2Name", "s", "k");
- addFunction(10.f, 0.f, dummy_func, "llSetTextureAnim", NULL, "iiiifff");
- addFunction(10.f, 0.f, dummy_func, "llTriggerSoundLimited", NULL, "sfvv");
- addFunction(10.f, 0.f, dummy_func, "llEjectFromLand", NULL, "k");
- addFunction(10.f, 0.f, dummy_func, "llParseString2List", "l", "sll");
- addFunction(10.f, 0.f, dummy_func, "llOverMyLand", "i", "k");
- addFunction(10.f, 0.f, dummy_func, "llGetLandOwnerAt", "k", "v");
- addFunction(10.f, 0.1f, dummy_func, "llGetNotecardLine", "k", "si");
- addFunction(10.f, 0.f, dummy_func, "llGetAgentSize", "v", "k");
- addFunction(10.f, 0.f, dummy_func, "llSameGroup", "i", "k");
- addFunction(10.f, 0.f, dummy_func, "llUnSit", NULL, "k");
- addFunction(10.f, 0.f, dummy_func, "llGroundSlope", "v", "v");
- addFunction(10.f, 0.f, dummy_func, "llGroundNormal", "v", "v");
- addFunction(10.f, 0.f, dummy_func, "llGroundContour", "v", "v");
- addFunction(10.f, 0.f, dummy_func, "llGetAttached", "i", NULL);
- addFunction(10.f, 0.f, dummy_func, "llGetFreeMemory", "i", NULL);
- addFunction(10.f, 0.f, dummy_func, "llGetRegionName", "s", NULL);
- addFunction(10.f, 0.f, dummy_func, "llGetRegionTimeDilation", "f", NULL);
- addFunction(10.f, 0.f, dummy_func, "llGetRegionFPS", "f", NULL);
-
- addFunction(10.f, 0.f, dummy_func, "llParticleSystem", NULL, "l");
- addFunction(10.f, 0.f, dummy_func, "llGroundRepel", NULL, "fif");
- addFunction(10.f, 3.f, dummy_func, "llGiveInventoryList", NULL, "ksl");
-
-// script calls for vehicle action
- addFunction(10.f, 0.f, dummy_func, "llSetVehicleType", NULL, "i");
- addFunction(10.f, 0.f, dummy_func, "llSetVehicleFloatParam", NULL, "if");
- addFunction(10.f, 0.f, dummy_func, "llSetVehicleVectorParam", NULL, "iv");
- addFunction(10.f, 0.f, dummy_func, "llSetVehicleRotationParam", NULL, "iq");
- addFunction(10.f, 0.f, dummy_func, "llSetVehicleFlags", NULL, "i");
- addFunction(10.f, 0.f, dummy_func, "llRemoveVehicleFlags", NULL, "i");
- addFunction(10.f, 0.f, dummy_func, "llSitTarget", NULL, "vq");
- addFunction(10.f, 0.f, dummy_func, "llAvatarOnSitTarget", "k", NULL);
- addFunction(10.f, 0.1f, dummy_func, "llAddToLandPassList", NULL, "kf");
- addFunction(10.f, 0.f, dummy_func, "llSetTouchText", NULL, "s");
- addFunction(10.f, 0.f, dummy_func, "llSetSitText", NULL, "s");
- addFunction(10.f, 0.f, dummy_func, "llSetCameraEyeOffset", NULL, "v");
- addFunction(10.f, 0.f, dummy_func, "llSetCameraAtOffset", NULL, "v");
-
- addFunction(10.f, 0.f, dummy_func, "llDumpList2String", "s", "ls");
- addFunction(10.f, 0.f, dummy_func, "llScriptDanger", "i", "v");
- addFunction(10.f, 1.f, dummy_func, "llDialog", NULL, "ksli");
- addFunction(10.f, 0.f, dummy_func, "llVolumeDetect", NULL, "i");
- addFunction(10.f, 0.f, dummy_func, "llResetOtherScript", NULL, "s");
- addFunction(10.f, 0.f, dummy_func, "llGetScriptState", "i", "s");
- addFunction(10.f, 3.f, dummy_func, "llRemoteLoadScript", NULL, "ksii");
-
- addFunction(10.f, 0.2f, dummy_func, "llSetRemoteScriptAccessPin", NULL, "i");
- addFunction(10.f, 3.f, dummy_func, "llRemoteLoadScriptPin", NULL, "ksiii");
-
- addFunction(10.f, 1.f, dummy_func, "llOpenRemoteDataChannel", NULL, NULL);
- addFunction(10.f, 3.f, dummy_func, "llSendRemoteData", "k", "ksis");
- addFunction(10.f, 3.f, dummy_func, "llRemoteDataReply", NULL, "kksi");
- addFunction(10.f, 1.f, dummy_func, "llCloseRemoteDataChannel", NULL, "k");
-
- addFunction(10.f, 0.f, dummy_func, "llMD5String", "s", "si");
- addFunction(10.f, 0.2f, dummy_func, "llSetPrimitiveParams", NULL, "l");
- addFunction(10.f, 0.f, dummy_func, "llStringToBase64", "s", "s");
- addFunction(10.f, 0.f, dummy_func, "llBase64ToString", "s", "s");
- addFunction(10.f, 0.3f, dummy_func, "llXorBase64Strings", "s", "ss");
- addFunction(10.f, 0.f, dummy_func, "llRemoteDataSetRegion", NULL, NULL);
- addFunction(10.f, 0.f, dummy_func, "llLog10", "f", "f");
- addFunction(10.f, 0.f, dummy_func, "llLog", "f", "f");
- addFunction(10.f, 0.f, dummy_func, "llGetAnimationList", "l", "k");
- addFunction(10.f, 2.f, dummy_func, "llSetParcelMusicURL", NULL, "s");
-
- addFunction(10.f, 0.f, dummy_func, "llGetRootPosition", "v", NULL);
- addFunction(10.f, 0.f, dummy_func, "llGetRootRotation", "q", NULL);
-
- addFunction(10.f, 0.f, dummy_func, "llGetObjectDesc", "s", NULL);
- addFunction(10.f, 0.f, dummy_func, "llSetObjectDesc", NULL, "s");
- addFunction(10.f, 0.f, dummy_func, "llGetCreator", "k", NULL);
- addFunction(10.f, 0.f, dummy_func, "llGetTimestamp", "s", NULL);
- addFunction(10.f, 0.f, dummy_func, "llSetLinkAlpha", NULL, "ifi");
- addFunction(10.f, 0.f, dummy_func, "llGetNumberOfPrims", "i", NULL);
- addFunction(10.f, 0.1f, dummy_func, "llGetNumberOfNotecardLines", "k", "s");
-
- addFunction(10.f, 0.f, dummy_func, "llGetBoundingBox", "l", "k");
- addFunction(10.f, 0.f, dummy_func, "llGetGeometricCenter", "v", NULL);
- addFunction(10.f, 0.2f, dummy_func, "llGetPrimitiveParams", "l", "l");
- addFunction(10.f, 0.0f, dummy_func, "llIntegerToBase64", "s", "i");
- addFunction(10.f, 0.0f, dummy_func, "llBase64ToInteger", "i", "s");
- addFunction(10.f, 0.f, dummy_func, "llGetGMTclock", "f", "");
- addFunction(10.f, 10.f, dummy_func, "llGetSimulatorHostname", "s", "");
-
- addFunction(10.f, 0.2f, dummy_func, "llSetLocalRot", NULL, "q");
-
- addFunction(10.f, 0.f, dummy_func, "llParseStringKeepNulls", "l", "sll");
- addFunction(200.f, 0.1f, dummy_func, "llRezAtRoot", NULL, "svvqi");
-
- addFunction(10.f, 0.f, dummy_func, "llGetObjectPermMask", "i", "i", FALSE);
- addFunction(10.f, 0.f, dummy_func, "llSetObjectPermMask", NULL, "ii", TRUE);
-
- addFunction(10.f, 0.f, dummy_func, "llGetInventoryPermMask", "i", "si", FALSE);
- addFunction(10.f, 0.f, dummy_func, "llSetInventoryPermMask", NULL, "sii", TRUE);
- addFunction(10.f, 0.f, dummy_func, "llGetInventoryCreator", "k", "s", FALSE);
- addFunction(10.f, 0.f, dummy_func, "llOwnerSay", NULL, "s");
- addFunction(10.f, 1.f, dummy_func, "llRequestSimulatorData", "k", "si");
- addFunction(10.f, 0.f, dummy_func, "llForceMouselook", NULL, "i");
- addFunction(10.f, 0.f, dummy_func, "llGetObjectMass", "f", "k");
- addFunction(10.f, 0.f, dummy_func, "llListReplaceList", "l", "llii");
- addFunction(10.f, 10.f, dummy_func, "llLoadURL", NULL, "kss");
-
- addFunction(10.f, 2.f, dummy_func, "llParcelMediaCommandList", NULL, "l");
- addFunction(10.f, 2.f, dummy_func, "llParcelMediaQuery", "l", "l");
-
- addFunction(10.f, 1.f, dummy_func, "llModPow", "i", "iii");
-
- addFunction(10.f, 0.f, dummy_func, "llGetInventoryType", "i", "s");
- addFunction(10.f, 0.f, dummy_func, "llSetPayPrice", NULL, "il");
- addFunction(10.f, 0.f, dummy_func, "llGetCameraPos", "v", "");
- addFunction(10.f, 0.f, dummy_func, "llGetCameraRot", "q", "");
-
- addFunction(10.f, 20.f, dummy_func, "llSetPrimURL", NULL, "s");
- addFunction(10.f, 20.f, dummy_func, "llRefreshPrimURL", NULL, "");
- addFunction(10.f, 0.f, dummy_func, "llEscapeURL", "s", "s");
- addFunction(10.f, 0.f, dummy_func, "llUnescapeURL", "s", "s");
-
- addFunction(10.f, 1.f, dummy_func, "llMapDestination", NULL, "svv");
- addFunction(10.f, 0.1f, dummy_func, "llAddToLandBanList", NULL, "kf");
- addFunction(10.f, 0.1f, dummy_func, "llRemoveFromLandPassList", NULL, "k");
- addFunction(10.f, 0.1f, dummy_func, "llRemoveFromLandBanList", NULL, "k");
-
- addFunction(10.f, 0.f, dummy_func, "llSetCameraParams", NULL, "l");
- addFunction(10.f, 0.f, dummy_func, "llClearCameraParams", NULL, NULL);
-
- addFunction(10.f, 0.f, dummy_func, "llListStatistics", "f", "il");
- addFunction(10.f, 0.f, dummy_func, "llGetUnixTime", "i", NULL);
- addFunction(10.f, 0.f, dummy_func, "llGetParcelFlags", "i", "v");
- addFunction(10.f, 0.f, dummy_func, "llGetRegionFlags", "i", NULL);
- addFunction(10.f, 0.f, dummy_func, "llXorBase64StringsCorrect", "s", "ss");
-
- addFunction(10.f, 0.f, dummy_func, "llHTTPRequest", "k", "sls");
-
- addFunction(10.f, 0.1f, dummy_func, "llResetLandBanList", NULL, NULL);
- addFunction(10.f, 0.1f, dummy_func, "llResetLandPassList", NULL, NULL);
-
- addFunction(10.f, 0.f, dummy_func, "llGetObjectPrimCount", "i", "k");
- addFunction(10.f, 2.0f, dummy_func, "llGetParcelPrimOwners", "l", "v");
- addFunction(10.f, 0.f, dummy_func, "llGetParcelPrimCount", "i", "vii");
- addFunction(10.f, 0.f, dummy_func, "llGetParcelMaxPrims", "i", "vi");
- addFunction(10.f, 0.f, dummy_func, "llGetParcelDetails", "l", "vl");
-
-
- addFunction(10.f, 0.2f, dummy_func, "llSetLinkPrimitiveParams", NULL, "il");
- addFunction(10.f, 0.2f, dummy_func, "llSetLinkTexture", NULL, "isi");
-
-
- addFunction(10.f, 0.f, dummy_func, "llStringTrim", "s", "si");
- addFunction(10.f, 0.f, dummy_func, "llRegionSay", NULL, "is");
- addFunction(10.f, 0.f, dummy_func, "llGetObjectDetails", "l", "kl");
- addFunction(10.f, 0.f, dummy_func, "llSetClickAction", NULL, "i");
-
- addFunction(10.f, 0.f, dummy_func, "llGetRegionAgentCount", "i", NULL);
- addFunction(10.f, 1.f, dummy_func, "llTextBox", NULL, "ksi");
- addFunction(10.f, 0.f, dummy_func, "llGetAgentLanguage", "s", "k");
- addFunction(10.f, 0.f, dummy_func, "llDetectedTouchUV", "v", "i");
- addFunction(10.f, 0.f, dummy_func, "llDetectedTouchFace", "i", "i");
- addFunction(10.f, 0.f, dummy_func, "llDetectedTouchPos", "v", "i");
- addFunction(10.f, 0.f, dummy_func, "llDetectedTouchNormal", "v", "i");
- addFunction(10.f, 0.f, dummy_func, "llDetectedTouchBinormal", "v", "i");
- addFunction(10.f, 0.f, dummy_func, "llDetectedTouchST", "v", "i");
-
- addFunction(10.f, 0.f, dummy_func, "llSHA1String", "s", "s");
-
- addFunction(10.f, 0.f, dummy_func, "llGetFreeURLs", "i", NULL);
- addFunction(10.f, 0.f, dummy_func, "llRequestURL", "k", NULL);
- addFunction(10.f, 0.f, dummy_func, "llRequestSecureURL", "k", NULL);
- addFunction(10.f, 0.f, dummy_func, "llReleaseURL", NULL, "s");
- addFunction(10.f, 0.f, dummy_func, "llHTTPResponse", NULL, "kis");
- addFunction(10.f, 0.f, dummy_func, "llGetHTTPHeader", "s", "ks");
-
- // Prim media (see lscript_prim_media.h)
- addFunction(10.f, 1.0f, dummy_func, "llSetPrimMediaParams", "i", "il");
- addFunction(10.f, 1.0f, dummy_func, "llGetPrimMediaParams", "l", "il");
- addFunction(10.f, 1.0f, dummy_func, "llClearPrimMedia", "i", "i");
- addFunction(10.f, 0.f, dummy_func, "llSetLinkPrimitiveParamsFast", NULL, "il");
- addFunction(10.f, 0.f, dummy_func, "llGetLinkPrimitiveParams", "l", "il");
- addFunction(10.f, 0.f, dummy_func, "llLinkParticleSystem", NULL, "il");
- addFunction(10.f, 0.f, dummy_func, "llSetLinkTextureAnim", NULL, "iiiiifff");
-
- addFunction(10.f, 0.f, dummy_func, "llGetLinkNumberOfSides", "i", "i");
-
- // IDEVO Name lookup calls, see lscript_avatar_names.h
- addFunction(10.f, 0.f, dummy_func, "llGetUsername", "s", "k");
- addFunction(10.f, 0.f, dummy_func, "llRequestUsername", "k", "k");
- addFunction(10.f, 0.f, dummy_func, "llGetDisplayName", "s", "k");
- addFunction(10.f, 0.f, dummy_func, "llRequestDisplayName", "k", "k");
-
- addFunction(10.f, 0.f, dummy_func, "llGetEnv", "s", "s");
- addFunction(10.f, 0.f, dummy_func, "llRegionSayTo", NULL, "kis");
-
- // energy, sleep, dummy_func, name, return type, parameters, help text, gods-only
-
- // IF YOU ADD NEW SCRIPT CALLS, YOU MUST PUT THEM AT THE END OF THIS LIST.
- // Otherwise the bytecode numbers for each call will be wrong, and all
- // existing scripts will crash.
-}
-
-LLScriptLibraryFunction::LLScriptLibraryFunction(F32 eu, F32 st, void (*exec_func)(LLScriptLibData *, LLScriptLibData *, const LLUUID &), const char *name, const char *ret_type, const char *args, BOOL god_only)
- : mEnergyUse(eu), mSleepTime(st), mExecFunc(exec_func), mName(name), mReturnType(ret_type), mArgs(args), mGodOnly(god_only)
-{
-}
-
-LLScriptLibraryFunction::~LLScriptLibraryFunction()
-{
-}
-
-void LLScriptLibrary::addFunction(F32 eu, F32 st, void (*exec_func)(LLScriptLibData *, LLScriptLibData *, const LLUUID &), const char *name, const char *ret_type, const char *args, BOOL god_only)
-{
- LLScriptLibraryFunction func(eu, st, exec_func, name, ret_type, args, god_only);
- mFunctions.push_back(func);
-}
-
-void LLScriptLibrary::assignExec(const char *name, void (*exec_func)(LLScriptLibData *, LLScriptLibData *, const LLUUID &))
-{
- for (std::vector<LLScriptLibraryFunction>::iterator i = mFunctions.begin();
- i != mFunctions.end(); ++i)
- {
- if (!strcmp(name, i->mName))
- {
- i->mExecFunc = exec_func;
- return;
- }
- }
-
- LL_ERRS() << "Unknown LSL function in assignExec: " << name << LL_ENDL;
-}
-
-void LLScriptLibData::print(std::ostream &s, BOOL b_prepend_comma)
-{
- char tmp[1024]; /*Flawfinder: ignore*/
- if (b_prepend_comma)
- {
- s << ", ";
- }
- switch (mType)
- {
- case LST_INTEGER:
- s << mInteger;
- break;
- case LST_FLOATINGPOINT:
- snprintf(tmp, 1024, "%f", mFP); /* Flawfinder: ignore */
- s << tmp;
- break;
- case LST_KEY:
- s << mKey;
- break;
- case LST_STRING:
- s << mString;
- break;
- case LST_VECTOR:
- snprintf(tmp, 1024, "<%f, %f, %f>", mVec.mV[VX], /* Flawfinder: ignore */
- mVec.mV[VY], mVec.mV[VZ]);
- s << tmp;
- break;
- case LST_QUATERNION:
- snprintf(tmp, 1024, "<%f, %f, %f, %f>", mQuat.mQ[VX], mQuat.mQ[VY], /* Flawfinder: ignore */
- mQuat.mQ[VZ], mQuat.mQ[VS]);
- s << tmp;
- break;
- default:
- break;
- }
-}
-
-void LLScriptLibData::print_separator(std::ostream& ostr, BOOL b_prepend_sep, char* sep)
-{
- if (b_prepend_sep)
- {
- ostr << sep;
- }
- //print(ostr, FALSE);
- {
- char tmp[1024]; /* Flawfinder: ignore */
- switch (mType)
- {
- case LST_INTEGER:
- ostr << mInteger;
- break;
- case LST_FLOATINGPOINT:
- snprintf(tmp, 1024, "%f", mFP); /* Flawfinder: ignore */
- ostr << tmp;
- break;
- case LST_KEY:
- ostr << mKey;
- break;
- case LST_STRING:
- ostr << mString;
- break;
- case LST_VECTOR:
- snprintf(tmp, 1024, "<%f, %f, %f>", mVec.mV[VX], /* Flawfinder: ignore */
- mVec.mV[VY], mVec.mV[VZ]);
- ostr << tmp;
- break;
- case LST_QUATERNION:
- snprintf(tmp, 1024, "<%f, %f, %f, %f>", mQuat.mQ[VX], mQuat.mQ[VY], /* Flawfinder: ignore */
- mQuat.mQ[VZ], mQuat.mQ[VS]);
- ostr << tmp;
- break;
- default:
- break;
- }
- }
-}
-
-
-LLScriptLibrary gScriptLibrary;
diff --git a/indra/lscript/lscript_rt_interface.h b/indra/lscript/lscript_rt_interface.h
deleted file mode 100755
index cdf2c5bbd7..0000000000
--- a/indra/lscript/lscript_rt_interface.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * @file lscript_rt_interface.h
- * @brief Interface between compiler library and applications
- *
- * $LicenseInfo:firstyear=2002&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#ifndef LL_LSCRIPT_RT_INTERFACE_H
-#define LL_LSCRIPT_RT_INTERFACE_H
-
-BOOL lscript_compile(char *filename, BOOL compile_to_mono, BOOL is_god_like = FALSE);
-BOOL lscript_compile(const char* src_filename, const char* dst_filename,
- const char* err_filename, BOOL compile_to_mono, const char* class_name, BOOL is_god_like = FALSE);
-void lscript_run(const std::string& filename, BOOL b_debug);
-
-
-#endif
diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt
index d3ac1612ad..422a75f3f1 100755
--- a/indra/newview/CMakeLists.txt
+++ b/indra/newview/CMakeLists.txt
@@ -36,7 +36,6 @@ include(LLUI)
include(LLVFS)
include(LLWindow)
include(LLXML)
-include(LScript)
include(Linking)
include(NDOF)
include(NVAPI)
@@ -85,8 +84,6 @@ include_directories(
${LLVFS_INCLUDE_DIRS}
${LLWINDOW_INCLUDE_DIRS}
${LLXML_INCLUDE_DIRS}
- ${LSCRIPT_INCLUDE_DIRS}
- ${LSCRIPT_INCLUDE_DIRS}/lscript_compile
${LLLOGIN_INCLUDE_DIRS}
${UPDATER_INCLUDE_DIRS}
${LIBS_PREBUILT_DIR}/include/collada
@@ -1111,6 +1108,7 @@ set(viewer_HEADER_FILES
llscreenchannel.h
llscripteditor.h
llscriptfloater.h
+ llscriptruntimeperms.h
llscrollingpanelparam.h
llscrollingpanelparambase.h
llsearchcombobox.h
@@ -1949,7 +1947,6 @@ target_link_libraries(${VIEWER_BINARY_NAME}
${LLVFS_LIBRARIES}
${LLWINDOW_LIBRARIES}
${LLXML_LIBRARIES}
- ${LSCRIPT_LIBRARIES}
${LLMATH_LIBRARIES}
${LLCOREHTTP_LIBRARIES}
${LLCOMMON_LIBRARIES}
diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp
index f151b15e29..64b3df21fd 100755
--- a/indra/newview/llagent.cpp
+++ b/indra/newview/llagent.cpp
@@ -63,6 +63,7 @@
#include "llpaneltopinfobar.h"
#include "llparcel.h"
#include "llrendersphere.h"
+#include "llscriptruntimeperms.h"
#include "llsdmessage.h"
#include "llsdutil.h"
#include "llsky.h"
@@ -92,7 +93,6 @@
#include "llwindow.h"
#include "llworld.h"
#include "llworldmap.h"
-#include "lscript_byteformat.h"
#include "stringize.h"
#include "boost/foreach.hpp"
diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp
index 5415c273e2..9184159321 100755
--- a/indra/newview/llpreviewscript.cpp
+++ b/indra/newview/llpreviewscript.cpp
@@ -53,7 +53,6 @@
#include "llscrolllistcell.h"
#include "llsdserialize.h"
#include "llslider.h"
-#include "lscript_rt_interface.h"
#include "lltooldraganddrop.h"
#include "llvfile.h"
@@ -1474,10 +1473,6 @@ void LLPreviewLSL::saveIfNeeded(bool sync /*= true*/)
{
uploadAssetViaCaps(url, filename, mItemUUID);
}
- else if (gAssetStorage)
- {
- uploadAssetLegacy(filename, mItemUUID, tid);
- }
}
}
@@ -1492,91 +1487,6 @@ void LLPreviewLSL::uploadAssetViaCaps(const std::string& url,
LLHTTPClient::post(url, body, new LLUpdateAgentInventoryResponder(body, filename, LLAssetType::AT_LSL_TEXT));
}
-void LLPreviewLSL::uploadAssetLegacy(const std::string& filename,
- const LLUUID& item_id,
- const LLTransactionID& tid)
-{
- LLLineEditor* descEditor = getChild<LLLineEditor>("desc");
- LLScriptSaveInfo* info = new LLScriptSaveInfo(item_id,
- descEditor->getText(),
- tid);
- gAssetStorage->storeAssetData(filename, tid,
- LLAssetType::AT_LSL_TEXT,
- &LLPreviewLSL::onSaveComplete,
- info);
-
- LLAssetID asset_id = tid.makeAssetID(gAgent.getSecureSessionID());
- std::string filepath = gDirUtilp->getExpandedFilename(LL_PATH_CACHE,asset_id.asString());
- std::string dst_filename = llformat("%s.lso", filepath.c_str());
- std::string err_filename = llformat("%s.out", filepath.c_str());
-
- const BOOL compile_to_mono = FALSE;
- if(!lscript_compile(filename.c_str(),
- dst_filename.c_str(),
- err_filename.c_str(),
- compile_to_mono,
- asset_id.asString().c_str(),
- gAgent.isGodlike()))
- {
- LL_INFOS() << "Compile failed!" << LL_ENDL;
- //char command[256];
- //sprintf(command, "type %s\n", err_filename.c_str());
- //system(command);
-
- // load the error file into the error scrolllist
- LLFILE* fp = LLFile::fopen(err_filename, "r");
- if(fp)
- {
- char buffer[MAX_STRING]; /*Flawfinder: ignore*/
- std::string line;
- while(!feof(fp))
- {
- if (fgets(buffer, MAX_STRING, fp) == NULL)
- {
- buffer[0] = '\0';
- }
- if(feof(fp))
- {
- break;
- }
- else
- {
- line.assign(buffer);
- LLStringUtil::stripNonprintable(line);
-
- LLSD row;
- row["columns"][0]["value"] = line;
- row["columns"][0]["font"] = "OCRA";
- mScriptEd->mErrorList->addElement(row);
- }
- }
- fclose(fp);
- mScriptEd->selectFirstError();
- }
- }
- else
- {
- LL_INFOS() << "Compile worked!" << LL_ENDL;
- if(gAssetStorage)
- {
- getWindow()->incBusyCount();
- mPendingUploads++;
- LLUUID* this_uuid = new LLUUID(mItemUUID);
- gAssetStorage->storeAssetData(dst_filename,
- tid,
- LLAssetType::AT_LSL_BYTECODE,
- &LLPreviewLSL::onSaveBytecodeComplete,
- (void**)this_uuid);
- }
- }
-
- // get rid of any temp files left lying around
- LLFile::remove(filename);
- LLFile::remove(err_filename);
- LLFile::remove(dst_filename);
-}
-
-
// static
void LLPreviewLSL::onSaveComplete(const LLUUID& asset_uuid, void* user_data, S32 status, LLExtStat ext_status) // StoreAssetData callback (fixed)
{
@@ -2170,10 +2080,6 @@ void LLLiveLSLEditor::saveIfNeeded(bool sync /*= true*/)
{
uploadAssetViaCaps(url, filename, mObjectUUID, mItemUUID, is_running);
}
- else if (gAssetStorage)
- {
- uploadAssetLegacy(filename, object, tid, is_running);
- }
}
void LLLiveLSLEditor::uploadAssetViaCaps(const std::string& url,
@@ -2192,105 +2098,6 @@ void LLLiveLSLEditor::uploadAssetViaCaps(const std::string& url,
new LLUpdateTaskInventoryResponder(body, filename, LLAssetType::AT_LSL_TEXT));
}
-void LLLiveLSLEditor::uploadAssetLegacy(const std::string& filename,
- LLViewerObject* object,
- const LLTransactionID& tid,
- BOOL is_running)
-{
- LLLiveLSLSaveData* data = new LLLiveLSLSaveData(mObjectUUID,
- mItem,
- is_running);
- gAssetStorage->storeAssetData(filename, tid,
- LLAssetType::AT_LSL_TEXT,
- &onSaveTextComplete,
- (void*)data,
- FALSE);
-
- LLAssetID asset_id = tid.makeAssetID(gAgent.getSecureSessionID());
- std::string filepath = gDirUtilp->getExpandedFilename(LL_PATH_CACHE,asset_id.asString());
- std::string dst_filename = llformat("%s.lso", filepath.c_str());
- std::string err_filename = llformat("%s.out", filepath.c_str());
-
- LLFILE *fp;
- const BOOL compile_to_mono = FALSE;
- if(!lscript_compile(filename.c_str(),
- dst_filename.c_str(),
- err_filename.c_str(),
- compile_to_mono,
- asset_id.asString().c_str(),
- gAgent.isGodlike()))
- {
- // load the error file into the error scrolllist
- LL_INFOS() << "Compile failed!" << LL_ENDL;
- if(NULL != (fp = LLFile::fopen(err_filename, "r")))
- {
- char buffer[MAX_STRING]; /*Flawfinder: ignore*/
- std::string line;
- while(!feof(fp))
- {
-
- if (fgets(buffer, MAX_STRING, fp) == NULL)
- {
- buffer[0] = '\0';
- }
- if(feof(fp))
- {
- break;
- }
- else
- {
- line.assign(buffer);
- LLStringUtil::stripNonprintable(line);
-
- LLSD row;
- row["columns"][0]["value"] = line;
- row["columns"][0]["font"] = "OCRA";
- mScriptEd->mErrorList->addElement(row);
- }
- }
- fclose(fp);
- mScriptEd->selectFirstError();
- // don't set the asset id, because we want to save the
- // script, even though the compile failed.
- //mItem->setAssetUUID(LLUUID::null);
- object->saveScript(mItem, FALSE, false);
- dialog_refresh_all();
- }
- }
- else
- {
- LL_INFOS() << "Compile worked!" << LL_ENDL;
- mScriptEd->mErrorList->setCommentText(LLTrans::getString("CompileSuccessfulSaving"));
- if(gAssetStorage)
- {
- LL_INFOS() << "LLLiveLSLEditor::saveAsset "
- << mItem->getAssetUUID() << LL_ENDL;
- getWindow()->incBusyCount();
- mPendingUploads++;
- LLLiveLSLSaveData* data = NULL;
- data = new LLLiveLSLSaveData(mObjectUUID,
- mItem,
- is_running);
- gAssetStorage->storeAssetData(dst_filename,
- tid,
- LLAssetType::AT_LSL_BYTECODE,
- &LLLiveLSLEditor::onSaveBytecodeComplete,
- (void*)data);
- dialog_refresh_all();
- }
- }
-
- // get rid of any temp files left lying around
- LLFile::remove(filename);
- LLFile::remove(err_filename);
- LLFile::remove(dst_filename);
-
- // If we successfully saved it, then we should be able to check/uncheck the running box!
- LLCheckBoxCtrl* runningCheckbox = getChild<LLCheckBoxCtrl>( "running");
- runningCheckbox->setLabel(getString("script_running"));
- runningCheckbox->setEnabled(TRUE);
-}
-
void LLLiveLSLEditor::onSaveTextComplete(const LLUUID& asset_uuid, void* user_data, S32 status, LLExtStat ext_status) // StoreAssetData callback (fixed)
{
LLLiveLSLSaveData* data = (LLLiveLSLSaveData*)user_data;
diff --git a/indra/newview/llpreviewscript.h b/indra/newview/llpreviewscript.h
index 66727bceee..fab997bc22 100755
--- a/indra/newview/llpreviewscript.h
+++ b/indra/newview/llpreviewscript.h
@@ -202,9 +202,6 @@ protected:
void uploadAssetViaCaps(const std::string& url,
const std::string& filename,
const LLUUID& item_id);
- void uploadAssetLegacy(const std::string& filename,
- const LLUUID& item_id,
- const LLTransactionID& tid);
static void onSearchReplace(void* userdata);
static void onLoad(void* userdata);
@@ -260,10 +257,6 @@ private:
const LLUUID& task_id,
const LLUUID& item_id,
BOOL is_running);
- void uploadAssetLegacy(const std::string& filename,
- LLViewerObject* object,
- const LLTransactionID& tid,
- BOOL is_running);
BOOL monoChecked() const;
diff --git a/indra/newview/llscriptruntimeperms.h b/indra/newview/llscriptruntimeperms.h
new file mode 100644
index 0000000000..4a8e4288d2
--- /dev/null
+++ b/indra/newview/llscriptruntimeperms.h
@@ -0,0 +1,60 @@
+/**
+ * @file llscriptruntimeperms.h
+ * @brief Script runtime permission definitions
+ *
+ * $LicenseInfo:firstyear=2002&license=viewerlgpl$
+ * Second Life Viewer Source Code
+ * Copyright (C) 2015, Linden Research, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License only.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
+ * $/LicenseInfo$
+ */
+
+#ifndef LL_LLSCRIPTRUNTIME_PERMS_H
+#define LL_LLSCRIPTRUNTIME_PERMS_H
+
+typedef struct _script_perm {
+ std::string question;
+ U32 permbit;
+ bool caution;
+ _script_perm(const std::string& q, const U32 b, const bool c) :
+ question(q), permbit(b), caution(c) {}
+} script_perm_t;
+
+const U32 NUM_SCRIPT_PERMISSIONS = 16;
+const S32 SCRIPT_PERMISSION_DEBIT = 0;
+
+static const boost::array<script_perm_t, NUM_SCRIPT_PERMISSIONS> SCRIPT_PERMISSIONS = {{
+ _script_perm("ScriptTakeMoney", (0x1 << 1), true),
+ _script_perm("ActOnControlInputs", (0x1 << 2), false),
+ _script_perm("RemapControlInputs", (0x1 << 3), false),
+ _script_perm("AnimateYourAvatar", (0x1 << 4), false),
+ _script_perm("AttachToYourAvatar", (0x1 << 5), false),
+ _script_perm("ReleaseOwnership", (0x1 << 6), false),
+ _script_perm("LinkAndDelink", (0x1 << 7), false),
+ _script_perm("AddAndRemoveJoints", (0x1 << 8), false),
+ _script_perm("ChangePermissions", (0x1 << 9), false),
+ _script_perm("TrackYourCamera", (0x1 << 10), false),
+ _script_perm("ControlYourCamera", (0x1 << 11), false),
+ _script_perm("TeleportYourAgent", (0x1 << 12), false),
+ _script_perm("JoinAnExperience", (0x1 << 13), false),
+ _script_perm("SilentlyManageEstateAccess", (0x1 << 14), false),
+ _script_perm("OverrideYourAnimations", (0x1 << 15), false),
+ _script_perm("ScriptReturnObjects", (0x1 << 16), false)
+}};
+
+#endif // LL_LLSCRIPTRUNTIME_PERMS_H
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index 762f75edd4..edefdff3c9 100755
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -33,7 +33,6 @@
#include "llaudioengine.h"
#include "llavataractions.h"
#include "llavatarnamecache.h" // IDEVO HACK
-#include "lscript_byteformat.h"
#include "lleconomy.h"
#include "lleventtimer.h"
#include "llfloaterreg.h"
@@ -76,6 +75,7 @@
#include "llpanelgrouplandmoney.h"
#include "llrecentpeople.h"
#include "llscriptfloater.h"
+#include "llscriptruntimeperms.h"
#include "llselectmgr.h"
#include "llstartup.h"
#include "llsky.h"
@@ -115,6 +115,7 @@
#include <boost/algorithm/string/split.hpp> //
#include <boost/regex.hpp>
+#include <boost/foreach.hpp>
#include "llnotificationmanager.h" //
@@ -153,47 +154,6 @@ const U8 AU_FLAGS_NONE = 0x00;
const U8 AU_FLAGS_HIDETITLE = 0x01;
const U8 AU_FLAGS_CLIENT_AUTOPILOT = 0x02;
-//script permissions
-const std::string SCRIPT_QUESTIONS[SCRIPT_PERMISSION_EOF] =
- {
- "ScriptTakeMoney",
- "ActOnControlInputs",
- "RemapControlInputs",
- "AnimateYourAvatar",
- "AttachToYourAvatar",
- "ReleaseOwnership",
- "LinkAndDelink",
- "AddAndRemoveJoints",
- "ChangePermissions",
- "TrackYourCamera",
- "ControlYourCamera",
- "TeleportYourAgent",
- "JoinAnExperience",
- "SilentlyManageEstateAccess",
- "OverrideYourAnimations",
- "ScriptReturnObjects"
- };
-
-const BOOL SCRIPT_QUESTION_IS_CAUTION[SCRIPT_PERMISSION_EOF] =
-{
- TRUE, // ScriptTakeMoney,
- FALSE, // ActOnControlInputs
- FALSE, // RemapControlInputs
- FALSE, // AnimateYourAvatar
- FALSE, // AttachToYourAvatar
- FALSE, // ReleaseOwnership,
- FALSE, // LinkAndDelink,
- FALSE, // AddAndRemoveJoints
- FALSE, // ChangePermissions
- FALSE, // TrackYourCamera,
- FALSE, // ControlYourCamera
- FALSE, // TeleportYourAgent
- FALSE, // JoinAnExperience
- FALSE, // SilentlyManageEstateAccess
- FALSE, // OverrideYourAnimations
- FALSE, // ScriptReturnObjects
-};
-
bool friendship_offer_callback(const LLSD& notification, const LLSD& response)
{
S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
@@ -6284,21 +6244,22 @@ void notify_cautioned_script_question(const LLSD& notification, const LLSD& resp
BOOL caution = FALSE;
S32 count = 0;
std::string perms;
- for (S32 i = 0; i < SCRIPT_PERMISSION_EOF; i++)
+ BOOST_FOREACH(script_perm_t script_perm, SCRIPT_PERMISSIONS)
{
- if ((orig_questions & LSCRIPTRunTimePermissionBits[i]) && SCRIPT_QUESTION_IS_CAUTION[i])
+ if ((orig_questions & script_perm.permbit)
+ && script_perm.caution)
{
count++;
caution = TRUE;
// add a comma before the permission description if it is not the first permission
// added to the list or the last permission to check
- if ((count > 1) && (i < SCRIPT_PERMISSION_EOF))
+ if (count > 1)
{
perms.append(", ");
}
- perms.append(LLTrans::getString(SCRIPT_QUESTIONS[i]));
+ perms.append(LLTrans::getString(script_perm.question));
}
}
@@ -6472,27 +6433,27 @@ void process_script_question(LLMessageSystem *msg, void **user_data)
std::string script_question;
if (questions)
{
- BOOL caution = FALSE;
+ bool caution = false;
S32 count = 0;
LLSD args;
args["OBJECTNAME"] = object_name;
args["NAME"] = LLCacheName::cleanFullName(owner_name);
S32 known_questions = 0;
- BOOL has_not_only_debit = questions ^ LSCRIPTRunTimePermissionBits[SCRIPT_PERMISSION_DEBIT];
+ bool has_not_only_debit = questions ^ SCRIPT_PERMISSIONS[SCRIPT_PERMISSION_DEBIT].permbit;
// check the received permission flags against each permission
- for (S32 i = 0; i < SCRIPT_PERMISSION_EOF; i++)
+ BOOST_FOREACH(script_perm_t script_perm, SCRIPT_PERMISSIONS)
{
- if (questions & LSCRIPTRunTimePermissionBits[i])
+ if (questions & script_perm.permbit)
{
count++;
- known_questions |= LSCRIPTRunTimePermissionBits[i];
+ known_questions |= script_perm.permbit;
// check whether permission question should cause special caution dialog
- caution |= (SCRIPT_QUESTION_IS_CAUTION[i]);
+ caution |= (script_perm.caution);
- if (("ScriptTakeMoney" == SCRIPT_QUESTIONS[i]) && has_not_only_debit)
+ if (("ScriptTakeMoney" == script_perm.question) && has_not_only_debit)
continue;
- script_question += " " + LLTrans::getString(SCRIPT_QUESTIONS[i]) + "\n";
+ script_question += " " + LLTrans::getString(script_perm.question) + "\n";
}
}
diff --git a/indra/test/CMakeLists.txt b/indra/test/CMakeLists.txt
index 01d1d830a2..9404dcf88e 100755
--- a/indra/test/CMakeLists.txt
+++ b/indra/test/CMakeLists.txt
@@ -9,7 +9,6 @@ include(LLMath)
include(LLMessage)
include(LLVFS)
include(LLXML)
-include(LScript)
include(Linking)
include(Tut)
include(LLAddBuildTest)
@@ -47,7 +46,6 @@ set(test_SOURCE_FILES
llpermissions_tut.cpp
llpipeutil.cpp
llsaleinfo_tut.cpp
- llscriptresource_tut.cpp
llsdmessagebuilder_tut.cpp
llsdmessagereader_tut.cpp
llsd_new_tut.cpp
diff --git a/indra/test/llscriptresource_tut.cpp b/indra/test/llscriptresource_tut.cpp
deleted file mode 100755
index 7a3b824e6d..0000000000
--- a/indra/test/llscriptresource_tut.cpp
+++ /dev/null
@@ -1,198 +0,0 @@
-/**
- * @file llscriptresource_tut.cpp
- * @brief Test LLScriptResource
- *
- * $LicenseInfo:firstyear=2008&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-//#include <tut/tut.h>
-#include "linden_common.h"
-
-#include "lltut.h"
-
-#include "llscriptresource.h"
-#include "llscriptresourceconsumer.h"
-#include "llscriptresourcepool.h"
-
-class TestConsumer : public LLScriptResourceConsumer
-{
-public:
- TestConsumer()
- : mUsedURLs(0)
- { }
-
- // LLScriptResourceConsumer interface:
- S32 getUsedPublicURLs() const
- {
- return mUsedURLs;
- }
-
- // Test details:
- S32 mUsedURLs;
-};
-
-
-namespace tut
-{
- class LLScriptResourceTestData
- {
- };
-
- typedef test_group<LLScriptResourceTestData> LLScriptResourceTestGroup;
- typedef LLScriptResourceTestGroup::object LLScriptResourceTestObject;
- LLScriptResourceTestGroup scriptResourceTestGroup("scriptResource");
-
- template<> template<>
- void LLScriptResourceTestObject::test<1>()
- {
- LLScriptResource resource;
- U32 total = 42;
-
- resource.setTotal(total);
- ensure_equals("Verify set/get total", resource.getTotal(), total);
- ensure_equals("Verify all resources are initially available",resource.getAvailable(),total);
-
- // Requesting too many, releasing non-allocated
- ensure("Request total + 1 resources should fail",!resource.request(total + 1));
- ensure_equals("Verify all resources available after failed request",resource.getAvailable(),total);
-
- ensure("Releasing resources when none allocated should fail",!resource.release());
- ensure_equals("All resources should be available after failed release",resource.getAvailable(),total);
-
- ensure("Request one resource", resource.request());
- ensure_equals("Verify available resources after successful request",resource.getAvailable(),total - 1);
-
- // Is this right? Or should we release all used resources if we try to release more than are currently used?
- ensure("Release more resources than allocated",!resource.release(2));
- ensure_equals("Verify resource availability after failed release",resource.getAvailable(),total - 1);
-
- ensure("Release a resource",resource.release());
- ensure_equals("Verify all resources available after successful release",resource.getAvailable(),total);
- }
-
-
- template<> template<>
- void LLScriptResourceTestObject::test<2>()
- {
- LLScriptResource resource;
- U32 total = 42;
-
- resource.setTotal(total);
-
- S32 resources_to_request = 30;
- ensure("Get multiple resources resources",resource.request(resources_to_request));
- ensure_equals("Verify available resources is correct after request of multiple resources",resource.getAvailable(), total - resources_to_request);
-
- S32 resources_to_release = (resources_to_request / 2);
- ensure("Release some resources",resource.release(resources_to_release));
-
- S32 expected_available = (total - resources_to_request + resources_to_release);
- ensure_equals("Verify available resources after release of some resources",resource.getAvailable(), expected_available);
-
- resources_to_release = (resources_to_request - resources_to_release);
- ensure("Release remaining resources",resource.release(resources_to_release));
-
- ensure_equals("Verify available resources after release of remaining resources",resource.getAvailable(), total);
- }
-
- template<> template<>
- void LLScriptResourceTestObject::test<3>()
- {
- LLScriptResource resource;
-
- U32 total = 42;
- resource.setTotal(total);
-
- ensure("Request all resources",resource.request(total));
-
- U32 low_total = 10;
- ensure("Release all resources",resource.release(total));
- ensure_equals("Verify all resources available after releasing",resource.getAvailable(),total);
-
- resource.setTotal(low_total);
- ensure_equals("Verify low total resources are available after set",resource.getAvailable(),low_total);
- }
-
-
- template<> template<>
- void LLScriptResourceTestObject::test<4>()
- {
- S32 big_resource_total = 100;
- S32 small_resource_total = 10;
- LLScriptResourcePool big_pool;
- big_pool.getPublicURLResource().setTotal(big_resource_total);
- LLScriptResourcePool small_pool;
- small_pool.getPublicURLResource().setTotal(small_resource_total);
-
- TestConsumer consumer;
- LLScriptResourcePool& initial_pool = consumer.getScriptResourcePool();
- ensure("Initial resource pool is 'null'.", (&initial_pool == &LLScriptResourcePool::null));
-
- consumer.switchScriptResourcePools(big_pool);
- LLScriptResourcePool& get_pool = consumer.getScriptResourcePool();
- ensure("Get resource that was set.", (&big_pool == &get_pool));
-
- ensure_equals("No public urls in use yet.", consumer.getUsedPublicURLs(),0);
-
- S32 request_urls = 5;
- consumer.mUsedURLs = request_urls;
- consumer.getScriptResourcePool().getPublicURLResource().request(request_urls);
-
- ensure_equals("Available urls on big_pool is 5 less than total.",
- big_pool.getPublicURLResource().getAvailable(), big_resource_total - request_urls);
-
- ensure("Switching from big pool to small pool",
- consumer.switchScriptResourcePools(small_pool));
-
- ensure_equals("All resources available to big pool again",
- big_pool.getPublicURLResource().getAvailable(), big_resource_total);
-
- ensure_equals("Available urls on small pool is 5 less than total.",
- small_pool.getPublicURLResource().getAvailable(), small_resource_total - request_urls);
-
- ensure("Switching from small pool to big pool",
- consumer.switchScriptResourcePools(big_pool));
-
- consumer.getScriptResourcePool().getPublicURLResource().release(request_urls);
-
- request_urls = 50; // Too many for the small_pool
-
- consumer.mUsedURLs = request_urls;
- consumer.getScriptResourcePool().getPublicURLResource().request(request_urls);
-
- // Verify big pool has them
- ensure_equals("Available urls on big pool is 50 less than total.",
- big_pool.getPublicURLResource().getAvailable(), big_resource_total - request_urls);
-
- // Verify can't switch to small_pool
- ensure("Switching to small pool with too many resources",
- !consumer.switchScriptResourcePools(small_pool));
-
- // Verify big pool still accounting for used resources
- ensure_equals("Available urls on big_pool is still 50 less than total.",
- big_pool.getPublicURLResource().getAvailable(), big_resource_total - request_urls);
-
- // Verify small pool still has all resources available.
- ensure_equals("All resources in small pool are still available.",
- small_pool.getPublicURLResource().getAvailable(), small_resource_total);
- }
-}