lscript_tree.cpp
上传用户:king477883
上传日期:2021-03-01
资源大小:9553k
文件大小:399k
- if (!legal_binary_expression(mReturnType, mLeftType, mRightType, mType))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- type = mReturnType;
- }
- break;
- case LSCP_TO_STACK:
- {
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- chunk->addByte(LSCRIPTOpCodes[LOPC_DIV]);
- operation2stack(chunk, mReturnType, mRightType);
- store2stack(this, mLValue, chunk, mReturnType);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- {
- print_cil_load_address(fp, mLValue, entry);
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_numeric_cast(fp, mRightSide->mReturnType, mLValue->mReturnType);
- mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_numeric_cast(fp, mLValue->mReturnType, mRightSide->mReturnType);
- print_cil_div(fp, mLValue->mReturnType, mRightSide->mReturnType);
- print_cil_assignment(fp, mLValue, entry);
- }
- break;
- default:
- mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- S32 LLScriptDivAssignment::getSize()
- {
- return 0;
- }
- static void print_cil_mod(LLFILE* fp, LSCRIPTType left_type, LSCRIPTType right_type)
- {
- switch(left_type)
- {
- case LST_INTEGER:
- // Numeric remainder.
- fprintf(fp, "call int32 [LslUserScript]LindenLab.SecondLife.LslUserScript::Modulo(int32, int32)n");
- break;
-
- case LST_VECTOR:
- // Vector cross product.
- fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Vector class [LslUserScript]LindenLab.SecondLife.LslUserScript::'Modulo'(class [ScriptTypes]LindenLab.SecondLife.Vector, class [ScriptTypes]LindenLab.SecondLife.Vector)n");
- break;
- default:
- // Error.
- break;
- }
- }
- void LLScriptModAssignment::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " %%= ");
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_EMIT_ASSEMBLY:
- {
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "MOD %s, %sn", LSCRIPTTypeNames[mRightType], LSCRIPTTypeNames[mLeftType]);
- print_assignment(fp, mLValue);
- }
- break;
- case LSCP_TYPE:
- {
- mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftType = type;
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightType = type;
- if (!legal_binary_expression(mReturnType, mLeftType, mRightType, mType))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- type = mReturnType;
- }
- break;
- case LSCP_TO_STACK:
- {
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- chunk->addByte(LSCRIPTOpCodes[LOPC_MOD]);
- operation2stack(chunk, mReturnType, mRightType);
- store2stack(this, mLValue, chunk, mReturnType);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- {
- print_cil_load_address(fp, mLValue, entry);
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_mod(fp, mLValue->mReturnType, mRightSide->mReturnType);
- print_cil_assignment(fp, mLValue, entry);
- }
- break;
- default:
- mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- S32 LLScriptModAssignment::getSize()
- {
- return 0;
- }
- static void print_cil_eq(LLFILE* fp, LSCRIPTType left_type, LSCRIPTType right_type)
- {
-
- switch(right_type)
- {
- case LST_INTEGER:
- case LST_FLOATINGPOINT:
- // Numeric equality.
- fprintf(fp, "ceqn");
- break;
- case LST_STRING:
- // NOTE: babbage: strings and keys can be compared, so a cast
- // may be required
- print_cil_cast(fp, left_type, right_type);
- // String equality.
- fprintf(fp, "call bool valuetype [mscorlib]System.String::op_Equality(string, string)n");
- break;
-
- case LST_KEY:
- // NOTE: babbage: strings and keys can be compared, so a cast
- // may be required
- print_cil_cast(fp, left_type, right_type);
- // Key equality.
- fprintf(fp, "call int32 [LslUserScript]LindenLab.SecondLife.LslUserScript::'Equals'(valuetype [ScriptTypes]LindenLab.SecondLife.Key, valuetype [ScriptTypes]LindenLab.SecondLife.Key)n");
- break;
-
- case LST_VECTOR:
- // Vector equality.
- fprintf(fp, "call int32 [LslUserScript]LindenLab.SecondLife.LslUserScript::'Equals'(class [ScriptTypes]LindenLab.SecondLife.Vector, class [ScriptTypes]LindenLab.SecondLife.Vector)n");
- break;
- case LST_QUATERNION:
- // Rotation equality.
- fprintf(fp, "call int32 [LslUserScript]LindenLab.SecondLife.LslUserScript::'Equals'(class [ScriptTypes]LindenLab.SecondLife.Quaternion, class [ScriptTypes]LindenLab.SecondLife.Quaternion)n");
- break;
- case LST_LIST:
- fprintf(fp, "call int32 [LslUserScript]LindenLab.SecondLife.LslUserScript::Equals(class [mscorlib]System.Collections.ArrayList, class [mscorlib]System.Collections.ArrayList)n");
- break;
- default:
- // Error.
- break;
- }
- }
- void LLScriptEquality::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " == ");
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_EMIT_ASSEMBLY:
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "EQ %s, %sn", LSCRIPTTypeNames[mRightType], LSCRIPTTypeNames[mLeftType]);
- break;
- case LSCP_TYPE:
- {
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftType = type;
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightType = type;
- if (!legal_binary_expression(mReturnType, mLeftType, mRightType, mType))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- type = mReturnType;
- }
- break;
- case LSCP_TO_STACK:
- {
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- U8 typebyte = LSCRIPTTypeByte[mRightType] | LSCRIPTTypeHi4Bits[mLeftType];
- chunk->addByte(LSCRIPTOpCodes[LOPC_EQ]);
- chunk->addByte(typebyte);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_numeric_cast(fp, mRightSide->mReturnType, mLeftSide->mReturnType);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_numeric_cast(fp, mLeftSide->mReturnType, mRightSide->mReturnType);
- print_cil_eq(fp, mLeftSide->mReturnType, mRightSide->mReturnType);
- break;
- default:
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- S32 LLScriptEquality::getSize()
- {
- return 0;
- }
- void LLScriptNotEquals::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " != ");
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_EMIT_ASSEMBLY:
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "NEQ %s, %sn", LSCRIPTTypeNames[mRightType], LSCRIPTTypeNames[mLeftType]);
- break;
- case LSCP_TYPE:
- {
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftType = type;
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightType = type;
- if (!legal_binary_expression(mReturnType, mLeftType, mRightType, mType))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- type = mReturnType;
- }
- break;
- case LSCP_TO_STACK:
- {
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- U8 typebyte = LSCRIPTTypeByte[mRightType] | LSCRIPTTypeHi4Bits[mLeftType];
- chunk->addByte(LSCRIPTOpCodes[LOPC_NEQ]);
- chunk->addByte(typebyte);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_numeric_cast(fp, mRightSide->mReturnType, mLeftSide->mReturnType);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_numeric_cast(fp, mLeftSide->mReturnType, mRightSide->mReturnType);
- if (LST_LIST == mLeftSide->mReturnType)
- {
- fprintf(fp, "call int32 [LslUserScript]LindenLab.SecondLife.LslUserScript::NotEquals(class [mscorlib]System.Collections.ArrayList, class [mscorlib]System.Collections.ArrayList)n");
- }
- else
- {
- print_cil_eq(fp, mLeftSide->mReturnType, mRightSide->mReturnType);
- fprintf(fp, "ldc.i4.0n");
- fprintf(fp, "ceqn"); // Compare result of first compare equal with 0 to get compare not equal.
- }
- break;
- default:
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- S32 LLScriptNotEquals::getSize()
- {
- return 0;
- }
- static void print_cil_lte(LLFILE* fp)
- {
- // NOTE: LSL pushes operands backwards, so <= becomes >=
- fprintf(fp, "cltn");
- fprintf(fp, "ldc.i4.0n");
- fprintf(fp, "ceqn");
- }
- void LLScriptLessEquals::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " <= ");
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_EMIT_ASSEMBLY:
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "LEQ %s, %sn", LSCRIPTTypeNames[mRightType], LSCRIPTTypeNames[mLeftType]);
- break;
- case LSCP_TYPE:
- {
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftType = type;
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightType = type;
- if (!legal_binary_expression(mReturnType, mLeftType, mRightType, mType))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- type = mReturnType;
- }
- break;
- case LSCP_TO_STACK:
- {
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- U8 typebyte = LSCRIPTTypeByte[mRightType] | LSCRIPTTypeHi4Bits[mLeftType];
- chunk->addByte(LSCRIPTOpCodes[LOPC_LEQ]);
- chunk->addByte(typebyte);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_numeric_cast(fp, mRightSide->mReturnType, mLeftSide->mReturnType);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_numeric_cast(fp, mLeftSide->mReturnType, mRightSide->mReturnType);
- print_cil_lte(fp);
- break;
- default:
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- S32 LLScriptLessEquals::getSize()
- {
- return 0;
- }
- static void print_cil_gte(LLFILE* fp)
- {
- // NOTE: LSL pushes operands backwards, so >= becomes <=
- fprintf(fp, "cgtn");
- fprintf(fp, "ldc.i4.0n");
- fprintf(fp, "ceqn");
- }
- void LLScriptGreaterEquals::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " >= ");
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_EMIT_ASSEMBLY:
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "GEQ %s, %sn", LSCRIPTTypeNames[mRightType], LSCRIPTTypeNames[mLeftType]);
- break;
- case LSCP_TYPE:
- {
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftType = type;
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightType = type;
- if (!legal_binary_expression(mReturnType, mLeftType, mRightType, mType))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- type = mReturnType;
- }
- break;
- case LSCP_TO_STACK:
- {
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- U8 typebyte = LSCRIPTTypeByte[mRightType] | LSCRIPTTypeHi4Bits[mLeftType];
- chunk->addByte(LSCRIPTOpCodes[LOPC_GEQ]);
- chunk->addByte(typebyte);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_numeric_cast(fp, mRightSide->mReturnType, mLeftSide->mReturnType);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_numeric_cast(fp, mLeftSide->mReturnType, mRightSide->mReturnType);
- print_cil_gte(fp);
- break;
- default:
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- S32 LLScriptGreaterEquals::getSize()
- {
- return 0;
- }
- static void print_cil_lt(LLFILE* fp)
- {
- // NOTE: LSL pushes operands backwards, so < becomes >
- fprintf(fp, "cgtn");
- }
- void LLScriptLessThan::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " < ");
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_EMIT_ASSEMBLY:
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "LESS %s, %sn", LSCRIPTTypeNames[mRightType], LSCRIPTTypeNames[mLeftType]);
- break;
- case LSCP_TYPE:
- {
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftType = type;
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightType = type;
- if (!legal_binary_expression(mReturnType, mLeftType, mRightType, mType))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- type = mReturnType;
- }
- break;
- case LSCP_TO_STACK:
- {
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- U8 typebyte = LSCRIPTTypeByte[mRightType] | LSCRIPTTypeHi4Bits[mLeftType];
- chunk->addByte(LSCRIPTOpCodes[LOPC_LESS]);
- chunk->addByte(typebyte);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_numeric_cast(fp, mRightSide->mReturnType, mLeftSide->mReturnType);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_numeric_cast(fp, mLeftSide->mReturnType, mRightSide->mReturnType);
- print_cil_lt(fp);
- break;
- default:
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- S32 LLScriptLessThan::getSize()
- {
- return 0;
- }
- static void print_cil_gt(LLFILE* fp)
- {
- // NOTE: LSL pushes operands backwards, so > becomes <
- fprintf(fp, "cltn");
- }
- void LLScriptGreaterThan::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " > ");
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_EMIT_ASSEMBLY:
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "GREATER %s, %sn", LSCRIPTTypeNames[mRightType], LSCRIPTTypeNames[mLeftType]);
- break;
- case LSCP_TYPE:
- {
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftType = type;
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightType = type;
- if (!legal_binary_expression(mReturnType, mLeftType, mRightType, mType))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- type = mReturnType;
- }
- break;
- case LSCP_TO_STACK:
- {
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- U8 typebyte = LSCRIPTTypeByte[mRightType] | LSCRIPTTypeHi4Bits[mLeftType];
- chunk->addByte(LSCRIPTOpCodes[LOPC_GREATER]);
- chunk->addByte(typebyte);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_numeric_cast(fp, mRightSide->mReturnType, mLeftSide->mReturnType);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_numeric_cast(fp, mLeftSide->mReturnType, mRightSide->mReturnType);
- print_cil_gt(fp);
- break;
- default:
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- S32 LLScriptGreaterThan::getSize()
- {
- return 0;
- }
- void LLScriptPlus::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " + ");
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_EMIT_ASSEMBLY:
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "ADD %s, %sn", LSCRIPTTypeNames[mRightType], LSCRIPTTypeNames[mLeftType]);
- break;
- case LSCP_TYPE:
- {
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftType = type;
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightType = type;
- if (!legal_binary_expression(mReturnType, mLeftType, mRightType, mType))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- type = mReturnType;
- }
- break;
- case LSCP_TO_STACK:
- {
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- U8 typebyte = LSCRIPTTypeByte[mRightType] | LSCRIPTTypeHi4Bits[mLeftType];
- chunk->addByte(LSCRIPTOpCodes[LOPC_ADD]);
- chunk->addByte(typebyte);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_numeric_cast(fp, mRightSide->mReturnType, mLeftSide->mReturnType);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_numeric_cast(fp, mLeftSide->mReturnType, mRightSide->mReturnType);
- print_cil_add(fp, mLeftSide->mReturnType, mRightSide->mReturnType);
- break;
- default:
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- S32 LLScriptPlus::getSize()
- {
- return 0;
- }
- void LLScriptMinus::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " - ");
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_EMIT_ASSEMBLY:
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "SUB %s, %sn", LSCRIPTTypeNames[mRightType], LSCRIPTTypeNames[mLeftType]);
- break;
- case LSCP_TYPE:
- {
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftType = type;
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightType = type;
- if (!legal_binary_expression(mReturnType, mLeftType, mRightType, mType))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- type = mReturnType;
- }
- break;
- case LSCP_TO_STACK:
- {
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- U8 typebyte = LSCRIPTTypeByte[mRightType] | LSCRIPTTypeHi4Bits[mLeftType];
- chunk->addByte(LSCRIPTOpCodes[LOPC_SUB]);
- chunk->addByte(typebyte);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_numeric_cast(fp, mRightSide->mReturnType, mLeftSide->mReturnType);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_numeric_cast(fp, mLeftSide->mReturnType, mRightSide->mReturnType);
- print_cil_sub(fp, mLeftSide->mReturnType, mRightSide->mReturnType);
- break;
- default:
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- S32 LLScriptMinus::getSize()
- {
- return 0;
- }
- void LLScriptTimes::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " * ");
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_EMIT_ASSEMBLY:
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "MUL %s, %sn", LSCRIPTTypeNames[mRightType], LSCRIPTTypeNames[mLeftType]);
- break;
- case LSCP_TYPE:
- {
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftType = type;
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightType = type;
- if (!legal_binary_expression(mReturnType, mLeftType, mRightType, mType))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- type = mReturnType;
- }
- break;
- case LSCP_TO_STACK:
- {
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- U8 typebyte = LSCRIPTTypeByte[mRightType] | LSCRIPTTypeHi4Bits[mLeftType];
- chunk->addByte(LSCRIPTOpCodes[LOPC_MUL]);
- chunk->addByte(typebyte);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_numeric_cast(fp, mRightSide->mReturnType, mLeftSide->mReturnType);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_numeric_cast(fp, mLeftSide->mReturnType, mRightSide->mReturnType);
- print_cil_mul(fp, mLeftSide->mReturnType, mRightSide->mReturnType);
- break;
- default:
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- S32 LLScriptTimes::getSize()
- {
- return 0;
- }
- void LLScriptDivide::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " / ");
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_EMIT_ASSEMBLY:
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "DIV %s, %sn", LSCRIPTTypeNames[mRightType], LSCRIPTTypeNames[mLeftType]);
- break;
- case LSCP_TYPE:
- {
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftType = type;
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightType = type;
- if (!legal_binary_expression(mReturnType, mLeftType, mRightType, mType))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- type = mReturnType;
- }
- break;
- case LSCP_TO_STACK:
- {
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- U8 typebyte = LSCRIPTTypeByte[mRightType] | LSCRIPTTypeHi4Bits[mLeftType];
- chunk->addByte(LSCRIPTOpCodes[LOPC_DIV]);
- chunk->addByte(typebyte);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_numeric_cast(fp, mRightSide->mReturnType, mLeftSide->mReturnType);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_numeric_cast(fp, mLeftSide->mReturnType, mRightSide->mReturnType);
- print_cil_div(fp, mLeftSide->mReturnType, mRightSide->mReturnType);
- break;
- default:
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- S32 LLScriptDivide::getSize()
- {
- return 0;
- }
- void LLScriptMod::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " %% ");
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_EMIT_ASSEMBLY:
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "MOD %s, %sn", LSCRIPTTypeNames[mRightType], LSCRIPTTypeNames[mLeftType]);
- break;
- case LSCP_TYPE:
- {
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftType = type;
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightType = type;
- if (!legal_binary_expression(mReturnType, mLeftType, mRightType, mType))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- type = mReturnType;
- }
- break;
- case LSCP_TO_STACK:
- {
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- U8 typebyte = LSCRIPTTypeByte[mRightType] | LSCRIPTTypeHi4Bits[mLeftType];
- chunk->addByte(LSCRIPTOpCodes[LOPC_MOD]);
- chunk->addByte(typebyte);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_mod(fp, mLeftSide->mReturnType, mRightSide->mReturnType);
- break;
- default:
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- S32 LLScriptMod::getSize()
- {
- return 0;
- }
- void LLScriptBitAnd::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " & ");
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_EMIT_ASSEMBLY:
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "BITANDn");
- break;
- case LSCP_TYPE:
- {
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftType = type;
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightType = type;
- if (!legal_binary_expression(mReturnType, mLeftType, mRightType, mType))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- type = mReturnType;
- }
- break;
- case LSCP_TO_STACK:
- {
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- chunk->addByte(LSCRIPTOpCodes[LOPC_BITAND]);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "andn");
- break;
- default:
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- S32 LLScriptBitAnd::getSize()
- {
- return 0;
- }
- void LLScriptBitOr::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " | ");
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_EMIT_ASSEMBLY:
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "BITORn");
- break;
- case LSCP_TYPE:
- {
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftType = type;
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightType = type;
- if (!legal_binary_expression(mReturnType, mLeftType, mRightType, mType))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- type = mReturnType;
- }
- break;
- case LSCP_TO_STACK:
- {
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- chunk->addByte(LSCRIPTOpCodes[LOPC_BITOR]);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "orn");
- break;
- default:
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- S32 LLScriptBitOr::getSize()
- {
- return 0;
- }
- void LLScriptBitXor::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " ^ ");
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_EMIT_ASSEMBLY:
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "BITXORn");
- break;
- case LSCP_TYPE:
- {
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftType = type;
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightType = type;
- if (!legal_binary_expression(mReturnType, mLeftType, mRightType, mType))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- type = mReturnType;
- }
- break;
- case LSCP_TO_STACK:
- {
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- chunk->addByte(LSCRIPTOpCodes[LOPC_BITXOR]);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "xorn");
- break;
- default:
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- S32 LLScriptBitXor::getSize()
- {
- return 0;
- }
- void LLScriptBooleanAnd::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " && ");
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_EMIT_ASSEMBLY:
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "BOOLANDn");
- break;
- case LSCP_TYPE:
- {
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftType = type;
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightType = type;
- if (!legal_binary_expression(mReturnType, mLeftType, mRightType, mType))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- type = mReturnType;
- }
- break;
- case LSCP_TO_STACK:
- {
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- chunk->addByte(LSCRIPTOpCodes[LOPC_BOOLAND]);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "ldc.i4.0n");
- fprintf(fp, "ceqn");
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "ldc.i4.0n");
- fprintf(fp, "ceqn");
- fprintf(fp, "orn");
- fprintf(fp, "ldc.i4.0n");
- fprintf(fp, "ceqn");
- break;
- default:
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- S32 LLScriptBooleanAnd::getSize()
- {
- return 0;
- }
- void LLScriptBooleanOr::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " || ");
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_EMIT_ASSEMBLY:
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "BOOLORn");
- break;
- case LSCP_TYPE:
- {
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftType = type;
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightType = type;
- if (!legal_binary_expression(mReturnType, mLeftType, mRightType, mType))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- type = mReturnType;
- }
- break;
- case LSCP_TO_STACK:
- {
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- chunk->addByte(LSCRIPTOpCodes[LOPC_BOOLOR]);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "orn");
- fprintf(fp, "ldc.i4.0n");
- fprintf(fp, "ceqn");
- fprintf(fp, "ldc.i4.0n");
- fprintf(fp, "ceqn");
- break;
- default:
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- S32 LLScriptBooleanOr::getSize()
- {
- return 0;
- }
- void LLScriptShiftLeft::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " << ");
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_EMIT_ASSEMBLY:
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "SHLn");
- break;
- case LSCP_TYPE:
- {
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftType = type;
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightType = type;
- if (!legal_binary_expression(mReturnType, mLeftType, mRightType, mType))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- type = mReturnType;
- }
- break;
- case LSCP_TO_STACK:
- {
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- chunk->addByte(LSCRIPTOpCodes[LOPC_SHL]);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "call int32 [LslUserScript]LindenLab.SecondLife.LslUserScript::ShiftLeft(int32, int32)n");
- break;
- default:
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- S32 LLScriptShiftLeft::getSize()
- {
- return 0;
- }
- void LLScriptShiftRight::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " >> ");
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_EMIT_ASSEMBLY:
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "SHRn");
- break;
- case LSCP_TYPE:
- {
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftType = type;
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightType = type;
- if (!legal_binary_expression(mReturnType, mLeftType, mRightType, mType))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- type = mReturnType;
- }
- break;
- case LSCP_TO_STACK:
- {
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- chunk->addByte(LSCRIPTOpCodes[LOPC_SHR]);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "call int32 [LslUserScript]LindenLab.SecondLife.LslUserScript::ShiftRight(int32, int32)n");
- break;
- default:
- mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- S32 LLScriptShiftRight::getSize()
- {
- return 0;
- }
- void LLScriptParenthesis::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- fprintf(fp, "( ");
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )");
- break;
- case LSCP_TYPE:
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mReturnType = mLeftType = type;
- break;
- case LSCP_EMIT_ASSEMBLY:
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mReturnType = mLeftType = type;
- break;
- default:
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- S32 LLScriptParenthesis::getSize()
- {
- return 0;
- }
- void LLScriptUnaryMinus::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- fprintf(fp, "-");
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_EMIT_ASSEMBLY:
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "NEG %sn", LSCRIPTTypeNames[mLeftType]);
- break;
- case LSCP_TYPE:
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (!legal_unary_expression(type, type, mType))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- else
- {
- mReturnType = mLeftType = type;
- }
- break;
- case LSCP_TO_STACK:
- {
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- U8 typebyte = LSCRIPTTypeByte[mLeftType];
- chunk->addByte(LSCRIPTOpCodes[LOPC_NEG]);
- chunk->addByte(typebyte);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- {
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_neg(fp, mLeftType);
- }
- break;
- default:
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- S32 LLScriptUnaryMinus::getSize()
- {
- return 0;
- }
- void LLScriptBooleanNot::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- fprintf(fp, "!");
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_EMIT_ASSEMBLY:
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "BOOLNOTn");
- break;
- case LSCP_TYPE:
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (!legal_unary_expression(type, type, mType))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- else
- {
- mReturnType = mLeftType = type;
- }
- break;
- case LSCP_TO_STACK:
- {
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- chunk->addByte(LSCRIPTOpCodes[LOPC_BOOLNOT]);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "ldc.i4.0n");
- fprintf(fp, "ceqn"); // If f(e) is (e == 0), f(e) returns 1 if e is 0 and 0 otherwise, therefore f(e) implements boolean not.
- break;
- default:
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- S32 LLScriptBooleanNot::getSize()
- {
- return 0;
- }
- void LLScriptBitNot::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- fprintf(fp, "~");
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_EMIT_ASSEMBLY:
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "BITNOTn");
- break;
- case LSCP_TYPE:
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (!legal_unary_expression(type, type, mType))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- else
- {
- mReturnType = mLeftType = type;
- }
- break;
- case LSCP_TO_STACK:
- {
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- chunk->addByte(LSCRIPTOpCodes[LOPC_BITNOT]);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "notn");
- break;
- default:
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- S32 LLScriptBitNot::getSize()
- {
- return 0;
- }
- void LLScriptPreIncrement::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- fprintf(fp, "++");
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_EMIT_ASSEMBLY:
- {
- if (mReturnType == LST_INTEGER)
- {
- fprintf(fp, "PUSHARGI 1n");
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "n");
- fprintf(fp, "ADD integer, integern");
- }
- else if (mReturnType == LST_FLOATINGPOINT)
- {
- fprintf(fp, "PUSHARGF 1n");
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "n");
- fprintf(fp, "ADD float, floatn");
- }
- else
- {
- fprintf(fp, "Unexpected Typen");
- }
- print_assignment(fp, mExpression);
- }
- break;
- case LSCP_TYPE:
- if (mExpression->mType != LET_LVALUE)
- {
- gErrorToText.writeError(fp, this, LSERROR_EXPRESSION_ON_LVALUE);
- }
- else
- {
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (!legal_unary_expression(type, type, mType))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- else
- {
- mReturnType = mLeftType = type;
- }
- }
- break;
- case LSCP_TO_STACK:
- {
- if (mReturnType == LST_INTEGER)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHARGI]);
- chunk->addInteger(1);
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- chunk->addByte(LSCRIPTOpCodes[LOPC_ADD]);
- chunk->addByte(LSCRIPTTypeByte[LST_INTEGER] | LSCRIPTTypeHi4Bits[LST_INTEGER]);
- }
- else if (mReturnType == LST_FLOATINGPOINT)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHARGF]);
- chunk->addFloat(1.f);
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- chunk->addByte(LSCRIPTOpCodes[LOPC_ADD]);
- chunk->addByte(LSCRIPTTypeByte[LST_FLOATINGPOINT] | LSCRIPTTypeHi4Bits[LST_FLOATINGPOINT]);
- }
- store2stack(this, mExpression, chunk, mReturnType);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- {
- print_cil_load_address(fp, mExpression, entry);
- if (mReturnType == LST_INTEGER)
- {
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "ldc.i4.1n");
- fprintf(fp, "addn");
- }
- else if (mReturnType == LST_FLOATINGPOINT)
- {
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "ldc.r8 1n");
- fprintf(fp, "addn");
- }
- else
- {
- fprintf(fp, "Unexpected Typen");
- }
- print_cil_assignment(fp, mExpression, entry);
- }
- break;
- default:
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- S32 LLScriptPreIncrement::getSize()
- {
- return 0;
- }
- void LLScriptPreDecrement::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- fprintf(fp, "--");
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_EMIT_ASSEMBLY:
- {
- if (mReturnType == LST_INTEGER)
- {
- fprintf(fp, "PUSHARGI 1n");
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "n");
- fprintf(fp, "SUB integer, integern");
- }
- else if (mReturnType == LST_FLOATINGPOINT)
- {
- fprintf(fp, "PUSHARGF 1n");
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "n");
- fprintf(fp, "SUB float, floatn");
- }
- else
- {
- fprintf(fp, "Unexpected Typen");
- }
- print_assignment(fp, mExpression);
- }
- break;
- case LSCP_TYPE:
- if (mExpression->mType != LET_LVALUE)
- {
- gErrorToText.writeError(fp, this, LSERROR_EXPRESSION_ON_LVALUE);
- }
- else
- {
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (!legal_unary_expression(type, type, mType))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- else
- {
- mReturnType = mLeftType = type;
- }
- }
- break;
- case LSCP_TO_STACK:
- {
- if (mReturnType == LST_INTEGER)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHARGI]);
- chunk->addInteger(1);
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- chunk->addByte(LSCRIPTOpCodes[LOPC_SUB]);
- chunk->addByte(LSCRIPTTypeByte[LST_INTEGER] | LSCRIPTTypeHi4Bits[LST_INTEGER]);
- }
- else if (mReturnType == LST_FLOATINGPOINT)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHARGF]);
- chunk->addFloat(1.f);
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- chunk->addByte(LSCRIPTOpCodes[LOPC_SUB]);
- chunk->addByte(LSCRIPTTypeByte[LST_FLOATINGPOINT] | LSCRIPTTypeHi4Bits[LST_FLOATINGPOINT]);
- }
- store2stack(this, mExpression, chunk, mReturnType);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- {
- print_cil_load_address(fp, mExpression, entry);
- if (mReturnType == LST_INTEGER)
- {
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "ldc.i4.1n");
- fprintf(fp, "subn");
- }
- else if (mReturnType == LST_FLOATINGPOINT)
- {
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "ldc.r8 1n");
- fprintf(fp, "subn");
- }
- else
- {
- fprintf(fp, "Unexpected Typen");
- }
- print_cil_assignment(fp, mExpression, entry);
- }
- break;
- default:
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- S32 LLScriptPreDecrement::getSize()
- {
- return 0;
- }
- void LLScriptTypeCast::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- fprintf(fp, "( ");
- mType->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ") ");
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_EMIT_ASSEMBLY:
- fprintf(fp, "CAST %s->%sn", LSCRIPTTypeNames[mRightType], LSCRIPTTypeNames[mType->mType]);
- break;
- case LSCP_TYPE:
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightType = type;
- if (!legal_casts(mType->mType, type))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- type = mType->mType;
- mReturnType = mLeftType = type;
- break;
- case LSCP_TO_STACK:
- {
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- chunk->addByte(LSCRIPTOpCodes[LOPC_CAST]);
- U8 castbyte = LSCRIPTTypeByte[mType->mType] | LSCRIPTTypeHi4Bits[mRightType];
- chunk->addByte(castbyte);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_cast(fp, mRightType, mType->mType);
- break;
- default:
- mType->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- S32 LLScriptTypeCast::getSize()
- {
- return 0;
- }
- void LLScriptVectorInitializer::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- fprintf(fp, "< ");
- mExpression1->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", ");
- mExpression2->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", ");
- mExpression3->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " >");
- break;
- case LSCP_EMIT_ASSEMBLY:
- mExpression1->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mExpression1->mReturnType != LST_FLOATINGPOINT)
- {
- fprintf(fp, "CAST %s->%sn", LSCRIPTTypeNames[mExpression1->mReturnType], LSCRIPTTypeNames[LST_FLOATINGPOINT]);
- }
- mExpression2->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mExpression2->mReturnType != LST_FLOATINGPOINT)
- {
- fprintf(fp, "CAST %s->%sn", LSCRIPTTypeNames[mExpression2->mReturnType], LSCRIPTTypeNames[LST_FLOATINGPOINT]);
- }
- mExpression3->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mExpression3->mReturnType != LST_FLOATINGPOINT)
- {
- fprintf(fp, "CAST %s->%sn", LSCRIPTTypeNames[mExpression3->mReturnType], LSCRIPTTypeNames[LST_FLOATINGPOINT]);
- }
- break;
- case LSCP_TYPE:
- // vector's take floats
- mExpression1->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (!legal_assignment(LST_FLOATINGPOINT, type))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- mExpression2->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (!legal_assignment(LST_FLOATINGPOINT, type))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- mExpression3->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (!legal_assignment(LST_FLOATINGPOINT, type))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- mReturnType = type = LST_VECTOR;
- if (mNextp)
- {
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- case LSCP_TO_STACK:
- pass = LSCP_TO_STACK;
- mExpression1->recurse(fp, tabs, tabsize, LSCP_TO_STACK, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mExpression1->mReturnType != LST_FLOATINGPOINT)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_CAST]);
- U8 castbyte = LSCRIPTTypeByte[LST_FLOATINGPOINT] | LSCRIPTTypeHi4Bits[mExpression1->mReturnType];
- chunk->addByte(castbyte);
- }
- mExpression2->recurse(fp, tabs, tabsize, LSCP_TO_STACK, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mExpression2->mReturnType != LST_FLOATINGPOINT)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_CAST]);
- U8 castbyte = LSCRIPTTypeByte[LST_FLOATINGPOINT] | LSCRIPTTypeHi4Bits[mExpression2->mReturnType];
- chunk->addByte(castbyte);
- }
- mExpression3->recurse(fp, tabs, tabsize, LSCP_TO_STACK, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mExpression3->mReturnType != LST_FLOATINGPOINT)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_CAST]);
- U8 castbyte = LSCRIPTTypeByte[LST_FLOATINGPOINT] | LSCRIPTTypeHi4Bits[mExpression3->mReturnType];
- chunk->addByte(castbyte);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- // Load arguments.
- mExpression1->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mExpression1->mReturnType != LST_FLOATINGPOINT)
- {
- print_cil_cast(fp, mExpression1->mReturnType, LST_FLOATINGPOINT);
- }
- mExpression2->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mExpression2->mReturnType != LST_FLOATINGPOINT)
- {
- print_cil_cast(fp, mExpression2->mReturnType, LST_FLOATINGPOINT);
- }
- mExpression3->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mExpression3->mReturnType != LST_FLOATINGPOINT)
- {
- print_cil_cast(fp, mExpression3->mReturnType, LST_FLOATINGPOINT);
- }
- // Call named ctor, which leaves new Vector on stack, so it can be saved in to local or argument just like a primitive type.
- fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Vector class [LslUserScript]LindenLab.SecondLife.LslUserScript::'CreateVector'(float32, float32, float32)n");
- break;
- default:
- mExpression1->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mExpression2->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mExpression3->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- S32 LLScriptVectorInitializer::getSize()
- {
- return 0;
- }
- void LLScriptQuaternionInitializer::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- fprintf(fp, "< ");
- mExpression1->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", ");
- mExpression2->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", ");
- mExpression3->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", ");
- mExpression4->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " >");
- break;
- case LSCP_EMIT_ASSEMBLY:
- mExpression1->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mExpression1->mReturnType != LST_FLOATINGPOINT)
- {
- fprintf(fp, "CAST %s->%sn", LSCRIPTTypeNames[mExpression1->mReturnType], LSCRIPTTypeNames[LST_FLOATINGPOINT]);
- }
- mExpression2->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mExpression2->mReturnType != LST_FLOATINGPOINT)
- {
- fprintf(fp, "CAST %s->%sn", LSCRIPTTypeNames[mExpression2->mReturnType], LSCRIPTTypeNames[LST_FLOATINGPOINT]);
- }
- mExpression3->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mExpression3->mReturnType != LST_FLOATINGPOINT)
- {
- fprintf(fp, "CAST %s->%sn", LSCRIPTTypeNames[mExpression3->mReturnType], LSCRIPTTypeNames[LST_FLOATINGPOINT]);
- }
- mExpression4->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mExpression4->mReturnType != LST_FLOATINGPOINT)
- {
- fprintf(fp, "CAST %s->%sn", LSCRIPTTypeNames[mExpression4->mReturnType], LSCRIPTTypeNames[LST_FLOATINGPOINT]);
- }
- break;
- case LSCP_TYPE:
- // vector's take floats
- mExpression1->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (!legal_assignment(LST_FLOATINGPOINT, type))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- mExpression2->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (!legal_assignment(LST_FLOATINGPOINT, type))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- mExpression3->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (!legal_assignment(LST_FLOATINGPOINT, type))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- mExpression4->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (!legal_assignment(LST_FLOATINGPOINT, type))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- mReturnType = type = LST_QUATERNION;
- if (mNextp)
- {
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- case LSCP_TO_STACK:
- pass = LSCP_TO_STACK;
- mExpression1->recurse(fp, tabs, tabsize, LSCP_TO_STACK, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mExpression1->mReturnType != LST_FLOATINGPOINT)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_CAST]);
- U8 castbyte = LSCRIPTTypeByte[LST_FLOATINGPOINT] | LSCRIPTTypeHi4Bits[mExpression1->mReturnType];
- chunk->addByte(castbyte);
- }
- mExpression2->recurse(fp, tabs, tabsize, LSCP_TO_STACK, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mExpression2->mReturnType != LST_FLOATINGPOINT)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_CAST]);
- U8 castbyte = LSCRIPTTypeByte[LST_FLOATINGPOINT] | LSCRIPTTypeHi4Bits[mExpression2->mReturnType];
- chunk->addByte(castbyte);
- }
- mExpression3->recurse(fp, tabs, tabsize, LSCP_TO_STACK, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mExpression3->mReturnType != LST_FLOATINGPOINT)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_CAST]);
- U8 castbyte = LSCRIPTTypeByte[LST_FLOATINGPOINT] | LSCRIPTTypeHi4Bits[mExpression3->mReturnType];
- chunk->addByte(castbyte);
- }
- mExpression4->recurse(fp, tabs, tabsize, LSCP_TO_STACK, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mExpression4->mReturnType != LST_FLOATINGPOINT)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_CAST]);
- U8 castbyte = LSCRIPTTypeByte[LST_FLOATINGPOINT] | LSCRIPTTypeHi4Bits[mExpression4->mReturnType];
- chunk->addByte(castbyte);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- // Load arguments.
- mExpression1->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mExpression1->mReturnType != LST_FLOATINGPOINT)
- {
- print_cil_cast(fp, mExpression1->mReturnType, LST_FLOATINGPOINT);
- }
- mExpression2->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mExpression2->mReturnType != LST_FLOATINGPOINT)
- {
- print_cil_cast(fp, mExpression2->mReturnType, LST_FLOATINGPOINT);
- }
- mExpression3->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mExpression3->mReturnType != LST_FLOATINGPOINT)
- {
- print_cil_cast(fp, mExpression3->mReturnType, LST_FLOATINGPOINT);
- }
- mExpression4->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mExpression4->mReturnType != LST_FLOATINGPOINT)
- {
- print_cil_cast(fp, mExpression4->mReturnType, LST_FLOATINGPOINT);
- }
- // Call named ctor, which leaves new Vector on stack, so it can be saved in to local or argument just like a primitive type.
- fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Quaternion class [LslUserScript]LindenLab.SecondLife.LslUserScript::'CreateQuaternion'(float32, float32, float32, float32)n");
- break;
- default:
- mExpression1->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mExpression2->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mExpression3->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mExpression4->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- S32 LLScriptQuaternionInitializer::getSize()
- {
- return 0;
- }
- void LLScriptListInitializer::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- fprintf(fp, "[ ");
- mExpressionList->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " ]");
- break;
- case LSCP_EMIT_ASSEMBLY:
- count = 0;
- if (mExpressionList)
- {
- mExpressionList->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "STACKTOL %llun", count);
- }
- break;
- case LSCP_TYPE:
- if (mExpressionList)
- {
- mExpressionList->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mReturnType = type = LST_LIST;
- }
- mReturnType = type = LST_LIST;
- break;
- case LSCP_TO_STACK:
- {
- if (mExpressionList)
- {
- pass = LSCP_TO_STACK;
- U64 list_element_count = 0;
- mExpressionList->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, list_element_count, chunk, heap, stacksize, entry, entrycount, NULL);
- chunk->addByte(LSCRIPTOpCodes[LOPC_STACKTOL]);
- chunk->addInteger((S32)list_element_count);
-
- }
- else
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_STACKTOL]);
- chunk->addInteger(0);
- }
- break;
- }
- case LSCP_EMIT_CIL_ASSEMBLY:
- {
- // Push boxed elements on stack.
- U64 list_element_count = 0;
- if (mExpressionList)
- {
- mExpressionList->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, list_element_count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- // Create list on stack.
- fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::CreateList()n");
- // Call Prepend to add remaining boxed expressions.
- for(U64 i = 0; i < list_element_count; i++)
- {
- fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::Prepend(object, class [mscorlib]System.Collections.ArrayList)n");
- }
- break;
- }
- default:
- if (mExpressionList)
- {
- mExpressionList->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- S32 LLScriptListInitializer::getSize()
- {
- return 0;
- }
- void LLScriptPostIncrement::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "++");
- break;
- case LSCP_EMIT_ASSEMBLY:
- {
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mReturnType == LST_INTEGER)
- {
- fprintf(fp, "PUSHARGI 1n");
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "ADD integer, integern");
- }
- else if (mReturnType == LST_FLOATINGPOINT)
- {
- fprintf(fp, "PUSHARGF 1n");
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "ADD float, floatn");
- }
- else
- {
- fprintf(fp, "Unexpected Typen");
- }
- print_assignment(fp, mExpression);
- fprintf(fp, "%sn", LSCRIPTTypePop[mReturnType]);
- }
- break;
- case LSCP_TYPE:
- if (mExpression->mType != LET_LVALUE)
- {
- gErrorToText.writeError(fp, this, LSERROR_EXPRESSION_ON_LVALUE);
- }
- else
- {
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (!legal_unary_expression(type, type, mType))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- else
- {
- mReturnType = mLeftType = type;
- }
- }
- break;
- case LSCP_TO_STACK:
- {
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mReturnType == LST_INTEGER)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHARGI]);
- chunk->addInteger(1);
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- chunk->addByte(LSCRIPTOpCodes[LOPC_ADD]);
- chunk->addByte(LSCRIPTTypeByte[LST_INTEGER] | LSCRIPTTypeHi4Bits[LST_INTEGER]);
- }
- else if (mReturnType == LST_FLOATINGPOINT)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHARGF]);
- chunk->addFloat(1.f);
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- chunk->addByte(LSCRIPTOpCodes[LOPC_ADD]);
- chunk->addByte(LSCRIPTTypeByte[LST_FLOATINGPOINT] | LSCRIPTTypeHi4Bits[LST_FLOATINGPOINT]);
- }
- store2stack(this, mExpression, chunk, mReturnType);
- switch(mReturnType)
- {
- case LST_INTEGER:
- case LST_FLOATINGPOINT:
- chunk->addByte(LSCRIPTOpCodes[LOPC_POP]);
- break;
- case LST_KEY:
- case LST_STRING:
- chunk->addByte(LSCRIPTOpCodes[LOPC_POPS]);
- break;
- case LST_LIST:
- chunk->addByte(LSCRIPTOpCodes[LOPC_POPL]);
- break;
- case LST_VECTOR:
- chunk->addByte(LSCRIPTOpCodes[LOPC_POPV]);
- break;
- case LST_QUATERNION:
- chunk->addByte(LSCRIPTOpCodes[LOPC_POPQ]);
- break;
- default:
- chunk->addByte(LSCRIPTOpCodes[LOPC_POP]);
- break;
- }
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- {
- // Push original value on to stack.
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- // Load address if needed for store.
- print_cil_load_address(fp, mExpression, entry);
- // Load value again.
- // TODO: Work out if sideeffects can result in 2 evaluations of expression giving different values.
- // Original LSL2 uses this method, so any bugs due to side effects will probably be identical ;-)
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mReturnType == LST_INTEGER)
- {
- fprintf(fp, "ldc.i4.1n");
- }
- else if (mReturnType == LST_FLOATINGPOINT)
- {
- fprintf(fp, "ldc.r8 1n");
- }
- else
- {
- fprintf(fp, "Unexpected Typen");
- }
- fprintf(fp, "addn");
- print_cil_assignment(fp, mExpression, entry);
- // Pop assignment result to leave original expression result on stack.
- // TODO: Optimise away redundant pop/dup pairs.
- fprintf(fp, "popn");
- }
- break;
- default:
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- S32 LLScriptPostIncrement::getSize()
- {
- return 0;
- }
- void LLScriptPostDecrement::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "--");
- break;
- case LSCP_EMIT_ASSEMBLY:
- {
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mReturnType == LST_INTEGER)
- {
- fprintf(fp, "PUSHARGI 1n");
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "SUB integer, integern");
- }
- else if (mReturnType == LST_FLOATINGPOINT)
- {
- fprintf(fp, "PUSHARGF 1n");
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "SUB float, floatn");
- }
- else
- {
- fprintf(fp, "Unexpected Typen");
- }
- print_assignment(fp, mExpression);
- fprintf(fp, "%sn", LSCRIPTTypePop[mReturnType]);
- }
- break;
- case LSCP_TYPE:
- if (mExpression->mType != LET_LVALUE)
- {
- gErrorToText.writeError(fp, this, LSERROR_EXPRESSION_ON_LVALUE);
- }
- else
- {
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (!legal_unary_expression(type, type, mType))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- else
- {
- mReturnType = mLeftType = type;
- }
- }
- break;
- case LSCP_TO_STACK:
- {
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mReturnType == LST_INTEGER)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHARGI]);
- chunk->addInteger(1);
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- chunk->addByte(LSCRIPTOpCodes[LOPC_SUB]);
- chunk->addByte(LSCRIPTTypeByte[LST_INTEGER] | LSCRIPTTypeHi4Bits[LST_INTEGER]);
- }
- else if (mReturnType == LST_FLOATINGPOINT)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHARGF]);
- chunk->addFloat(1.f);
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- chunk->addByte(LSCRIPTOpCodes[LOPC_SUB]);
- chunk->addByte(LSCRIPTTypeByte[LST_FLOATINGPOINT] | LSCRIPTTypeHi4Bits[LST_FLOATINGPOINT]);
- }
- store2stack(this, mExpression, chunk, mReturnType);
- switch(mReturnType)
- {
- case LST_INTEGER:
- case LST_FLOATINGPOINT:
- chunk->addByte(LSCRIPTOpCodes[LOPC_POP]);
- break;
- case LST_KEY:
- case LST_STRING:
- chunk->addByte(LSCRIPTOpCodes[LOPC_POPS]);
- break;
- case LST_LIST:
- chunk->addByte(LSCRIPTOpCodes[LOPC_POPL]);
- break;
- case LST_VECTOR:
- chunk->addByte(LSCRIPTOpCodes[LOPC_POPV]);
- break;
- case LST_QUATERNION:
- chunk->addByte(LSCRIPTOpCodes[LOPC_POPQ]);
- break;
- default:
- chunk->addByte(LSCRIPTOpCodes[LOPC_POP]);
- break;
- }
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- {
- // Push original value on to stack.
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- // Load address if needed for store.
- print_cil_load_address(fp, mExpression, entry);
- // Load value again.
- // TODO: Work out if sideeffects can result in 2 evaluations of expression giving different values.
- // Original LSL2 uses this method, so any bugs due to side effects will probably be identical ;-)
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mReturnType == LST_INTEGER)
- {
- fprintf(fp, "ldc.i4.1n");
- }
- else if (mReturnType == LST_FLOATINGPOINT)
- {
- fprintf(fp, "ldc.r8 1n");
- }
- else
- {
- fprintf(fp, "Unexpected Typen");
- }
- fprintf(fp, "subn");
- print_cil_assignment(fp, mExpression, entry);
- // Pop assignment result to leave original expression result on stack.
- // TODO: Optimise away redundant pop/dup pairs.
- fprintf(fp, "popn");
- }
- break;
- default:
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- S32 LLScriptPostDecrement::getSize()
- {
- return 0;
- }
- // Generate arg list.
- static void print_cil_arg_list(LLFILE *fp, LLScriptArgString& args)
- {
- int i = 0;
- bool finished = (i >= args.getNumber());
- while(! finished)
- {
- print_cil_type(fp, args.getType(i));
- ++i;
- finished = (i >= args.getNumber());
- if(! finished)
- {
- fprintf(fp, ", ");
- }
- }
- }
- void LLScriptFunctionCall::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "( ");
- if (mExpressionList)
- mExpressionList->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )");
- break;
- case LSCP_EMIT_ASSEMBLY:
- if (mIdentifier->mScopeEntry->mType)
- fprintf(fp, "%sn", LSCRIPTTypePush[mIdentifier->mScopeEntry->mType]);
- fprintf(fp,"PUSHEn");
- fprintf(fp, "PUSHBPn");
- if (mExpressionList)
- mExpressionList->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, mIdentifier->mScopeEntry, 0, NULL);
- fprintf(fp, "PUSHARGE %dn", mIdentifier->mScopeEntry->mSize - mIdentifier->mScopeEntry->mOffset);
- fprintf(fp, "PUSHSPn");
- fprintf(fp, "PUSHARGI %dn", mIdentifier->mScopeEntry->mSize);
- fprintf(fp, "ADD integer, integern");
- fprintf(fp, "POPBPn");
- if (mIdentifier->mScopeEntry->mIDType != LIT_LIBRARY_FUNCTION)
- {
- fprintf(fp, "CALL ");
- mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- else
- {
- fprintf(fp, "CALLLID ");
- mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", %d", (U32)mIdentifier->mScopeEntry->mLibraryNumber);
- }
- fprintf(fp, "n");
- fprintf(fp, "POPBPn");
- break;
- case LSCP_SCOPE_PASS1:
- if (mExpressionList)
- mExpressionList->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_SCOPE_PASS2:
- {
- LLScriptScopeEntry *entry = scope->findEntryTyped(mIdentifier->mName, LIT_FUNCTION);
- if (!entry)
- {
- gErrorToText.writeError(fp, this, LSERROR_UNDEFINED_NAME);
- }
- else
- {
- // if we did find it, make sure this identifier is associated with the correct scope entry
- mIdentifier->mScopeEntry = entry;
- }
- if (mExpressionList)
- mExpressionList->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- case LSCP_TYPE:
- if (mIdentifier->mScopeEntry)
- {
- U64 argcount = 0;
- if (mExpressionList)
- mExpressionList->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, argcount, chunk, heap, stacksize, mIdentifier->mScopeEntry, 0, NULL);
- if (!mIdentifier->mScopeEntry->mFunctionArgs.mString)
- {
- if (argcount)
- {
- gErrorToText.writeError(fp, this, LSERROR_FUNCTION_TYPE_ERROR);
- }
- }
- else if (argcount != strlen(mIdentifier->mScopeEntry->mFunctionArgs.mString))
- {
- gErrorToText.writeError(fp, this, LSERROR_FUNCTION_TYPE_ERROR);
- }
- }
- if (mIdentifier->mScopeEntry)
- type = mIdentifier->mScopeEntry->mType;
- else
- type = LST_NULL;
- mReturnType = type;
- break;
- case LSCP_TO_STACK:
- switch(mIdentifier->mScopeEntry->mType)
- {
- case LST_INTEGER:
- case LST_FLOATINGPOINT:
- case LST_STRING:
- case LST_KEY:
- case LST_LIST:
- chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHE]);
- break;
- case LST_VECTOR:
- chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHEV]);
- break;
- case LST_QUATERNION:
- chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHEQ]);
- break;
- default:
- break;
- }
- chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHE]);
- chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHBP]);
- if (mExpressionList)
- {
- // Don't let this change the count.
- U64 dummy_count = 0;
- mExpressionList->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, dummy_count, chunk, heap, stacksize, mIdentifier->mScopeEntry, 0, NULL);
- //mExpressionList->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, mIdentifier->mScopeEntry, 0, NULL);
- }
- chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHARGE]);
- chunk->addInteger(mIdentifier->mScopeEntry->mSize - mIdentifier->mScopeEntry->mOffset);
- chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHSP]);
- chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHARGI]);
- chunk->addInteger(mIdentifier->mScopeEntry->mSize);
- chunk->addByte(LSCRIPTOpCodes[LOPC_ADD]);
- chunk->addByte(LSCRIPTTypeByte[LST_INTEGER] | LSCRIPTTypeHi4Bits[LST_INTEGER]);
- chunk->addByte(LSCRIPTOpCodes[LOPC_POPBP]);
- if (mIdentifier->mScopeEntry->mIDType != LIT_LIBRARY_FUNCTION)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_CALL]);
- chunk->addInteger(mIdentifier->mScopeEntry->mCount);
- }
- else
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_CALLLIB_TWO_BYTE]);
- chunk->addU16(mIdentifier->mScopeEntry->mLibraryNumber);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- {
- bool library_call = (mIdentifier->mScopeEntry->mIDType == LIT_LIBRARY_FUNCTION);
- if(! library_call)
- {
- // Load this pointer.
- fprintf(fp, "ldarg.0n");
- }
- // Load args on to stack.
- if (mExpressionList)
- {
- //mExpressionList->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry /* Needed for is_parameter calls */, 0, NULL);
- llassert(LET_FUNC_EXPRESSION_LIST == mExpressionList->mType);
- print_cil_func_expression_list((LLScriptFuncExpressionList*) mExpressionList, fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry /* Caller entry needed for is_parameter calls */, 0, NULL, mIdentifier->mScopeEntry /* Callee entry needed for argument casting */);
- }
- // Make call.
- if (! library_call)
- {
- fprintf(fp, "call instance ");
- }
- else
- {
- fprintf(fp, "call ");
- }
- print_cil_type(fp, mIdentifier->mScopeEntry->mType);
- fprintf(fp, " class ");
- if (library_call)
- {
- fprintf(fp, "[LslLibrary]LindenLab.SecondLife.Library::'");
- }
- else
- {
- // Prefix function name with g to distinguish from
- // event handlers.
- fprintf(fp, "%s", gScriptp->getClassName());
- fprintf(fp, "::'g");
- }
- fprintf(fp, "%s", mIdentifier->mName);
- fprintf(fp, "'(");
- print_cil_arg_list(fp, mIdentifier->mScopeEntry->mFunctionArgs);
- fprintf(fp, ")n");
- }
- break;
- default:
- mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mExpressionList)
- mExpressionList->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- S32 LLScriptFunctionCall::getSize()
- {
- return 0;
- }
- void LLScriptPrint::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- fprintf(fp, " PRINT ( ");
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )");
- break;
- case LSCP_EMIT_ASSEMBLY:
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "PRINT %sn", LSCRIPTTypeNames[mLeftType]);
- break;
- case LSCP_TYPE:
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftType = type;
- mReturnType = LST_NULL;
- break;
- case LSCP_TO_STACK:
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- chunk->addByte(LSCRIPTOpCodes[LOPC_PRINT]);
- chunk->addByte(LSCRIPTTypeByte[mLeftType]);
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_cast(fp, mLeftType, LST_STRING);
- fprintf(fp, "call void class [LslLibrary]LindenLab.SecondLife.Library::Print(string)");
- break;
- default:
- mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- S32 LLScriptPrint::getSize()
- {
- return 0;
- }
- void LLScriptConstantExpression::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- mConstant->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_TYPE:
- mConstant->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mReturnType = type;
- break;
- case LSCP_TO_STACK:
- mConstant->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- default:
- mConstant->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- S32 LLScriptConstantExpression::getSize()
- {
- return 0;
- }
- void LLScriptStatement::addStatement(LLScriptStatement *event)
- {
- if (mNextp)
- {
- event->mNextp = mNextp;
- }
- mNextp = event;
- }
- void LLScriptStatement::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- fprintf(fp, "Statement Base Class -- should never get here!n");
- }
- S32 LLScriptStatement::getSize()
- {
- printf("Statement Base Class -- should never get here!n");
- return 0;
- }
- void LLScriptStatement::gonext(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- if (mNextp)
- {
- fprintf(fp, ", ");
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- case LSCP_EMIT_ASSEMBLY:
- if (mNextp)
- {
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- default:
- if (mNextp)
- {
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- }
- }
- S32 LLScriptStatementSequence::getSize()
- {
- return 0;
- }
- void LLScriptStatementSequence::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- mFirstp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mSecondp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_EMIT_ASSEMBLY:
- mFirstp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mSecondp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_PRUNE:
- mFirstp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (prunearg)
- {
- // babbage: only warn on first dead code block found.
- if(ptype != LSPRUNE_DEAD_CODE)
- {
- gErrorToText.writeWarning(fp, this, LSWARN_DEAD_CODE);
- }
-
- // babbage: set prune type to LSPRUNE_DEAD_CODE to mask other
- // prune errors.
- ptype = LSPRUNE_DEAD_CODE;
-
- // babbage: reset prunearg, to track whether return needed at
- // end of dead code path as CIL always needs a return/throw.
- prunearg = FALSE;