lscript_tree.cpp
上传用户:king477883
上传日期:2021-03-01
资源大小:9553k
文件大小:399k
- /**
- * @file lscript_tree.cpp
- * @brief implements methods for lscript_tree.h classes
- *
- * $LicenseInfo:firstyear=2002&license=viewergpl$
- *
- * Copyright (c) 2002-2010, Linden Research, Inc.
- *
- * Second Life Viewer Source Code
- * The source code in this file ("Source Code") is provided by Linden Lab
- * to you under the terms of the GNU General Public License, version 2.0
- * ("GPL"), unless you have obtained a separate licensing agreement
- * ("Other License"), formally executed by you and Linden Lab. Terms of
- * the GPL can be found in doc/GPL-license.txt in this distribution, or
- * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
- *
- * There are special exceptions to the terms and conditions of the GPL as
- * it is applied to this Source Code. View the full text of the exception
- * in the file doc/FLOSS-exception.txt in this software distribution, or
- * online at
- * http://secondlifegrid.net/programs/open_source/licensing/flossexception
- *
- * By copying, modifying or distributing this software, you acknowledge
- * that you have read and understood your obligations described above,
- * and agree to abide by those obligations.
- *
- * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
- * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
- * COMPLETENESS OR PERFORMANCE.
- * $/LicenseInfo$
- */
- // TO DO: Move print functionality from .h file to here
- #include "linden_common.h"
- #include "lscript_tree.h"
- #include "lscript_typecheck.h"
- #include "lscript_resource.h"
- #include "lscript_bytecode.h"
- #include "lscript_heap.h"
- #include "lscript_library.h"
- #include "lscript_alloc.h"
- //#define LSL_INCLUDE_DEBUG_INFO
- static void print_cil_box(LLFILE* fp, LSCRIPTType type)
- {
-
- switch(type)
- {
- case LST_INTEGER:
- fprintf(fp, "box [mscorlib]System.Int32n");
- break;
- case LST_FLOATINGPOINT:
- fprintf(fp, "box [mscorlib]System.Singlen");
- break;
- case LST_STRING:
- // System.String is not a System.ValueType,
- // so does not need to be boxed.
- break;
- case LST_KEY:
- fprintf(fp, "box [ScriptTypes]LindenLab.SecondLife.Keyn");
- break;
- case LST_VECTOR:
- fprintf(fp, "box [ScriptTypes]LindenLab.SecondLife.Vectorn");
- break;
- case LST_QUATERNION:
- fprintf(fp, "box [ScriptTypes]LindenLab.SecondLife.Quaternionn");
- break;
- default:
- llassert(false);
- break;
- }
- }
- static void print_cil_type(LLFILE* fp, LSCRIPTType type)
- {
- switch(type)
- {
- case LST_INTEGER:
- fprintf(fp, "int32");
- break;
- case LST_FLOATINGPOINT:
- fprintf(fp, "float32");
- break;
- case LST_STRING:
- fprintf(fp, "string");
- break;
- case LST_KEY:
- fprintf(fp, "valuetype [ScriptTypes]LindenLab.SecondLife.Key");
- break;
- case LST_VECTOR:
- fprintf(fp, "class [ScriptTypes]LindenLab.SecondLife.Vector");
- break;
- case LST_QUATERNION:
- fprintf(fp, "class [ScriptTypes]LindenLab.SecondLife.Quaternion");
- break;
- case LST_LIST:
- fprintf(fp, "class [mscorlib]System.Collections.ArrayList");
- break;
- case LST_NULL:
- fprintf(fp, "void");
- break;
- default:
- break;
- }
- }
- void LLScriptType::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- case LSCP_EMIT_ASSEMBLY:
- fprintf(fp,"%s",LSCRIPTTypeNames[mType]);
- break;
- case LSCP_TYPE:
- type = mType;
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- print_cil_type(fp, mType);
- break;
- default:
- break;
- }
- }
- S32 LLScriptType::getSize()
- {
- return LSCRIPTDataSize[mType];
- }
- void LLScriptConstant::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- case LSCP_EMIT_ASSEMBLY:
- fprintf(fp,"Script Constant Base class -- should never get here!n");
- break;
- default:
- break;
- }
- }
- S32 LLScriptConstant::getSize()
- {
- printf("Script Constant Base class -- should never get here!n");
- return 0;
- }
- void LLScriptConstantInteger::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- fprintf(fp, "%d", mValue);
- break;
- case LSCP_EMIT_ASSEMBLY:
- fprintf(fp, "PUSHARGI %dn", mValue);
- break;
- case LSCP_TYPE:
- type = mType;
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
- chunk->addInteger(mValue);
- type = mType;
- }
- break;
- case LSCP_TO_STACK:
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHARGI]);
- chunk->addInteger(mValue);
- type = mType;
- }
- break;
- case LSCP_LIST_BUILD_SIMPLE:
- {
- *ldata = new LLScriptLibData(mValue);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- fprintf(fp, "ldc.i4 %dn", mValue);
- type = mType;
- break;
- default:
- break;
- }
- }
- S32 LLScriptConstantInteger::getSize()
- {
- return LSCRIPTDataSize[LST_INTEGER];
- }
- void LLScriptConstantFloat::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- fprintf(fp, "%5.5f", mValue);
- break;
- case LSCP_EMIT_ASSEMBLY:
- fprintf(fp, "PUSHARGF %5.5fn", mValue);
- break;
- case LSCP_TYPE:
- type = mType;
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
- chunk->addFloat(mValue);
- type = mType;
- }
- break;
- case LSCP_TO_STACK:
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHARGF]);
- chunk->addFloat(mValue);
- type = mType;
- }
- break;
- case LSCP_LIST_BUILD_SIMPLE:
- {
- *ldata = new LLScriptLibData(mValue);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- {
- double v = (double)mValue;
- U8 * p = (U8 *)&v; // See ECMA-335 Partition VI, Appendix C.4.6 Examples, line 4
- fprintf(fp, "ldc.r8 (%02x %02x %02x %02x %02x %02x %02x %02x)n", p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7]);
- type = mType;
- }
- break;
- default:
- break;
- }
- }
- S32 LLScriptConstantFloat::getSize()
- {
- return LSCRIPTDataSize[LST_FLOATINGPOINT];
- }
- void print_escaped(LLFILE* fp, const char* str)
- {
- putc('"', fp);
- for(const char* c = str; *c != ' '; ++c)
- {
- switch(*c)
- {
- case '"':
- putc('\', fp);
- putc(*c, fp);
- break;
- case 'n':
- putc('\', fp);
- putc('n', fp);
- break;
- case 't':
- putc(' ', fp);
- putc(' ', fp);
- putc(' ', fp);
- putc(' ', fp);
- break;
- case '\':
- putc('\', fp);
- putc('\', fp);
- break;
- default:
- putc(*c, fp);
- }
- }
- putc('"', fp);
- }
- void LLScriptConstantString::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- fprintf(fp, ""%s"", mValue);
- break;
- case LSCP_EMIT_ASSEMBLY:
- fprintf(fp, "PUSHARGS "%s"n", mValue);
- break;
- case LSCP_TYPE:
- type = mType;
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
- chunk->addInteger(heap->mCurrentOffset + 1);
- LLScriptLibData *data = new LLScriptLibData(mValue);
- U8 *temp;
- S32 size = lsa_create_data_block(&temp, data, heap->mCurrentOffset);
- heap->addBytes(temp, size);
- delete [] temp;
- delete data;
- }
- break;
- case LSCP_TO_STACK:
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHARGS]);
- chunk->addBytes(mValue, (S32)strlen(mValue) + 1);
- type = mType;
- }
- break;
- case LSCP_LIST_BUILD_SIMPLE:
- {
- *ldata = new LLScriptLibData(mValue);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- fprintf(fp, "ldstr ");
- print_escaped(fp, mValue);
- fprintf(fp, "n");
- default:
- break;
- }
- }
- S32 LLScriptConstantString::getSize()
- {
- return (S32)strlen(mValue) + 1;
- }
- void LLScriptIdentifier::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- fprintf(fp, "%s", mName);
- break;
- case LSCP_EMIT_ASSEMBLY:
- if (mScopeEntry)
- {
- if (mScopeEntry->mIDType == LIT_VARIABLE)
- {
- fprintf(fp, "$BP + %d [%s]", mScopeEntry->mOffset, mName);
- }
- else if (mScopeEntry->mIDType == LIT_GLOBAL)
- {
- fprintf(fp, "$GVR + %d [%s]", mScopeEntry->mOffset, mName);
- }
- else
- {
- fprintf(fp, "%s", mName);
- }
- }
- break;
- case LSCP_TYPE:
- if (mScopeEntry)
- type = mScopeEntry->mType;
- else
- type = LST_NULL;
- break;
- case LSCP_RESOURCE:
- if (mScopeEntry)
- {
- if (mScopeEntry->mIDType == LIT_VARIABLE)
- {
- // fprintf(fp, "LOCAL : %d : %d : %sn", mScopeEntry->mOffset, mScopeEntry->mSize, mName);
- }
- else if (mScopeEntry->mIDType == LIT_GLOBAL)
- {
- // fprintf(fp, "GLOBAL: %d : %d : %sn", mScopeEntry->mOffset, mScopeEntry->mSize, mName);
- }
- }
- break;
- case LSCP_LIST_BUILD_SIMPLE:
- {
- if (mScopeEntry)
- {
- if (mScopeEntry->mType == LST_LIST)
- {
- gErrorToText.writeError(fp, this, LSERROR_NO_LISTS_IN_LISTS);
- }
- else if (mScopeEntry->mAssignable)
- {
- mScopeEntry->mAssignable->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, ldata);
- }
- else
- {
- gErrorToText.writeError(fp, this, LSERROR_NO_UNITIALIZED_VARIABLES_IN_LISTS);
- }
- }
- else
- {
- gErrorToText.writeError(fp, this, LSERROR_UNDEFINED_NAME);
- }
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- fprintf(fp, "'%s'", mName);
- break;
- default:
- break;
- }
- }
- S32 LLScriptIdentifier::getSize()
- {
-
- return 0;
- }
- void LLScriptSimpleAssignable::addAssignable(LLScriptSimpleAssignable *assign)
- {
- if (mNextp)
- {
- assign->mNextp = mNextp;
- }
- mNextp = assign;
- }
- void LLScriptSimpleAssignable::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- fprintf(fp, "Simple Assignable Base Class -- should never get here!n");
- }
- S32 LLScriptSimpleAssignable::getSize()
- {
-
- printf("Simple Assignable Base Class -- should never get here!n");
- return 0;
- }
- static void print_cil_member(LLFILE* fp, LLScriptIdentifier *ident)
- {
- print_cil_type(fp, ident->mScopeEntry->mType);
- fprintf(fp, " %s::'%s'n", gScriptp->getClassName(), ident->mScopeEntry->mIdentifier);
- }
- void LLScriptSAIdentifier::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- case LSCP_EMIT_ASSEMBLY:
- mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mNextp)
- {
- fprintf(fp, ", ");
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- case LSCP_SCOPE_PASS1:
- {
- LLScriptScopeEntry *entry = scope->findEntry(mIdentifier->mName);
- if (!entry)
- {
- gErrorToText.writeError(fp, this, LSERROR_UNDEFINED_NAME);
- }
- else
- {
- // if we did find it, make sure this identifier is associated with the correct scope entry
- mIdentifier->mScopeEntry = entry;
- }
- if (mNextp)
- {
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- }
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
- if (mIdentifier->mScopeEntry)
- {
- if(mIdentifier->mScopeEntry->mAssignable)
- {
- mIdentifier->mScopeEntry->mAssignable->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- else
- {
- // Babbage: 29/8/06: If the scope entry has no mAssignable,
- // set the default type and add the default 0 value to the
- // chunk. Without this SAVectors and SAQuaternions will
- // assume the arbitrary current type is the assignable type
- // and may attempt to access a null chunk. (SL-20156)
- type = mIdentifier->mScopeEntry->mType;
- chunk->addBytes(LSCRIPTDataSize[type]);
- }
- }
- if (mNextp)
- {
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- }
- break;
- case LSCP_LIST_BUILD_SIMPLE:
- {
- mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, ldata);
- if (mNextp)
- {
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, &(*ldata)->mListp);
- }
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- {
- fprintf(fp, "ldarg.0n");
- fprintf(fp, "ldfld ");
- print_cil_member(fp, mIdentifier);
- fprintf(fp, "n");
- if (mNextp)
- {
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- }
- default:
- mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mNextp)
- {
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- }
- }
- S32 LLScriptSAIdentifier::getSize()
- {
- return mIdentifier->getSize();
- }
- void LLScriptSAConstant::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- case LSCP_EMIT_ASSEMBLY:
- mConstant->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mNextp)
- {
- fprintf(fp, ", ");
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- case LSCP_LIST_BUILD_SIMPLE:
- {
- mConstant->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, ldata);
- if (mNextp)
- {
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, &(*ldata)->mListp);
- }
- }
- break;
- default:
- mConstant->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mNextp)
- {
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- }
- }
- S32 LLScriptSAConstant::getSize()
- {
- return mConstant->getSize();
- }
- static void print_cil_cast(LLFILE* fp, LSCRIPTType srcType, LSCRIPTType targetType)
- {
- switch(srcType)
- {
- case LST_INTEGER:
- switch(targetType)
- {
- case LST_FLOATINGPOINT:
- fprintf(fp, "conv.r8n");
- break;
- case LST_STRING:
- fprintf(fp, "call string class [mscorlib]System.Convert::ToString(int32)n");
- break;
- case LST_LIST:
- print_cil_box(fp, LST_INTEGER);
- fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::CreateList(object)n");
- break;
- default:
- break;
- }
- break;
- case LST_FLOATINGPOINT:
- switch(targetType)
- {
- case LST_INTEGER:
- fprintf(fp, "call int32 [LslLibrary]LindenLab.SecondLife.LslRunTime::ToInteger(float32)n");
- break;
- case LST_STRING:
- fprintf(fp, "call string [LslLibrary]LindenLab.SecondLife.LslRunTime::ToString(float32)n");
- break;
- case LST_LIST:
- print_cil_box(fp, LST_FLOATINGPOINT);
- fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::CreateList(object)n");
- break;
- default:
- break;
- }
- break;
- case LST_STRING:
- switch(targetType)
- {
- case LST_INTEGER:
- fprintf(fp, "call int32 [LslLibrary]LindenLab.SecondLife.LslRunTime::StringToInt(string)n");
- break;
- case LST_FLOATINGPOINT:
- fprintf(fp, "call float32 [LslLibrary]LindenLab.SecondLife.LslRunTime::StringToFloat(string)n");
- break;
- case LST_KEY:
- fprintf(fp, "call valuetype [ScriptTypes]LindenLab.SecondLife.Key class [LslUserScript]LindenLab.SecondLife.LslUserScript::'CreateKey'(string)n");
- break;
- case LST_LIST:
- fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::CreateList(object)n");
- break;
- case LST_VECTOR:
- fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Vector class [LslUserScript]LindenLab.SecondLife.LslUserScript::'ParseVector'(string)n");
- break;
- case LST_QUATERNION:
- fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Quaternion class [LslUserScript]LindenLab.SecondLife.LslUserScript::'ParseQuaternion'(string)n");
- break;
- default:
- break;
- }
- break;
- case LST_KEY:
- switch(targetType)
- {
- case LST_KEY:
- break;
- case LST_STRING:
- fprintf(fp, "call string [LslUserScript]LindenLab.SecondLife.LslUserScript::'ToString'(valuetype [ScriptTypes]LindenLab.SecondLife.Key)n");
- break;
- case LST_LIST:
- print_cil_box(fp, LST_KEY);
- fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::CreateList(object)n");
- break;
- default:
- break;
- }
- break;
- case LST_VECTOR:
- switch(targetType)
- {
- case LST_VECTOR:
- break;
- case LST_STRING:
- fprintf(fp, "call string [LslUserScript]LindenLab.SecondLife.LslUserScript::'ToString'(valuetype [ScriptTypes]LindenLab.SecondLife.Vector)n");
- break;
- case LST_LIST:
- print_cil_box(fp, LST_VECTOR);
- fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::CreateList(object)n");
- break;
- default:
- break;
- }
- break;
- case LST_QUATERNION:
- switch(targetType)
- {
- case LST_QUATERNION:
- break;
- case LST_STRING:
- fprintf(fp, "call string [LslUserScript]LindenLab.SecondLife.LslUserScript::'ToString'(valuetype [ScriptTypes]LindenLab.SecondLife.Quaternion)n");
- break;
- case LST_LIST:
- print_cil_box(fp, LST_QUATERNION);
- fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::CreateList(object)n");
- break;
- default:
- break;
- }
- break;
- case LST_LIST:
- switch(targetType)
- {
- case LST_LIST:
- break;
- case LST_STRING:
- fprintf(fp, "call string [LslLibrary]LindenLab.SecondLife.LslRunTime::ListToString(class [mscorlib]System.Collections.ArrayList)n");
- break;
- default:
- break;
- }
- break;
- default:
- break;
- }
- }
- static void print_cil_numeric_cast(LLFILE* fp, LSCRIPTType currentArg, LSCRIPTType otherArg)
- {
- if((currentArg == LST_INTEGER) && ((otherArg == LST_FLOATINGPOINT) || (otherArg == LST_VECTOR)))
- {
- print_cil_cast(fp, LST_INTEGER, LST_FLOATINGPOINT);
- }
- }
- static void print_cil_assignment_cast(LLFILE* fp, LSCRIPTType src,
- LSCRIPTType dest)
- {
- if (LST_STRING == src && LST_KEY == dest)
- {
- print_cil_cast(fp, src, dest);
- }
- else if(LST_KEY == src && LST_STRING == dest)
- {
- print_cil_cast(fp, src, dest);
- }
- else
- {
- print_cil_numeric_cast(fp, src, dest);
- }
- }
-
- // HACK! Babbage: should be converted to virtual on LSCRIPTSimpleAssignableType to avoid downcasts.
- LSCRIPTType get_type(LLScriptSimpleAssignable* sa)
- {
- LSCRIPTType result = LST_NULL;
- switch(sa->mType)
- {
- case LSSAT_IDENTIFIER:
- result = ((LLScriptSAIdentifier*) sa)->mIdentifier->mScopeEntry->mType;
- break;
- case LSSAT_CONSTANT:
- result = ((LLScriptSAConstant*) sa)->mConstant->mType;
- break;
- case LSSAT_VECTOR_CONSTANT:
- result = LST_VECTOR;
- break;
- case LSSAT_QUATERNION_CONSTANT:
- result = LST_QUATERNION;
- break;
- case LSSAT_LIST_CONSTANT:
- result = LST_LIST;
- break;
- default:
- result = LST_UNDEFINED;
- break;
- }
- return result;
- }
- void LLScriptSAVector::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- case LSCP_EMIT_ASSEMBLY:
- fprintf(fp, "< ");
- mEntry3->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", ");
- mEntry2->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", ");
- mEntry1->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " >");
- if (mNextp)
- {
- fprintf(fp, ", ");
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- case LSCP_TYPE:
- // vector's take floats
- mEntry3->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (!legal_assignment(LST_FLOATINGPOINT, type))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- mEntry2->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (!legal_assignment(LST_FLOATINGPOINT, type))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- mEntry1->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (!legal_assignment(LST_FLOATINGPOINT, type))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- type = LST_VECTOR;
- if (mNextp)
- {
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- case LSCP_EMIT_BYTE_CODE:
- mEntry3->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (type == LST_INTEGER)
- {
- S32 offset = chunk->mCurrentOffset - 4;
- bytestream_int2float(chunk->mCodeChunk, offset);
- }
- mEntry2->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (type == LST_INTEGER)
- {
- S32 offset = chunk->mCurrentOffset - 4;
- bytestream_int2float(chunk->mCodeChunk, offset);
- }
- mEntry1->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (type == LST_INTEGER)
- {
- S32 offset = chunk->mCurrentOffset - 4;
- bytestream_int2float(chunk->mCodeChunk, offset);
- }
- if (mNextp)
- {
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- case LSCP_LIST_BUILD_SIMPLE:
- {
- LLScriptByteCodeChunk *list = new LLScriptByteCodeChunk(FALSE);
- mEntry3->recurse(fp, tabs, tabsize, LSCP_EMIT_BYTE_CODE, ptype, prunearg, scope, type, basetype, count, list, heap, stacksize, entry, entrycount, NULL);
- if (type == LST_INTEGER)
- {
- S32 offset = list->mCurrentOffset - 4;
- bytestream_int2float(list->mCodeChunk, offset);
- }
- mEntry2->recurse(fp, tabs, tabsize, LSCP_EMIT_BYTE_CODE, ptype, prunearg, scope, type, basetype, count, list, heap, stacksize, entry, entrycount, NULL);
- if (type == LST_INTEGER)
- {
- S32 offset = list->mCurrentOffset - 4;
- bytestream_int2float(list->mCodeChunk, offset);
- }
- mEntry1->recurse(fp, tabs, tabsize, LSCP_EMIT_BYTE_CODE, ptype, prunearg, scope, type, basetype, count, list, heap, stacksize, entry, entrycount, NULL);
- if (type == LST_INTEGER)
- {
- S32 offset = list->mCurrentOffset - 4;
- bytestream_int2float(list->mCodeChunk, offset);
- }
- LLVector3 vec;
- S32 offset = 0;
- bytestream2vector(vec, list->mCodeChunk, offset);
- *ldata = new LLScriptLibData(vec);
- delete list;
- if (mNextp)
- {
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, &(*ldata)->mListp);
- }
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- // Load arguments.
- mEntry1->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if(LST_INTEGER == get_type(mEntry1))
- {
- print_cil_cast(fp, LST_INTEGER, LST_FLOATINGPOINT);
- }
- mEntry2->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if(LST_INTEGER == get_type(mEntry2))
- {
- print_cil_cast(fp, LST_INTEGER, LST_FLOATINGPOINT);
- }
- mEntry3->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if(LST_INTEGER == get_type(mEntry3))
- {
- print_cil_cast(fp, LST_INTEGER, LST_FLOATINGPOINT);
- }
-
- // Call named ctor, which leaves new Vector on stack, so it can be saved in to local or argument just like a primitive type.
- fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Vector class [LslUserScript]LindenLab.SecondLife.LslUserScript::'CreateVector'(float32, float32, float32)n");
- // Next.
- if (mNextp)
- {
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- default:
- mEntry3->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mEntry2->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mEntry1->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mNextp)
- {
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- }
- }
- S32 LLScriptSAVector::getSize()
- {
- return mEntry1->getSize() + mEntry2->getSize() + mEntry3->getSize();
- }
- void LLScriptSAQuaternion::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- case LSCP_EMIT_ASSEMBLY:
- fprintf(fp, "< ");
- mEntry4->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", ");
- mEntry3->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", ");
- mEntry2->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", ");
- mEntry1->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " >");
- if (mNextp)
- {
- fprintf(fp, ", ");
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- case LSCP_TYPE:
- // vector's take floats
- mEntry4->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (!legal_assignment(LST_FLOATINGPOINT, type))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- mEntry3->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (!legal_assignment(LST_FLOATINGPOINT, type))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- mEntry2->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (!legal_assignment(LST_FLOATINGPOINT, type))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- mEntry1->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (!legal_assignment(LST_FLOATINGPOINT, type))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- type = LST_QUATERNION;
- if (mNextp)
- {
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- case LSCP_EMIT_BYTE_CODE:
- mEntry4->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (type == LST_INTEGER)
- {
- S32 offset = chunk->mCurrentOffset - 4;
- bytestream_int2float(chunk->mCodeChunk, offset);
- }
- mEntry3->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (type == LST_INTEGER)
- {
- S32 offset = chunk->mCurrentOffset - 4;
- bytestream_int2float(chunk->mCodeChunk, offset);
- }
- mEntry2->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (type == LST_INTEGER)
- {
- S32 offset = chunk->mCurrentOffset - 4;
- bytestream_int2float(chunk->mCodeChunk, offset);
- }
- mEntry1->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (type == LST_INTEGER)
- {
- S32 offset = chunk->mCurrentOffset - 4;
- bytestream_int2float(chunk->mCodeChunk, offset);
- }
- if (mNextp)
- {
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- case LSCP_LIST_BUILD_SIMPLE:
- {
- LLScriptByteCodeChunk *list = new LLScriptByteCodeChunk(FALSE);
- mEntry4->recurse(fp, tabs, tabsize, LSCP_EMIT_BYTE_CODE, ptype, prunearg, scope, type, basetype, count, list, heap, stacksize, entry, entrycount, NULL);
- if (type == LST_INTEGER)
- {
- S32 offset = list->mCurrentOffset - 4;
- bytestream_int2float(list->mCodeChunk, offset);
- }
- mEntry3->recurse(fp, tabs, tabsize, LSCP_EMIT_BYTE_CODE, ptype, prunearg, scope, type, basetype, count, list, heap, stacksize, entry, entrycount, NULL);
- if (type == LST_INTEGER)
- {
- S32 offset = list->mCurrentOffset - 4;
- bytestream_int2float(list->mCodeChunk, offset);
- }
- mEntry2->recurse(fp, tabs, tabsize, LSCP_EMIT_BYTE_CODE, ptype, prunearg, scope, type, basetype, count, list, heap, stacksize, entry, entrycount, NULL);
- if (type == LST_INTEGER)
- {
- S32 offset = list->mCurrentOffset - 4;
- bytestream_int2float(list->mCodeChunk, offset);
- }
- mEntry1->recurse(fp, tabs, tabsize, LSCP_EMIT_BYTE_CODE, ptype, prunearg, scope, type, basetype, count, list, heap, stacksize, entry, entrycount, NULL);
- if (type == LST_INTEGER)
- {
- S32 offset = list->mCurrentOffset - 4;
- bytestream_int2float(list->mCodeChunk, offset);
- }
- LLQuaternion quat;
- S32 offset = 0;
- bytestream2quaternion(quat, list->mCodeChunk, offset);
- *ldata = new LLScriptLibData(quat);
- delete list;
- if (mNextp)
- {
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, &(*ldata)->mListp);
- }
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- // Load arguments.
- mEntry1->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if(LST_INTEGER == get_type(mEntry1))
- {
- print_cil_cast(fp, LST_INTEGER, LST_FLOATINGPOINT);
- }
- mEntry2->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if(LST_INTEGER == get_type(mEntry2))
- {
- print_cil_cast(fp, LST_INTEGER, LST_FLOATINGPOINT);
- }
- mEntry3->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if(LST_INTEGER == get_type(mEntry3))
- {
- print_cil_cast(fp, LST_INTEGER, LST_FLOATINGPOINT);
- }
- mEntry4->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if(LST_INTEGER == get_type(mEntry4))
- {
- print_cil_cast(fp, LST_INTEGER, LST_FLOATINGPOINT);
- }
-
- // Call named ctor, which leaves new Vector on stack, so it can be saved in to local or argument just like a primitive type.
- fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Quaternion class [LslUserScript]LindenLab.SecondLife.LslUserScript::'CreateQuaternion'(float32, float32, float32, float32)n");
- // Next.
- if (mNextp)
- {
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- default:
- mEntry4->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mEntry3->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mEntry2->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mEntry1->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mNextp)
- {
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- }
- }
- S32 LLScriptSAQuaternion::getSize()
- {
- return mEntry1->getSize() + mEntry2->getSize() + mEntry3->getSize() + mEntry4->getSize();
- }
- void LLScriptSAList::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- case LSCP_EMIT_ASSEMBLY:
- fprintf(fp, "[ ");
- if (mEntryList)
- mEntryList->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " ]");
- if (mNextp)
- {
- fprintf(fp, ", ");
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- case LSCP_TYPE:
- if (mEntryList)
- mEntryList->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- type = LST_LIST;
- if (mNextp)
- {
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
- LLScriptLibData *list_data = new LLScriptLibData;
- list_data->mType = LST_LIST;
- if (mEntryList)
- mEntryList->recurse(fp, tabs, tabsize, LSCP_LIST_BUILD_SIMPLE, ptype, prunearg, scope, type, basetype, count, chunk, NULL, stacksize, entry, entrycount, &(list_data->mListp));
- U8 *temp;
- chunk->addInteger(heap->mCurrentOffset + 1);
- S32 size = lsa_create_data_block(&temp, list_data, heap->mCurrentOffset);
- heap->addBytes(temp, size);
- delete list_data;
- delete [] temp;
- if (mNextp)
- {
- mNextp->recurse(fp, tabs, tabsize, LSCP_EMIT_BYTE_CODE, ptype, prunearg, scope, type, basetype, count, chunk, NULL, stacksize, entry, entrycount, NULL);
- }
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- {
- // Create list.
- fprintf(fp, "call class [mscorlib]System.Collections.ArrayList [LslUserScript]LindenLab.SecondLife.LslUserScript::CreateList()n");
- // Add elements.
- LLScriptSimpleAssignable* current_entry = mEntryList;
- LLScriptSimpleAssignable* next_entry = NULL;
- while(NULL != current_entry)
- {
- next_entry = current_entry->mNextp;
- // Null mNextp pointer, so only current list element is processed.
- current_entry->mNextp = NULL;
- current_entry->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- // Restore mNextp pointer.
- current_entry->mNextp = next_entry;
- // Box element and store in list.
- print_cil_box(fp, get_type(current_entry));
- fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::Append(class [mscorlib]System.Collections.ArrayList, object)n");
- // Process next element.
- current_entry = next_entry;
- }
- // Process next list.
- if (mNextp)
- {
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- }
- break;
- default:
- if (mEntryList)
- mEntryList->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, ldata);
- if (mNextp)
- {
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, ldata);
- }
- break;
- }
- }
- S32 LLScriptSAList::getSize()
- {
- return mEntryList->getSize();
- }
- void LLScriptGlobalVariable::addGlobal(LLScriptGlobalVariable *global)
- {
- if (mNextp)
- {
- global->mNextp = mNextp;
- }
- mNextp = global;
- }
- void LLScriptGlobalVariable::gonext(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- if (mNextp)
- {
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- default:
- if (mNextp)
- {
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- }
- }
- // Push initialised variable of type on to stack.
- static void print_cil_init_variable(LLFILE* fp, LSCRIPTType type)
- {
- switch(type)
- {
- case LST_INTEGER:
- fprintf(fp, "ldc.i4.0n");
- break;
- case LST_FLOATINGPOINT:
- fprintf(fp, "ldc.r8 0n");
- break;
- case LST_STRING:
- fprintf(fp, "ldstr ""n");
- break;
- case LST_KEY:
- fprintf(fp, "ldstr ""n");
- fprintf(fp, "call valuetype [ScriptTypes]LindenLab.SecondLife.Key class [LslUserScript]LindenLab.SecondLife.LslUserScript::'CreateKey'(string)n");
- break;
- case LST_VECTOR:
- fprintf(fp, "ldc.r8 0n");
- fprintf(fp, "ldc.r8 0n");
- fprintf(fp, "ldc.r8 0n");
- fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Vector class [LslUserScript]LindenLab.SecondLife.LslUserScript::'CreateVector'(float32, float32, float32)n");
- break;
- case LST_QUATERNION:
- fprintf(fp, "ldc.r8 0n");
- fprintf(fp, "ldc.r8 0n");
- fprintf(fp, "ldc.r8 0n");
- fprintf(fp, "ldc.r8 1n");
- fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Quaternion class [LslUserScript]LindenLab.SecondLife.LslUserScript::'CreateQuaternion'(float32, float32, float32, float32)n");
- break;
- case LST_LIST:
- fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::CreateList()n");
- break;
- default:
- break;
- }
- }
- void LLScriptGlobalVariable::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- mType->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp,"t");
- mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mAssignable)
- {
- fprintf(fp, " = ");
- mAssignable->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- fprintf(fp, ";n");
- break;
- case LSCP_EMIT_ASSEMBLY:
- mType->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp,"t");
- mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mAssignable)
- {
- fprintf(fp, " = ");
- mAssignable->recurse(fp, tabs, tabsize, LSCP_PRETTY_PRINT, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "n");
- fprintf(fp, "Offset: %d Type: %dn", mIdentifier->mScopeEntry->mOffset, (S32)LSCRIPTTypeByte[mType->mType]);
- }
- else
- {
- fprintf(fp, "n");
- fprintf(fp, "Offset: %d Type: %dn", mIdentifier->mScopeEntry->mOffset, (S32)LSCRIPTTypeByte[mType->mType]);
- }
- break;
- case LSCP_SCOPE_PASS1:
- if (scope->checkEntry(mIdentifier->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- if (mAssignable)
- {
- mAssignable->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- // this needs to go after expression decent to make sure that we don't add ourselves or something silly
- mIdentifier->mScopeEntry = scope->addEntry(mIdentifier->mName, LIT_GLOBAL, mType->mType);
- if (mIdentifier->mScopeEntry && mAssignable)
- mIdentifier->mScopeEntry->mAssignable = mAssignable;
- }
- break;
- case LSCP_TYPE:
- // if the variable has an assignable, it must assignable to the variable's type
- if (mAssignable)
- {
- mAssignable->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mAssignableType = type;
- if (!legal_assignment(mType->mType, mAssignableType))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- }
- break;
- case LSCP_RESOURCE:
- {
- // we're just tryng to determine how much space the variable needs
- // it also includes the name of the variable as well as the type
- // plus 4 bytes of offset from it's apparent address to the actual data
- #ifdef LSL_INCLUDE_DEBUG_INFO
- count += strlen(mIdentifier->mName) + 1 + 1 + 4;
- #else
- count += 1 + 1 + 4;
- #endif
- mIdentifier->mScopeEntry->mOffset = (S32)count;
- mIdentifier->mScopeEntry->mSize = mType->getSize();
- count += mIdentifier->mScopeEntry->mSize;
- mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
- // order for global variables
- // 0 - 4: offset to actual data
- S32 offsetoffset = chunk->mCurrentOffset;
- S32 offsetdelta = 0;
- chunk->addBytes(4);
- // type
- char vtype;
- vtype = LSCRIPTTypeByte[mType->mType];
- chunk->addBytes(&vtype, 1);
- // null terminated name
- #ifdef LSL_INCLUDE_DEBUG_INFO
- chunk->addBytes(mIdentifier->mName, strlen(mIdentifier->mName) + 1);
- #else
- chunk->addBytes(1);
- #endif
- // put correct offset delta in
- offsetdelta = chunk->mCurrentOffset - offsetoffset;
- integer2bytestream(chunk->mCodeChunk, offsetoffset, offsetdelta);
- // now we need space for the variable itself
- LLScriptByteCodeChunk *value = new LLScriptByteCodeChunk(FALSE);
- if (mAssignable)
- {
- mAssignable->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, value, heap, stacksize, entry, entrycount, NULL);
- // need to put sneaky type conversion here
- if (mAssignableType != mType->mType)
- {
- // the only legal case that is a problem is int->float
- if (mType->mType == LST_FLOATINGPOINT && mAssignableType == LST_INTEGER)
- {
- S32 offset = value->mCurrentOffset - 4;
- bytestream_int2float(value->mCodeChunk, offset);
- }
- }
- }
- else
- {
- if ( (mType->mType == LST_STRING)
- ||(mType->mType == LST_KEY))
- {
- // string and keys (even empty ones) need heap entries
- chunk->addInteger(heap->mCurrentOffset + 1);
- LLScriptLibData *data = new LLScriptLibData("");
- U8 *temp;
- S32 size = lsa_create_data_block(&temp, data, heap->mCurrentOffset);
- heap->addBytes(temp, size);
- delete [] temp;
- delete data;
- }
- else if (mType->mType == LST_LIST)
- {
- chunk->addInteger(heap->mCurrentOffset + 1);
- LLScriptLibData *data = new LLScriptLibData;
- data->mType = LST_LIST;
- U8 *temp;
- S32 size = lsa_create_data_block(&temp, data, heap->mCurrentOffset);
- heap->addBytes(temp, size);
- delete [] temp;
- delete data;
- }
- else if (mType->mType == LST_QUATERNION)
- {
- chunk->addFloat(1.f);
- chunk->addFloat(0.f);
- chunk->addFloat(0.f);
- chunk->addFloat(0.f);
- }
- else
- {
- value->addBytes(LSCRIPTDataSize[mType->mType]);
- }
- }
- chunk->addBytes(value->mCodeChunk, value->mCurrentOffset);
- delete value;
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- // Initialisation inside ctor.
- fprintf(fp, "ldarg.0n");
- if (mAssignable)
- {
- // Initialise to value.
- mAssignable->recurse(fp, tabs, tabsize, LSCP_EMIT_CIL_ASSEMBLY,
- ptype, prunearg, scope, type, basetype,
- count, chunk, heap, stacksize, entry,
- entrycount, NULL);
- print_cil_assignment_cast(fp, get_type(mAssignable), mType->mType);
- }
- else
- {
- // Initialise to zero.
- print_cil_init_variable(fp, mType->mType);
- }
- // Store value.
- fprintf(fp, "stfld ");
- mType->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp," %s::", gScriptp->getClassName());
- mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "n");
- break;
- default:
- mType->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mAssignable)
- {
- mAssignable->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- S32 LLScriptGlobalVariable::getSize()
- {
- S32 return_size;
- return_size = mType->getSize();
- return return_size;
- }
- void LLScriptEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- fprintf(fp, "Event Base Class -- should never get here!n");
- }
- S32 LLScriptEvent::getSize()
- {
- printf("Event Base Class -- should never get here!n");
- return 0;
- }
- static void checkForDuplicateHandler(LLFILE *fp, LLScriptFilePosition *pos,
- LLScriptScope *scope,
- const char* name)
- {
- LLScriptScope *parent = scope->mParentScope;
- if (parent->checkEntry((char*)name))
- {
- gErrorToText.writeError(fp, pos, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- parent->addEntry(((char*)name), LIT_HANDLER, LST_NULL);
- }
- }
- void LLScriptStateEntryEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "state_entry()n");
- break;
- case LSCP_EMIT_ASSEMBLY:
- fprintf(fp, "state_entry()n");
- break;
- case LSCP_SCOPE_PASS1:
- checkForDuplicateHandler(fp, this, scope, "state_entry");
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
- #ifdef LSL_INCLUDE_DEBUG_INFO
- char name[] = "state_entry";
- chunk->addBytes(name, strlen(name) + 1);
- #endif
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- fprintf(fp, "state_entry()");
- break;
- default:
- break;
- }
- }
- S32 LLScriptStateEntryEvent::getSize()
- {
- return 0;
- }
- void LLScriptStateExitEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "state_exit()n");
- break;
- case LSCP_SCOPE_PASS1:
- checkForDuplicateHandler(fp, this, scope, "state_exit");
- break;
- case LSCP_EMIT_ASSEMBLY:
- fprintf(fp, "state_exit()n");
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
- #ifdef LSL_INCLUDE_DEBUG_INFO
- char name[] = "state_exit";
- chunk->addBytes(name, strlen(name) + 1);
- #endif
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- fprintf(fp, "state_exit()");
- break;
- default:
- break;
- }
- }
- S32 LLScriptStateExitEvent::getSize()
- {
- return 0;
- }
- void LLScriptTouchStartEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- case LSCP_EMIT_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "touch_start( integer ");
- mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )n");
- break;
- break;
- case LSCP_SCOPE_PASS1:
- checkForDuplicateHandler(fp, this, scope, "touch_start");
- if (scope->checkEntry(mCount->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mCount->mScopeEntry = scope->addEntry(mCount->mName, LIT_VARIABLE, LST_INTEGER);
- }
- break;
- case LSCP_RESOURCE:
- {
- // we're just tryng to determine how much space the variable needs
- if (mCount->mScopeEntry)
- {
- mCount->mScopeEntry->mOffset = (S32)count;
- mCount->mScopeEntry->mSize = 4;
- count += mCount->mScopeEntry->mSize;
- }
- }
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
- #ifdef LSL_INCLUDE_DEBUG_INFO
- char name[] = "touch_start";
- chunk->addBytes(name, strlen(name) + 1);
- chunk->addBytes(mCount->mName, strlen(mCount->mName) + 1);
- #endif
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "touch_start( int32 ");
- mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )");
- break;
- break;
- default:
- mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- }
- S32 LLScriptTouchStartEvent::getSize()
- {
- // integer = 4
- return 4;
- }
- void LLScriptTouchEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- case LSCP_EMIT_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "touch( integer ");
- mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )n");
- break;
- break;
- case LSCP_SCOPE_PASS1:
- checkForDuplicateHandler(fp, this, scope, "touch");
- if (scope->checkEntry(mCount->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mCount->mScopeEntry = scope->addEntry(mCount->mName, LIT_VARIABLE, LST_INTEGER);
- }
- break;
- case LSCP_RESOURCE:
- {
- // we're just tryng to determine how much space the variable needs
- if (mCount->mScopeEntry)
- {
- mCount->mScopeEntry->mOffset = (S32)count;
- mCount->mScopeEntry->mSize = 4;
- count += mCount->mScopeEntry->mSize;
- }
- }
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
- #ifdef LSL_INCLUDE_DEBUG_INFO
- char name[] = "touch";
- chunk->addBytes(name, strlen(name) + 1);
- chunk->addBytes(mCount->mName, strlen(mCount->mName) + 1);
- #endif
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "touch( int32 ");
- mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )");
- break;
- break;
- default:
- mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- }
- S32 LLScriptTouchEvent::getSize()
- {
- // integer = 4
- return 4;
- }
- void LLScriptTouchEndEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- case LSCP_EMIT_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "touch_end( integer ");
- mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )n");
- break;
- break;
- case LSCP_SCOPE_PASS1:
- checkForDuplicateHandler(fp, this, scope, "touch_end");
- if (scope->checkEntry(mCount->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mCount->mScopeEntry = scope->addEntry(mCount->mName, LIT_VARIABLE, LST_INTEGER);
- }
- break;
- case LSCP_RESOURCE:
- {
- // we're just tryng to determine how much space the variable needs
- if (mCount->mScopeEntry)
- {
- mCount->mScopeEntry->mOffset = (S32)count;
- mCount->mScopeEntry->mSize = 4;
- count += mCount->mScopeEntry->mSize;
- }
- }
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
- #ifdef LSL_INCLUDE_DEBUG_INFO
- char name[] = "touch_end";
- chunk->addBytes(name, strlen(name) + 1);
- chunk->addBytes(mCount->mName, strlen(mCount->mName) + 1);
- #endif
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "touch_end( int32 ");
- mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )");
- break;
- break;
- default:
- mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- }
- S32 LLScriptTouchEndEvent::getSize()
- {
- // integer = 4
- return 4;
- }
- void LLScriptCollisionStartEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- case LSCP_EMIT_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "collision_start( integer ");
- mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )n");
- break;
- break;
- case LSCP_SCOPE_PASS1:
- checkForDuplicateHandler(fp, this, scope, "collision_start");
- if (scope->checkEntry(mCount->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mCount->mScopeEntry = scope->addEntry(mCount->mName, LIT_VARIABLE, LST_INTEGER);
- }
- break;
- case LSCP_RESOURCE:
- {
- // we're just tryng to determine how much space the variable needs
- if (mCount->mScopeEntry)
- {
- mCount->mScopeEntry->mOffset = (S32)count;
- mCount->mScopeEntry->mSize = 4;
- count += mCount->mScopeEntry->mSize;
- }
- }
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
- #ifdef LSL_INCLUDE_DEBUG_INFO
- char name[] = "collision_start";
- chunk->addBytes(name, (S32)strlen(name) + 1);
- chunk->addBytes(mCount->mName, (S32)strlen(mCount->mName) + 1);
- #endif
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "collision_start( int32 ");
- mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )");
- break;
- default:
- mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- }
- S32 LLScriptCollisionStartEvent::getSize()
- {
- // integer = 4
- return 4;
- }
- void LLScriptCollisionEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- case LSCP_EMIT_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "collision( integer ");
- mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )n");
- break;
- break;
- case LSCP_SCOPE_PASS1:
- checkForDuplicateHandler(fp, this, scope, "collision");
- if (scope->checkEntry(mCount->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mCount->mScopeEntry = scope->addEntry(mCount->mName, LIT_VARIABLE, LST_INTEGER);
- }
- break;
- case LSCP_RESOURCE:
- {
- // we're just tryng to determine how much space the variable needs
- if (mCount->mScopeEntry)
- {
- mCount->mScopeEntry->mOffset = (S32)count;
- mCount->mScopeEntry->mSize = 4;
- count += mCount->mScopeEntry->mSize;
- }
- }
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
- #ifdef LSL_INCLUDE_DEBUG_INFO
- char name[] = "collision";
- chunk->addBytes(name, strlen(name) + 1);
- chunk->addBytes(mCount->mName, strlen(mCount->mName) + 1);
- #endif
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- fprintf(fp, "collision( int32 ");
- mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )");
- break;
- default:
- mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- }
- S32 LLScriptCollisionEvent::getSize()
- {
- // integer = 4
- return 4;
- }
- void LLScriptCollisionEndEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- case LSCP_EMIT_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "collision_end( integer ");
- mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )n");
- break;
- break;
- case LSCP_SCOPE_PASS1:
- checkForDuplicateHandler(fp, this, scope, "collision_end");
- if (scope->checkEntry(mCount->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mCount->mScopeEntry = scope->addEntry(mCount->mName, LIT_VARIABLE, LST_INTEGER);
- }
- break;
- case LSCP_RESOURCE:
- {
- // we're just tryng to determine how much space the variable needs
- if (mCount->mScopeEntry)
- {
- mCount->mScopeEntry->mOffset = (S32)count;
- mCount->mScopeEntry->mSize = 4;
- count += mCount->mScopeEntry->mSize;
- }
- }
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
- #ifdef LSL_INCLUDE_DEBUG_INFO
- char name[] = "collision_end";
- chunk->addBytes(name, strlen(name) + 1);
- chunk->addBytes(mCount->mName, strlen(mCount->mName) + 1);
- #endif
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "collision_end( int32 ");
- mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )");
- break;
- default:
- mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- }
- S32 LLScriptCollisionEndEvent::getSize()
- {
- // integer = 4
- return 4;
- }
- void LLScriptLandCollisionStartEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- case LSCP_EMIT_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "land_collision_start( vector ");
- mPosition->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )n");
- break;
- case LSCP_SCOPE_PASS1:
- checkForDuplicateHandler(fp, this, scope, "land_collision_start");
- if (scope->checkEntry(mPosition->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mPosition->mScopeEntry = scope->addEntry(mPosition->mName, LIT_VARIABLE, LST_VECTOR);
- }
- break;
- case LSCP_RESOURCE:
- {
- // we're just tryng to determine how much space the variable needs
- if (mPosition->mScopeEntry)
- {
- mPosition->mScopeEntry->mOffset = (S32)count;
- mPosition->mScopeEntry->mSize = 12;
- count += mPosition->mScopeEntry->mSize;
- }
- }
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
- #ifdef LSL_INCLUDE_DEBUG_INFO
- char name[] = "land_collision_start";
- chunk->addBytes(name, strlen(name) + 1);
- chunk->addBytes(mPosition->mName, strlen(mPosition->mName) + 1);
- #endif
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "land_collision_start( class [ScriptTypes]LindenLab.SecondLife.Vector ");
- mPosition->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )");
- break;
- default:
- mPosition->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- }
- S32 LLScriptLandCollisionStartEvent::getSize()
- {
- // vector = 12
- return 12;
- }
- void LLScriptLandCollisionEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- case LSCP_EMIT_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "land_collision( vector ");
- mPosition->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )n");
- break;
- case LSCP_SCOPE_PASS1:
- checkForDuplicateHandler(fp, this, scope, "land_collision");
- if (scope->checkEntry(mPosition->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mPosition->mScopeEntry = scope->addEntry(mPosition->mName, LIT_VARIABLE, LST_VECTOR);
- }
- break;
- case LSCP_RESOURCE:
- {
- // we're just tryng to determine how much space the variable needs
- if (mPosition->mScopeEntry)
- {
- mPosition->mScopeEntry->mOffset = (S32)count;
- mPosition->mScopeEntry->mSize = 12;
- count += mPosition->mScopeEntry->mSize;
- }
- }
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
- #ifdef LSL_INCLUDE_DEBUG_INFO
- char name[] = "land_collision";
- chunk->addBytes(name, strlen(name) + 1);
- chunk->addBytes(mPosition->mName, strlen(mPosition->mName) + 1);
- #endif
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "land_collision( class [ScriptTypes]LindenLab.SecondLife.Vector ");
- mPosition->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )");
- break;
- default:
- mPosition->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- }
- S32 LLScriptLandCollisionEvent::getSize()
- {
- // vector = 12
- return 12;
- }
- void LLScriptLandCollisionEndEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- case LSCP_EMIT_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "land_collision_end( vector ");
- mPosition->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )n");
- break;
- case LSCP_SCOPE_PASS1:
- checkForDuplicateHandler(fp, this, scope, "land_collision_end");
- if (scope->checkEntry(mPosition->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mPosition->mScopeEntry = scope->addEntry(mPosition->mName, LIT_VARIABLE, LST_VECTOR);
- }
- break;
- case LSCP_RESOURCE:
- {
- // we're just tryng to determine how much space the variable needs
- if (mPosition->mScopeEntry)
- {
- mPosition->mScopeEntry->mOffset = (S32)count;
- mPosition->mScopeEntry->mSize = 12;
- count += mPosition->mScopeEntry->mSize;
- }
- }
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
- #ifdef LSL_INCLUDE_DEBUG_INFO
- char name[] = "land_collision_end";
- chunk->addBytes(name, strlen(name) + 1);
- chunk->addBytes(mPosition->mName, strlen(mPosition->mName) + 1);
- #endif
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "land_collision_end( class [ScriptTypes]LindenLab.SecondLife.Vector ");
- mPosition->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )");
- break;
- default:
- mPosition->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- }
- S32 LLScriptLandCollisionEndEvent::getSize()
- {
- // vector = 12
- return 12;
- }
- void LLScriptInventoryEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- case LSCP_EMIT_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "changed( integer ");
- mChange->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )n");
- break;
- case LSCP_SCOPE_PASS1:
- checkForDuplicateHandler(fp, this, scope, "changed");
- if (scope->checkEntry(mChange->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mChange->mScopeEntry = scope->addEntry(mChange->mName, LIT_VARIABLE, LST_INTEGER);
- }
- break;
- case LSCP_RESOURCE:
- {
- // we're just tryng to determine how much space the variable needs
- if (mChange->mScopeEntry)
- {
- mChange->mScopeEntry->mOffset = (S32)count;
- mChange->mScopeEntry->mSize = 4;
- count += mChange->mScopeEntry->mSize;
- }
- }
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
- #ifdef LSL_INCLUDE_DEBUG_INFO
- char name[] = "changed";
- chunk->addBytes(name, strlen(name) + 1);
- chunk->addBytes(mChange->mName, strlen(mChange->mName) + 1);
- #endif
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "changed( int32 ");
- mChange->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )");
- break;
- default:
- mChange->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- }
- S32 LLScriptInventoryEvent::getSize()
- {
- // integer = 4
- return 4;
- }
- void LLScriptAttachEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- case LSCP_EMIT_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "attach( key ");
- mAttach->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )n");
- break;
- case LSCP_SCOPE_PASS1:
- checkForDuplicateHandler(fp, this, scope, "attach");
- if (scope->checkEntry(mAttach->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mAttach->mScopeEntry = scope->addEntry(mAttach->mName, LIT_VARIABLE, LST_KEY);
- }
- break;
- case LSCP_RESOURCE:
- {
- // we're just tryng to determine how much space the variable needs
- if (mAttach->mScopeEntry)
- {
- mAttach->mScopeEntry->mOffset = (S32)count;
- mAttach->mScopeEntry->mSize = 4;
- count += mAttach->mScopeEntry->mSize;
- }
- }
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
- #ifdef LSL_INCLUDE_DEBUG_INFO
- char name[] = "attach";
- chunk->addBytes(name, strlen(name) + 1);
- chunk->addBytes(mAttach->mName, strlen(mAttach->mName) + 1);
- #endif
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "attach( valuetype [ScriptTypes]LindenLab.SecondLife.Key ");
- mAttach->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )n");
- break;
- default:
- mAttach->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- }
- S32 LLScriptAttachEvent::getSize()
- {
- // key = 4
- return 4;
- }
- void LLScriptDataserverEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- case LSCP_EMIT_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "dataserver( key ");
- mID->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", string ");
- mData->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )n");
- break;
- case LSCP_SCOPE_PASS1:
- checkForDuplicateHandler(fp, this, scope, "dataserver");
- if (scope->checkEntry(mID->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mID->mScopeEntry = scope->addEntry(mID->mName, LIT_VARIABLE, LST_KEY);
- }
- if (scope->checkEntry(mData->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mData->mScopeEntry = scope->addEntry(mData->mName, LIT_VARIABLE, LST_STRING);
- }
- break;
- case LSCP_RESOURCE:
- {
- // we're just tryng to determine how much space the variable needs
- if (mID->mScopeEntry)
- {
- mID->mScopeEntry->mOffset = (S32)count;
- mID->mScopeEntry->mSize = 4;
- count += mID->mScopeEntry->mSize;
- mData->mScopeEntry->mOffset = (S32)count;
- mData->mScopeEntry->mSize = 4;
- count += mData->mScopeEntry->mSize;
- }
- }
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
- #ifdef LSL_INCLUDE_DEBUG_INFO
- char name[] = "dataserver";
- chunk->addBytes(name, strlen(name) + 1);
- chunk->addBytes(mID->mName, strlen(mID->mName) + 1);
- chunk->addBytes(mData->mName, strlen(mData->mName) + 1);
- #endif
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "dataserver( valuetype [ScriptTypes]LindenLab.SecondLife.Key ");
- mID->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", string ");
- mData->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )");
- break;
- default:
- mID->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mData->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- }
- S32 LLScriptDataserverEvent::getSize()
- {
- // key + string = 8
- return 8;
- }
- void LLScriptTimerEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "timer()n");
- break;
- case LSCP_EMIT_ASSEMBLY:
- fprintf(fp, "timer()n");
- break;
- case LSCP_SCOPE_PASS1:
- checkForDuplicateHandler(fp, this, scope, "timer");
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
- #ifdef LSL_INCLUDE_DEBUG_INFO
- char name[] = "timer";
- chunk->addBytes(name, strlen(name) + 1);
- #endif
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- fprintf(fp, "timer()");
- break;
- default:
- break;
- }
- }
- S32 LLScriptTimerEvent::getSize()
- {
- return 0;
- }
- void LLScriptMovingStartEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- case LSCP_EMIT_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "moving_start()n");
- break;
- case LSCP_SCOPE_PASS1:
- checkForDuplicateHandler(fp, this, scope, "moving_start");
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
- #ifdef LSL_INCLUDE_DEBUG_INFO
- char name[] = "moving_start";
- chunk->addBytes(name, strlen(name) + 1);
- #endif
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- fprintf(fp, "moving_start()");
- break;
- default:
- break;
- }
- }
- S32 LLScriptMovingStartEvent::getSize()
- {
- return 0;
- }
- void LLScriptMovingEndEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- case LSCP_EMIT_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "moving_end()n");
- break;
- case LSCP_SCOPE_PASS1:
- checkForDuplicateHandler(fp, this, scope, "moving_end");
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
- #ifdef LSL_INCLUDE_DEBUG_INFO
- char name[] = "moving_end";
- chunk->addBytes(name, strlen(name) + 1);
- #endif
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- fprintf(fp, "moving_end()");
- break;
- default:
- break;
- }
- }
- S32 LLScriptMovingEndEvent::getSize()
- {
- return 0;
- }
- void LLScriptRTPEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- case LSCP_EMIT_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "chat( integer ");
- mRTPermissions->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )n");
- break;
- case LSCP_SCOPE_PASS1:
- checkForDuplicateHandler(fp, this, scope, "run_time_perms");
- if (scope->checkEntry(mRTPermissions->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mRTPermissions->mScopeEntry = scope->addEntry(mRTPermissions->mName, LIT_VARIABLE, LST_INTEGER);
- }
- break;
- case LSCP_RESOURCE:
- {
- // we're just tryng to determine how much space the variable needs
- if (mRTPermissions->mScopeEntry)
- {
- mRTPermissions->mScopeEntry->mOffset = (S32)count;
- mRTPermissions->mScopeEntry->mSize = 4;
- count += mRTPermissions->mScopeEntry->mSize;
- }
- }
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
- #ifdef LSL_INCLUDE_DEBUG_INFO
- char name[] = "chat";
- chunk->addBytes(name, strlen(name) + 1);
- chunk->addBytes(mRTPermissions->mName, strlen(mRTPermissions->mName) + 1);
- #endif
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- // NOTE: Not replicating LSL2 bug by calling RTP event hander "chat"
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "run_time_perms( int32 ");
- mRTPermissions->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )");
- break;
- default:
- mRTPermissions->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- }
- S32 LLScriptRTPEvent::getSize()
- {
- // integer = 4
- return 4;
- }
- void LLScriptChatEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- case LSCP_EMIT_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "chat( integer ");
- mChannel->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", string ");
- mName->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", key ");
- mID->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", string ");
- mMessage->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )n");
- break;
- case LSCP_SCOPE_PASS1:
- checkForDuplicateHandler(fp, this, scope, "listen"); // note: this is actually listen in lsl source
- if (scope->checkEntry(mChannel->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mChannel->mScopeEntry = scope->addEntry(mChannel->mName, LIT_VARIABLE, LST_INTEGER);
- }
- if (scope->checkEntry(mName->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mName->mScopeEntry = scope->addEntry(mName->mName, LIT_VARIABLE, LST_STRING);
- }
- if (scope->checkEntry(mID->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mID->mScopeEntry = scope->addEntry(mID->mName, LIT_VARIABLE, LST_KEY);
- }
- if (scope->checkEntry(mMessage->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mMessage->mScopeEntry = scope->addEntry(mMessage->mName, LIT_VARIABLE, LST_STRING);
- }
- break;
- case LSCP_RESOURCE:
- {
- // we're just tryng to determine how much space the variable needs
- if (mName->mScopeEntry)
- {
- mChannel->mScopeEntry->mOffset = (S32)count;
- mChannel->mScopeEntry->mSize = 4;
- count += mChannel->mScopeEntry->mSize;
- mName->mScopeEntry->mOffset = (S32)count;
- mName->mScopeEntry->mSize = 4;
- count += mName->mScopeEntry->mSize;
- mID->mScopeEntry->mOffset = (S32)count;
- mID->mScopeEntry->mSize = 4;
- count += mID->mScopeEntry->mSize;
- mMessage->mScopeEntry->mOffset = (S32)count;
- mMessage->mScopeEntry->mSize = 4;
- count += mMessage->mScopeEntry->mSize;
- }
- }
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
- #ifdef LSL_INCLUDE_DEBUG_INFO
- char name[] = "chat";
- chunk->addBytes(name, strlen(name) + 1);
- chunk->addBytes(mChannel->mName, strlen(mChannel->mName) + 1);
- chunk->addBytes(mName->mName, strlen(mName->mName) + 1);
- chunk->addBytes(mID->mName, strlen(mID->mName) + 1);
- chunk->addBytes(mMessage->mName, strlen(mMessage->mName) + 1);
- #endif
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "chat( int32 ");
- mChannel->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", string ");
- mName->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", valuetype [ScriptTypes]LindenLab.SecondLife.Key ");
- mID->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", string ");
- mMessage->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )");
- break;
- default:
- mChannel->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mName->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mID->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mMessage->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- }
- S32 LLScriptChatEvent::getSize()
- {
- // integer + key + string + string = 16
- return 16;
- }
- void LLScriptSensorEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- case LSCP_EMIT_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "sensor( integer ");
- mNumber->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )n");
- break;
- case LSCP_SCOPE_PASS1:
- checkForDuplicateHandler(fp, this, scope, "sensor");
- if (scope->checkEntry(mNumber->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mNumber->mScopeEntry = scope->addEntry(mNumber->mName, LIT_VARIABLE, LST_INTEGER);
- }
- break;
- case LSCP_RESOURCE:
- {
- // we're just tryng to determine how much space the variable needs
- if (mNumber->mScopeEntry)
- {
- mNumber->mScopeEntry->mOffset = (S32)count;
- mNumber->mScopeEntry->mSize = 4;
- count += mNumber->mScopeEntry->mSize;
- }
- }
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
- #ifdef LSL_INCLUDE_DEBUG_INFO
- char name[] = "sensor";
- chunk->addBytes(name, strlen(name) + 1);
- chunk->addBytes(mNumber->mName, strlen(mNumber->mName) + 1);
- #endif
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "sensor( int32 ");