merge changes for OPEN-292
commit
867ef882fd
|
|
@ -318,6 +318,7 @@ Cinder Roxley
|
|||
BUG-8786
|
||||
OPEN-185
|
||||
OPEN-282
|
||||
OPEN-292
|
||||
STORM-1703
|
||||
STORM-1948
|
||||
STORM-1831
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -81,7 +81,6 @@ set(cmake_SOURCE_FILES
|
|||
LLVFS.cmake
|
||||
LLWindow.cmake
|
||||
LLXML.cmake
|
||||
LScript.cmake
|
||||
Linking.cmake
|
||||
MediaPluginBase.cmake
|
||||
NDOF.cmake
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
@ -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)
|
||||
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,575 +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_EXPERMISSIONS,
|
||||
LSTT_TRANSACTION_RESULT,
|
||||
LSTT_PATH_UPDATE,
|
||||
LSTT_EXPERMISSIONS_DENIED,
|
||||
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
|
||||
0x0000000400000000LL, // LSTT_EXPERMISSIONS
|
||||
0x0000000800000000LL, // LSTT_TRANSACTION_RESULT
|
||||
0x0000001000000000LL, // LSTT_PATH_UPDATE
|
||||
0x0000002000000000LL, //LSTT_EXPERMISSIONS_DENIED
|
||||
};
|
||||
|
||||
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_INVALID_STATE,
|
||||
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
|
||||
|
||||
|
|
@ -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})
|
||||
|
|
@ -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
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -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$
|
||||
*/
|
||||
|
||||
|
|
@ -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;
|
||||
|
|
@ -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
|
||||
|
||||
|
|
@ -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];
|
||||
}
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
||||
|
|
@ -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;
|
||||
|
|
@ -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
|
||||
|
||||
|
|
@ -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;
|
||||
|
|
@ -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
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
@ -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
|
||||
|
|
@ -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. */
|
||||
|
|
@ -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
|
||||
|
|
@ -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})
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
|
@ -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 == ¤t_pool )
|
||||
{
|
||||
// This consumer is already in this pool
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -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;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -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
|
||||
|
|
@ -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
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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})
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -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$
|
||||
*/
|
||||
|
||||
|
|
@ -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;
|
||||
|
|
@ -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
|
||||
|
|
@ -36,7 +36,6 @@ include(LLUI)
|
|||
include(LLVFS)
|
||||
include(LLWindow)
|
||||
include(LLXML)
|
||||
include(LScript)
|
||||
include(Linking)
|
||||
include(NDOF)
|
||||
include(NVAPI)
|
||||
|
|
@ -82,8 +81,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
|
||||
|
|
@ -1136,6 +1133,7 @@ set(viewer_HEADER_FILES
|
|||
llscreenchannel.h
|
||||
llscripteditor.h
|
||||
llscriptfloater.h
|
||||
llscriptruntimeperms.h
|
||||
llscrollingpanelparam.h
|
||||
llscrollingpanelparambase.h
|
||||
llsearchcombobox.h
|
||||
|
|
@ -1938,7 +1936,6 @@ target_link_libraries(${VIEWER_BINARY_NAME}
|
|||
${LLVFS_LIBRARIES}
|
||||
${LLWINDOW_LIBRARIES}
|
||||
${LLXML_LIBRARIES}
|
||||
${LSCRIPT_LIBRARIES}
|
||||
${LLMATH_LIBRARIES}
|
||||
${LLCOREHTTP_LIBRARIES}
|
||||
${LLCOMMON_LIBRARIES}
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
||||
|
|
|
|||
|
|
@ -53,7 +53,6 @@
|
|||
#include "llscrolllistcell.h"
|
||||
#include "llsdserialize.h"
|
||||
#include "llslider.h"
|
||||
#include "lscript_rt_interface.h"
|
||||
#include "lltooldraganddrop.h"
|
||||
#include "llvfile.h"
|
||||
|
||||
|
|
@ -1683,10 +1682,6 @@ void LLPreviewLSL::saveIfNeeded(bool sync /*= true*/)
|
|||
{
|
||||
uploadAssetViaCaps(url, filename, mItemUUID);
|
||||
}
|
||||
else if (gAssetStorage)
|
||||
{
|
||||
uploadAssetLegacy(filename, mItemUUID, tid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1701,91 +1696,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)
|
||||
{
|
||||
|
|
@ -2391,10 +2301,6 @@ void LLLiveLSLEditor::saveIfNeeded(bool sync /*= true*/)
|
|||
{
|
||||
uploadAssetViaCaps(url, filename, mObjectUUID, mItemUUID, is_running, mScriptEd->getAssociatedExperience());
|
||||
}
|
||||
else if (gAssetStorage)
|
||||
{
|
||||
uploadAssetLegacy(filename, object, tid, is_running);
|
||||
}
|
||||
}
|
||||
|
||||
void LLLiveLSLEditor::uploadAssetViaCaps(const std::string& url,
|
||||
|
|
@ -2415,105 +2321,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;
|
||||
|
|
|
|||
|
|
@ -206,9 +206,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);
|
||||
|
|
@ -276,10 +273,6 @@ private:
|
|||
const LLUUID& item_id,
|
||||
BOOL is_running,
|
||||
const LLUUID& experience_public_id);
|
||||
void uploadAssetLegacy(const std::string& filename,
|
||||
LLViewerObject* object,
|
||||
const LLTransactionID& tid,
|
||||
BOOL is_running);
|
||||
BOOL monoChecked() const;
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -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"
|
||||
|
|
@ -78,6 +77,7 @@
|
|||
#include "llpanelgrouplandmoney.h"
|
||||
#include "llrecentpeople.h"
|
||||
#include "llscriptfloater.h"
|
||||
#include "llscriptruntimeperms.h"
|
||||
#include "llselectmgr.h"
|
||||
#include "llstartup.h"
|
||||
#include "llsky.h"
|
||||
|
|
@ -117,6 +117,7 @@
|
|||
|
||||
#include <boost/algorithm/string/split.hpp> //
|
||||
#include <boost/regex.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
#include "llnotificationmanager.h" //
|
||||
#include "llexperiencecache.h"
|
||||
|
|
@ -157,47 +158,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);
|
||||
|
|
@ -6359,21 +6319,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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -6605,27 +6566,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";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue