lscript_tree.cpp
上传用户:king477883
上传日期:2021-03-01
资源大小:9553k
文件大小:399k
- mNumber->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )");
- break;
- default:
- mNumber->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- }
- S32 LLScriptSensorEvent::getSize()
- {
- // integer = 4
- return 4;
- }
- void LLScriptObjectRezEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- case LSCP_EMIT_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "object_rez( key ");
- mID->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )n");
- break;
- case LSCP_SCOPE_PASS1:
- checkForDuplicateHandler(fp, this, scope, "object_rez");
- if (scope->checkEntry(mID->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mID->mScopeEntry = scope->addEntry(mID->mName, LIT_VARIABLE, LST_KEY);
- }
- break;
- case LSCP_RESOURCE:
- {
- // we're just tryng to determine how much space the variable needs
- if (mID->mScopeEntry)
- {
- mID->mScopeEntry->mOffset = (S32)count;
- mID->mScopeEntry->mSize = 4;
- count += mID->mScopeEntry->mSize;
- }
- }
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
- #ifdef LSL_INCLUDE_DEBUG_INFO
- char name[] = "sensor";
- chunk->addBytes(name, strlen(name) + 1);
- chunk->addBytes(mID->mName, strlen(mID->mName) + 1);
- #endif
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "object_rez( valuetype [ScriptTypes]LindenLab.SecondLife.Key ");
- mID->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )");
- break;
- default:
- mID->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- }
- S32 LLScriptObjectRezEvent::getSize()
- {
- // key = 4
- return 4;
- }
- void LLScriptControlEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- case LSCP_EMIT_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "control( key ");
- mName->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", integer ");
- mLevels->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", integer ");
- mEdges->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )n");
- break;
- case LSCP_SCOPE_PASS1:
- checkForDuplicateHandler(fp, this, scope, "control");
- if (scope->checkEntry(mName->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mName->mScopeEntry = scope->addEntry(mName->mName, LIT_VARIABLE, LST_KEY);
- }
- if (scope->checkEntry(mLevels->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mLevels->mScopeEntry = scope->addEntry(mLevels->mName, LIT_VARIABLE, LST_INTEGER);
- }
- if (scope->checkEntry(mEdges->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mEdges->mScopeEntry = scope->addEntry(mEdges->mName, LIT_VARIABLE, LST_INTEGER);
- }
- break;
- case LSCP_RESOURCE:
- {
- // we're just tryng to determine how much space the variable needs
- if (mName->mScopeEntry)
- {
- mName->mScopeEntry->mOffset = (S32)count;
- mName->mScopeEntry->mSize = 4;
- count += mName->mScopeEntry->mSize;
- mLevels->mScopeEntry->mOffset = (S32)count;
- mLevels->mScopeEntry->mSize = 4;
- count += mLevels->mScopeEntry->mSize;
- mEdges->mScopeEntry->mOffset = (S32)count;
- mEdges->mScopeEntry->mSize = 4;
- count += mEdges->mScopeEntry->mSize;
- }
- }
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
- #ifdef LSL_INCLUDE_DEBUG_INFO
- char name[] = "control";
- chunk->addBytes(name, strlen(name) + 1);
- chunk->addBytes(mName->mName, strlen(mName->mName) + 1);
- chunk->addBytes(mLevels->mName, strlen(mLevels->mName) + 1);
- chunk->addBytes(mEdges->mName, strlen(mEdges->mName) + 1);
- #endif
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "control( valuetype [ScriptTypes]LindenLab.SecondLife.Key ");
- mName->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", int32 ");
- mLevels->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", int32 ");
- mEdges->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )");
- break;
- default:
- mName->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLevels->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mEdges->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- }
- S32 LLScriptControlEvent::getSize()
- {
- // key + integer + integer = 12
- return 12;
- }
- void LLScriptLinkMessageEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- case LSCP_EMIT_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "link_message( integer ");
- mSender->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", integer ");
- mNum->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", string ");
- mStr->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", key ");
- mID->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )n");
- break;
- case LSCP_SCOPE_PASS1:
- checkForDuplicateHandler(fp, this, scope, "link_message");
- if (scope->checkEntry(mSender->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mSender->mScopeEntry = scope->addEntry(mSender->mName, LIT_VARIABLE, LST_INTEGER);
- }
- if (scope->checkEntry(mNum->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mNum->mScopeEntry = scope->addEntry(mNum->mName, LIT_VARIABLE, LST_INTEGER);
- }
- if (scope->checkEntry(mStr->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mStr->mScopeEntry = scope->addEntry(mStr->mName, LIT_VARIABLE, LST_STRING);
- }
- if (scope->checkEntry(mID->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mID->mScopeEntry = scope->addEntry(mID->mName, LIT_VARIABLE, LST_KEY);
- }
- break;
- case LSCP_RESOURCE:
- {
- // we're just tryng to determine how much space the variable needs
- if (mSender->mScopeEntry)
- {
- mSender->mScopeEntry->mOffset = (S32)count;
- mSender->mScopeEntry->mSize = 4;
- count += mSender->mScopeEntry->mSize;
- mNum->mScopeEntry->mOffset = (S32)count;
- mNum->mScopeEntry->mSize = 4;
- count += mNum->mScopeEntry->mSize;
- mStr->mScopeEntry->mOffset = (S32)count;
- mStr->mScopeEntry->mSize = 4;
- count += mStr->mScopeEntry->mSize;
- mID->mScopeEntry->mOffset = (S32)count;
- mID->mScopeEntry->mSize = 4;
- count += mID->mScopeEntry->mSize;
- }
- }
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
- #ifdef LSL_INCLUDE_DEBUG_INFO
- char name[] = "link_message";
- chunk->addBytes(name, strlen(name) + 1);
- chunk->addBytes(mSender->mName, strlen(mSender->mName) + 1);
- chunk->addBytes(mNum->mName, strlen(mNum->mName) + 1);
- chunk->addBytes(mStr->mName, strlen(mStr->mName) + 1);
- chunk->addBytes(mID->mName, strlen(mID->mName) + 1);
- #endif
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "link_message( int32 ");
- mSender->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", int32 ");
- mNum->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", string ");
- mStr->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", valuetype [ScriptTypes]LindenLab.SecondLife.Key ");
- mID->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )");
- break;
- default:
- mSender->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mNum->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mStr->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mID->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- }
- S32 LLScriptLinkMessageEvent::getSize()
- {
- // integer + key + integer + string = 16
- return 16;
- }
- void LLScriptRemoteEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- case LSCP_EMIT_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "remote_event( integer ");
- mType->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", key ");
- mChannel->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", key ");
- mMessageID->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", string ");
- mSender->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", integer ");
- mIntVal->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", string ");
- mStrVal->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )n");
- break;
- case LSCP_SCOPE_PASS1:
- checkForDuplicateHandler(fp, this, scope, "remote_event");
- if (scope->checkEntry(mType->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mType->mScopeEntry = scope->addEntry(mType->mName, LIT_VARIABLE, LST_INTEGER);
- }
- if (scope->checkEntry(mChannel->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mChannel->mScopeEntry = scope->addEntry(mChannel->mName, LIT_VARIABLE, LST_KEY);
- }
- if (scope->checkEntry(mMessageID->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mMessageID->mScopeEntry = scope->addEntry(mMessageID->mName, LIT_VARIABLE, LST_KEY);
- }
- if (scope->checkEntry(mSender->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mSender->mScopeEntry = scope->addEntry(mSender->mName, LIT_VARIABLE, LST_STRING);
- }
- if (scope->checkEntry(mIntVal->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mIntVal->mScopeEntry = scope->addEntry(mIntVal->mName, LIT_VARIABLE, LST_INTEGER);
- }
- if (scope->checkEntry(mStrVal->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mStrVal->mScopeEntry = scope->addEntry(mStrVal->mName, LIT_VARIABLE, LST_STRING);
- }
- break;
- case LSCP_RESOURCE:
- {
- // we're just tryng to determine how much space the variable needs
- if (mType->mScopeEntry)
- {
- mType->mScopeEntry->mOffset = (S32)count;
- mType->mScopeEntry->mSize = 4;
- count += mType->mScopeEntry->mSize;
- mChannel->mScopeEntry->mOffset = (S32)count;
- mChannel->mScopeEntry->mSize = 4;
- count += mChannel->mScopeEntry->mSize;
- mMessageID->mScopeEntry->mOffset = (S32)count;
- mMessageID->mScopeEntry->mSize = 4;
- count += mMessageID->mScopeEntry->mSize;
- mSender->mScopeEntry->mOffset = (S32)count;
- mSender->mScopeEntry->mSize = 4;
- count += mSender->mScopeEntry->mSize;
- mIntVal->mScopeEntry->mOffset = (S32)count;
- mIntVal->mScopeEntry->mSize = 4;
- count += mIntVal->mScopeEntry->mSize;
- mStrVal->mScopeEntry->mOffset = (S32)count;
- mStrVal->mScopeEntry->mSize = 4;
- count += mStrVal->mScopeEntry->mSize;
- }
- }
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
- #ifdef LSL_INCLUDE_DEBUG_INFO
- char name[] = "remote_event";
- chunk->addBytes(name, strlen(name) + 1);
- chunk->addBytes(mType->mName, strlen(mType->mName) + 1);
- chunk->addBytes(mChannel->mName, strlen(mChannel->mName) + 1);
- chunk->addBytes(mMessageID->mName, strlen(mMessageID->mName) + 1);
- chunk->addBytes(mSender->mName, strlen(mSender->mName) + 1);
- chunk->addBytes(mIntVal->mName, strlen(mIntVal->mName) + 1);
- chunk->addBytes(mStrVal->mName, strlen(mStrVal->mName) + 1);
- #endif
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "remote_event( int32 ");
- mType->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", valuetype [ScriptTypes]LindenLab.SecondLife.Key ");
- mChannel->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", valuetype [ScriptTypes]LindenLab.SecondLife.Key ");
- mMessageID->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", string ");
- mSender->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", int32 ");
- mIntVal->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", string ");
- mStrVal->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )");
- break;
- default:
- mType->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mChannel->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mMessageID->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mSender->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mIntVal->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mStrVal->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- }
- S32 LLScriptRemoteEvent::getSize()
- {
- // integer + key + key + string + integer + string = 24
- return 24;
- }
- void LLScriptHTTPResponseEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- case LSCP_EMIT_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "http_response( key ");
- mRequestId->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", integer ");
- mStatus->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", class [mscorlib]System.Collections.ArrayList ");
- mMetadata->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", string ");
- mBody->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )n");
- break;
-
- case LSCP_SCOPE_PASS1:
- checkForDuplicateHandler(fp, this, scope, "http_response");
- if (scope->checkEntry(mRequestId->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mRequestId->mScopeEntry = scope->addEntry(mRequestId->mName, LIT_VARIABLE, LST_KEY);
- }
-
- if (scope->checkEntry(mStatus->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mStatus->mScopeEntry = scope->addEntry(mStatus->mName, LIT_VARIABLE, LST_INTEGER);
- }
-
- if (scope->checkEntry(mMetadata->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mMetadata->mScopeEntry = scope->addEntry(mMetadata->mName, LIT_VARIABLE, LST_LIST);
- }
-
- if (scope->checkEntry(mBody->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mBody->mScopeEntry = scope->addEntry(mBody->mName, LIT_VARIABLE, LST_STRING);
- }
- break;
-
- case LSCP_RESOURCE:
- {
- // we're just tryng to determine how much space the variable needs
- if (mRequestId->mScopeEntry)
- {
- mRequestId->mScopeEntry->mOffset = (S32)count;
- mRequestId->mScopeEntry->mSize = 4;
- count += mRequestId->mScopeEntry->mSize;
- mStatus->mScopeEntry->mOffset = (S32)count;
- mStatus->mScopeEntry->mSize = 4;
- count += mStatus->mScopeEntry->mSize;
- mMetadata->mScopeEntry->mOffset = (S32)count;
- mMetadata->mScopeEntry->mSize = 4;
- count += mMetadata->mScopeEntry->mSize;
- mBody->mScopeEntry->mOffset = (S32)count;
- mBody->mScopeEntry->mSize = 4;
- count += mBody->mScopeEntry->mSize;
- }
- }
- break;
-
- case LSCP_EMIT_BYTE_CODE:
- {
- #ifdef LSL_INCLUDE_DEBUG_INFO
- char name[] = "http_response";
- chunk->addBytes(name, strlen(name) + 1);
- chunk->addBytes(mRequestId->mName, strlen(mRequestId->mName) + 1);
- chunk->addBytes(mStatus->mName, strlen(mStatus->mName) + 1);
- chunk->addBytes(mMetadata->mName, strlen(mMetadata->mName) + 1);
- chunk->addBytes(mBody->mName, strlen(mBody->mName) + 1);
- #endif
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "http_response( valuetype [ScriptTypes]LindenLab.SecondLife.Key ");
- mRequestId->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", int32 ");
- mStatus->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", class [mscorlib]System.Collections.ArrayList ");
- mMetadata->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", string ");
- mBody->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )n");
- break;
- default:
- mRequestId->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mStatus->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mMetadata->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mBody->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- }
- S32 LLScriptHTTPResponseEvent::getSize()
- {
- // key + integer + list + string = 16
- return 16;
- }
- void LLScriptHTTPRequestEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- case LSCP_EMIT_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "http_request( key ");
- mRequestId->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", string ");
- mMethod->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", string ");
- mBody->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )n");
- break;
-
- case LSCP_SCOPE_PASS1:
- checkForDuplicateHandler(fp, this, scope, "http_request");
- if (scope->checkEntry(mRequestId->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mRequestId->mScopeEntry = scope->addEntry(mRequestId->mName, LIT_VARIABLE, LST_KEY);
- }
- if (scope->checkEntry(mMethod->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mMethod->mScopeEntry = scope->addEntry(mMethod->mName, LIT_VARIABLE, LST_STRING);
- }
-
- if (scope->checkEntry(mBody->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mBody->mScopeEntry = scope->addEntry(mBody->mName, LIT_VARIABLE, LST_STRING);
- }
- break;
-
- case LSCP_RESOURCE:
- {
- // we're just tryng to determine how much space the variable needs
- if (mRequestId->mScopeEntry)
- {
- mRequestId->mScopeEntry->mOffset = (S32)count;
- mRequestId->mScopeEntry->mSize = 4;
- count += mRequestId->mScopeEntry->mSize;
- mMethod->mScopeEntry->mOffset = (S32)count;
- mMethod->mScopeEntry->mSize = 4;
- count += mMethod->mScopeEntry->mSize;
- mBody->mScopeEntry->mOffset = (S32)count;
- mBody->mScopeEntry->mSize = 4;
- count += mBody->mScopeEntry->mSize;
- }
- }
- break;
-
- case LSCP_EMIT_BYTE_CODE:
- {
- #ifdef LSL_INCLUDE_DEBUG_INFO
- char name[] = "http_request";
- chunk->addBytes(name, strlen(name) + 1); /*Flawfinder: ignore*/
- chunk->addBytes(mRequestId->mName, strlen(mRequestId->mName) + 1); /*Flawfinder: ignore*/
- chunk->addBytes(mMethod->mName, strlen(mMethod->mName) + 1); /*Flawfinder: ignore*/
- chunk->addBytes(mBody->mName, strlen(mBody->mName) + 1); /*Flawfinder: ignore*/
- #endif
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "http_request( valuetype [ScriptTypes]LindenLab.SecondLife.Key ");
- mRequestId->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", string ");
- mMethod->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", string ");
- mBody->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )n");
- break;
- default:
- mRequestId->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mMethod->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mBody->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- }
- S32 LLScriptHTTPRequestEvent::getSize()
- {
- // key + string + string = 12
- return 12;
- }
- void LLScriptMoneyEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- case LSCP_EMIT_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "money( key ");
- mName->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", integer ");
- mAmount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )n");
- break;
- case LSCP_SCOPE_PASS1:
- checkForDuplicateHandler(fp, this, scope, "money");
- if (scope->checkEntry(mName->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mName->mScopeEntry = scope->addEntry(mName->mName, LIT_VARIABLE, LST_KEY);
- }
- if (scope->checkEntry(mAmount->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mAmount->mScopeEntry = scope->addEntry(mAmount->mName, LIT_VARIABLE, LST_INTEGER);
- }
- break;
- case LSCP_RESOURCE:
- {
- // we're just tryng to determine how much space the variable needs
- if (mName->mScopeEntry)
- {
- mName->mScopeEntry->mOffset = (S32)count;
- mName->mScopeEntry->mSize = 4;
- count += mName->mScopeEntry->mSize;
- mAmount->mScopeEntry->mOffset = (S32)count;
- mAmount->mScopeEntry->mSize = 4;
- count += mAmount->mScopeEntry->mSize;
- }
- }
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
- #ifdef LSL_INCLUDE_DEBUG_INFO
- char name[] = "money";
- chunk->addBytes(name, strlen(name) + 1);
- chunk->addBytes(mName->mName, strlen(mName->mName) + 1);
- chunk->addBytes(mAmount->mName, strlen(mAmount->mName) + 1);
- #endif
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "money( valuetype [ScriptTypes]LindenLab.SecondLife.Key ");
- mName->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", int32 ");
- mAmount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )");
- break;
- default:
- mName->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mAmount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- }
- S32 LLScriptMoneyEvent::getSize()
- {
- // key + integer = 8
- return 8;
- }
- void LLScriptEmailEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- case LSCP_EMIT_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "email( string ");
- mTime->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", string ");
- mAddress->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", string ");
- mSubject->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", string ");
- mBody->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", integer ");
- mNumber->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )n");
- break;
- case LSCP_SCOPE_PASS1:
- checkForDuplicateHandler(fp, this, scope, "email");
- if (scope->checkEntry(mTime->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mTime->mScopeEntry = scope->addEntry(mTime->mName, LIT_VARIABLE, LST_STRING);
- }
- if (scope->checkEntry(mAddress->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mAddress->mScopeEntry = scope->addEntry(mAddress->mName, LIT_VARIABLE, LST_STRING);
- }
- if (scope->checkEntry(mSubject->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mSubject->mScopeEntry = scope->addEntry(mSubject->mName, LIT_VARIABLE, LST_STRING);
- }
- if (scope->checkEntry(mBody->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mBody->mScopeEntry = scope->addEntry(mBody->mName, LIT_VARIABLE, LST_STRING);
- }
- if (scope->checkEntry(mNumber->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mNumber->mScopeEntry = scope->addEntry(mNumber->mName, LIT_VARIABLE, LST_INTEGER);
- }
- break;
- case LSCP_RESOURCE:
- {
- // we're just tryng to determine how much space the variable needs
- if (mAddress->mScopeEntry)
- {
- mTime->mScopeEntry->mOffset = (S32)count;
- mTime->mScopeEntry->mSize = 4;
- count += mTime->mScopeEntry->mSize;
- mAddress->mScopeEntry->mOffset = (S32)count;
- mAddress->mScopeEntry->mSize = 4;
- count += mAddress->mScopeEntry->mSize;
- mSubject->mScopeEntry->mOffset = (S32)count;
- mSubject->mScopeEntry->mSize = 4;
- count += mSubject->mScopeEntry->mSize;
- mBody->mScopeEntry->mOffset = (S32)count;
- mBody->mScopeEntry->mSize = 4;
- count += mBody->mScopeEntry->mSize;
- mNumber->mScopeEntry->mOffset = (S32)count;
- mNumber->mScopeEntry->mSize = 4;
- count += mNumber->mScopeEntry->mSize;
- }
- }
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
- #ifdef LSL_INCLUDE_DEBUG_INFO
- char name[] = "email";
- chunk->addBytes(name, strlen(name) + 1);
- chunk->addBytes(mTime->mName, strlen(mTime->mName) + 1);
- chunk->addBytes(mAddress->mName, strlen(mAddress->mName) + 1);
- chunk->addBytes(mSubject->mName, strlen(mSubject->mName) + 1);
- chunk->addBytes(mBody->mName, strlen(mBody->mName) + 1);
- chunk->addBytes(mNumber->mName, strlen(mNumber->mName) + 1);
- #endif
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "email( string ");
- mTime->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", string ");
- mAddress->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", string ");
- mSubject->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", string ");
- mBody->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", int32 ");
- mNumber->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )");
- break;
- default:
- mTime->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mAddress->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mSubject->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mBody->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mNumber->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- }
- S32 LLScriptEmailEvent::getSize()
- {
- // string + string + string + string + integer = 16
- return 20;
- }
- void LLScriptRezEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- case LSCP_EMIT_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "rez( integer ");
- mStartParam->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )n");
- break;
- case LSCP_SCOPE_PASS1:
- checkForDuplicateHandler(fp, this, scope, "on_rez");
- if (scope->checkEntry(mStartParam->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mStartParam->mScopeEntry = scope->addEntry(mStartParam->mName, LIT_VARIABLE, LST_INTEGER);
- }
- break;
- case LSCP_RESOURCE:
- {
- // we're just tryng to determine how much space the variable needs
- if (mStartParam->mScopeEntry)
- {
- mStartParam->mScopeEntry->mOffset = (S32)count;
- mStartParam->mScopeEntry->mSize = 4;
- count += mStartParam->mScopeEntry->mSize;
- }
- }
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
- #ifdef LSL_INCLUDE_DEBUG_INFO
- char name[] = "rez";
- chunk->addBytes(name, strlen(name) + 1);
- chunk->addBytes(mStartParam->mName, strlen(mStartParam->mName) + 1);
- #endif
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "rez( int32 ");
- mStartParam->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )");
- break;
- default:
- mStartParam->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- }
- S32 LLScriptRezEvent::getSize()
- {
- // integer = 4
- return 4;
- }
- void LLScriptNoSensorEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "no_sensor()n");
- break;
- case LSCP_EMIT_ASSEMBLY:
- fprintf(fp, "no_sensor()n");
- break;
- case LSCP_SCOPE_PASS1:
- checkForDuplicateHandler(fp, this, scope, "no_sensor");
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
- #ifdef LSL_INCLUDE_DEBUG_INFO
- char name[] = "no_sensor";
- chunk->addBytes(name, strlen(name) + 1);
- #endif
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- fprintf(fp, "no_sensor()");
- break;
- default:
- break;
- }
- }
- S32 LLScriptNoSensorEvent::getSize()
- {
- return 0;
- }
- void LLScriptAtTarget::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- case LSCP_EMIT_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "at_target( integer ");
- mTargetNumber->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", vector ");
- mTargetPosition->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", vector ");
- mOurPosition->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )n");
- break;
- case LSCP_SCOPE_PASS1:
- checkForDuplicateHandler(fp, this, scope, "at_target");
- if (scope->checkEntry(mTargetNumber->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mTargetNumber->mScopeEntry = scope->addEntry(mTargetNumber->mName, LIT_VARIABLE, LST_INTEGER);
- }
- if (scope->checkEntry(mTargetPosition->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mTargetPosition->mScopeEntry = scope->addEntry(mTargetPosition->mName, LIT_VARIABLE, LST_VECTOR);
- }
- if (scope->checkEntry(mOurPosition->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mOurPosition->mScopeEntry = scope->addEntry(mOurPosition->mName, LIT_VARIABLE, LST_VECTOR);
- }
- break;
- case LSCP_RESOURCE:
- {
- // we're just tryng to determine how much space the variable needs
- if (mTargetNumber->mScopeEntry)
- {
- mTargetNumber->mScopeEntry->mOffset = (S32)count;
- mTargetNumber->mScopeEntry->mSize = 4;
- count += mTargetNumber->mScopeEntry->mSize;
- mTargetPosition->mScopeEntry->mOffset = (S32)count;
- mTargetPosition->mScopeEntry->mSize = 12;
- count += mTargetPosition->mScopeEntry->mSize;
- mOurPosition->mScopeEntry->mOffset = (S32)count;
- mOurPosition->mScopeEntry->mSize = 12;
- count += mOurPosition->mScopeEntry->mSize;
- }
- }
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
- #ifdef LSL_INCLUDE_DEBUG_INFO
- char name[] = "at_target";
- chunk->addBytes(name, strlen(name) + 1);
- chunk->addBytes(mTargetNumber->mName, strlen(mTargetNumber->mName) + 1);
- chunk->addBytes(mTargetPosition->mName, strlen(mTargetPosition->mName) + 1);
- chunk->addBytes(mOurPosition->mName, strlen(mOurPosition->mName) + 1);
- #endif
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "at_target( int32 ");
- mTargetNumber->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", class [ScriptTypes]LindenLab.SecondLife.Vector ");
- mTargetPosition->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", class [ScriptTypes]LindenLab.SecondLife.Vector ");
- mOurPosition->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )");
- break;
- default:
- mTargetNumber->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mTargetPosition->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mOurPosition->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- }
- S32 LLScriptAtTarget::getSize()
- {
- // integer + vector + vector = 28
- return 28;
- }
- void LLScriptNotAtTarget::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "not_at_target()n");
- break;
- case LSCP_EMIT_ASSEMBLY:
- fprintf(fp, "not_at_target()n");
- break;
- case LSCP_SCOPE_PASS1:
- checkForDuplicateHandler(fp, this, scope, "not_at_target");
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
- #ifdef LSL_INCLUDE_DEBUG_INFO
- char name[] = "not_at_target";
- chunk->addBytes(name, strlen(name) + 1);
- #endif
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- fprintf(fp, "not_at_target()");
- break;
- default:
- break;
- }
- }
- S32 LLScriptNotAtTarget::getSize()
- {
- return 0;
- }
- void LLScriptAtRotTarget::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- case LSCP_EMIT_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "at_rot_target( integer ");
- mTargetNumber->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", quaternion ");
- mTargetRotation->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", quaternion ");
- mOurRotation->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )n");
- break;
- case LSCP_SCOPE_PASS1:
- checkForDuplicateHandler(fp, this, scope, "at_rot_target");
- if (scope->checkEntry(mTargetNumber->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mTargetNumber->mScopeEntry = scope->addEntry(mTargetNumber->mName, LIT_VARIABLE, LST_INTEGER);
- }
- if (scope->checkEntry(mTargetRotation->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mTargetRotation->mScopeEntry = scope->addEntry(mTargetRotation->mName, LIT_VARIABLE, LST_QUATERNION);
- }
- if (scope->checkEntry(mOurRotation->mName))
- {
- gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
- }
- else
- {
- mOurRotation->mScopeEntry = scope->addEntry(mOurRotation->mName, LIT_VARIABLE, LST_QUATERNION);
- }
- break;
- case LSCP_RESOURCE:
- {
- // we're just tryng to determine how much space the variable needs
- if (mTargetNumber->mScopeEntry)
- {
- mTargetNumber->mScopeEntry->mOffset = (S32)count;
- mTargetNumber->mScopeEntry->mSize = 4;
- count += mTargetNumber->mScopeEntry->mSize;
- mTargetRotation->mScopeEntry->mOffset = (S32)count;
- mTargetRotation->mScopeEntry->mSize = 16;
- count += mTargetRotation->mScopeEntry->mSize;
- mOurRotation->mScopeEntry->mOffset = (S32)count;
- mOurRotation->mScopeEntry->mSize = 16;
- count += mOurRotation->mScopeEntry->mSize;
- }
- }
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
- #ifdef LSL_INCLUDE_DEBUG_INFO
- char name[] = "at_rot_target";
- chunk->addBytes(name, strlen(name) + 1);
- chunk->addBytes(mTargetNumber->mName, strlen(mTargetNumber->mName) + 1);
- chunk->addBytes(mTargetRotation->mName, strlen(mTargetRotation->mName) + 1);
- chunk->addBytes(mOurRotation->mName, strlen(mOurRotation->mName) + 1);
- #endif
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "at_rot_target( int32 ");
- mTargetNumber->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", class [ScriptTypes]LindenLab.SecondLife.Quaternion ");
- mTargetRotation->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, ", class [ScriptTypes]LindenLab.SecondLife.Quaternion ");
- mOurRotation->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " )");
- break;
- default:
- mTargetNumber->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mTargetRotation->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mOurRotation->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- }
- S32 LLScriptAtRotTarget::getSize()
- {
- // integer + quaternion + quaternion = 36
- return 36;
- }
- void LLScriptNotAtRotTarget::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- fdotabs(fp, tabs, tabsize);
- fprintf(fp, "not_at_rot_target()n");
- break;
- case LSCP_EMIT_ASSEMBLY:
- fprintf(fp, "not_at_rot_target()n");
- break;
- case LSCP_EMIT_BYTE_CODE:
- {
- #ifdef LSL_INCLUDE_DEBUG_INFO
- char name[] = "not_at_rot_target";
- chunk->addBytes(name, strlen(name) + 1);
- #endif
- }
- break;
- case LSCP_SCOPE_PASS1:
- checkForDuplicateHandler(fp, this, scope, "not_at_rot_target");
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- fprintf(fp, "not_at_rot_target()");
- break;
- default:
- break;
- }
- }
- S32 LLScriptNotAtRotTarget::getSize()
- {
- return 0;
- }
- void LLScriptExpression::addExpression(LLScriptExpression *expression)
- {
- if (mNextp)
- {
- expression->mNextp = mNextp;
- }
- mNextp = expression;
- }
- void LLScriptExpression::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- fprintf(fp, "Expression Base Class -- should never get here!n");
- }
- S32 LLScriptExpression::getSize()
- {
- printf("Expression Base Class -- should never get here!n");
- return 0;
- }
- void LLScriptExpression::gonext(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- if (mNextp)
- {
- fprintf(fp, ", ");
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- default:
- if (mNextp)
- {
- mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- }
- }
- void LLScriptForExpressionList::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- mFirstp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mSecondp)
- {
- fprintf(fp, ", ");
- mSecondp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- case LSCP_EMIT_ASSEMBLY:
- mFirstp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mFirstp->mReturnType)
- {
- fprintf(fp, "%sn", LSCRIPTTypePop[mFirstp->mReturnType]);
- }
- if (mSecondp)
- {
- mSecondp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mSecondp->mReturnType)
- {
- fprintf(fp, "%sn", LSCRIPTTypePop[mSecondp->mReturnType]);
- }
- }
- break;
- case LSCP_TO_STACK:
- mFirstp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- switch(mFirstp->mReturnType)
- {
- case LST_INTEGER:
- case LST_FLOATINGPOINT:
- chunk->addByte(LSCRIPTOpCodes[LOPC_POP]);
- break;
- case LST_STRING:
- case LST_KEY:
- chunk->addByte(LSCRIPTOpCodes[LOPC_POPS]);
- break;
- case LST_LIST:
- chunk->addByte(LSCRIPTOpCodes[LOPC_POPL]);
- break;
- case LST_VECTOR:
- chunk->addByte(LSCRIPTOpCodes[LOPC_POPV]);
- break;
- case LST_QUATERNION:
- chunk->addByte(LSCRIPTOpCodes[LOPC_POPQ]);
- break;
- default:
- break;
- }
- if (mSecondp)
- {
- mSecondp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- switch(mSecondp->mReturnType)
- {
- case LST_INTEGER:
- case LST_FLOATINGPOINT:
- chunk->addByte(LSCRIPTOpCodes[LOPC_POP]);
- break;
- case LST_STRING:
- case LST_KEY:
- chunk->addByte(LSCRIPTOpCodes[LOPC_POPS]);
- break;
- case LST_LIST:
- chunk->addByte(LSCRIPTOpCodes[LOPC_POPL]);
- break;
- case LST_VECTOR:
- chunk->addByte(LSCRIPTOpCodes[LOPC_POPV]);
- break;
- case LST_QUATERNION:
- chunk->addByte(LSCRIPTOpCodes[LOPC_POPQ]);
- break;
- default:
- break;
- }
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- mFirstp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mFirstp->mReturnType)
- {
- fprintf(fp, "popn");
- }
- if (mSecondp)
- {
- mSecondp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mSecondp->mReturnType)
- {
- fprintf(fp, "popn");
- }
- }
- break;
- default:
- mFirstp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mSecondp)
- {
- mSecondp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- }
- }
- S32 LLScriptForExpressionList::getSize()
- {
- return 0;
- }
- // CIL code generation requires both caller and callee scope entries, so cannot use normal recurse signature.
- // TODO: Refactor general purpose recurse calls in to pass specific virtuals using visitor pattern to select method by pass and node type.
- static void print_cil_func_expression_list(LLScriptFuncExpressionList* self, LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata, LLScriptScopeEntry *callee_entry)
- {
- self->mFirstp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- LSCRIPTType argtype = callee_entry->mFunctionArgs.getType(entrycount);
- if (argtype != self->mFirstp->mReturnType)
- {
- print_cil_cast(fp, self->mFirstp->mReturnType, argtype);
- }
- entrycount++;
- if (self->mSecondp)
- {
- llassert(LET_FUNC_EXPRESSION_LIST == self->mSecondp->mType);
- print_cil_func_expression_list((LLScriptFuncExpressionList*) self->mSecondp, fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL, callee_entry);
- }
- }
- void LLScriptFuncExpressionList::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- mFirstp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mSecondp)
- {
- fprintf(fp, ", ");
- mSecondp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- case LSCP_TYPE:
- {
- mFirstp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (!entry->mFunctionArgs.getType(entrycount))
- {
- gErrorToText.writeError(fp, this, LSERROR_FUNCTION_TYPE_ERROR);
- }
- if (!legal_assignment(entry->mFunctionArgs.getType(entrycount), mFirstp->mReturnType))
- {
- gErrorToText.writeError(fp, this, LSERROR_FUNCTION_TYPE_ERROR);
- }
- count++;
- entrycount++;
- if (mSecondp)
- {
- mSecondp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mSecondp->mReturnType)
- {
- count++;
- if (!entry->mFunctionArgs.getType(entrycount))
- {
- gErrorToText.writeError(fp, this, LSERROR_FUNCTION_TYPE_ERROR);
- }
- if (!legal_assignment(entry->mFunctionArgs.getType(entrycount), mSecondp->mReturnType))
- {
- gErrorToText.writeError(fp, this, LSERROR_FUNCTION_TYPE_ERROR);
- }
- }
- }
- }
- break;
- case LSCP_EMIT_ASSEMBLY:
- {
- mFirstp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- LSCRIPTType argtype = entry->mFunctionArgs.getType(entrycount);
- if (argtype != mFirstp->mReturnType)
- {
- fprintf(fp, "CAST %s->%sn", LSCRIPTTypeNames[mFirstp->mReturnType], LSCRIPTTypeNames[argtype]);
- }
- entrycount++;
- if (mSecondp)
- {
- mSecondp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mSecondp->mReturnType)
- {
- argtype = entry->mFunctionArgs.getType(entrycount);
- if (argtype != mSecondp->mReturnType)
- {
- fprintf(fp, "CAST %s->%sn", LSCRIPTTypeNames[mSecondp->mReturnType], LSCRIPTTypeNames[argtype]);
- }
- }
- }
- }
- break;
- case LSCP_TO_STACK:
- {
- mFirstp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- LSCRIPTType argtype = entry->mFunctionArgs.getType(entrycount);
- if (argtype != mFirstp->mReturnType)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_CAST]);
- U8 castbyte = LSCRIPTTypeByte[argtype] | LSCRIPTTypeHi4Bits[mFirstp->mReturnType];
- chunk->addByte(castbyte);
- }
- entrycount++;
- if (mSecondp)
- {
- mSecondp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mSecondp->mReturnType)
- {
- argtype = entry->mFunctionArgs.getType(entrycount);
- if (argtype != mSecondp->mReturnType)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_CAST]);
- U8 castbyte = LSCRIPTTypeByte[argtype] | LSCRIPTTypeHi4Bits[mSecondp->mReturnType];
- chunk->addByte(castbyte);
- }
- }
- }
- }
- break;
- default:
- mFirstp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mSecondp)
- {
- mSecondp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- }
- }
- S32 LLScriptFuncExpressionList::getSize()
- {
- return 0;
- }
- void LLScriptListExpressionList::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- mFirstp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mSecondp)
- {
- fprintf(fp, ", ");
- mSecondp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- case LSCP_EMIT_ASSEMBLY:
- mFirstp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mFirstp->mType != LET_LIST_EXPRESSION_LIST)
- {
- fprintf(fp, "%sn", LSCRIPTListDescription[mFirstp->mReturnType]);
- count++;
- }
- if (mSecondp)
- {
- mSecondp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mSecondp->mType != LET_LIST_EXPRESSION_LIST)
- {
- fprintf(fp, "%sn", LSCRIPTListDescription[mSecondp->mReturnType]);
- count++;
- }
- }
- break;
- case LSCP_TO_STACK:
- mFirstp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mFirstp->mType != LET_LIST_EXPRESSION_LIST)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHARGB]);
- chunk->addByte(LSCRIPTTypeByte[mFirstp->mReturnType]);
- count++;
- }
- if (mSecondp)
- {
- mSecondp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mSecondp->mType != LET_LIST_EXPRESSION_LIST)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHARGB]);
- chunk->addByte(LSCRIPTTypeByte[mSecondp->mReturnType]);
- count++;
- }
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- mFirstp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mFirstp->mType != LET_LIST_EXPRESSION_LIST)
- {
- // Box value.
- print_cil_box(fp, mFirstp->mReturnType);
- ++count;
- }
- if (mSecondp)
- {
- mSecondp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mSecondp->mType != LET_LIST_EXPRESSION_LIST)
- {
- // Box value.
- print_cil_box(fp, mSecondp->mReturnType);
- ++count;
- }
- }
- break;
- default:
- mFirstp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mSecondp)
- {
- mSecondp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- }
- }
- S32 LLScriptListExpressionList::getSize()
- {
- return 0;
- }
- // Returns true if identifier is a parameter and false if identifier is a local variable within function_scope.
- bool is_parameter(LLScriptIdentifier* identifier, LLScriptScopeEntry* function_scope)
- {
- // Function stores offset of first local.
- if(0 == function_scope->mOffset)
- {
- // Function offset 0 -> no parameters -> identifier is a local.
- return false;
- }
- else
- {
- // Compare variable offset with function offset to
- // determine whether variable is local or parameter.
- return (identifier->mScopeEntry->mOffset < function_scope->mOffset);
- }
- }
- // If assignment is to global variable, pushes this pointer on to stack.
- static void print_cil_load_address(LLFILE* fp, LLScriptExpression* exp, LLScriptScopeEntry* function_scope)
- {
- LLScriptLValue *lvalue = (LLScriptLValue *) exp;
- LLScriptIdentifier *ident = lvalue->mIdentifier;
- // If global (member), load this pointer.
- if(ident->mScopeEntry->mIDType == LIT_GLOBAL)
- {
- fprintf(fp, "ldarg.0n");
- }
- // If accessor, load value type address, consumed by ldfld.
- if(lvalue->mAccessor)
- {
- if(ident->mScopeEntry->mIDType == LIT_VARIABLE)
- {
- if(is_parameter(ident, function_scope))
- {
- // Parameter, load by name.
- fprintf(fp, "ldarga.s '%s'n", ident->mScopeEntry->mIdentifier);
- }
- else
- {
- // Local, load by index.
- fprintf(fp, "ldloca.s %dn", ident->mScopeEntry->mCount);
- }
- }
- else if (ident->mScopeEntry->mIDType == LIT_GLOBAL)
- {
- fprintf(fp, "ldflda ");
- print_cil_member(fp, ident);
- }
- }
- }
- static void print_cil_accessor(LLFILE* fp, LLScriptLValue *lvalue)
- {
- LLScriptIdentifier *ident = lvalue->mIdentifier;
- print_cil_type(fp, lvalue->mReturnType);
- fprintf(fp, " ");
- print_cil_type(fp, ident->mScopeEntry->mType);
- fprintf(fp, "::%sn", lvalue->mAccessor->mName);
- }
- void LLScriptLValue::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- if (mAccessor)
- {
- fprintf(fp, ".");
- mAccessor->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- break;
- case LSCP_EMIT_ASSEMBLY:
- if (mIdentifier->mScopeEntry->mIDType == LIT_VARIABLE)
- {
- if (mAccessor)
- {
- fprintf(fp, "%s%d [%s.%s]n", LSCRIPTTypeLocalPush[mReturnType], mIdentifier->mScopeEntry->mOffset + mOffset, mIdentifier->mName, mAccessor->mName);
- }
- else
- {
- fprintf(fp, "%s%d [%s]n", LSCRIPTTypeLocalPush[mIdentifier->mScopeEntry->mType], mIdentifier->mScopeEntry->mOffset, mIdentifier->mName);
- }
- }
- else if (mIdentifier->mScopeEntry->mIDType == LIT_GLOBAL)
- {
- if (mAccessor)
- {
- fprintf(fp, "%s%d [%s.%s]n", LSCRIPTTypeGlobalPush[mReturnType], mIdentifier->mScopeEntry->mOffset + mOffset, mIdentifier->mName, mAccessor->mName);
- }
- else
- {
- fprintf(fp, "%s%d [%s]n", LSCRIPTTypeGlobalPush[mIdentifier->mScopeEntry->mType], mIdentifier->mScopeEntry->mOffset, mIdentifier->mName);
- }
- }
- else
- {
- fprintf(fp, "Unexpected LValue!n");
- }
- break;
- case LSCP_SCOPE_PASS1:
- {
- LLScriptScopeEntry *entry = scope->findEntry(mIdentifier->mName);
- if (!entry || ( (entry->mIDType != LIT_GLOBAL) && (entry->mIDType != LIT_VARIABLE)))
- {
- gErrorToText.writeError(fp, this, LSERROR_UNDEFINED_NAME);
- }
- else
- {
- // if we did find it, make sure this identifier is associated with the correct scope entry
- mIdentifier->mScopeEntry = entry;
- }
- }
- break;
- case LSCP_TYPE:
- // if we have an accessor, we need to change what type our identifier returns and set our offset value
- if (mIdentifier->mScopeEntry)
- {
- if (mAccessor)
- {
- BOOL b_ok = FALSE;
- if (mIdentifier->mScopeEntry->mIDType == LIT_VARIABLE)
- {
- if (mIdentifier->mScopeEntry->mType == LST_VECTOR)
- {
- if (!strcmp("x", mAccessor->mName))
- {
- mOffset = 0;
- b_ok = TRUE;
- }
- else if (!strcmp("y", mAccessor->mName))
- {
- mOffset = 4;
- b_ok = TRUE;
- }
- else if (!strcmp("z", mAccessor->mName))
- {
- mOffset = 8;
- b_ok = TRUE;
- }
- }
- else if (mIdentifier->mScopeEntry->mType == LST_QUATERNION)
- {
- if (!strcmp("x", mAccessor->mName))
- {
- mOffset = 0;
- b_ok = TRUE;
- }
- else if (!strcmp("y", mAccessor->mName))
- {
- mOffset = 4;
- b_ok = TRUE;
- }
- else if (!strcmp("z", mAccessor->mName))
- {
- mOffset = 8;
- b_ok = TRUE;
- }
- else if (!strcmp("s", mAccessor->mName))
- {
- mOffset = 12;
- b_ok = TRUE;
- }
- }
- }
- else
- {
- if (mIdentifier->mScopeEntry->mType == LST_VECTOR)
- {
- if (!strcmp("x", mAccessor->mName))
- {
- mOffset = 8;
- b_ok = TRUE;
- }
- else if (!strcmp("y", mAccessor->mName))
- {
- mOffset = 4;
- b_ok = TRUE;
- }
- else if (!strcmp("z", mAccessor->mName))
- {
- mOffset = 0;
- b_ok = TRUE;
- }
- }
- else if (mIdentifier->mScopeEntry->mType == LST_QUATERNION)
- {
- if (!strcmp("x", mAccessor->mName))
- {
- mOffset = 12;
- b_ok = TRUE;
- }
- else if (!strcmp("y", mAccessor->mName))
- {
- mOffset = 8;
- b_ok = TRUE;
- }
- else if (!strcmp("z", mAccessor->mName))
- {
- mOffset = 4;
- b_ok = TRUE;
- }
- else if (!strcmp("s", mAccessor->mName))
- {
- mOffset = 0;
- b_ok = TRUE;
- }
- }
- }
- if (b_ok)
- {
- mReturnType = type = LST_FLOATINGPOINT;
- }
- else
- {
- gErrorToText.writeError(fp, this, LSERROR_VECTOR_METHOD_ERROR);
- }
- }
- else
- {
- mReturnType = type = mIdentifier->mScopeEntry->mType;
- }
- }
- else
- {
- mReturnType = type = LST_UNDEFINED;
- }
- break;
- case LSCP_TO_STACK:
- {
- switch(mReturnType)
- {
- case LST_INTEGER:
- case LST_FLOATINGPOINT:
- if (mIdentifier->mScopeEntry->mIDType == LIT_VARIABLE)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_PUSH]);
- }
- else
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHG]);
- }
- break;
- case LST_KEY:
- case LST_STRING:
- if (mIdentifier->mScopeEntry->mIDType == LIT_VARIABLE)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHS]);
- }
- else
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHGS]);
- }
- break;
- case LST_LIST:
- if (mIdentifier->mScopeEntry->mIDType == LIT_VARIABLE)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHL]);
- }
- else
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHGL]);
- }
- break;
- case LST_VECTOR:
- if (mIdentifier->mScopeEntry->mIDType == LIT_VARIABLE)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHV]);
- }
- else
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHGV]);
- }
- break;
- case LST_QUATERNION:
- if (mIdentifier->mScopeEntry->mIDType == LIT_VARIABLE)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHQ]);
- }
- else
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHGQ]);
- }
- break;
- default:
- if (mIdentifier->mScopeEntry->mIDType == LIT_VARIABLE)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_PUSH]);
- }
- else
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHG]);
- }
- break;
- }
- S32 address = mIdentifier->mScopeEntry->mOffset + mOffset;
- chunk->addInteger(address);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- print_cil_load_address(fp, this, entry);
- if(mAccessor)
- {
- fprintf(fp, "ldfld ");
- print_cil_accessor(fp, this);
- }
- else if(mIdentifier->mScopeEntry->mIDType == LIT_VARIABLE)
- {
- if(is_parameter(mIdentifier, entry))
- {
- // Parameter, load by name.
- fprintf(fp, "ldarg.s '%s'n", mIdentifier->mScopeEntry->mIdentifier);
- }
- else
- {
- // Local, load by index.
- fprintf(fp, "ldloc.s %dn", mIdentifier->mScopeEntry->mCount);
- }
- }
- else if (mIdentifier->mScopeEntry->mIDType == LIT_GLOBAL)
- {
- fprintf(fp, "ldfld ");
- print_cil_member(fp, mIdentifier);
- }
- else
- {
- fprintf(fp, "Unexpected LValue!n");
- }
- break;
- default:
- mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- S32 LLScriptLValue::getSize()
- {
- return 0;
- }
- static void print_assignment(LLFILE *fp, LLScriptExpression *exp)
- {
- LLScriptLValue *lvalue = (LLScriptLValue *)exp;
- LLScriptIdentifier *ident = lvalue->mIdentifier;
- if (lvalue->mAccessor)
- {
- if (ident->mScopeEntry->mIDType == LIT_VARIABLE)
- {
- fprintf(fp, "%s%d [%s.%s]n", LSCRIPTTypeLocalStore[ident->mScopeEntry->mType], ident->mScopeEntry->mOffset + lvalue->mOffset, ident->mName, lvalue->mAccessor->mName);
- }
- else if (ident->mScopeEntry->mIDType == LIT_GLOBAL)
- {
- fprintf(fp, "%s%d [%s.%s]n", LSCRIPTTypeGlobalStore[ident->mScopeEntry->mType], ident->mScopeEntry->mOffset + lvalue->mOffset, ident->mName, lvalue->mAccessor->mName);
- }
- }
- else
- {
- if (ident->mScopeEntry->mIDType == LIT_VARIABLE)
- {
- fprintf(fp, "%s%d [%s]n", LSCRIPTTypeLocalStore[ident->mScopeEntry->mType], ident->mScopeEntry->mOffset, ident->mName);
- }
- else if (ident->mScopeEntry->mIDType == LIT_GLOBAL)
- {
- fprintf(fp, "%s%d [%s]n", LSCRIPTTypeGlobalStore[ident->mScopeEntry->mType], ident->mScopeEntry->mOffset, ident->mName);
- }
- }
- }
- static void print_cil_assignment(LLFILE *fp, LLScriptExpression *exp, LLScriptScopeEntry* function_scope)
- {
- LLScriptLValue *lvalue = (LLScriptLValue *) exp;
- LLScriptIdentifier *ident = lvalue->mIdentifier;
- if (lvalue->mAccessor)
- {
- // Object address loaded, store in to field.
- fprintf(fp, "stfld ");
- print_cil_accessor(fp, lvalue);
- // Load object address.
- print_cil_load_address(fp, exp, function_scope);
- // Load field.
- fprintf(fp, "ldfld ");
- print_cil_accessor(fp, lvalue);
- }
- else
- {
- if (ident->mScopeEntry->mIDType == LIT_VARIABLE)
- {
- // Language semantics require value of assignment to be left on stack.
- // TODO: Optimise away redundant dup/pop pairs.
- fprintf(fp, "dupn");
- if(is_parameter(ident, function_scope))
- {
- // Parameter, store by name.
- fprintf(fp, "starg.s '%s'n", ident->mScopeEntry->mIdentifier);
- }
- else
- {
- // Local, store by index.
- fprintf(fp, "stloc.s %dn", ident->mScopeEntry->mCount);
- }
- }
- else if (ident->mScopeEntry->mIDType == LIT_GLOBAL)
- {
- // Object address loaded, store in to field.
- fprintf(fp, "stfld ");
- print_cil_member(fp, ident);
- // Load object address.
- print_cil_load_address(fp, exp, function_scope);
- // Load field.
- fprintf(fp, "ldfld ");
- print_cil_member(fp, ident);
- }
- }
- }
- void print_cast(LLFILE *fp, LSCRIPTType ret_type, LSCRIPTType right_type)
- {
- if (right_type != ret_type)
- {
- fprintf(fp, "CAST %s->%sn", LSCRIPTTypeNames[right_type], LSCRIPTTypeNames[ret_type]);
- }
- }
- void cast2stack(LLScriptByteCodeChunk *chunk, LSCRIPTType ret_type, LSCRIPTType right_type)
- {
- if (right_type != ret_type)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_CAST]);
- U8 castbyte = LSCRIPTTypeByte[right_type] | LSCRIPTTypeHi4Bits[ret_type];
- chunk->addByte(castbyte);
- }
- }
- void operation2stack(LLScriptByteCodeChunk *chunk, LSCRIPTType ret_type, LSCRIPTType right_type)
- {
- U8 typebyte = LSCRIPTTypeByte[right_type] | LSCRIPTTypeHi4Bits[ret_type];
- chunk->addByte(typebyte);
- }
- void store2stack(LLScriptExpression *exp, LLScriptExpression *lv, LLScriptByteCodeChunk *chunk, LSCRIPTType right_type)
- {
- LLScriptLValue *lvalue = (LLScriptLValue *)lv;
- LLScriptIdentifier *ident = lvalue->mIdentifier;
- LSCRIPTType rettype = exp->mReturnType;
- if (exp->mRightType != LST_NULL)
- {
- if (legal_binary_expression(rettype, exp->mLeftType, exp->mRightType, exp->mType))
- cast2stack(chunk, right_type, exp->mReturnType);
- }
- switch(exp->mReturnType)
- {
- case LST_INTEGER:
- case LST_FLOATINGPOINT:
- if (ident->mScopeEntry->mIDType == LIT_VARIABLE)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_STORE]);
- }
- else
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_STOREG]);
- }
- break;
- case LST_KEY:
- case LST_STRING:
- if (ident->mScopeEntry->mIDType == LIT_VARIABLE)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_STORES]);
- }
- else
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_STOREGS]);
- }
- break;
- case LST_LIST:
- if (ident->mScopeEntry->mIDType == LIT_VARIABLE)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_STOREL]);
- }
- else
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_STOREGL]);
- }
- break;
- case LST_VECTOR:
- if (ident->mScopeEntry->mIDType == LIT_VARIABLE)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_STOREV]);
- }
- else
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_STOREGV]);
- }
- break;
- case LST_QUATERNION:
- if (ident->mScopeEntry->mIDType == LIT_VARIABLE)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_STOREQ]);
- }
- else
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_STOREGQ]);
- }
- break;
- default:
- if (ident->mScopeEntry->mIDType == LIT_VARIABLE)
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_STORE]);
- }
- else
- {
- chunk->addByte(LSCRIPTOpCodes[LOPC_STOREG]);
- }
- break;
- }
- S32 address = ident->mScopeEntry->mOffset + lvalue->mOffset;
- chunk->addInteger(address);
- }
- void LLScriptAssignment::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " = ");
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_EMIT_ASSEMBLY:
- {
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cast(fp, mReturnType, mRightType);
- print_assignment(fp, mLValue);
- }
- break;
- case LSCP_TYPE:
- {
- mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLeftType = type;
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightType = type;
- if (!legal_assignment(mLeftType, mRightType))
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- type = mReturnType = mLeftType;
- }
- break;
- case LSCP_TO_STACK:
- {
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- store2stack(this, mLValue, chunk, mRightType);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- {
- print_cil_load_address(fp, mLValue, entry);
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_assignment_cast(fp, mRightType, mReturnType);
- print_cil_assignment(fp, mLValue, entry);
- }
- break;
- default:
- mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- S32 LLScriptAssignment::getSize()
- {
- return 0;
- }
- static void print_cil_add(LLFILE* fp, LSCRIPTType left_type, LSCRIPTType right_type)
- {
- if(LST_LIST == right_type && LST_LIST != left_type)
- {
- print_cil_box(fp, left_type);
- fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::Prepend(class [mscorlib]System.Collections.ArrayList, object)n");
- return;
- }
- switch(left_type)
- {
- case LST_INTEGER:
- case LST_FLOATINGPOINT:
- // Numeric addition.
- fprintf(fp, "addn");
- break;
- case LST_STRING:
- case LST_KEY:
- // String concatenation.
- fprintf(fp, "call string valuetype [LslUserScript]LindenLab.SecondLife.LslUserScript::Add(string, string)n");
- break;
-
- case LST_VECTOR:
- // Vector addition.
- fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Vector class [LslUserScript]LindenLab.SecondLife.LslUserScript::'Add'(class [ScriptTypes]LindenLab.SecondLife.Vector, class [ScriptTypes]LindenLab.SecondLife.Vector)n");
- break;
- case LST_QUATERNION:
- // Rotation addition.
- fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Quaternion class [LslUserScript]LindenLab.SecondLife.LslUserScript::'Add'(class [ScriptTypes]LindenLab.SecondLife.Quaternion, class [ScriptTypes]LindenLab.SecondLife.Quaternion)n");
- break;
- case LST_LIST:
- switch(right_type)
- {
- case LST_LIST:
- // Concatenate lists.
- fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::Append(class [mscorlib]System.Collections.ArrayList, class [mscorlib]System.Collections.ArrayList)n");
- break;
- case LST_INTEGER:
- fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::Append(int32, class [mscorlib]System.Collections.ArrayList)n");
- break;
- case LST_FLOATINGPOINT:
- fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::Append(float32, class [mscorlib]System.Collections.ArrayList)n");
- break;
- case LST_STRING:
- fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::Append(string, class [mscorlib]System.Collections.ArrayList)n");
- break;
- case LST_KEY:
- fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::Append(valuetype [ScriptTypes]LindenLab.SecondLife.Key, class [mscorlib]System.Collections.ArrayList)n");
- break;
- case LST_VECTOR:
- fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::Append(valuetype [ScriptTypes]LindenLab.SecondLife.Vector, class [mscorlib]System.Collections.ArrayList)n");
- break;
- case LST_QUATERNION:
- fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::Append(valuetype [ScriptTypes]LindenLab.SecondLife.Quaternion, class [mscorlib]System.Collections.ArrayList)n");
- break;
- default:
- break;
- }
- default:
- break;
- }
- }
- void LLScriptAddAssignment::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " += ");
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_EMIT_ASSEMBLY:
- {
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "ADD %s, %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_ADD]);
- operation2stack(chunk, mReturnType, mRightType);
- store2stack(this, mLValue, chunk, mReturnType);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- {
- print_cil_load_address(fp, mLValue, entry);
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_numeric_cast(fp, mRightSide->mReturnType, mLValue->mReturnType);
- mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_numeric_cast(fp, mLValue->mReturnType, mRightSide->mReturnType);
- print_cil_add(fp, mLValue->mReturnType, mRightSide->mReturnType);
- print_cil_assignment(fp, mLValue, entry);
- }
- break;
- default:
- mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- S32 LLScriptAddAssignment::getSize()
- {
- return 0;
- }
- static void print_cil_sub(LLFILE* fp, LSCRIPTType left_type, LSCRIPTType right_type)
- {
- switch(left_type)
- {
- case LST_INTEGER:
- if(LST_INTEGER == right_type)
- {
- fprintf(fp, "call int32 [LslUserScript]LindenLab.SecondLife.LslUserScript::Subtract(int32, int32)n");
- break;
- }
- case LST_FLOATINGPOINT:
- // Numeric subtraction.
- fprintf(fp, "call float64 [LslUserScript]LindenLab.SecondLife.LslUserScript::Subtract(float64, float64)n");
- break;
- case LST_VECTOR:
- // Vector subtraction.
- fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Vector class [LslUserScript]LindenLab.SecondLife.LslUserScript::'Subtract'(class [ScriptTypes]LindenLab.SecondLife.Vector, class [ScriptTypes]LindenLab.SecondLife.Vector)n");
- break;
- case LST_QUATERNION:
- // Rotation subtraction.
- fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Quaternion class [LslUserScript]LindenLab.SecondLife.LslUserScript::'Subtract'(class [ScriptTypes]LindenLab.SecondLife.Quaternion, class [ScriptTypes]LindenLab.SecondLife.Quaternion)n");
- break;
- default:
- // Error.
- break;
- }
- }
- void LLScriptSubAssignment::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " -= ");
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_EMIT_ASSEMBLY:
- {
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "SUB %s, %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_SUB]);
- operation2stack(chunk, mReturnType, mRightType);
- store2stack(this, mLValue, chunk, mReturnType);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- {
- print_cil_load_address(fp, mLValue, entry);
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_numeric_cast(fp, mRightSide->mReturnType, mLValue->mReturnType);
- mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_numeric_cast(fp, mLValue->mReturnType, mRightSide->mReturnType);
- print_cil_sub(fp, mLValue->mReturnType, mRightSide->mReturnType);
- print_cil_assignment(fp, mLValue, entry);
- }
- break;
- default:
- mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- S32 LLScriptSubAssignment::getSize()
- {
- return 0;
- }
- static void print_cil_neg(LLFILE* fp, LSCRIPTType type)
- {
- switch(type)
- {
- case LST_INTEGER:
- case LST_FLOATINGPOINT:
- fprintf(fp, "negn");
- break;
- case LST_VECTOR:
- fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Vector class [LslUserScript]LindenLab.SecondLife.LslUserScript::'Negate'(class [ScriptTypes]LindenLab.SecondLife.Vector)n");
- break;
- case LST_QUATERNION:
- fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Quaternion class [LslUserScript]LindenLab.SecondLife.LslUserScript::'Negate'(class [ScriptTypes]LindenLab.SecondLife.Quaternion)n");
- break;
- default:
- break;
- }
- }
- static void print_cil_mul(LLFILE* fp, LSCRIPTType left_type, LSCRIPTType right_type)
- {
- switch(left_type)
- {
- case LST_INTEGER:
- switch(right_type)
- {
- case LST_INTEGER:
- case LST_FLOATINGPOINT:
- // Numeric multiplication.
- fprintf(fp, "muln");
- break;
- case LST_VECTOR:
- // Vector scaling.
- fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Vector class [LslUserScript]LindenLab.SecondLife.LslUserScript::'Multiply'(class [ScriptTypes]LindenLab.SecondLife.Vector, float32)n");
- break;
- default:
- break;
- }
- break;
- case LST_FLOATINGPOINT:
- switch(right_type)
- {
- case LST_INTEGER:
- case LST_FLOATINGPOINT:
- // Numeric multiplication.
- fprintf(fp, "muln");
- break;
- case LST_VECTOR:
- // Vector scaling.
- fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Vector class [LslUserScript]LindenLab.SecondLife.LslUserScript::'Multiply'(class [ScriptTypes]LindenLab.SecondLife.Vector, float32)n");
- break;
- default:
- break;
- }
- break;
-
- case LST_VECTOR:
- switch(right_type)
- {
- case LST_INTEGER:
- case LST_FLOATINGPOINT:
- // Vector scaling.
- fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Vector class [LslUserScript]LindenLab.SecondLife.LslUserScript::'Multiply'(float32, class [ScriptTypes]LindenLab.SecondLife.Vector)n");
- break;
- case LST_VECTOR:
- // Dot product.
- fprintf(fp, "call float32 class [LslUserScript]LindenLab.SecondLife.LslUserScript::'Multiply'(class [ScriptTypes]LindenLab.SecondLife.Vector, class [ScriptTypes]LindenLab.SecondLife.Vector)n");
- break;
- case LST_QUATERNION:
- // Vector rotation.
- fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Vector class [LslUserScript]LindenLab.SecondLife.LslUserScript::'Multiply'(class [ScriptTypes]LindenLab.SecondLife.Quaternion, class [ScriptTypes]LindenLab.SecondLife.Vector)n");
- break;
- default:
- break;
- }
- break;
- case LST_QUATERNION:
- // Rotation multiplication.
- fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Quaternion class [LslUserScript]LindenLab.SecondLife.LslUserScript::'Multiply'(class [ScriptTypes]LindenLab.SecondLife.Quaternion, class [ScriptTypes]LindenLab.SecondLife.Quaternion)n");
- break;
- default:
- // Error.
- break;
- }
- }
- void LLScriptMulAssignment::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " *= ");
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_EMIT_ASSEMBLY:
- {
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "MUL %s, %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) /*|| !legal_assignment(mLValue->mReturnType, mReturnType)*/)
- {
- gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
- }
- type = mReturnType;
- }
- break;
- case LSCP_TO_STACK:
- {
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- chunk->addByte(LSCRIPTOpCodes[LOPC_MUL]);
- operation2stack(chunk, mReturnType, mRightType);
- store2stack(this, mLValue, chunk, mReturnType);
- }
- break;
- case LSCP_EMIT_CIL_ASSEMBLY:
- {
- print_cil_load_address(fp, mLValue, entry);
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_numeric_cast(fp, mRightSide->mReturnType, mLValue->mReturnType);
- mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- print_cil_numeric_cast(fp, mLValue->mReturnType, mRightSide->mReturnType);
- print_cil_mul(fp, mLValue->mReturnType, mRightSide->mReturnType);
- if((mLValue->mReturnType == LST_INTEGER) &&
- (mRightSide->mReturnType == LST_FLOATINGPOINT))
- {
- print_cil_cast(fp, LST_FLOATINGPOINT, LST_INTEGER);
- }
- print_cil_assignment(fp, mLValue, entry);
- }
- break;
- default:
- mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- }
- gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- }
- S32 LLScriptMulAssignment::getSize()
- {
- return 0;
- }
- static void print_cil_div(LLFILE* fp, LSCRIPTType left_type, LSCRIPTType right_type)
- {
- switch(left_type)
- {
- case LST_INTEGER:
- if(LST_INTEGER == right_type)
- {
- fprintf(fp, "call int32 [LslUserScript]LindenLab.SecondLife.LslUserScript::Divide(int32, int32)n");
- break;
- }
- case LST_FLOATINGPOINT:
- // Numeric division.
- fprintf(fp, "call float64 [LslUserScript]LindenLab.SecondLife.LslUserScript::Divide(float64, float64)n");
- break;
-
- case LST_VECTOR:
- switch(right_type)
- {
- case LST_INTEGER:
- case LST_FLOATINGPOINT:
- // Scale.
- fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Vector class [LslUserScript]LindenLab.SecondLife.LslUserScript::'Divide'(float32, class [ScriptTypes]LindenLab.SecondLife.Vector)n");
- break;
- case LST_QUATERNION:
- // Inverse rotation.
- fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Vector class [LslUserScript]LindenLab.SecondLife.LslUserScript::'Divide'(class [ScriptTypes]LindenLab.SecondLife.Quaternion, class [ScriptTypes]LindenLab.SecondLife.Vector)n");
- break;
- default:
- break;
- }
- break;
- case LST_QUATERNION:
- fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Quaternion class [LslUserScript]LindenLab.SecondLife.LslUserScript::'Divide'(class [ScriptTypes]LindenLab.SecondLife.Quaternion, class [ScriptTypes]LindenLab.SecondLife.Quaternion)n");
- break;
- default:
- // Error.
- break;
- }
- }
- void LLScriptDivAssignment::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
- {
- if (gErrorToText.getErrors())
- {
- return;
- }
- switch(pass)
- {
- case LSCP_PRETTY_PRINT:
- mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, " /= ");
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- break;
- case LSCP_EMIT_ASSEMBLY:
- {
- mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
- fprintf(fp, "DIV %s, %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;