00001
00032
00033
00034 #include "linden_common.h"
00035
00036 #include "lscript_tree.h"
00037 #include "lscript_typecheck.h"
00038 #include "lscript_resource.h"
00039 #include "lscript_bytecode.h"
00040 #include "lscript_heap.h"
00041 #include "lscript_library.h"
00042 #include "lscript_alloc.h"
00043
00044
00045
00046 void print_cil_box(FILE* fp, LSCRIPTType type)
00047 {
00048 switch(type)
00049 {
00050 case LST_INTEGER:
00051 fprintf(fp, "box [mscorlib]System.Int32\n");
00052 break;
00053 case LST_FLOATINGPOINT:
00054 fprintf(fp, "box [mscorlib]System.Double\n");
00055 break;
00056 case LST_STRING:
00057 case LST_KEY:
00058 fprintf(fp, "box [mscorlib]System.String\n");
00059 break;
00060 case LST_VECTOR:
00061 fprintf(fp, "box [LScriptLibrary]LLVector\n");
00062 break;
00063 case LST_QUATERNION:
00064 fprintf(fp, "box [LScriptLibrary]LLQuaternion\n");
00065 break;
00066 default:
00067 break;
00068 }
00069 }
00070
00071 void print_cil_type(FILE* fp, LSCRIPTType type)
00072 {
00073 switch(type)
00074 {
00075 case LST_INTEGER:
00076 fprintf(fp, "int32");
00077 break;
00078 case LST_FLOATINGPOINT:
00079 fprintf(fp, "float32");
00080 break;
00081 case LST_STRING:
00082 case LST_KEY:
00083 fprintf(fp, "string");
00084 break;
00085 case LST_VECTOR:
00086 fprintf(fp, "valuetype [LScriptLibrary]LLVector");
00087 break;
00088 case LST_QUATERNION:
00089 fprintf(fp, "valuetype [LScriptLibrary]LLQuaternion");
00090 break;
00091 case LST_LIST:
00092 fprintf(fp, "class [mscorlib]System.Collections.ArrayList");
00093 break;
00094 case LST_NULL:
00095 fprintf(fp, "void");
00096 break;
00097 default:
00098 break;
00099 }
00100 }
00101
00102 void LLScriptType::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
00103 {
00104 if (gErrorToText.getErrors())
00105 {
00106 return;
00107 }
00108 switch(pass)
00109 {
00110 case LSCP_PRETTY_PRINT:
00111 case LSCP_EMIT_ASSEMBLY:
00112 fprintf(fp,"%s",LSCRIPTTypeNames[mType]);
00113 break;
00114 case LSCP_TYPE:
00115 type = mType;
00116 break;
00117 case LSCP_EMIT_CIL_ASSEMBLY:
00118 print_cil_type(fp, mType);
00119 break;
00120 default:
00121 break;
00122 }
00123 }
00124
00125 S32 LLScriptType::getSize()
00126 {
00127 return LSCRIPTDataSize[mType];
00128 }
00129
00130 void LLScriptConstant::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
00131 {
00132 if (gErrorToText.getErrors())
00133 {
00134 return;
00135 }
00136 switch(pass)
00137 {
00138 case LSCP_PRETTY_PRINT:
00139 case LSCP_EMIT_ASSEMBLY:
00140 fprintf(fp,"Script Constant Base class -- should never get here!\n");
00141 break;
00142 default:
00143 break;
00144 }
00145 }
00146
00147 S32 LLScriptConstant::getSize()
00148 {
00149 printf("Script Constant Base class -- should never get here!\n");
00150 return 0;
00151 }
00152
00153
00154
00155 void LLScriptConstantInteger::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
00156 {
00157 if (gErrorToText.getErrors())
00158 {
00159 return;
00160 }
00161 switch(pass)
00162 {
00163 case LSCP_PRETTY_PRINT:
00164 fprintf(fp, "%d", mValue);
00165 break;
00166 case LSCP_EMIT_ASSEMBLY:
00167 fprintf(fp, "PUSHARGI %d\n", mValue);
00168 break;
00169 case LSCP_TYPE:
00170 type = mType;
00171 break;
00172 case LSCP_EMIT_BYTE_CODE:
00173 {
00174 chunk->addInteger(mValue);
00175 type = mType;
00176 }
00177 break;
00178 case LSCP_TO_STACK:
00179 {
00180 chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHARGI]);
00181 chunk->addInteger(mValue);
00182 type = mType;
00183 }
00184 break;
00185 case LSCP_LIST_BUILD_SIMPLE:
00186 {
00187 *ldata = new LLScriptLibData(mValue);
00188 }
00189 break;
00190 case LSCP_EMIT_CIL_ASSEMBLY:
00191 fprintf(fp, "ldc.i4 %d\n", mValue);
00192 break;
00193 default:
00194 break;
00195 }
00196 }
00197
00198 S32 LLScriptConstantInteger::getSize()
00199 {
00200 return LSCRIPTDataSize[LST_INTEGER];
00201 }
00202
00203 void LLScriptConstantFloat::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
00204 {
00205 if (gErrorToText.getErrors())
00206 {
00207 return;
00208 }
00209 switch(pass)
00210 {
00211 case LSCP_PRETTY_PRINT:
00212 fprintf(fp, "%5.5f", mValue);
00213 break;
00214 case LSCP_EMIT_ASSEMBLY:
00215 fprintf(fp, "PUSHARGF %5.5f\n", mValue);
00216 break;
00217 case LSCP_TYPE:
00218 type = mType;
00219 break;
00220 case LSCP_EMIT_BYTE_CODE:
00221 {
00222 chunk->addFloat(mValue);
00223 type = mType;
00224 }
00225 break;
00226 case LSCP_TO_STACK:
00227 {
00228 chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHARGF]);
00229 chunk->addFloat(mValue);
00230 type = mType;
00231 }
00232 break;
00233 case LSCP_LIST_BUILD_SIMPLE:
00234 {
00235 *ldata = new LLScriptLibData(mValue);
00236 }
00237 break;
00238 case LSCP_EMIT_CIL_ASSEMBLY:
00239 fprintf(fp, "ldc.r8 %5.5f\n", mValue);
00240 default:
00241 break;
00242 }
00243 }
00244
00245 S32 LLScriptConstantFloat::getSize()
00246 {
00247 return LSCRIPTDataSize[LST_FLOATINGPOINT];
00248 }
00249
00250 void print_escape_quotes(FILE* fp, const char* str)
00251 {
00252 putc('"', fp);
00253 for(const char* c = str; *c != '\0'; ++c)
00254 {
00255 if(*c == '"')
00256 {
00257 putc('\\', fp);
00258 }
00259 putc(*c, fp);
00260 }
00261 putc('"', fp);
00262 }
00263
00264 void LLScriptConstantString::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
00265 {
00266 if (gErrorToText.getErrors())
00267 {
00268 return;
00269 }
00270 switch(pass)
00271 {
00272 case LSCP_PRETTY_PRINT:
00273 fprintf(fp, "\"%s\"", mValue);
00274 break;
00275 case LSCP_EMIT_ASSEMBLY:
00276 fprintf(fp, "PUSHARGS \"%s\"\n", mValue);
00277 break;
00278 case LSCP_TYPE:
00279 type = mType;
00280 break;
00281 case LSCP_EMIT_BYTE_CODE:
00282 {
00283 chunk->addInteger(heap->mCurrentOffset + 1);
00284 LLScriptLibData *data = new LLScriptLibData(mValue);
00285 U8 *temp;
00286 S32 size = lsa_create_data_block(&temp, data, heap->mCurrentOffset);
00287
00288 heap->addBytes(temp, size);
00289 delete [] temp;
00290 delete data;
00291 }
00292 break;
00293 case LSCP_TO_STACK:
00294 {
00295 chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHARGS]);
00296 chunk->addBytes(mValue, (S32)strlen(mValue) + 1);
00297 type = mType;
00298 }
00299 break;
00300 case LSCP_LIST_BUILD_SIMPLE:
00301 {
00302 *ldata = new LLScriptLibData(mValue);
00303 }
00304 break;
00305 case LSCP_EMIT_CIL_ASSEMBLY:
00306 fprintf(fp, "ldstr ");
00307 print_escape_quotes(fp, mValue);
00308 fprintf(fp, "\n");
00309 default:
00310 break;
00311 }
00312 }
00313
00314 S32 LLScriptConstantString::getSize()
00315 {
00316 return (S32)strlen(mValue) + 1;
00317 }
00318
00319
00320 void LLScriptIdentifier::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
00321 {
00322 if (gErrorToText.getErrors())
00323 {
00324 return;
00325 }
00326 switch(pass)
00327 {
00328 case LSCP_PRETTY_PRINT:
00329 fprintf(fp, "%s", mName);
00330 break;
00331 case LSCP_EMIT_ASSEMBLY:
00332 if (mScopeEntry)
00333 {
00334 if (mScopeEntry->mIDType == LIT_VARIABLE)
00335 {
00336 fprintf(fp, "$BP + %d [%s]", mScopeEntry->mOffset, mName);
00337 }
00338 else if (mScopeEntry->mIDType == LIT_GLOBAL)
00339 {
00340 fprintf(fp, "$GVR + %d [%s]", mScopeEntry->mOffset, mName);
00341 }
00342 else
00343 {
00344 fprintf(fp, "%s", mName);
00345 }
00346 }
00347 break;
00348 case LSCP_TYPE:
00349 if (mScopeEntry)
00350 type = mScopeEntry->mType;
00351 else
00352 type = LST_NULL;
00353 break;
00354 case LSCP_RESOURCE:
00355 if (mScopeEntry)
00356 {
00357 if (mScopeEntry->mIDType == LIT_VARIABLE)
00358 {
00359
00360 }
00361 else if (mScopeEntry->mIDType == LIT_GLOBAL)
00362 {
00363
00364 }
00365 }
00366 break;
00367 case LSCP_LIST_BUILD_SIMPLE:
00368 {
00369 if (mScopeEntry)
00370 {
00371 if (mScopeEntry->mType == LST_LIST)
00372 {
00373 gErrorToText.writeError(fp, this, LSERROR_NO_LISTS_IN_LISTS);
00374 }
00375 else if (mScopeEntry->mAssignable)
00376 {
00377 mScopeEntry->mAssignable->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, ldata);
00378 }
00379 else
00380 {
00381 gErrorToText.writeError(fp, this, LSERROR_NO_UNITIALIZED_VARIABLES_IN_LISTS);
00382 }
00383 }
00384 else
00385 {
00386 gErrorToText.writeError(fp, this, LSERROR_UNDEFINED_NAME);
00387 }
00388 }
00389 break;
00390 case LSCP_EMIT_CIL_ASSEMBLY:
00391 fprintf(fp, "%s", mName);
00392 break;
00393 default:
00394 break;
00395 }
00396 }
00397
00398 S32 LLScriptIdentifier::getSize()
00399 {
00400
00401 return 0;
00402 }
00403
00404
00405
00406 void LLScriptSimpleAssignable::addAssignable(LLScriptSimpleAssignable *assign)
00407 {
00408 if (mNextp)
00409 {
00410 assign->mNextp = mNextp;
00411 }
00412 mNextp = assign;
00413 }
00414
00415 void LLScriptSimpleAssignable::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
00416 {
00417 if (gErrorToText.getErrors())
00418 {
00419 return;
00420 }
00421 fprintf(fp, "Simple Assignable Base Class -- should never get here!\n");
00422 }
00423
00424 S32 LLScriptSimpleAssignable::getSize()
00425 {
00426
00427 printf("Simple Assignable Base Class -- should never get here!\n");
00428 return 0;
00429 }
00430
00431 void LLScriptSAIdentifier::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
00432 {
00433 if (gErrorToText.getErrors())
00434 {
00435 return;
00436 }
00437 switch(pass)
00438 {
00439 case LSCP_PRETTY_PRINT:
00440 case LSCP_EMIT_ASSEMBLY:
00441 mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
00442 if (mNextp)
00443 {
00444 fprintf(fp, ", ");
00445 mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
00446 }
00447 break;
00448 case LSCP_SCOPE_PASS1:
00449 {
00450 LLScriptScopeEntry *entry = scope->findEntry(mIdentifier->mName);
00451 if (!entry)
00452 {
00453 gErrorToText.writeError(fp, this, LSERROR_UNDEFINED_NAME);
00454 }
00455 else
00456 {
00457
00458 mIdentifier->mScopeEntry = entry;
00459 }
00460 if (mNextp)
00461 {
00462 mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
00463 }
00464 }
00465 break;
00466 case LSCP_EMIT_BYTE_CODE:
00467 {
00468 if (mIdentifier->mScopeEntry)
00469 {
00470 if(mIdentifier->mScopeEntry->mAssignable)
00471 {
00472 mIdentifier->mScopeEntry->mAssignable->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
00473 }
00474 else
00475 {
00476
00477
00478
00479
00480
00481 type = mIdentifier->mScopeEntry->mType;
00482 chunk->addBytes(LSCRIPTDataSize[type]);
00483 }
00484 }
00485 if (mNextp)
00486 {
00487 mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
00488 }
00489 }
00490 break;
00491 case LSCP_LIST_BUILD_SIMPLE:
00492 {
00493 mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, ldata);
00494 if (mNextp)
00495 {
00496 mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, &(*ldata)->mListp);
00497 }
00498 }
00499 break;
00500 default:
00501 mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
00502 if (mNextp)
00503 {
00504 mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
00505 }
00506 break;
00507 }
00508 }
00509
00510 S32 LLScriptSAIdentifier::getSize()
00511 {
00512 return mIdentifier->getSize();
00513 }
00514
00515 void LLScriptSAConstant::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
00516 {
00517 if (gErrorToText.getErrors())
00518 {
00519 return;
00520 }
00521 switch(pass)
00522 {
00523 case LSCP_PRETTY_PRINT:
00524 case LSCP_EMIT_ASSEMBLY:
00525 mConstant->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
00526 if (mNextp)
00527 {
00528 fprintf(fp, ", ");
00529 mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
00530 }
00531 break;
00532 case LSCP_LIST_BUILD_SIMPLE:
00533 {
00534 mConstant->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, ldata);
00535 if (mNextp)
00536 {
00537 mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, &(*ldata)->mListp);
00538 }
00539 }
00540 break;
00541 default:
00542 mConstant->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
00543 if (mNextp)
00544 {
00545 mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
00546 }
00547 break;
00548 }
00549 }
00550
00551 S32 LLScriptSAConstant::getSize()
00552 {
00553 return mConstant->getSize();
00554 }
00555
00556 void print_cil_cast(FILE* fp, LSCRIPTType srcType, LSCRIPTType targetType)
00557 {
00558 switch(srcType)
00559 {
00560 case LST_INTEGER:
00561 switch(targetType)
00562 {
00563 case LST_FLOATINGPOINT:
00564 fprintf(fp, "conv.r8\n");
00565 break;
00566 case LST_STRING:
00567 fprintf(fp, "call string class [mscorlib]System.Convert::ToString(int32)\n");
00568 break;
00569 case LST_LIST:
00570 fprintf(fp, "box [mscorlib]System.Int32\n");
00571 fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LScriptLibrary]LScriptInternal::CreateList()\n");
00572 fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LScriptLibrary]LScriptInternal::AddReturnList(object, class [mscorlib]System.Collections.ArrayList)\n");
00573 break;
00574 default:
00575 break;
00576 }
00577 break;
00578 case LST_FLOATINGPOINT:
00579 switch(targetType)
00580 {
00581 case LST_INTEGER:
00582 fprintf(fp, "conv.i4\n");
00583 break;
00584 case LST_STRING:
00585 fprintf(fp, "call string class [mscorlib]System.Convert::ToString(float32)\n");
00586 break;
00587 case LST_LIST:
00588 fprintf(fp, "call class [mscorlib]System.Collections.ArrayList [LScriptLibrary]LScriptInternal::CreateList(object)\n");
00589 break;
00590 default:
00591 break;
00592 }
00593 break;
00594 case LST_STRING:
00595 switch(targetType)
00596 {
00597 case LST_INTEGER:
00598 fprintf(fp, "call int32 valuetype [mscorlib]System.Int32::Parse(string)\n");
00599 break;
00600 case LST_FLOATINGPOINT:
00601 fprintf(fp, "call float64 valuetype [mscorlib]System.Double::Parse(string)\n");
00602 break;
00603 case LST_LIST:
00604 fprintf(fp, "call class [mscorlib]System.Collections.ArrayList [LScriptLibrary]LScriptInternal::CreateList(object)\n");
00605 break;
00606 case LST_VECTOR:
00607 fprintf(fp, "call valuetype [LScriptLibrary]LLVector valuetype [LScriptLibrary]LLVector::'Parse'(string)\n");
00608 break;
00609 case LST_QUATERNION:
00610 fprintf(fp, "call valuetype [LScriptLibrary]LLQuaternion valuetype [LScriptLibrary]LLQuaternion::'Parse'(string)\n");
00611 break;
00612 default:
00613 break;
00614 }
00615 break;
00616 case LST_KEY:
00617 switch(targetType)
00618 {
00619 case LST_KEY:
00620 break;
00621 case LST_STRING:
00622 break;
00623 case LST_LIST:
00624 fprintf(fp, "call class [mscorlib]System.Collections.ArrayList [LScriptLibrary]LScriptInternal::CreateList(object)\n");
00625 break;
00626 default:
00627 break;
00628 }
00629 break;
00630 case LST_VECTOR:
00631 switch(targetType)
00632 {
00633 case LST_VECTOR:
00634 break;
00635 case LST_STRING:
00636 fprintf(fp, "call string valuetype [LScriptLibrary]LLVector::'ToString'(valuetype [LScriptLibrary]LLVector)\n");
00637 break;
00638 case LST_LIST:
00639 fprintf(fp, "call class [mscorlib]System.Collections.ArrayList [LScriptLibrary]LScriptInternal::CreateList(object)\n");
00640 break;
00641 default:
00642 break;
00643 }
00644 break;
00645 case LST_QUATERNION:
00646 switch(targetType)
00647 {
00648 case LST_QUATERNION:
00649 break;
00650 case LST_STRING:
00651 fprintf(fp, "call string valuetype [LScriptLibrary]LLQuaternion::'ToString'(valuetype [LScriptLibrary]LLQuaternion)\n");
00652 break;
00653 case LST_LIST:
00654 fprintf(fp, "call class [mscorlib]System.Collections.ArrayList [LScriptLibrary]LScriptInternal::CreateList(object)\n");
00655 break;
00656 default:
00657 break;
00658 }
00659 break;
00660 case LST_LIST:
00661 switch(targetType)
00662 {
00663 case LST_LIST:
00664 break;
00665 case LST_STRING:
00666 fprintf(fp, "call string [LScriptLibrary]LScriptInternal::ListToString(class [mscorlib]System.Collections.ArrayList)\n");
00667 break;
00668 default:
00669 break;
00670 }
00671 break;
00672 default:
00673 break;
00674 }
00675 }
00676
00677 bool is_SA_constant_integer(LLScriptSimpleAssignable* sa)
00678 {
00679
00680 return (sa->mType == LSSAT_CONSTANT && ((LLScriptSAConstant*) sa)->mConstant->mType == LST_INTEGER);
00681 }
00682
00683 void LLScriptSAVector::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
00684 {
00685 if (gErrorToText.getErrors())
00686 {
00687 return;
00688 }
00689 switch(pass)
00690 {
00691 case LSCP_PRETTY_PRINT:
00692 case LSCP_EMIT_ASSEMBLY:
00693 fprintf(fp, "< ");
00694 mEntry3->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
00695 fprintf(fp, ", ");
00696 mEntry2->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
00697 fprintf(fp, ", ");
00698 mEntry1->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
00699 fprintf(fp, " >");
00700 if (mNextp)
00701 {
00702 fprintf(fp, ", ");
00703 mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
00704 }
00705 break;
00706 case LSCP_TYPE:
00707
00708 mEntry3->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
00709 if (!legal_assignment(LST_FLOATINGPOINT, type))
00710 {
00711 gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
00712 }
00713 mEntry2->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
00714 if (!legal_assignment(LST_FLOATINGPOINT, type))
00715 {
00716 gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
00717 }
00718 mEntry1->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
00719 if (!legal_assignment(LST_FLOATINGPOINT, type))
00720 {
00721 gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
00722 }
00723 type = LST_VECTOR;
00724 if (mNextp)
00725 {
00726 mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
00727 }
00728 break;
00729 case LSCP_EMIT_BYTE_CODE:
00730 mEntry3->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
00731 if (type == LST_INTEGER)
00732 {
00733 S32 offset = chunk->mCurrentOffset - 4;
00734 bytestream_int2float(chunk->mCodeChunk, offset);
00735 }
00736 mEntry2->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
00737 if (type == LST_INTEGER)
00738 {
00739 S32 offset = chunk->mCurrentOffset - 4;
00740 bytestream_int2float(chunk->mCodeChunk, offset);
00741 }
00742 mEntry1->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
00743 if (type == LST_INTEGER)
00744 {
00745 S32 offset = chunk->mCurrentOffset - 4;
00746 bytestream_int2float(chunk->mCodeChunk, offset);
00747 }
00748 if (mNextp)
00749 {
00750 mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
00751 }
00752 break;
00753 case LSCP_LIST_BUILD_SIMPLE:
00754 {
00755 LLScriptByteCodeChunk *list = new LLScriptByteCodeChunk(FALSE);
00756 mEntry3->recurse(fp, tabs, tabsize, LSCP_EMIT_BYTE_CODE, ptype, prunearg, scope, type, basetype, count, list, heap, stacksize, entry, entrycount, NULL);
00757 if (type == LST_INTEGER)
00758 {
00759 S32 offset = list->mCurrentOffset - 4;
00760 bytestream_int2float(list->mCodeChunk, offset);
00761 }
00762 mEntry2->recurse(fp, tabs, tabsize, LSCP_EMIT_BYTE_CODE, ptype, prunearg, scope, type, basetype, count, list, heap, stacksize, entry, entrycount, NULL);
00763 if (type == LST_INTEGER)
00764 {
00765 S32 offset = list->mCurrentOffset - 4;
00766 bytestream_int2float(list->mCodeChunk, offset);
00767 }
00768 mEntry1->recurse(fp, tabs, tabsize, LSCP_EMIT_BYTE_CODE, ptype, prunearg, scope, type, basetype, count, list, heap, stacksize, entry, entrycount, NULL);
00769 if (type == LST_INTEGER)
00770 {
00771 S32 offset = list->mCurrentOffset - 4;
00772 bytestream_int2float(list->mCodeChunk, offset);
00773 }
00774 LLVector3 vec;
00775 S32 offset = 0;
00776 bytestream2vector(vec, list->mCodeChunk, offset);
00777 *ldata = new LLScriptLibData(vec);
00778 delete list;
00779 if (mNextp)
00780 {
00781 mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, &(*ldata)->mListp);
00782 }
00783 }
00784 break;
00785 case LSCP_EMIT_CIL_ASSEMBLY:
00786
00787
00788 mEntry1->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
00789 if(is_SA_constant_integer(mEntry1))
00790 {
00791 print_cil_cast(fp, LST_INTEGER, LST_FLOATINGPOINT);
00792 }
00793 mEntry2->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
00794 if(is_SA_constant_integer(mEntry3))
00795 {
00796 print_cil_cast(fp, LST_INTEGER, LST_FLOATINGPOINT);
00797 }
00798 mEntry3->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
00799 if(is_SA_constant_integer(mEntry3))
00800 {
00801 print_cil_cast(fp, LST_INTEGER, LST_FLOATINGPOINT);
00802 }
00803
00804
00805 fprintf(fp, "call valuetype [LScriptLibrary]LLVector valuetype [LScriptLibrary]LLVector::'create'(float32, float32, float32)\n");
00806
00807
00808 if (mNextp)
00809 {
00810 mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
00811 }
00812 break;
00813 default:
00814 mEntry3->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
00815 mEntry2->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
00816 mEntry1->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
00817 if (mNextp)
00818 {
00819 mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
00820 }
00821 break;
00822 }
00823 }
00824
00825 S32 LLScriptSAVector::getSize()
00826 {
00827 return mEntry1->getSize() + mEntry2->getSize() + mEntry3->getSize();
00828 }
00829
00830 void LLScriptSAQuaternion::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
00831 {
00832 if (gErrorToText.getErrors())
00833 {
00834 return;
00835 }
00836 switch(pass)
00837 {
00838 case LSCP_PRETTY_PRINT:
00839 case LSCP_EMIT_ASSEMBLY:
00840 fprintf(fp, "< ");
00841 mEntry4->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
00842 fprintf(fp, ", ");
00843 mEntry3->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
00844 fprintf(fp, ", ");
00845 mEntry2->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
00846 fprintf(fp, ", ");
00847 mEntry1->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
00848 fprintf(fp, " >");
00849 if (mNextp)
00850 {
00851 fprintf(fp, ", ");
00852 mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
00853 }
00854 break;
00855 case LSCP_TYPE:
00856
00857 mEntry4->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
00858 if (!legal_assignment(LST_FLOATINGPOINT, type))
00859 {
00860 gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
00861 }
00862 mEntry3->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
00863 if (!legal_assignment(LST_FLOATINGPOINT, type))
00864 {
00865 gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
00866 }
00867 mEntry2->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
00868 if (!legal_assignment(LST_FLOATINGPOINT, type))
00869 {
00870 gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
00871 }
00872 mEntry1->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
00873 if (!legal_assignment(LST_FLOATINGPOINT, type))
00874 {
00875 gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
00876 }
00877 type = LST_QUATERNION;
00878 if (mNextp)
00879 {
00880 mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
00881 }
00882 break;
00883 case LSCP_EMIT_BYTE_CODE:
00884 mEntry4->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
00885 if (type == LST_INTEGER)
00886 {
00887 S32 offset = chunk->mCurrentOffset - 4;
00888 bytestream_int2float(chunk->mCodeChunk, offset);
00889 }
00890 mEntry3->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
00891 if (type == LST_INTEGER)
00892 {
00893 S32 offset = chunk->mCurrentOffset - 4;
00894 bytestream_int2float(chunk->mCodeChunk, offset);
00895 }
00896 mEntry2->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
00897 if (type == LST_INTEGER)
00898 {
00899 S32 offset = chunk->mCurrentOffset - 4;
00900 bytestream_int2float(chunk->mCodeChunk, offset);
00901 }
00902 mEntry1->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
00903 if (type == LST_INTEGER)
00904 {
00905 S32 offset = chunk->mCurrentOffset - 4;
00906 bytestream_int2float(chunk->mCodeChunk, offset);
00907 }
00908 if (mNextp)
00909 {
00910 mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
00911 }
00912 break;
00913 case LSCP_LIST_BUILD_SIMPLE:
00914 {
00915 LLScriptByteCodeChunk *list = new LLScriptByteCodeChunk(FALSE);
00916 mEntry4->recurse(fp, tabs, tabsize, LSCP_EMIT_BYTE_CODE, ptype, prunearg, scope, type, basetype, count, list, heap, stacksize, entry, entrycount, NULL);
00917 if (type == LST_INTEGER)
00918 {
00919 S32 offset = list->mCurrentOffset - 4;
00920 bytestream_int2float(list->mCodeChunk, offset);
00921 }
00922 mEntry3->recurse(fp, tabs, tabsize, LSCP_EMIT_BYTE_CODE, ptype, prunearg, scope, type, basetype, count, list, heap, stacksize, entry, entrycount, NULL);
00923 if (type == LST_INTEGER)
00924 {
00925 S32 offset = list->mCurrentOffset - 4;
00926 bytestream_int2float(list->mCodeChunk, offset);
00927 }
00928 mEntry2->recurse(fp, tabs, tabsize, LSCP_EMIT_BYTE_CODE, ptype, prunearg, scope, type, basetype, count, list, heap, stacksize, entry, entrycount, NULL);
00929 if (type == LST_INTEGER)
00930 {
00931 S32 offset = list->mCurrentOffset - 4;
00932 bytestream_int2float(list->mCodeChunk, offset);
00933 }
00934 mEntry1->recurse(fp, tabs, tabsize, LSCP_EMIT_BYTE_CODE, ptype, prunearg, scope, type, basetype, count, list, heap, stacksize, entry, entrycount, NULL);
00935 if (type == LST_INTEGER)
00936 {
00937 S32 offset = list->mCurrentOffset - 4;
00938 bytestream_int2float(list->mCodeChunk, offset);
00939 }
00940 LLQuaternion quat;
00941 S32 offset = 0;
00942 bytestream2quaternion(quat, list->mCodeChunk, offset);
00943 *ldata = new LLScriptLibData(quat);
00944 delete list;
00945 if (mNextp)
00946 {
00947 mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, &(*ldata)->mListp);
00948 }
00949 }
00950 break;
00951 case LSCP_EMIT_CIL_ASSEMBLY:
00952
00953
00954 mEntry1->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
00955 if(is_SA_constant_integer(mEntry1))
00956 {
00957 print_cil_cast(fp, LST_INTEGER, LST_FLOATINGPOINT);
00958 }
00959 mEntry2->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
00960 if(is_SA_constant_integer(mEntry2))
00961 {
00962 print_cil_cast(fp, LST_INTEGER, LST_FLOATINGPOINT);
00963 }
00964 mEntry3->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
00965 if(is_SA_constant_integer(mEntry3))
00966 {
00967 print_cil_cast(fp, LST_INTEGER, LST_FLOATINGPOINT);
00968 }
00969 mEntry4->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
00970 if(is_SA_constant_integer(mEntry4))
00971 {
00972 print_cil_cast(fp, LST_INTEGER, LST_FLOATINGPOINT);
00973 }
00974
00975
00976 fprintf(fp, "call valuetype [LScriptLibrary]LLQuaternion valuetype [LScriptLibrary]LLQuaternion::'create'(float32, float32, float32, float32)\n");
00977
00978
00979 if (mNextp)
00980 {
00981 mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
00982 }
00983 break;
00984 default:
00985 mEntry4->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
00986 mEntry3->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
00987 mEntry2->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
00988 mEntry1->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
00989 if (mNextp)
00990 {
00991 mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
00992 }
00993 break;
00994 }
00995 }
00996
00997 S32 LLScriptSAQuaternion::getSize()
00998 {
00999 return mEntry1->getSize() + mEntry2->getSize() + mEntry3->getSize() + mEntry4->getSize();
01000 }
01001
01002 void LLScriptSAList::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
01003 {
01004 if (gErrorToText.getErrors())
01005 {
01006 return;
01007 }
01008 switch(pass)
01009 {
01010 case LSCP_PRETTY_PRINT:
01011 case LSCP_EMIT_ASSEMBLY:
01012 fprintf(fp, "[ ");
01013 if (mEntryList)
01014 mEntryList->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
01015 fprintf(fp, " ]");
01016 if (mNextp)
01017 {
01018 fprintf(fp, ", ");
01019 mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
01020 }
01021 break;
01022 case LSCP_TYPE:
01023 if (mEntryList)
01024 mEntryList->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
01025 type = LST_LIST;
01026 if (mNextp)
01027 {
01028 mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
01029 }
01030 break;
01031 case LSCP_EMIT_BYTE_CODE:
01032 {
01033 LLScriptLibData *list_data = new LLScriptLibData;
01034
01035 list_data->mType = LST_LIST;
01036 if (mEntryList)
01037 mEntryList->recurse(fp, tabs, tabsize, LSCP_LIST_BUILD_SIMPLE, ptype, prunearg, scope, type, basetype, count, chunk, NULL, stacksize, entry, entrycount, &(list_data->mListp));
01038
01039 U8 *temp;
01040 chunk->addInteger(heap->mCurrentOffset + 1);
01041 S32 size = lsa_create_data_block(&temp, list_data, heap->mCurrentOffset);
01042 heap->addBytes(temp, size);
01043 delete list_data;
01044 delete [] temp;
01045
01046 if (mNextp)
01047 {
01048 mNextp->recurse(fp, tabs, tabsize, LSCP_EMIT_BYTE_CODE, ptype, prunearg, scope, type, basetype, count, chunk, NULL, stacksize, entry, entrycount, NULL);
01049 }
01050 }
01051 break;
01052 default:
01053 if (mEntryList)
01054 mEntryList->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, ldata);
01055 if (mNextp)
01056 {
01057 mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, ldata);
01058 }
01059 break;
01060 }
01061 }
01062
01063 S32 LLScriptSAList::getSize()
01064 {
01065 return mEntryList->getSize();
01066 }
01067
01068 void LLScriptGlobalVariable::addGlobal(LLScriptGlobalVariable *global)
01069 {
01070 if (mNextp)
01071 {
01072 global->mNextp = mNextp;
01073 }
01074 mNextp = global;
01075 }
01076
01077 void LLScriptGlobalVariable::gonext(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
01078 {
01079 switch(pass)
01080 {
01081 case LSCP_PRETTY_PRINT:
01082 if (mNextp)
01083 {
01084 mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
01085 }
01086 break;
01087 default:
01088 if (mNextp)
01089 {
01090 mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
01091 }
01092 break;
01093 }
01094 }
01095
01096 void LLScriptGlobalVariable::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
01097 {
01098 if (gErrorToText.getErrors())
01099 {
01100 return;
01101 }
01102 switch(pass)
01103 {
01104 case LSCP_PRETTY_PRINT:
01105 mType->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
01106 fprintf(fp,"\t");
01107 mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
01108 if (mAssignable)
01109 {
01110 fprintf(fp, " = ");
01111 mAssignable->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
01112 }
01113 fprintf(fp, ";\n");
01114 break;
01115 case LSCP_EMIT_ASSEMBLY:
01116 mType->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
01117 fprintf(fp,"\t");
01118 mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
01119 if (mAssignable)
01120 {
01121 fprintf(fp, " = ");
01122 mAssignable->recurse(fp, tabs, tabsize, LSCP_PRETTY_PRINT, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
01123 fprintf(fp, "\n");
01124 fprintf(fp, "Offset: %d Type: %d\n", mIdentifier->mScopeEntry->mOffset, (S32)LSCRIPTTypeByte[mType->mType]);
01125 }
01126 else
01127 {
01128 fprintf(fp, "\n");
01129 fprintf(fp, "Offset: %d Type: %d\n", mIdentifier->mScopeEntry->mOffset, (S32)LSCRIPTTypeByte[mType->mType]);
01130 }
01131 break;
01132 case LSCP_SCOPE_PASS1:
01133 if (scope->checkEntry(mIdentifier->mName))
01134 {
01135 gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
01136 }
01137 else
01138 {
01139 if (mAssignable)
01140 {
01141 mAssignable->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
01142 }
01143
01144 mIdentifier->mScopeEntry = scope->addEntry(mIdentifier->mName, LIT_GLOBAL, mType->mType);
01145 if (mIdentifier->mScopeEntry && mAssignable)
01146 mIdentifier->mScopeEntry->mAssignable = mAssignable;
01147 }
01148 break;
01149 case LSCP_TYPE:
01150
01151 if (mAssignable)
01152 {
01153 mAssignable->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
01154 mAssignableType = type;
01155 if (!legal_assignment(mType->mType, mAssignableType))
01156 {
01157 gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
01158 }
01159 }
01160 break;
01161 case LSCP_RESOURCE:
01162 {
01163
01164
01165
01166 #ifdef LSL_INCLUDE_DEBUG_INFO
01167 count += strlen(mIdentifier->mName) + 1 + 1 + 4;
01168 #else
01169 count += 1 + 1 + 4;
01170 #endif
01171 mIdentifier->mScopeEntry->mOffset = (S32)count;
01172 mIdentifier->mScopeEntry->mSize = mType->getSize();
01173 count += mIdentifier->mScopeEntry->mSize;
01174 mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
01175 }
01176 break;
01177 case LSCP_EMIT_BYTE_CODE:
01178 {
01179
01180
01181 S32 offsetoffset = chunk->mCurrentOffset;
01182 S32 offsetdelta = 0;
01183 chunk->addBytes(4);
01184
01185 char vtype;
01186 vtype = LSCRIPTTypeByte[mType->mType];
01187 chunk->addBytes(&vtype, 1);
01188
01189 #ifdef LSL_INCLUDE_DEBUG_INFO
01190 chunk->addBytes(mIdentifier->mName, strlen(mIdentifier->mName) + 1);
01191 #else
01192 chunk->addBytes(1);
01193 #endif
01194
01195 offsetdelta = chunk->mCurrentOffset - offsetoffset;
01196 integer2bytestream(chunk->mCodeChunk, offsetoffset, offsetdelta);
01197
01198
01199 LLScriptByteCodeChunk *value = new LLScriptByteCodeChunk(FALSE);
01200 if (mAssignable)
01201 {
01202 mAssignable->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, value, heap, stacksize, entry, entrycount, NULL);
01203
01204 if (mAssignableType != mType->mType)
01205 {
01206
01207 if (mType->mType == LST_FLOATINGPOINT && mAssignableType == LST_INTEGER)
01208 {
01209 S32 offset = value->mCurrentOffset - 4;
01210 bytestream_int2float(value->mCodeChunk, offset);
01211 }
01212 }
01213 }
01214 else
01215 {
01216 if ( (mType->mType == LST_STRING)
01217 ||(mType->mType == LST_KEY))
01218 {
01219
01220 chunk->addInteger(heap->mCurrentOffset + 1);
01221 LLScriptLibData *data = new LLScriptLibData("");
01222 U8 *temp;
01223 S32 size = lsa_create_data_block(&temp, data, heap->mCurrentOffset);
01224
01225 heap->addBytes(temp, size);
01226 delete [] temp;
01227 delete data;
01228 }
01229 else if (mType->mType == LST_LIST)
01230 {
01231 chunk->addInteger(heap->mCurrentOffset + 1);
01232 LLScriptLibData *data = new LLScriptLibData;
01233 data->mType = LST_LIST;
01234 U8 *temp;
01235 S32 size = lsa_create_data_block(&temp, data, heap->mCurrentOffset);
01236
01237 heap->addBytes(temp, size);
01238 delete [] temp;
01239 delete data;
01240 }
01241 else if (mType->mType == LST_QUATERNION)
01242 {
01243 chunk->addFloat(1.f);
01244 chunk->addFloat(0.f);
01245 chunk->addFloat(0.f);
01246 chunk->addFloat(0.f);
01247 }
01248 else
01249 {
01250 value->addBytes(LSCRIPTDataSize[mType->mType]);
01251 }
01252 }
01253 chunk->addBytes(value->mCodeChunk, value->mCurrentOffset);
01254 delete value;
01255 }
01256 break;
01257 case LSCP_EMIT_CIL_ASSEMBLY:
01258
01259
01260 if (mAssignable)
01261 {
01262 fprintf(fp, "ldarg.0\n");
01263 mAssignable->recurse(fp, tabs, tabsize, LSCP_EMIT_CIL_ASSEMBLY, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
01264 fprintf(fp, "stfld ");
01265 mType->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
01266 fprintf(fp," LSL::");
01267 mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
01268 fprintf(fp, "\n");
01269 }
01270 break;
01271 default:
01272 mType->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
01273 mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
01274 if (mAssignable)
01275 {
01276 mAssignable->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
01277 }
01278 break;
01279 }
01280 gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
01281 }
01282
01283 S32 LLScriptGlobalVariable::getSize()
01284 {
01285 S32 return_size;
01286
01287 return_size = mType->getSize();
01288 return return_size;
01289 }
01290
01291 void LLScriptEvent::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
01292 {
01293 fprintf(fp, "Event Base Class -- should never get here!\n");
01294 }
01295
01296 S32 LLScriptEvent::getSize()
01297 {
01298 printf("Event Base Class -- should never get here!\n");
01299 return 0;
01300 }
01301
01302 void LLScriptStateEntryEvent::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
01303 {
01304 if (gErrorToText.getErrors())
01305 {
01306 return;
01307 }
01308 switch(pass)
01309 {
01310 case LSCP_PRETTY_PRINT:
01311 fdotabs(fp, tabs, tabsize);
01312 fprintf(fp, "state_entry()\n");
01313 break;
01314 case LSCP_EMIT_ASSEMBLY:
01315 fprintf(fp, "state_entry()\n");
01316 break;
01317 case LSCP_EMIT_BYTE_CODE:
01318 {
01319 #ifdef LSL_INCLUDE_DEBUG_INFO
01320 char name[] = "state_entry";
01321 chunk->addBytes(name, strlen(name) + 1);
01322 #endif
01323 }
01324 break;
01325 case LSCP_EMIT_CIL_ASSEMBLY:
01326 fprintf(fp, "state_entry()");
01327 break;
01328 default:
01329 break;
01330 }
01331 }
01332
01333 S32 LLScriptStateEntryEvent::getSize()
01334 {
01335 return 0;
01336 }
01337
01338 void LLScriptStateExitEvent::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
01339 {
01340 if (gErrorToText.getErrors())
01341 {
01342 return;
01343 }
01344 switch(pass)
01345 {
01346 case LSCP_PRETTY_PRINT:
01347 fdotabs(fp, tabs, tabsize);
01348 fprintf(fp, "state_exit()\n");
01349 break;
01350 case LSCP_EMIT_ASSEMBLY:
01351 fprintf(fp, "state_exit()\n");
01352 break;
01353 case LSCP_EMIT_BYTE_CODE:
01354 {
01355 #ifdef LSL_INCLUDE_DEBUG_INFO
01356 char name[] = "state_exit";
01357 chunk->addBytes(name, strlen(name) + 1);
01358 #endif
01359 }
01360 break;
01361 case LSCP_EMIT_CIL_ASSEMBLY:
01362 fprintf(fp, "state_exit()");
01363 break;
01364 default:
01365 break;
01366 }
01367 }
01368
01369 S32 LLScriptStateExitEvent::getSize()
01370 {
01371 return 0;
01372 }
01373
01374 void LLScriptTouchStartEvent::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
01375 {
01376 if (gErrorToText.getErrors())
01377 {
01378 return;
01379 }
01380 switch(pass)
01381 {
01382 case LSCP_PRETTY_PRINT:
01383 case LSCP_EMIT_ASSEMBLY:
01384 fdotabs(fp, tabs, tabsize);
01385 fprintf(fp, "touch_start( integer ");
01386 mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
01387 fprintf(fp, " )\n");
01388 break;
01389 break;
01390 case LSCP_SCOPE_PASS1:
01391 if (scope->checkEntry(mCount->mName))
01392 {
01393 gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
01394 }
01395 else
01396 {
01397 mCount->mScopeEntry = scope->addEntry(mCount->mName, LIT_VARIABLE, LST_INTEGER);
01398 }
01399 break;
01400 case LSCP_RESOURCE:
01401 {
01402
01403 if (mCount->mScopeEntry)
01404 {
01405 mCount->mScopeEntry->mOffset = (S32)count;
01406 mCount->mScopeEntry->mSize = 4;
01407 count += mCount->mScopeEntry->mSize;
01408 }
01409 }
01410 break;
01411 case LSCP_EMIT_BYTE_CODE:
01412 {
01413 #ifdef LSL_INCLUDE_DEBUG_INFO
01414 char name[] = "touch_start";
01415 chunk->addBytes(name, strlen(name) + 1);
01416 chunk->addBytes(mCount->mName, strlen(mCount->mName) + 1);
01417 #endif
01418 }
01419 break;
01420 default:
01421 mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
01422 break;
01423 }
01424 }
01425
01426 S32 LLScriptTouchStartEvent::getSize()
01427 {
01428
01429 return 4;
01430 }
01431
01432 void LLScriptTouchEvent::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
01433 {
01434 if (gErrorToText.getErrors())
01435 {
01436 return;
01437 }
01438 switch(pass)
01439 {
01440 case LSCP_PRETTY_PRINT:
01441 case LSCP_EMIT_ASSEMBLY:
01442 fdotabs(fp, tabs, tabsize);
01443 fprintf(fp, "touch( integer ");
01444 mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
01445 fprintf(fp, " )\n");
01446 break;
01447 break;
01448 case LSCP_SCOPE_PASS1:
01449 if (scope->checkEntry(mCount->mName))
01450 {
01451 gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
01452 }
01453 else
01454 {
01455 mCount->mScopeEntry = scope->addEntry(mCount->mName, LIT_VARIABLE, LST_INTEGER);
01456 }
01457 break;
01458 case LSCP_RESOURCE:
01459 {
01460
01461 if (mCount->mScopeEntry)
01462 {
01463 mCount->mScopeEntry->mOffset = (S32)count;
01464 mCount->mScopeEntry->mSize = 4;
01465 count += mCount->mScopeEntry->mSize;
01466 }
01467 }
01468 break;
01469 case LSCP_EMIT_BYTE_CODE:
01470 {
01471 #ifdef LSL_INCLUDE_DEBUG_INFO
01472 char name[] = "touch";
01473 chunk->addBytes(name, strlen(name) + 1);
01474 chunk->addBytes(mCount->mName, strlen(mCount->mName) + 1);
01475 #endif
01476 }
01477 break;
01478 default:
01479 mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
01480 break;
01481 }
01482 }
01483
01484 S32 LLScriptTouchEvent::getSize()
01485 {
01486
01487 return 4;
01488 }
01489
01490 void LLScriptTouchEndEvent::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
01491 {
01492 if (gErrorToText.getErrors())
01493 {
01494 return;
01495 }
01496 switch(pass)
01497 {
01498 case LSCP_PRETTY_PRINT:
01499 case LSCP_EMIT_ASSEMBLY:
01500 fdotabs(fp, tabs, tabsize);
01501 fprintf(fp, "touch_end( integer ");
01502 mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
01503 fprintf(fp, " )\n");
01504 break;
01505 break;
01506 case LSCP_SCOPE_PASS1:
01507 if (scope->checkEntry(mCount->mName))
01508 {
01509 gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
01510 }
01511 else
01512 {
01513 mCount->mScopeEntry = scope->addEntry(mCount->mName, LIT_VARIABLE, LST_INTEGER);
01514 }
01515 break;
01516 case LSCP_RESOURCE:
01517 {
01518
01519 if (mCount->mScopeEntry)
01520 {
01521 mCount->mScopeEntry->mOffset = (S32)count;
01522 mCount->mScopeEntry->mSize = 4;
01523 count += mCount->mScopeEntry->mSize;
01524 }
01525 }
01526 break;
01527 case LSCP_EMIT_BYTE_CODE:
01528 {
01529 #ifdef LSL_INCLUDE_DEBUG_INFO
01530 char name[] = "touch_end";
01531 chunk->addBytes(name, strlen(name) + 1);
01532 chunk->addBytes(mCount->mName, strlen(mCount->mName) + 1);
01533 #endif
01534 }
01535 break;
01536 default:
01537 mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
01538 break;
01539 }
01540 }
01541
01542 S32 LLScriptTouchEndEvent::getSize()
01543 {
01544
01545 return 4;
01546 }
01547
01548 void LLScriptCollisionStartEvent::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
01549 {
01550 if (gErrorToText.getErrors())
01551 {
01552 return;
01553 }
01554 switch(pass)
01555 {
01556 case LSCP_PRETTY_PRINT:
01557 case LSCP_EMIT_ASSEMBLY:
01558 fdotabs(fp, tabs, tabsize);
01559 fprintf(fp, "collision_start( integer ");
01560 mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
01561 fprintf(fp, " )\n");
01562 break;
01563 break;
01564 case LSCP_SCOPE_PASS1:
01565 if (scope->checkEntry(mCount->mName))
01566 {
01567 gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
01568 }
01569 else
01570 {
01571 mCount->mScopeEntry = scope->addEntry(mCount->mName, LIT_VARIABLE, LST_INTEGER);
01572 }
01573 break;
01574 case LSCP_RESOURCE:
01575 {
01576
01577 if (mCount->mScopeEntry)
01578 {
01579 mCount->mScopeEntry->mOffset = (S32)count;
01580 mCount->mScopeEntry->mSize = 4;
01581 count += mCount->mScopeEntry->mSize;
01582 }
01583 }
01584 break;
01585 case LSCP_EMIT_BYTE_CODE:
01586 {
01587 #ifdef LSL_INCLUDE_DEBUG_INFO
01588 char name[] = "collision_start";
01589 chunk->addBytes(name, (S32)strlen(name) + 1);
01590 chunk->addBytes(mCount->mName, (S32)strlen(mCount->mName) + 1);
01591 #endif
01592 }
01593 break;
01594 default:
01595 mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
01596 break;
01597 }
01598 }
01599
01600 S32 LLScriptCollisionStartEvent::getSize()
01601 {
01602
01603 return 4;
01604 }
01605
01606 void LLScriptCollisionEvent::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
01607 {
01608 if (gErrorToText.getErrors())
01609 {
01610 return;
01611 }
01612 switch(pass)
01613 {
01614 case LSCP_PRETTY_PRINT:
01615 case LSCP_EMIT_ASSEMBLY:
01616 fdotabs(fp, tabs, tabsize);
01617 fprintf(fp, "collision( integer ");
01618 mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
01619 fprintf(fp, " )\n");
01620 break;
01621 break;
01622 case LSCP_SCOPE_PASS1:
01623 if (scope->checkEntry(mCount->mName))
01624 {
01625 gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
01626 }
01627 else
01628 {
01629 mCount->mScopeEntry = scope->addEntry(mCount->mName, LIT_VARIABLE, LST_INTEGER);
01630 }
01631 break;
01632 case LSCP_RESOURCE:
01633 {
01634
01635 if (mCount->mScopeEntry)
01636 {
01637 mCount->mScopeEntry->mOffset = (S32)count;
01638 mCount->mScopeEntry->mSize = 4;
01639 count += mCount->mScopeEntry->mSize;
01640 }
01641 }
01642 break;
01643 case LSCP_EMIT_BYTE_CODE:
01644 {
01645 #ifdef LSL_INCLUDE_DEBUG_INFO
01646 char name[] = "collision";
01647 chunk->addBytes(name, strlen(name) + 1);
01648 chunk->addBytes(mCount->mName, strlen(mCount->mName) + 1);
01649 #endif
01650 }
01651 break;
01652 default:
01653 mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
01654 break;
01655 }
01656 }
01657
01658 S32 LLScriptCollisionEvent::getSize()
01659 {
01660
01661 return 4;
01662 }
01663
01664 void LLScriptCollisionEndEvent::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
01665 {
01666 if (gErrorToText.getErrors())
01667 {
01668 return;
01669 }
01670 switch(pass)
01671 {
01672 case LSCP_PRETTY_PRINT:
01673 case LSCP_EMIT_ASSEMBLY:
01674 fdotabs(fp, tabs, tabsize);
01675 fprintf(fp, "collision_end( integer ");
01676 mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
01677 fprintf(fp, " )\n");
01678 break;
01679 break;
01680 case LSCP_SCOPE_PASS1:
01681 if (scope->checkEntry(mCount->mName))
01682 {
01683 gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
01684 }
01685 else
01686 {
01687 mCount->mScopeEntry = scope->addEntry(mCount->mName, LIT_VARIABLE, LST_INTEGER);
01688 }
01689 break;
01690 case LSCP_RESOURCE:
01691 {
01692
01693 if (mCount->mScopeEntry)
01694 {
01695 mCount->mScopeEntry->mOffset = (S32)count;
01696 mCount->mScopeEntry->mSize = 4;
01697 count += mCount->mScopeEntry->mSize;
01698 }
01699 }
01700 break;
01701 case LSCP_EMIT_BYTE_CODE:
01702 {
01703 #ifdef LSL_INCLUDE_DEBUG_INFO
01704 char name[] = "collision_end";
01705 chunk->addBytes(name, strlen(name) + 1);
01706 chunk->addBytes(mCount->mName, strlen(mCount->mName) + 1);
01707 #endif
01708 }
01709 break;
01710 default:
01711 mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
01712 break;
01713 }
01714 }
01715
01716 S32 LLScriptCollisionEndEvent::getSize()
01717 {
01718
01719 return 4;
01720 }
01721
01722 void LLScriptLandCollisionStartEvent::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
01723 {
01724 if (gErrorToText.getErrors())
01725 {
01726 return;
01727 }
01728 switch(pass)
01729 {
01730 case LSCP_PRETTY_PRINT:
01731 case LSCP_EMIT_ASSEMBLY:
01732 fdotabs(fp, tabs, tabsize);
01733 fprintf(fp, "land_collision_start( vector ");
01734 mPosition->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
01735 fprintf(fp, " )\n");
01736 break;
01737 case LSCP_SCOPE_PASS1:
01738 if (scope->checkEntry(mPosition->mName))
01739 {
01740 gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
01741 }
01742 else
01743 {
01744 mPosition->mScopeEntry = scope->addEntry(mPosition->mName, LIT_VARIABLE, LST_VECTOR);
01745 }
01746 break;
01747 case LSCP_RESOURCE:
01748 {
01749
01750 if (mPosition->mScopeEntry)
01751 {
01752 mPosition->mScopeEntry->mOffset = (S32)count;
01753 mPosition->mScopeEntry->mSize = 12;
01754 count += mPosition->mScopeEntry->mSize;
01755 }
01756 }
01757 break;
01758 case LSCP_EMIT_BYTE_CODE:
01759 {
01760 #ifdef LSL_INCLUDE_DEBUG_INFO
01761 char name[] = "land_collision_start";
01762 chunk->addBytes(name, strlen(name) + 1);
01763 chunk->addBytes(mPosition->mName, strlen(mPosition->mName) + 1);
01764 #endif
01765 }
01766 break;
01767 default:
01768 mPosition->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
01769 break;
01770 }
01771 }
01772
01773 S32 LLScriptLandCollisionStartEvent::getSize()
01774 {
01775
01776 return 12;
01777 }
01778
01779
01780
01781 void LLScriptLandCollisionEvent::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
01782 {
01783 if (gErrorToText.getErrors())
01784 {
01785 return;
01786 }
01787 switch(pass)
01788 {
01789 case LSCP_PRETTY_PRINT:
01790 case LSCP_EMIT_ASSEMBLY:
01791 fdotabs(fp, tabs, tabsize);
01792 fprintf(fp, "land_collision( vector ");
01793 mPosition->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
01794 fprintf(fp, " )\n");
01795 break;
01796 case LSCP_SCOPE_PASS1:
01797 if (scope->checkEntry(mPosition->mName))
01798 {
01799 gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
01800 }
01801 else
01802 {
01803 mPosition->mScopeEntry = scope->addEntry(mPosition->mName, LIT_VARIABLE, LST_VECTOR);
01804 }
01805 break;
01806 case LSCP_RESOURCE:
01807 {
01808
01809 if (mPosition->mScopeEntry)
01810 {
01811 mPosition->mScopeEntry->mOffset = (S32)count;
01812 mPosition->mScopeEntry->mSize = 12;
01813 count += mPosition->mScopeEntry->mSize;
01814 }
01815 }
01816 break;
01817 case LSCP_EMIT_BYTE_CODE:
01818 {
01819 #ifdef LSL_INCLUDE_DEBUG_INFO
01820 char name[] = "land_collision";
01821 chunk->addBytes(name, strlen(name) + 1);
01822 chunk->addBytes(mPosition->mName, strlen(mPosition->mName) + 1);
01823 #endif
01824 }
01825 break;
01826 default:
01827 mPosition->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
01828 break;
01829 }
01830 }
01831
01832 S32 LLScriptLandCollisionEvent::getSize()
01833 {
01834
01835 return 12;
01836 }
01837
01838
01839 void LLScriptLandCollisionEndEvent::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
01840 {
01841 if (gErrorToText.getErrors())
01842 {
01843 return;
01844 }
01845 switch(pass)
01846 {
01847 case LSCP_PRETTY_PRINT:
01848 case LSCP_EMIT_ASSEMBLY:
01849 fdotabs(fp, tabs, tabsize);
01850 fprintf(fp, "land_collision_end( vector ");
01851 mPosition->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
01852 fprintf(fp, " )\n");
01853 break;
01854 case LSCP_SCOPE_PASS1:
01855 if (scope->checkEntry(mPosition->mName))
01856 {
01857 gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
01858 }
01859 else
01860 {
01861 mPosition->mScopeEntry = scope->addEntry(mPosition->mName, LIT_VARIABLE, LST_VECTOR);
01862 }
01863 break;
01864 case LSCP_RESOURCE:
01865 {
01866
01867 if (mPosition->mScopeEntry)
01868 {
01869 mPosition->mScopeEntry->mOffset = (S32)count;
01870 mPosition->mScopeEntry->mSize = 12;
01871 count += mPosition->mScopeEntry->mSize;
01872 }
01873 }
01874 break;
01875 case LSCP_EMIT_BYTE_CODE:
01876 {
01877 #ifdef LSL_INCLUDE_DEBUG_INFO
01878 char name[] = "land_collision_end";
01879 chunk->addBytes(name, strlen(name) + 1);
01880 chunk->addBytes(mPosition->mName, strlen(mPosition->mName) + 1);
01881 #endif
01882 }
01883 break;
01884 default:
01885 mPosition->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
01886 break;
01887 }
01888 }
01889
01890 S32 LLScriptLandCollisionEndEvent::getSize()
01891 {
01892
01893 return 12;
01894 }
01895
01896
01897 void LLScriptInventoryEvent::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
01898 {
01899 if (gErrorToText.getErrors())
01900 {
01901 return;
01902 }
01903 switch(pass)
01904 {
01905 case LSCP_PRETTY_PRINT:
01906 case LSCP_EMIT_ASSEMBLY:
01907 fdotabs(fp, tabs, tabsize);
01908 fprintf(fp, "changed( integer ");
01909 mChange->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
01910 fprintf(fp, " )\n");
01911 break;
01912 case LSCP_SCOPE_PASS1:
01913 if (scope->checkEntry(mChange->mName))
01914 {
01915 gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
01916 }
01917 else
01918 {
01919 mChange->mScopeEntry = scope->addEntry(mChange->mName, LIT_VARIABLE, LST_INTEGER);
01920 }
01921 break;
01922 case LSCP_RESOURCE:
01923 {
01924
01925 if (mChange->mScopeEntry)
01926 {
01927 mChange->mScopeEntry->mOffset = (S32)count;
01928 mChange->mScopeEntry->mSize = 4;
01929 count += mChange->mScopeEntry->mSize;
01930 }
01931 }
01932 break;
01933 case LSCP_EMIT_BYTE_CODE:
01934 {
01935 #ifdef LSL_INCLUDE_DEBUG_INFO
01936 char name[] = "changed";
01937 chunk->addBytes(name, strlen(name) + 1);
01938 chunk->addBytes(mChange->mName, strlen(mChange->mName) + 1);
01939 #endif
01940 }
01941 break;
01942 default:
01943 mChange->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
01944 break;
01945 }
01946 }
01947
01948 S32 LLScriptInventoryEvent::getSize()
01949 {
01950
01951 return 4;
01952 }
01953
01954 void LLScriptAttachEvent::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
01955 {
01956 if (gErrorToText.getErrors())
01957 {
01958 return;
01959 }
01960 switch(pass)
01961 {
01962 case LSCP_PRETTY_PRINT:
01963 case LSCP_EMIT_ASSEMBLY:
01964 fdotabs(fp, tabs, tabsize);
01965 fprintf(fp, "attach( key ");
01966 mAttach->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
01967 fprintf(fp, " )\n");
01968 break;
01969 case LSCP_SCOPE_PASS1:
01970 if (scope->checkEntry(mAttach->mName))
01971 {
01972 gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
01973 }
01974 else
01975 {
01976 mAttach->mScopeEntry = scope->addEntry(mAttach->mName, LIT_VARIABLE, LST_KEY);
01977 }
01978 break;
01979 case LSCP_RESOURCE:
01980 {
01981
01982 if (mAttach->mScopeEntry)
01983 {
01984 mAttach->mScopeEntry->mOffset = (S32)count;
01985 mAttach->mScopeEntry->mSize = 4;
01986 count += mAttach->mScopeEntry->mSize;
01987 }
01988 }
01989 break;
01990 case LSCP_EMIT_BYTE_CODE:
01991 {
01992 #ifdef LSL_INCLUDE_DEBUG_INFO
01993 char name[] = "attach";
01994 chunk->addBytes(name, strlen(name) + 1);
01995 chunk->addBytes(mAttach->mName, strlen(mAttach->mName) + 1);
01996 #endif
01997 }
01998 break;
01999 default:
02000 mAttach->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
02001 break;
02002 }
02003 }
02004
02005 S32 LLScriptAttachEvent::getSize()
02006 {
02007
02008 return 4;
02009 }
02010
02011 void LLScriptDataserverEvent::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
02012 {
02013 if (gErrorToText.getErrors())
02014 {
02015 return;
02016 }
02017 switch(pass)
02018 {
02019 case LSCP_PRETTY_PRINT:
02020 case LSCP_EMIT_ASSEMBLY:
02021 fdotabs(fp, tabs, tabsize);
02022 fprintf(fp, "dataserver( key ");
02023 mID->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
02024 fprintf(fp, ", string ");
02025 mData->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
02026 fprintf(fp, " )\n");
02027 break;
02028 case LSCP_SCOPE_PASS1:
02029 if (scope->checkEntry(mID->mName))
02030 {
02031 gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
02032 }
02033 else
02034 {
02035 mID->mScopeEntry = scope->addEntry(mID->mName, LIT_VARIABLE, LST_KEY);
02036 }
02037 if (scope->checkEntry(mData->mName))
02038 {
02039 gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
02040 }
02041 else
02042 {
02043 mData->mScopeEntry = scope->addEntry(mData->mName, LIT_VARIABLE, LST_STRING);
02044 }
02045 break;
02046 case LSCP_RESOURCE:
02047 {
02048
02049 if (mID->mScopeEntry)
02050 {
02051 mID->mScopeEntry->mOffset = (S32)count;
02052 mID->mScopeEntry->mSize = 4;
02053 count += mID->mScopeEntry->mSize;
02054 mData->mScopeEntry->mOffset = (S32)count;
02055 mData->mScopeEntry->mSize = 4;
02056 count += mData->mScopeEntry->mSize;
02057 }
02058 }
02059 break;
02060 case LSCP_EMIT_BYTE_CODE:
02061 {
02062 #ifdef LSL_INCLUDE_DEBUG_INFO
02063 char name[] = "dataserver";
02064 chunk->addBytes(name, strlen(name) + 1);
02065 chunk->addBytes(mID->mName, strlen(mID->mName) + 1);
02066 chunk->addBytes(mData->mName, strlen(mData->mName) + 1);
02067 #endif
02068 }
02069 break;
02070 default:
02071 mID->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
02072 mData->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
02073 break;
02074 }
02075 }
02076
02077 S32 LLScriptDataserverEvent::getSize()
02078 {
02079
02080 return 8;
02081 }
02082
02083 void LLScriptTimerEvent::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
02084 {
02085 if (gErrorToText.getErrors())
02086 {
02087 return;
02088 }
02089 switch(pass)
02090 {
02091 case LSCP_PRETTY_PRINT:
02092 fdotabs(fp, tabs, tabsize);
02093 fprintf(fp, "timer()\n");
02094 break;
02095 case LSCP_EMIT_ASSEMBLY:
02096 fprintf(fp, "timer()\n");
02097 break;
02098 case LSCP_EMIT_BYTE_CODE:
02099 {
02100 #ifdef LSL_INCLUDE_DEBUG_INFO
02101 char name[] = "timer";
02102 chunk->addBytes(name, strlen(name) + 1);
02103 #endif
02104 }
02105 break;
02106 default:
02107 break;
02108 }
02109 }
02110
02111 S32 LLScriptTimerEvent::getSize()
02112 {
02113 return 0;
02114 }
02115
02116 void LLScriptMovingStartEvent::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
02117 {
02118 if (gErrorToText.getErrors())
02119 {
02120 return;
02121 }
02122 switch(pass)
02123 {
02124 case LSCP_PRETTY_PRINT:
02125 case LSCP_EMIT_ASSEMBLY:
02126 fdotabs(fp, tabs, tabsize);
02127 fprintf(fp, "moving_start()\n");
02128 break;
02129 case LSCP_EMIT_BYTE_CODE:
02130 {
02131 #ifdef LSL_INCLUDE_DEBUG_INFO
02132 char name[] = "moving_start";
02133 chunk->addBytes(name, strlen(name) + 1);
02134 #endif
02135 }
02136 break;
02137 default:
02138 break;
02139 }
02140 }
02141
02142 S32 LLScriptMovingStartEvent::getSize()
02143 {
02144 return 0;
02145 }
02146
02147 void LLScriptMovingEndEvent::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
02148 {
02149 if (gErrorToText.getErrors())
02150 {
02151 return;
02152 }
02153 switch(pass)
02154 {
02155 case LSCP_PRETTY_PRINT:
02156 case LSCP_EMIT_ASSEMBLY:
02157 fdotabs(fp, tabs, tabsize);
02158 fprintf(fp, "moving_end()\n");
02159 break;
02160 case LSCP_EMIT_BYTE_CODE:
02161 {
02162 #ifdef LSL_INCLUDE_DEBUG_INFO
02163 char name[] = "moving_end";
02164 chunk->addBytes(name, strlen(name) + 1);
02165 #endif
02166 }
02167 break;
02168 default:
02169 break;
02170 }
02171 }
02172
02173 S32 LLScriptMovingEndEvent::getSize()
02174 {
02175 return 0;
02176 }
02177
02178 void LLScriptRTPEvent::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
02179 {
02180 if (gErrorToText.getErrors())
02181 {
02182 return;
02183 }
02184 switch(pass)
02185 {
02186 case LSCP_PRETTY_PRINT:
02187 case LSCP_EMIT_ASSEMBLY:
02188 fdotabs(fp, tabs, tabsize);
02189 fprintf(fp, "chat( integer ");
02190 mRTPermissions->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
02191 fprintf(fp, " )\n");
02192 break;
02193 case LSCP_SCOPE_PASS1:
02194 if (scope->checkEntry(mRTPermissions->mName))
02195 {
02196 gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
02197 }
02198 else
02199 {
02200 mRTPermissions->mScopeEntry = scope->addEntry(mRTPermissions->mName, LIT_VARIABLE, LST_INTEGER);
02201 }
02202 break;
02203 case LSCP_RESOURCE:
02204 {
02205
02206 if (mRTPermissions->mScopeEntry)
02207 {
02208 mRTPermissions->mScopeEntry->mOffset = (S32)count;
02209 mRTPermissions->mScopeEntry->mSize = 4;
02210 count += mRTPermissions->mScopeEntry->mSize;
02211 }
02212 }
02213 break;
02214 case LSCP_EMIT_BYTE_CODE:
02215 {
02216 #ifdef LSL_INCLUDE_DEBUG_INFO
02217 char name[] = "chat";
02218 chunk->addBytes(name, strlen(name) + 1);
02219 chunk->addBytes(mRTPermissions->mName, strlen(mRTPermissions->mName) + 1);
02220 #endif
02221 }
02222 break;
02223 default:
02224 mRTPermissions->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
02225 break;
02226 }
02227 }
02228
02229 S32 LLScriptRTPEvent::getSize()
02230 {
02231
02232 return 4;
02233 }
02234
02235 void LLScriptChatEvent::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
02236 {
02237 if (gErrorToText.getErrors())
02238 {
02239 return;
02240 }
02241 switch(pass)
02242 {
02243 case LSCP_PRETTY_PRINT:
02244 case LSCP_EMIT_ASSEMBLY:
02245 fdotabs(fp, tabs, tabsize);
02246 fprintf(fp, "chat( integer ");
02247 mChannel->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
02248 fprintf(fp, ", string ");
02249 mName->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
02250 fprintf(fp, ", key ");
02251 mID->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
02252 fprintf(fp, ", string ");
02253 mMessage->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
02254 fprintf(fp, " )\n");
02255 break;
02256 case LSCP_SCOPE_PASS1:
02257 if (scope->checkEntry(mChannel->mName))
02258 {
02259 gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
02260 }
02261 else
02262 {
02263 mChannel->mScopeEntry = scope->addEntry(mChannel->mName, LIT_VARIABLE, LST_INTEGER);
02264 }
02265 if (scope->checkEntry(mName->mName))
02266 {
02267 gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
02268 }
02269 else
02270 {
02271 mName->mScopeEntry = scope->addEntry(mName->mName, LIT_VARIABLE, LST_STRING);
02272 }
02273 if (scope->checkEntry(mID->mName))
02274 {
02275 gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
02276 }
02277 else
02278 {
02279 mID->mScopeEntry = scope->addEntry(mID->mName, LIT_VARIABLE, LST_KEY);
02280 }
02281 if (scope->checkEntry(mMessage->mName))
02282 {
02283 gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
02284 }
02285 else
02286 {
02287 mMessage->mScopeEntry = scope->addEntry(mMessage->mName, LIT_VARIABLE, LST_STRING);
02288 }
02289 break;
02290 case LSCP_RESOURCE:
02291 {
02292
02293 if (mName->mScopeEntry)
02294 {
02295 mChannel->mScopeEntry->mOffset = (S32)count;
02296 mChannel->mScopeEntry->mSize = 4;
02297 count += mChannel->mScopeEntry->mSize;
02298 mName->mScopeEntry->mOffset = (S32)count;
02299 mName->mScopeEntry->mSize = 4;
02300 count += mName->mScopeEntry->mSize;
02301 mID->mScopeEntry->mOffset = (S32)count;
02302 mID->mScopeEntry->mSize = 4;
02303 count += mID->mScopeEntry->mSize;
02304 mMessage->mScopeEntry->mOffset = (S32)count;
02305 mMessage->mScopeEntry->mSize = 4;
02306 count += mMessage->mScopeEntry->mSize;
02307 }
02308 }
02309 break;
02310 case LSCP_EMIT_BYTE_CODE:
02311 {
02312 #ifdef LSL_INCLUDE_DEBUG_INFO
02313 char name[] = "chat";
02314 chunk->addBytes(name, strlen(name) + 1);
02315 chunk->addBytes(mChannel->mName, strlen(mChannel->mName) + 1);
02316 chunk->addBytes(mName->mName, strlen(mName->mName) + 1);
02317 chunk->addBytes(mID->mName, strlen(mID->mName) + 1);
02318 chunk->addBytes(mMessage->mName, strlen(mMessage->mName) + 1);
02319 #endif
02320 }
02321 break;
02322 default:
02323 mChannel->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
02324 mName->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
02325 mID->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
02326 mMessage->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
02327 break;
02328 }
02329 }
02330
02331 S32 LLScriptChatEvent::getSize()
02332 {
02333
02334 return 16;
02335 }
02336
02337 void LLScriptSensorEvent::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
02338 {
02339 if (gErrorToText.getErrors())
02340 {
02341 return;
02342 }
02343 switch(pass)
02344 {
02345 case LSCP_PRETTY_PRINT:
02346 case LSCP_EMIT_ASSEMBLY:
02347 fdotabs(fp, tabs, tabsize);
02348 fprintf(fp, "sensor( integer ");
02349 mNumber->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
02350 fprintf(fp, " )\n");
02351 break;
02352 case LSCP_SCOPE_PASS1:
02353 if (scope->checkEntry(mNumber->mName))
02354 {
02355 gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
02356 }
02357 else
02358 {
02359 mNumber->mScopeEntry = scope->addEntry(mNumber->mName, LIT_VARIABLE, LST_INTEGER);
02360 }
02361 break;
02362 case LSCP_RESOURCE:
02363 {
02364
02365 if (mNumber->mScopeEntry)
02366 {
02367 mNumber->mScopeEntry->mOffset = (S32)count;
02368 mNumber->mScopeEntry->mSize = 4;
02369 count += mNumber->mScopeEntry->mSize;
02370 }
02371 }
02372 break;
02373 case LSCP_EMIT_BYTE_CODE:
02374 {
02375 #ifdef LSL_INCLUDE_DEBUG_INFO
02376 char name[] = "sensor";
02377 chunk->addBytes(name, strlen(name) + 1);
02378 chunk->addBytes(mNumber->mName, strlen(mNumber->mName) + 1);
02379 #endif
02380 }
02381 break;
02382 default:
02383 mNumber->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
02384 break;
02385 }
02386 }
02387
02388 S32 LLScriptSensorEvent::getSize()
02389 {
02390
02391 return 4;
02392 }
02393
02394 void LLScriptObjectRezEvent::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
02395 {
02396 if (gErrorToText.getErrors())
02397 {
02398 return;
02399 }
02400 switch(pass)
02401 {
02402 case LSCP_PRETTY_PRINT:
02403 case LSCP_EMIT_ASSEMBLY:
02404 fdotabs(fp, tabs, tabsize);
02405 fprintf(fp, "object_rez( key ");
02406 mID->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
02407 fprintf(fp, " )\n");
02408 break;
02409 case LSCP_SCOPE_PASS1:
02410 if (scope->checkEntry(mID->mName))
02411 {
02412 gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
02413 }
02414 else
02415 {
02416 mID->mScopeEntry = scope->addEntry(mID->mName, LIT_VARIABLE, LST_KEY);
02417 }
02418 break;
02419 case LSCP_RESOURCE:
02420 {
02421
02422 if (mID->mScopeEntry)
02423 {
02424 mID->mScopeEntry->mOffset = (S32)count;
02425 mID->mScopeEntry->mSize = 4;
02426 count += mID->mScopeEntry->mSize;
02427 }
02428 }
02429 break;
02430 case LSCP_EMIT_BYTE_CODE:
02431 {
02432 #ifdef LSL_INCLUDE_DEBUG_INFO
02433 char name[] = "sensor";
02434 chunk->addBytes(name, strlen(name) + 1);
02435 chunk->addBytes(mID->mName, strlen(mID->mName) + 1);
02436 #endif
02437 }
02438 break;
02439 default:
02440 mID->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
02441 break;
02442 }
02443 }
02444
02445 S32 LLScriptObjectRezEvent::getSize()
02446 {
02447
02448 return 4;
02449 }
02450
02451 void LLScriptControlEvent::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
02452 {
02453 if (gErrorToText.getErrors())
02454 {
02455 return;
02456 }
02457 switch(pass)
02458 {
02459 case LSCP_PRETTY_PRINT:
02460 case LSCP_EMIT_ASSEMBLY:
02461 fdotabs(fp, tabs, tabsize);
02462 fprintf(fp, "control( key ");
02463 mName->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
02464 fprintf(fp, ", integer ");
02465 mLevels->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
02466 fprintf(fp, ", integer ");
02467 mEdges->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
02468 fprintf(fp, " )\n");
02469 break;
02470 case LSCP_SCOPE_PASS1:
02471 if (scope->checkEntry(mName->mName))
02472 {
02473 gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
02474 }
02475 else
02476 {
02477 mName->mScopeEntry = scope->addEntry(mName->mName, LIT_VARIABLE, LST_KEY);
02478 }
02479 if (scope->checkEntry(mLevels->mName))
02480 {
02481 gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
02482 }
02483 else
02484 {
02485 mLevels->mScopeEntry = scope->addEntry(mLevels->mName, LIT_VARIABLE, LST_INTEGER);
02486 }
02487 if (scope->checkEntry(mEdges->mName))
02488 {
02489 gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
02490 }
02491 else
02492 {
02493 mEdges->mScopeEntry = scope->addEntry(mEdges->mName, LIT_VARIABLE, LST_INTEGER);
02494 }
02495 break;
02496 case LSCP_RESOURCE:
02497 {
02498
02499 if (mName->mScopeEntry)
02500 {
02501 mName->mScopeEntry->mOffset = (S32)count;
02502 mName->mScopeEntry->mSize = 4;
02503 count += mName->mScopeEntry->mSize;
02504 mLevels->mScopeEntry->mOffset = (S32)count;
02505 mLevels->mScopeEntry->mSize = 4;
02506 count += mLevels->mScopeEntry->mSize;
02507 mEdges->mScopeEntry->mOffset = (S32)count;
02508 mEdges->mScopeEntry->mSize = 4;
02509 count += mEdges->mScopeEntry->mSize;
02510 }
02511 }
02512 break;
02513 case LSCP_EMIT_BYTE_CODE:
02514 {
02515 #ifdef LSL_INCLUDE_DEBUG_INFO
02516 char name[] = "control";
02517 chunk->addBytes(name, strlen(name) + 1);
02518 chunk->addBytes(mName->mName, strlen(mName->mName) + 1);
02519 chunk->addBytes(mLevels->mName, strlen(mLevels->mName) + 1);
02520 chunk->addBytes(mEdges->mName, strlen(mEdges->mName) + 1);
02521 #endif
02522 }
02523 break;
02524 default:
02525 mName->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
02526 mLevels->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
02527 mEdges->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
02528 break;
02529 }
02530 }
02531
02532 S32 LLScriptControlEvent::getSize()
02533 {
02534
02535 return 12;
02536 }
02537
02538 void LLScriptLinkMessageEvent::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
02539 {
02540 if (gErrorToText.getErrors())
02541 {
02542 return;
02543 }
02544 switch(pass)
02545 {
02546 case LSCP_PRETTY_PRINT:
02547 case LSCP_EMIT_ASSEMBLY:
02548 fdotabs(fp, tabs, tabsize);
02549 fprintf(fp, "link_message( integer ");
02550 mSender->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
02551 fprintf(fp, ", integer ");
02552 mNum->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
02553 fprintf(fp, ", string ");
02554 mStr->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
02555 fprintf(fp, ", key ");
02556 mID->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
02557 fprintf(fp, " )\n");
02558 break;
02559 case LSCP_SCOPE_PASS1:
02560 if (scope->checkEntry(mSender->mName))
02561 {
02562 gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
02563 }
02564 else
02565 {
02566 mSender->mScopeEntry = scope->addEntry(mSender->mName, LIT_VARIABLE, LST_INTEGER);
02567 }
02568 if (scope->checkEntry(mNum->mName))
02569 {
02570 gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
02571 }
02572 else
02573 {
02574 mNum->mScopeEntry = scope->addEntry(mNum->mName, LIT_VARIABLE, LST_INTEGER);
02575 }
02576 if (scope->checkEntry(mStr->mName))
02577 {
02578 gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
02579 }
02580 else
02581 {
02582 mStr->mScopeEntry = scope->addEntry(mStr->mName, LIT_VARIABLE, LST_STRING);
02583 }
02584 if (scope->checkEntry(mID->mName))
02585 {
02586 gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
02587 }
02588 else
02589 {
02590 mID->mScopeEntry = scope->addEntry(mID->mName, LIT_VARIABLE, LST_KEY);
02591 }
02592 break;
02593 case LSCP_RESOURCE:
02594 {
02595
02596 if (mSender->mScopeEntry)
02597 {
02598 mSender->mScopeEntry->mOffset = (S32)count;
02599 mSender->mScopeEntry->mSize = 4;
02600 count += mSender->mScopeEntry->mSize;
02601 mNum->mScopeEntry->mOffset = (S32)count;
02602 mNum->mScopeEntry->mSize = 4;
02603 count += mNum->mScopeEntry->mSize;
02604 mStr->mScopeEntry->mOffset = (S32)count;
02605 mStr->mScopeEntry->mSize = 4;
02606 count += mStr->mScopeEntry->mSize;
02607 mID->mScopeEntry->mOffset = (S32)count;
02608 mID->mScopeEntry->mSize = 4;
02609 count += mID->mScopeEntry->mSize;
02610 }
02611 }
02612 break;
02613 case LSCP_EMIT_BYTE_CODE:
02614 {
02615 #ifdef LSL_INCLUDE_DEBUG_INFO
02616 char name[] = "link_message";
02617 chunk->addBytes(name, strlen(name) + 1);
02618 chunk->addBytes(mSender->mName, strlen(mSender->mName) + 1);
02619 chunk->addBytes(mNum->mName, strlen(mNum->mName) + 1);
02620 chunk->addBytes(mStr->mName, strlen(mStr->mName) + 1);
02621 chunk->addBytes(mID->mName, strlen(mID->mName) + 1);
02622 #endif
02623 }
02624 break;
02625 default:
02626 mSender->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
02627 mNum->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
02628 mStr->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
02629 mID->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
02630 break;
02631 }
02632 }
02633
02634 S32 LLScriptLinkMessageEvent::getSize()
02635 {
02636
02637 return 16;
02638 }
02639
02640 void LLScriptRemoteEvent::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
02641 {
02642 if (gErrorToText.getErrors())
02643 {
02644 return;
02645 }
02646 switch(pass)
02647 {
02648 case LSCP_PRETTY_PRINT:
02649 case LSCP_EMIT_ASSEMBLY:
02650 fdotabs(fp, tabs, tabsize);
02651 fprintf(fp, "remote_event( integer ");
02652 mType->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
02653 fprintf(fp, ", key ");
02654 mChannel->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
02655 fprintf(fp, ", key ");
02656 mMessageID->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
02657 fprintf(fp, ", string ");
02658 mSender->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
02659 fprintf(fp, ", integer ");
02660 mIntVal->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
02661 fprintf(fp, ", string ");
02662 mStrVal->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
02663 fprintf(fp, " )\n");
02664 break;
02665 case LSCP_SCOPE_PASS1:
02666 if (scope->checkEntry(mType->mName))
02667 {
02668 gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
02669 }
02670 else
02671 {
02672 mType->mScopeEntry = scope->addEntry(mType->mName, LIT_VARIABLE, LST_INTEGER);
02673 }
02674 if (scope->checkEntry(mChannel->mName))
02675 {
02676 gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
02677 }
02678 else
02679 {
02680 mChannel->mScopeEntry = scope->addEntry(mChannel->mName, LIT_VARIABLE, LST_KEY);
02681 }
02682 if (scope->checkEntry(mMessageID->mName))
02683 {
02684 gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
02685 }
02686 else
02687 {
02688 mMessageID->mScopeEntry = scope->addEntry(mMessageID->mName, LIT_VARIABLE, LST_KEY);
02689 }
02690 if (scope->checkEntry(mSender->mName))
02691 {
02692 gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
02693 }
02694 else
02695 {
02696 mSender->mScopeEntry = scope->addEntry(mSender->mName, LIT_VARIABLE, LST_STRING);
02697 }
02698 if (scope->checkEntry(mIntVal->mName))
02699 {
02700 gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
02701 }
02702 else
02703 {
02704 mIntVal->mScopeEntry = scope->addEntry(mIntVal->mName, LIT_VARIABLE, LST_INTEGER);
02705 }
02706 if (scope->checkEntry(mStrVal->mName))
02707 {
02708 gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
02709 }
02710 else
02711 {
02712 mStrVal->mScopeEntry = scope->addEntry(mStrVal->mName, LIT_VARIABLE, LST_STRING);
02713 }
02714 break;
02715 case LSCP_RESOURCE:
02716 {
02717
02718 if (mType->mScopeEntry)
02719 {
02720 mType->mScopeEntry->mOffset = (S32)count;
02721 mType->mScopeEntry->mSize = 4;
02722 count += mType->mScopeEntry->mSize;
02723 mChannel->mScopeEntry->mOffset = (S32)count;
02724 mChannel->mScopeEntry->mSize = 4;
02725 count += mChannel->mScopeEntry->mSize;
02726 mMessageID->mScopeEntry->mOffset = (S32)count;
02727 mMessageID->mScopeEntry->mSize = 4;
02728 count += mMessageID->mScopeEntry->mSize;
02729 mSender->mScopeEntry->mOffset = (S32)count;
02730 mSender->mScopeEntry->mSize = 4;
02731 count += mSender->mScopeEntry->mSize;
02732 mIntVal->mScopeEntry->mOffset = (S32)count;
02733 mIntVal->mScopeEntry->mSize = 4;
02734 count += mIntVal->mScopeEntry->mSize;
02735 mStrVal->mScopeEntry->mOffset = (S32)count;
02736 mStrVal->mScopeEntry->mSize = 4;
02737 count += mStrVal->mScopeEntry->mSize;
02738 }
02739 }
02740 break;
02741 case LSCP_EMIT_BYTE_CODE:
02742 {
02743 #ifdef LSL_INCLUDE_DEBUG_INFO
02744 char name[] = "remote_event";
02745 chunk->addBytes(name, strlen(name) + 1);
02746 chunk->addBytes(mType->mName, strlen(mType->mName) + 1);
02747 chunk->addBytes(mChannel->mName, strlen(mChannel->mName) + 1);
02748 chunk->addBytes(mMessageID->mName, strlen(mMessageID->mName) + 1);
02749 chunk->addBytes(mSender->mName, strlen(mSender->mName) + 1);
02750 chunk->addBytes(mIntVal->mName, strlen(mIntVal->mName) + 1);
02751 chunk->addBytes(mStrVal->mName, strlen(mStrVal->mName) + 1);
02752 #endif
02753 }
02754 break;
02755 default:
02756 mType->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
02757 mChannel->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
02758 mMessageID->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
02759 mSender->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
02760 mIntVal->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
02761 mStrVal->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
02762 break;
02763 }
02764 }
02765
02766 S32 LLScriptRemoteEvent::getSize()
02767 {
02768
02769 return 24;
02770 }
02771
02772 void LLScriptHTTPResponseEvent::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
02773 {
02774 if (gErrorToText.getErrors())
02775 {
02776 return;
02777 }
02778 switch(pass)
02779 {
02780 case LSCP_PRETTY_PRINT:
02781 case LSCP_EMIT_ASSEMBLY:
02782 fdotabs(fp, tabs, tabsize);
02783 fprintf(fp, "http_response( key ");
02784 mRequestId->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
02785 fprintf(fp, ", integer ");
02786 mStatus->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
02787 fprintf(fp, ", list ");
02788 mMetadata->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
02789 fprintf(fp, ", string ");
02790 mBody->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
02791 fprintf(fp, " )\n");
02792 break;
02793
02794 case LSCP_SCOPE_PASS1:
02795 if (scope->checkEntry(mRequestId->mName))
02796 {
02797 gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
02798 }
02799 else
02800 {
02801 mRequestId->mScopeEntry = scope->addEntry(mRequestId->mName, LIT_VARIABLE, LST_KEY);
02802 }
02803
02804 if (scope->checkEntry(mStatus->mName))
02805 {
02806 gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
02807 }
02808 else
02809 {
02810 mStatus->mScopeEntry = scope->addEntry(mStatus->mName, LIT_VARIABLE, LST_INTEGER);
02811 }
02812
02813 if (scope->checkEntry(mMetadata->mName))
02814 {
02815 gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
02816 }
02817 else
02818 {
02819 mMetadata->mScopeEntry = scope->addEntry(mMetadata->mName, LIT_VARIABLE, LST_LIST);
02820 }
02821
02822 if (scope->checkEntry(mBody->mName))
02823 {
02824 gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
02825 }
02826 else
02827 {
02828 mBody->mScopeEntry = scope->addEntry(mBody->mName, LIT_VARIABLE, LST_STRING);
02829 }
02830 break;
02831
02832 case LSCP_RESOURCE:
02833 {
02834
02835 if (mRequestId->mScopeEntry)
02836 {
02837 mRequestId->mScopeEntry->mOffset = (S32)count;
02838 mRequestId->mScopeEntry->mSize = 4;
02839 count += mRequestId->mScopeEntry->mSize;
02840
02841 mStatus->mScopeEntry->mOffset = (S32)count;
02842 mStatus->mScopeEntry->mSize = 4;
02843 count += mStatus->mScopeEntry->mSize;
02844
02845 mMetadata->mScopeEntry->mOffset = (S32)count;
02846 mMetadata->mScopeEntry->mSize = 4;
02847 count += mMetadata->mScopeEntry->mSize;
02848
02849 mBody->mScopeEntry->mOffset = (S32)count;
02850 mBody->mScopeEntry->mSize = 4;
02851 count += mBody->mScopeEntry->mSize;
02852 }
02853 }
02854 break;
02855
02856 case LSCP_EMIT_BYTE_CODE:
02857 {
02858 #ifdef LSL_INCLUDE_DEBUG_INFO
02859 char name[] = "http_response";
02860 chunk->addBytes(name, strlen(name) + 1);
02861 chunk->addBytes(mRequestId->mName, strlen(mRequestId->mName) + 1);
02862 chunk->addBytes(mStatus->mName, strlen(mStatus->mName) + 1);
02863 chunk->addBytes(mMetadata->mName, strlen(mMetadata->mName) + 1);
02864 chunk->addBytes(mBody->mName, strlen(mBody->mName) + 1);
02865 #endif
02866 }
02867 break;
02868
02869 default:
02870 mRequestId->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
02871 mStatus->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
02872 mMetadata->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
02873 mBody->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
02874 break;
02875 }
02876 }
02877
02878 S32 LLScriptHTTPResponseEvent::getSize()
02879 {
02880
02881 return 16;
02882 }
02883
02884
02885 void LLScriptMoneyEvent::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
02886 {
02887 if (gErrorToText.getErrors())
02888 {
02889 return;
02890 }
02891 switch(pass)
02892 {
02893 case LSCP_PRETTY_PRINT:
02894 case LSCP_EMIT_ASSEMBLY:
02895 fdotabs(fp, tabs, tabsize);
02896 fprintf(fp, "money( key ");
02897 mName->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
02898 fprintf(fp, ", integer ");
02899 mAmount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
02900 fprintf(fp, " )\n");
02901 break;
02902 case LSCP_SCOPE_PASS1:
02903 if (scope->checkEntry(mName->mName))
02904 {
02905 gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
02906 }
02907 else
02908 {
02909 mName->mScopeEntry = scope->addEntry(mName->mName, LIT_VARIABLE, LST_KEY);
02910 }
02911 if (scope->checkEntry(mAmount->mName))
02912 {
02913 gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
02914 }
02915 else
02916 {
02917 mAmount->mScopeEntry = scope->addEntry(mAmount->mName, LIT_VARIABLE, LST_INTEGER);
02918 }
02919 break;
02920 case LSCP_RESOURCE:
02921 {
02922
02923 if (mName->mScopeEntry)
02924 {
02925 mName->mScopeEntry->mOffset = (S32)count;
02926 mName->mScopeEntry->mSize = 4;
02927 count += mName->mScopeEntry->mSize;
02928 mAmount->mScopeEntry->mOffset = (S32)count;
02929 mAmount->mScopeEntry->mSize = 4;
02930 count += mAmount->mScopeEntry->mSize;
02931 }
02932 }
02933 break;
02934 case LSCP_EMIT_BYTE_CODE:
02935 {
02936 #ifdef LSL_INCLUDE_DEBUG_INFO
02937 char name[] = "money";
02938 chunk->addBytes(name, strlen(name) + 1);
02939 chunk->addBytes(mName->mName, strlen(mName->mName) + 1);
02940 chunk->addBytes(mAmount->mName, strlen(mAmount->mName) + 1);
02941 #endif
02942 }
02943 break;
02944 default:
02945 mName->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
02946 mAmount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
02947 break;
02948 }
02949 }
02950
02951 S32 LLScriptMoneyEvent::getSize()
02952 {
02953
02954 return 8;
02955 }
02956
02957 void LLScriptEmailEvent::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
02958 {
02959 if (gErrorToText.getErrors())
02960 {
02961 return;
02962 }
02963 switch(pass)
02964 {
02965 case LSCP_PRETTY_PRINT:
02966 case LSCP_EMIT_ASSEMBLY:
02967 fdotabs(fp, tabs, tabsize);
02968 fprintf(fp, "email( string ");
02969 mTime->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
02970 fprintf(fp, ", string ");
02971 mAddress->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
02972 fprintf(fp, ", string ");
02973 mSubject->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
02974 fprintf(fp, ", string ");
02975 mBody->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
02976 fprintf(fp, ", integer ");
02977 mNumber->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
02978 fprintf(fp, " )\n");
02979 break;
02980 case LSCP_SCOPE_PASS1:
02981 if (scope->checkEntry(mTime->mName))
02982 {
02983 gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
02984 }
02985 else
02986 {
02987 mTime->mScopeEntry = scope->addEntry(mTime->mName, LIT_VARIABLE, LST_STRING);
02988 }
02989 if (scope->checkEntry(mAddress->mName))
02990 {
02991 gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
02992 }
02993 else
02994 {
02995 mAddress->mScopeEntry = scope->addEntry(mAddress->mName, LIT_VARIABLE, LST_STRING);
02996 }
02997 if (scope->checkEntry(mSubject->mName))
02998 {
02999 gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
03000 }
03001 else
03002 {
03003 mSubject->mScopeEntry = scope->addEntry(mSubject->mName, LIT_VARIABLE, LST_STRING);
03004 }
03005 if (scope->checkEntry(mBody->mName))
03006 {
03007 gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
03008 }
03009 else
03010 {
03011 mBody->mScopeEntry = scope->addEntry(mBody->mName, LIT_VARIABLE, LST_STRING);
03012 }
03013 if (scope->checkEntry(mNumber->mName))
03014 {
03015 gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
03016 }
03017 else
03018 {
03019 mNumber->mScopeEntry = scope->addEntry(mNumber->mName, LIT_VARIABLE, LST_INTEGER);
03020 }
03021 break;
03022 case LSCP_RESOURCE:
03023 {
03024
03025 if (mAddress->mScopeEntry)
03026 {
03027 mTime->mScopeEntry->mOffset = (S32)count;
03028 mTime->mScopeEntry->mSize = 4;
03029 count += mTime->mScopeEntry->mSize;
03030 mAddress->mScopeEntry->mOffset = (S32)count;
03031 mAddress->mScopeEntry->mSize = 4;
03032 count += mAddress->mScopeEntry->mSize;
03033 mSubject->mScopeEntry->mOffset = (S32)count;
03034 mSubject->mScopeEntry->mSize = 4;
03035 count += mSubject->mScopeEntry->mSize;
03036 mBody->mScopeEntry->mOffset = (S32)count;
03037 mBody->mScopeEntry->mSize = 4;
03038 count += mBody->mScopeEntry->mSize;
03039 mNumber->mScopeEntry->mOffset = (S32)count;
03040 mNumber->mScopeEntry->mSize = 4;
03041 count += mNumber->mScopeEntry->mSize;
03042 }
03043 }
03044 break;
03045 case LSCP_EMIT_BYTE_CODE:
03046 {
03047 #ifdef LSL_INCLUDE_DEBUG_INFO
03048 char name[] = "email";
03049 chunk->addBytes(name, strlen(name) + 1);
03050 chunk->addBytes(mTime->mName, strlen(mTime->mName) + 1);
03051 chunk->addBytes(mAddress->mName, strlen(mAddress->mName) + 1);
03052 chunk->addBytes(mSubject->mName, strlen(mSubject->mName) + 1);
03053 chunk->addBytes(mBody->mName, strlen(mBody->mName) + 1);
03054 chunk->addBytes(mNumber->mName, strlen(mNumber->mName) + 1);
03055 #endif
03056 }
03057 break;
03058 default:
03059 mTime->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
03060 mAddress->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
03061 mSubject->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
03062 mBody->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
03063 mNumber->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
03064 break;
03065 }
03066 }
03067
03068 S32 LLScriptEmailEvent::getSize()
03069 {
03070
03071 return 20;
03072 }
03073
03074 void LLScriptRezEvent::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
03075 {
03076 if (gErrorToText.getErrors())
03077 {
03078 return;
03079 }
03080 switch(pass)
03081 {
03082 case LSCP_PRETTY_PRINT:
03083 case LSCP_EMIT_ASSEMBLY:
03084 fdotabs(fp, tabs, tabsize);
03085 fprintf(fp, "rez( integer ");
03086 mStartParam->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
03087 fprintf(fp, " )\n");
03088 break;
03089 case LSCP_SCOPE_PASS1:
03090 if (scope->checkEntry(mStartParam->mName))
03091 {
03092 gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
03093 }
03094 else
03095 {
03096 mStartParam->mScopeEntry = scope->addEntry(mStartParam->mName, LIT_VARIABLE, LST_INTEGER);
03097 }
03098 break;
03099 case LSCP_RESOURCE:
03100 {
03101
03102 if (mStartParam->mScopeEntry)
03103 {
03104 mStartParam->mScopeEntry->mOffset = (S32)count;
03105 mStartParam->mScopeEntry->mSize = 4;
03106 count += mStartParam->mScopeEntry->mSize;
03107 }
03108 }
03109 break;
03110 case LSCP_EMIT_BYTE_CODE:
03111 {
03112 #ifdef LSL_INCLUDE_DEBUG_INFO
03113 char name[] = "rez";
03114 chunk->addBytes(name, strlen(name) + 1);
03115 chunk->addBytes(mStartParam->mName, strlen(mStartParam->mName) + 1);
03116 #endif
03117 }
03118 break;
03119 default:
03120 mStartParam->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
03121 break;
03122 }
03123 }
03124
03125 S32 LLScriptRezEvent::getSize()
03126 {
03127
03128 return 4;
03129 }
03130
03131 void LLScriptNoSensorEvent::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
03132 {
03133 if (gErrorToText.getErrors())
03134 {
03135 return;
03136 }
03137 switch(pass)
03138 {
03139 case LSCP_PRETTY_PRINT:
03140 fdotabs(fp, tabs, tabsize);
03141 fprintf(fp, "no_sensor()\n");
03142 break;
03143 case LSCP_EMIT_ASSEMBLY:
03144 fprintf(fp, "no_sensor()\n");
03145 break;
03146 case LSCP_EMIT_BYTE_CODE:
03147 {
03148 #ifdef LSL_INCLUDE_DEBUG_INFO
03149 char name[] = "no_sensor";
03150 chunk->addBytes(name, strlen(name) + 1);
03151 #endif
03152 }
03153 break;
03154 default:
03155 break;
03156 }
03157 }
03158
03159 S32 LLScriptNoSensorEvent::getSize()
03160 {
03161 return 0;
03162 }
03163
03164 void LLScriptAtTarget::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
03165 {
03166 if (gErrorToText.getErrors())
03167 {
03168 return;
03169 }
03170 switch(pass)
03171 {
03172 case LSCP_PRETTY_PRINT:
03173 case LSCP_EMIT_ASSEMBLY:
03174 fdotabs(fp, tabs, tabsize);
03175 fprintf(fp, "at_target( integer ");
03176 mTargetNumber->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
03177 fprintf(fp, ", vector ");
03178 mTargetPosition->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
03179 fprintf(fp, ", vector ");
03180 mOurPosition->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
03181 fprintf(fp, " )\n");
03182 break;
03183 case LSCP_SCOPE_PASS1:
03184 if (scope->checkEntry(mTargetNumber->mName))
03185 {
03186 gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
03187 }
03188 else
03189 {
03190 mTargetNumber->mScopeEntry = scope->addEntry(mTargetNumber->mName, LIT_VARIABLE, LST_INTEGER);
03191 }
03192 if (scope->checkEntry(mTargetPosition->mName))
03193 {
03194 gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
03195 }
03196 else
03197 {
03198 mTargetPosition->mScopeEntry = scope->addEntry(mTargetPosition->mName, LIT_VARIABLE, LST_VECTOR);
03199 }
03200 if (scope->checkEntry(mOurPosition->mName))
03201 {
03202 gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
03203 }
03204 else
03205 {
03206 mOurPosition->mScopeEntry = scope->addEntry(mOurPosition->mName, LIT_VARIABLE, LST_VECTOR);
03207 }
03208 break;
03209 case LSCP_RESOURCE:
03210 {
03211
03212 if (mTargetNumber->mScopeEntry)
03213 {
03214 mTargetNumber->mScopeEntry->mOffset = (S32)count;
03215 mTargetNumber->mScopeEntry->mSize = 4;
03216 count += mTargetNumber->mScopeEntry->mSize;
03217 mTargetPosition->mScopeEntry->mOffset = (S32)count;
03218 mTargetPosition->mScopeEntry->mSize = 12;
03219 count += mTargetPosition->mScopeEntry->mSize;
03220 mOurPosition->mScopeEntry->mOffset = (S32)count;
03221 mOurPosition->mScopeEntry->mSize = 12;
03222 count += mOurPosition->mScopeEntry->mSize;
03223 }
03224 }
03225 break;
03226 case LSCP_EMIT_BYTE_CODE:
03227 {
03228 #ifdef LSL_INCLUDE_DEBUG_INFO
03229 char name[] = "at_target";
03230 chunk->addBytes(name, strlen(name) + 1);
03231 chunk->addBytes(mTargetNumber->mName, strlen(mTargetNumber->mName) + 1);
03232 chunk->addBytes(mTargetPosition->mName, strlen(mTargetPosition->mName) + 1);
03233 chunk->addBytes(mOurPosition->mName, strlen(mOurPosition->mName) + 1);
03234 #endif
03235 }
03236 break;
03237 default:
03238 mTargetNumber->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
03239 mTargetPosition->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
03240 mOurPosition->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
03241 break;
03242 }
03243 }
03244
03245 S32 LLScriptAtTarget::getSize()
03246 {
03247
03248 return 28;
03249 }
03250
03251
03252
03253 void LLScriptNotAtTarget::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
03254 {
03255 if (gErrorToText.getErrors())
03256 {
03257 return;
03258 }
03259 switch(pass)
03260 {
03261 case LSCP_PRETTY_PRINT:
03262 fdotabs(fp, tabs, tabsize);
03263 fprintf(fp, "not_at_target()\n");
03264 break;
03265 case LSCP_EMIT_ASSEMBLY:
03266 fprintf(fp, "not_at_target()\n");
03267 break;
03268 case LSCP_EMIT_BYTE_CODE:
03269 {
03270 #ifdef LSL_INCLUDE_DEBUG_INFO
03271 char name[] = "not_at_target";
03272 chunk->addBytes(name, strlen(name) + 1);
03273 #endif
03274 }
03275 break;
03276 default:
03277 break;
03278 }
03279 }
03280
03281 S32 LLScriptNotAtTarget::getSize()
03282 {
03283 return 0;
03284 }
03285
03286 void LLScriptAtRotTarget::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
03287 {
03288 if (gErrorToText.getErrors())
03289 {
03290 return;
03291 }
03292 switch(pass)
03293 {
03294 case LSCP_PRETTY_PRINT:
03295 case LSCP_EMIT_ASSEMBLY:
03296 fdotabs(fp, tabs, tabsize);
03297 fprintf(fp, "at_target( integer ");
03298 mTargetNumber->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
03299 fprintf(fp, ", quaternion ");
03300 mTargetRotation->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
03301 fprintf(fp, ", quaternion ");
03302 mOurRotation->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
03303 fprintf(fp, " )\n");
03304 break;
03305 case LSCP_SCOPE_PASS1:
03306 if (scope->checkEntry(mTargetNumber->mName))
03307 {
03308 gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
03309 }
03310 else
03311 {
03312 mTargetNumber->mScopeEntry = scope->addEntry(mTargetNumber->mName, LIT_VARIABLE, LST_INTEGER);
03313 }
03314 if (scope->checkEntry(mTargetRotation->mName))
03315 {
03316 gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
03317 }
03318 else
03319 {
03320 mTargetRotation->mScopeEntry = scope->addEntry(mTargetRotation->mName, LIT_VARIABLE, LST_QUATERNION);
03321 }
03322 if (scope->checkEntry(mOurRotation->mName))
03323 {
03324 gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME);
03325 }
03326 else
03327 {
03328 mOurRotation->mScopeEntry = scope->addEntry(mOurRotation->mName, LIT_VARIABLE, LST_QUATERNION);
03329 }
03330 break;
03331 case LSCP_RESOURCE:
03332 {
03333
03334 if (mTargetNumber->mScopeEntry)
03335 {
03336 mTargetNumber->mScopeEntry->mOffset = (S32)count;
03337 mTargetNumber->mScopeEntry->mSize = 4;
03338 count += mTargetNumber->mScopeEntry->mSize;
03339 mTargetRotation->mScopeEntry->mOffset = (S32)count;
03340 mTargetRotation->mScopeEntry->mSize = 16;
03341 count += mTargetRotation->mScopeEntry->mSize;
03342 mOurRotation->mScopeEntry->mOffset = (S32)count;
03343 mOurRotation->mScopeEntry->mSize = 16;
03344 count += mOurRotation->mScopeEntry->mSize;
03345 }
03346 }
03347 break;
03348 case LSCP_EMIT_BYTE_CODE:
03349 {
03350 #ifdef LSL_INCLUDE_DEBUG_INFO
03351 char name[] = "at_rot_target";
03352 chunk->addBytes(name, strlen(name) + 1);
03353 chunk->addBytes(mTargetNumber->mName, strlen(mTargetNumber->mName) + 1);
03354 chunk->addBytes(mTargetRotation->mName, strlen(mTargetRotation->mName) + 1);
03355 chunk->addBytes(mOurRotation->mName, strlen(mOurRotation->mName) + 1);
03356 #endif
03357 }
03358 break;
03359 default:
03360 mTargetNumber->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
03361 mTargetRotation->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
03362 mOurRotation->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
03363 break;
03364 }
03365 }
03366
03367 S32 LLScriptAtRotTarget::getSize()
03368 {
03369
03370 return 36;
03371 }
03372
03373
03374
03375 void LLScriptNotAtRotTarget::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
03376 {
03377 if (gErrorToText.getErrors())
03378 {
03379 return;
03380 }
03381 switch(pass)
03382 {
03383 case LSCP_PRETTY_PRINT:
03384 fdotabs(fp, tabs, tabsize);
03385 fprintf(fp, "not_at_rot_target()\n");
03386 break;
03387 case LSCP_EMIT_ASSEMBLY:
03388 fprintf(fp, "not_at_rot_target()\n");
03389 break;
03390 case LSCP_EMIT_BYTE_CODE:
03391 {
03392 #ifdef LSL_INCLUDE_DEBUG_INFO
03393 char name[] = "not_at_rot_target";
03394 chunk->addBytes(name, strlen(name) + 1);
03395 #endif
03396 }
03397 break;
03398 default:
03399 break;
03400 }
03401 }
03402
03403 S32 LLScriptNotAtRotTarget::getSize()
03404 {
03405 return 0;
03406 }
03407
03408
03409
03410 void LLScriptExpression::addExpression(LLScriptExpression *expression)
03411 {
03412 if (mNextp)
03413 {
03414 expression->mNextp = mNextp;
03415 }
03416 mNextp = expression;
03417 }
03418
03419 void LLScriptExpression::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
03420 {
03421 fprintf(fp, "Expression Base Class -- should never get here!\n");
03422 }
03423
03424 S32 LLScriptExpression::getSize()
03425 {
03426 printf("Expression Base Class -- should never get here!\n");
03427 return 0;
03428 }
03429
03430 void LLScriptExpression::gonext(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
03431 {
03432 if (gErrorToText.getErrors())
03433 {
03434 return;
03435 }
03436 switch(pass)
03437 {
03438 case LSCP_PRETTY_PRINT:
03439 if (mNextp)
03440 {
03441 fprintf(fp, ", ");
03442 mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
03443 }
03444 break;
03445 default:
03446 if (mNextp)
03447 {
03448 mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
03449 }
03450 break;
03451 }
03452 }
03453
03454 void LLScriptForExpressionList::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
03455 {
03456 if (gErrorToText.getErrors())
03457 {
03458 return;
03459 }
03460 switch(pass)
03461 {
03462 case LSCP_PRETTY_PRINT:
03463 mFirstp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
03464 if (mSecondp)
03465 {
03466 fprintf(fp, ", ");
03467 mSecondp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
03468 }
03469 break;
03470 case LSCP_EMIT_ASSEMBLY:
03471 mFirstp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
03472 if (mFirstp->mReturnType)
03473 {
03474 fprintf(fp, "%s\n", LSCRIPTTypePop[mFirstp->mReturnType]);
03475 }
03476 if (mSecondp)
03477 {
03478 mSecondp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
03479 if (mSecondp->mReturnType)
03480 {
03481 fprintf(fp, "%s\n", LSCRIPTTypePop[mSecondp->mReturnType]);
03482 }
03483 }
03484 break;
03485 case LSCP_TO_STACK:
03486 mFirstp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
03487 switch(mFirstp->mReturnType)
03488 {
03489 case LST_INTEGER:
03490 case LST_FLOATINGPOINT:
03491 chunk->addByte(LSCRIPTOpCodes[LOPC_POP]);
03492 break;
03493 case LST_STRING:
03494 case LST_KEY:
03495 chunk->addByte(LSCRIPTOpCodes[LOPC_POPS]);
03496 break;
03497 case LST_LIST:
03498 chunk->addByte(LSCRIPTOpCodes[LOPC_POPL]);
03499 break;
03500 case LST_VECTOR:
03501 chunk->addByte(LSCRIPTOpCodes[LOPC_POPV]);
03502 break;
03503 case LST_QUATERNION:
03504 chunk->addByte(LSCRIPTOpCodes[LOPC_POPQ]);
03505 break;
03506 default:
03507 break;
03508 }
03509 if (mSecondp)
03510 {
03511 mSecondp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
03512 switch(mSecondp->mReturnType)
03513 {
03514 case LST_INTEGER:
03515 case LST_FLOATINGPOINT:
03516 chunk->addByte(LSCRIPTOpCodes[LOPC_POP]);
03517 break;
03518 case LST_STRING:
03519 case LST_KEY:
03520 chunk->addByte(LSCRIPTOpCodes[LOPC_POPS]);
03521 break;
03522 case LST_LIST:
03523 chunk->addByte(LSCRIPTOpCodes[LOPC_POPL]);
03524 break;
03525 case LST_VECTOR:
03526 chunk->addByte(LSCRIPTOpCodes[LOPC_POPV]);
03527 break;
03528 case LST_QUATERNION:
03529 chunk->addByte(LSCRIPTOpCodes[LOPC_POPQ]);
03530 break;
03531 default:
03532 break;
03533 }
03534 }
03535 break;
03536 case LSCP_EMIT_CIL_ASSEMBLY:
03537 mFirstp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
03538 if (mFirstp->mReturnType)
03539 {
03540 fprintf(fp, "pop\n");
03541 }
03542 if (mSecondp)
03543 {
03544 mSecondp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
03545 if (mSecondp->mReturnType)
03546 {
03547 fprintf(fp, "pop\n");
03548 }
03549 }
03550 break;
03551 default:
03552 mFirstp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
03553 if (mSecondp)
03554 {
03555 mSecondp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
03556 }
03557 break;
03558 }
03559 }
03560
03561 S32 LLScriptForExpressionList::getSize()
03562 {
03563 return 0;
03564 }
03565
03566 void LLScriptFuncExpressionList::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
03567 {
03568 if (gErrorToText.getErrors())
03569 {
03570 return;
03571 }
03572 switch(pass)
03573 {
03574 case LSCP_PRETTY_PRINT:
03575 mFirstp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
03576 if (mSecondp)
03577 {
03578 fprintf(fp, ", ");
03579 mSecondp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
03580 }
03581 break;
03582 case LSCP_TYPE:
03583 {
03584 mFirstp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
03585 if (!entry->mFunctionArgs.getType(entrycount))
03586 {
03587 gErrorToText.writeError(fp, this, LSERROR_FUNCTION_TYPE_ERROR);
03588 }
03589 if (!legal_assignment(entry->mFunctionArgs.getType(entrycount), mFirstp->mReturnType))
03590 {
03591 gErrorToText.writeError(fp, this, LSERROR_FUNCTION_TYPE_ERROR);
03592 }
03593 count++;
03594 entrycount++;
03595 if (mSecondp)
03596 {
03597 mSecondp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
03598 if (mSecondp->mReturnType)
03599 {
03600 count++;
03601 if (!entry->mFunctionArgs.getType(entrycount))
03602 {
03603 gErrorToText.writeError(fp, this, LSERROR_FUNCTION_TYPE_ERROR);
03604 }
03605 if (!legal_assignment(entry->mFunctionArgs.getType(entrycount), mSecondp->mReturnType))
03606 {
03607 gErrorToText.writeError(fp, this, LSERROR_FUNCTION_TYPE_ERROR);
03608 }
03609 }
03610 }
03611 }
03612 break;
03613 case LSCP_EMIT_ASSEMBLY:
03614 {
03615 mFirstp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
03616 LSCRIPTType argtype = entry->mFunctionArgs.getType(entrycount);
03617 if (argtype != mFirstp->mReturnType)
03618 {
03619 fprintf(fp, "CAST %s->%s\n", LSCRIPTTypeNames[mFirstp->mReturnType], LSCRIPTTypeNames[argtype]);
03620 }
03621 entrycount++;
03622 if (mSecondp)
03623 {
03624 mSecondp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
03625 if (mSecondp->mReturnType)
03626 {
03627 argtype = entry->mFunctionArgs.getType(entrycount);
03628 if (argtype != mSecondp->mReturnType)
03629 {
03630 fprintf(fp, "CAST %s->%s\n", LSCRIPTTypeNames[mSecondp->mReturnType], LSCRIPTTypeNames[argtype]);
03631 }
03632 }
03633 }
03634 }
03635 break;
03636 case LSCP_TO_STACK:
03637 {
03638 mFirstp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
03639 LSCRIPTType argtype = entry->mFunctionArgs.getType(entrycount);
03640 if (argtype != mFirstp->mReturnType)
03641 {
03642 chunk->addByte(LSCRIPTOpCodes[LOPC_CAST]);
03643 U8 castbyte = LSCRIPTTypeByte[argtype] | LSCRIPTTypeHi4Bits[mFirstp->mReturnType];
03644 chunk->addByte(castbyte);
03645 }
03646 entrycount++;
03647 if (mSecondp)
03648 {
03649 mSecondp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
03650 if (mSecondp->mReturnType)
03651 {
03652 argtype = entry->mFunctionArgs.getType(entrycount);
03653 if (argtype != mSecondp->mReturnType)
03654 {
03655 chunk->addByte(LSCRIPTOpCodes[LOPC_CAST]);
03656 U8 castbyte = LSCRIPTTypeByte[argtype] | LSCRIPTTypeHi4Bits[mSecondp->mReturnType];
03657 chunk->addByte(castbyte);
03658 }
03659 }
03660 }
03661 }
03662 break;
03663
03664
03665
03666
03667
03668
03669
03670
03671
03672
03673
03674
03675
03676
03677
03678
03679
03680
03681
03682
03683
03684
03685
03686
03687
03688 default:
03689 mFirstp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
03690 if (mSecondp)
03691 {
03692 mSecondp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
03693 }
03694 break;
03695 }
03696 }
03697
03698 S32 LLScriptFuncExpressionList::getSize()
03699 {
03700 return 0;
03701 }
03702
03703 void LLScriptListExpressionList::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
03704 {
03705 if (gErrorToText.getErrors())
03706 {
03707 return;
03708 }
03709 switch(pass)
03710 {
03711 case LSCP_PRETTY_PRINT:
03712 mFirstp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
03713 if (mSecondp)
03714 {
03715 fprintf(fp, ", ");
03716 mSecondp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
03717 }
03718 break;
03719 case LSCP_EMIT_ASSEMBLY:
03720 mFirstp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
03721 if (mFirstp->mType != LET_LIST_EXPRESSION_LIST)
03722 {
03723 fprintf(fp, "%s\n", LSCRIPTListDescription[mFirstp->mReturnType]);
03724 count++;
03725 }
03726 if (mSecondp)
03727 {
03728 mSecondp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
03729 if (mSecondp->mType != LET_LIST_EXPRESSION_LIST)
03730 {
03731 fprintf(fp, "%s\n", LSCRIPTListDescription[mSecondp->mReturnType]);
03732 count++;
03733 }
03734 }
03735 break;
03736 case LSCP_TO_STACK:
03737 mFirstp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
03738 if (mFirstp->mType != LET_LIST_EXPRESSION_LIST)
03739 {
03740 chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHARGB]);
03741 chunk->addByte(LSCRIPTTypeByte[mFirstp->mReturnType]);
03742 count++;
03743 }
03744 if (mSecondp)
03745 {
03746 mSecondp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
03747 if (mSecondp->mType != LET_LIST_EXPRESSION_LIST)
03748 {
03749 chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHARGB]);
03750 chunk->addByte(LSCRIPTTypeByte[mSecondp->mReturnType]);
03751 count++;
03752 }
03753 }
03754 break;
03755 case LSCP_EMIT_CIL_ASSEMBLY:
03756
03757
03758 if (mSecondp)
03759 {
03760 mSecondp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
03761 if (mSecondp->mType != LET_LIST_EXPRESSION_LIST)
03762 {
03763
03764 print_cil_box(fp, mSecondp->mReturnType);
03765
03766 ++count;
03767 }
03768 }
03769 mFirstp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
03770 if (mFirstp->mType != LET_LIST_EXPRESSION_LIST)
03771 {
03772
03773 print_cil_box(fp, mFirstp->mReturnType);
03774
03775 ++count;
03776 }
03777 break;
03778 default:
03779 mFirstp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
03780 if (mSecondp)
03781 {
03782 mSecondp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
03783 }
03784 break;
03785 }
03786 }
03787
03788 S32 LLScriptListExpressionList::getSize()
03789 {
03790 return 0;
03791 }
03792
03793
03794 bool is_parameter(LLScriptIdentifier* identifier, LLScriptScopeEntry* function_scope)
03795 {
03796
03797
03798
03799 return (identifier->mScopeEntry->mOffset < function_scope->mOffset);
03800 }
03801
03802
03803 void print_cil_load_address(FILE* fp, LLScriptExpression* exp, LLScriptScopeEntry* function_scope)
03804 {
03805 LLScriptLValue *lvalue = (LLScriptLValue *) exp;
03806 LLScriptIdentifier *ident = lvalue->mIdentifier;
03807
03808
03809 if(ident->mScopeEntry->mIDType == LIT_GLOBAL)
03810 {
03811 fprintf(fp, "ldarg.0\n");
03812 }
03813
03814
03815 if(lvalue->mAccessor)
03816 {
03817 if(ident->mScopeEntry->mIDType == LIT_VARIABLE)
03818 {
03819 if(is_parameter(ident, function_scope))
03820 {
03821
03822 fprintf(fp, "ldarga.s %s\n", ident->mScopeEntry->mIdentifier);
03823 }
03824 else
03825 {
03826
03827 fprintf(fp, "ldloca.s %d\n", ident->mScopeEntry->mCount);
03828 }
03829 }
03830 else if (ident->mScopeEntry->mIDType == LIT_GLOBAL)
03831 {
03832 fprintf(fp, "ldflda ");
03833 print_cil_type(fp, ident->mScopeEntry->mType);
03834 fprintf(fp, " LSL::%s\n", ident->mScopeEntry->mIdentifier);
03835 }
03836 }
03837 }
03838
03839 void print_cil_accessor(FILE* fp, LLScriptLValue *lvalue)
03840 {
03841 LLScriptIdentifier *ident = lvalue->mIdentifier;
03842 print_cil_type(fp, lvalue->mReturnType);
03843 fprintf(fp, " ");
03844 print_cil_type(fp, ident->mScopeEntry->mType);
03845 fprintf(fp, "::%s\n", lvalue->mAccessor->mName);
03846 }
03847
03848 void print_cil_member(FILE* fp, LLScriptIdentifier *ident)
03849 {
03850 print_cil_type(fp, ident->mScopeEntry->mType);
03851 fprintf(fp, " LSL::%s\n", ident->mScopeEntry->mIdentifier);
03852 }
03853
03854 void LLScriptLValue::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
03855 {
03856 if (gErrorToText.getErrors())
03857 {
03858 return;
03859 }
03860 switch(pass)
03861 {
03862 case LSCP_PRETTY_PRINT:
03863 mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
03864 if (mAccessor)
03865 {
03866 fprintf(fp, ".");
03867 mAccessor->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
03868 }
03869 break;
03870 case LSCP_EMIT_ASSEMBLY:
03871 if (mIdentifier->mScopeEntry->mIDType == LIT_VARIABLE)
03872 {
03873 if (mAccessor)
03874 {
03875 fprintf(fp, "%s%d [%s.%s]\n", LSCRIPTTypeLocalPush[mReturnType], mIdentifier->mScopeEntry->mOffset + mOffset, mIdentifier->mName, mAccessor->mName);
03876 }
03877 else
03878 {
03879 fprintf(fp, "%s%d [%s]\n", LSCRIPTTypeLocalPush[mIdentifier->mScopeEntry->mType], mIdentifier->mScopeEntry->mOffset, mIdentifier->mName);
03880 }
03881 }
03882 else if (mIdentifier->mScopeEntry->mIDType == LIT_GLOBAL)
03883 {
03884 if (mAccessor)
03885 {
03886 fprintf(fp, "%s%d [%s.%s]\n", LSCRIPTTypeGlobalPush[mReturnType], mIdentifier->mScopeEntry->mOffset + mOffset, mIdentifier->mName, mAccessor->mName);
03887 }
03888 else
03889 {
03890 fprintf(fp, "%s%d [%s]\n", LSCRIPTTypeGlobalPush[mIdentifier->mScopeEntry->mType], mIdentifier->mScopeEntry->mOffset, mIdentifier->mName);
03891 }
03892 }
03893 else
03894 {
03895 fprintf(fp, "Unexpected LValue!\n");
03896 }
03897 break;
03898 case LSCP_SCOPE_PASS1:
03899 {
03900 LLScriptScopeEntry *entry = scope->findEntry(mIdentifier->mName);
03901 if (!entry || ( (entry->mIDType != LIT_GLOBAL) && (entry->mIDType != LIT_VARIABLE)))
03902 {
03903 gErrorToText.writeError(fp, this, LSERROR_UNDEFINED_NAME);
03904 }
03905 else
03906 {
03907
03908 mIdentifier->mScopeEntry = entry;
03909 }
03910 }
03911 break;
03912 case LSCP_TYPE:
03913
03914 if (mIdentifier->mScopeEntry)
03915 {
03916 if (mAccessor)
03917 {
03918 BOOL b_ok = FALSE;
03919 if (mIdentifier->mScopeEntry->mIDType == LIT_VARIABLE)
03920 {
03921 if (mIdentifier->mScopeEntry->mType == LST_VECTOR)
03922 {
03923 if (!strcmp("x", mAccessor->mName))
03924 {
03925 mOffset = 0;
03926 b_ok = TRUE;
03927 }
03928 else if (!strcmp("y", mAccessor->mName))
03929 {
03930 mOffset = 4;
03931 b_ok = TRUE;
03932 }
03933 else if (!strcmp("z", mAccessor->mName))
03934 {
03935 mOffset = 8;
03936 b_ok = TRUE;
03937 }
03938 }
03939 else if (mIdentifier->mScopeEntry->mType == LST_QUATERNION)
03940 {
03941 if (!strcmp("x", mAccessor->mName))
03942 {
03943 mOffset = 0;
03944 b_ok = TRUE;
03945 }
03946 else if (!strcmp("y", mAccessor->mName))
03947 {
03948 mOffset = 4;
03949 b_ok = TRUE;
03950 }
03951 else if (!strcmp("z", mAccessor->mName))
03952 {
03953 mOffset = 8;
03954 b_ok = TRUE;
03955 }
03956 else if (!strcmp("s", mAccessor->mName))
03957 {
03958 mOffset = 12;
03959 b_ok = TRUE;
03960 }
03961 }
03962 }
03963 else
03964 {
03965 if (mIdentifier->mScopeEntry->mType == LST_VECTOR)
03966 {
03967 if (!strcmp("x", mAccessor->mName))
03968 {
03969 mOffset = 8;
03970 b_ok = TRUE;
03971 }
03972 else if (!strcmp("y", mAccessor->mName))
03973 {
03974 mOffset = 4;
03975 b_ok = TRUE;
03976 }
03977 else if (!strcmp("z", mAccessor->mName))
03978 {
03979 mOffset = 0;
03980 b_ok = TRUE;
03981 }
03982 }
03983 else if (mIdentifier->mScopeEntry->mType == LST_QUATERNION)
03984 {
03985 if (!strcmp("x", mAccessor->mName))
03986 {
03987 mOffset = 12;
03988 b_ok = TRUE;
03989 }
03990 else if (!strcmp("y", mAccessor->mName))
03991 {
03992 mOffset = 8;
03993 b_ok = TRUE;
03994 }
03995 else if (!strcmp("z", mAccessor->mName))
03996 {
03997 mOffset = 4;
03998 b_ok = TRUE;
03999 }
04000 else if (!strcmp("s", mAccessor->mName))
04001 {
04002 mOffset = 0;
04003 b_ok = TRUE;
04004 }
04005 }
04006 }
04007 if (b_ok)
04008 {
04009 mReturnType = type = LST_FLOATINGPOINT;
04010 }
04011 else
04012 {
04013 gErrorToText.writeError(fp, this, LSERROR_VECTOR_METHOD_ERROR);
04014 }
04015 }
04016 else
04017 {
04018 mReturnType = type = mIdentifier->mScopeEntry->mType;
04019 }
04020 }
04021 else
04022 {
04023 mReturnType = type = LST_UNDEFINED;
04024 }
04025 break;
04026 case LSCP_TO_STACK:
04027 {
04028 switch(mReturnType)
04029 {
04030 case LST_INTEGER:
04031 case LST_FLOATINGPOINT:
04032 if (mIdentifier->mScopeEntry->mIDType == LIT_VARIABLE)
04033 {
04034 chunk->addByte(LSCRIPTOpCodes[LOPC_PUSH]);
04035 }
04036 else
04037 {
04038 chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHG]);
04039 }
04040 break;
04041 case LST_KEY:
04042 case LST_STRING:
04043 if (mIdentifier->mScopeEntry->mIDType == LIT_VARIABLE)
04044 {
04045 chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHS]);
04046 }
04047 else
04048 {
04049 chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHGS]);
04050 }
04051 break;
04052 case LST_LIST:
04053 if (mIdentifier->mScopeEntry->mIDType == LIT_VARIABLE)
04054 {
04055 chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHL]);
04056 }
04057 else
04058 {
04059 chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHGL]);
04060 }
04061 break;
04062 case LST_VECTOR:
04063 if (mIdentifier->mScopeEntry->mIDType == LIT_VARIABLE)
04064 {
04065 chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHV]);
04066 }
04067 else
04068 {
04069 chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHGV]);
04070 }
04071 break;
04072 case LST_QUATERNION:
04073 if (mIdentifier->mScopeEntry->mIDType == LIT_VARIABLE)
04074 {
04075 chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHQ]);
04076 }
04077 else
04078 {
04079 chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHGQ]);
04080 }
04081 break;
04082 default:
04083 if (mIdentifier->mScopeEntry->mIDType == LIT_VARIABLE)
04084 {
04085 chunk->addByte(LSCRIPTOpCodes[LOPC_PUSH]);
04086 }
04087 else
04088 {
04089 chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHG]);
04090 }
04091 break;
04092 }
04093 S32 address = mIdentifier->mScopeEntry->mOffset + mOffset;
04094 chunk->addInteger(address);
04095 }
04096 break;
04097 case LSCP_EMIT_CIL_ASSEMBLY:
04098 print_cil_load_address(fp, this, entry);
04099 if(mAccessor)
04100 {
04101 fprintf(fp, "ldfld ");
04102 print_cil_accessor(fp, this);
04103 }
04104 else if(mIdentifier->mScopeEntry->mIDType == LIT_VARIABLE)
04105 {
04106 if(is_parameter(mIdentifier, entry))
04107 {
04108
04109 fprintf(fp, "ldarg.s %s\n", mIdentifier->mScopeEntry->mIdentifier);
04110 }
04111 else
04112 {
04113
04114 fprintf(fp, "ldloc.s %d\n", mIdentifier->mScopeEntry->mCount);
04115 }
04116 }
04117 else if (mIdentifier->mScopeEntry->mIDType == LIT_GLOBAL)
04118 {
04119 fprintf(fp, "ldfld ");
04120 print_cil_member(fp, mIdentifier);
04121 }
04122 else
04123 {
04124 fprintf(fp, "Unexpected LValue!\n");
04125 }
04126 break;
04127 default:
04128 mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04129 break;
04130 }
04131 gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04132 }
04133
04134 S32 LLScriptLValue::getSize()
04135 {
04136 return 0;
04137 }
04138
04139 void print_asignment(FILE *fp, LLScriptExpression *exp)
04140 {
04141 LLScriptLValue *lvalue = (LLScriptLValue *)exp;
04142 LLScriptIdentifier *ident = lvalue->mIdentifier;
04143 if (lvalue->mAccessor)
04144 {
04145 if (ident->mScopeEntry->mIDType == LIT_VARIABLE)
04146 {
04147 fprintf(fp, "%s%d [%s.%s]\n", LSCRIPTTypeLocalStore[ident->mScopeEntry->mType], ident->mScopeEntry->mOffset + lvalue->mOffset, ident->mName, lvalue->mAccessor->mName);
04148 }
04149 else if (ident->mScopeEntry->mIDType == LIT_GLOBAL)
04150 {
04151 fprintf(fp, "%s%d [%s.%s]\n", LSCRIPTTypeGlobalStore[ident->mScopeEntry->mType], ident->mScopeEntry->mOffset + lvalue->mOffset, ident->mName, lvalue->mAccessor->mName);
04152 }
04153 }
04154 else
04155 {
04156 if (ident->mScopeEntry->mIDType == LIT_VARIABLE)
04157 {
04158 fprintf(fp, "%s%d [%s]\n", LSCRIPTTypeLocalStore[ident->mScopeEntry->mType], ident->mScopeEntry->mOffset, ident->mName);
04159 }
04160 else if (ident->mScopeEntry->mIDType == LIT_GLOBAL)
04161 {
04162 fprintf(fp, "%s%d [%s]\n", LSCRIPTTypeGlobalStore[ident->mScopeEntry->mType], ident->mScopeEntry->mOffset, ident->mName);
04163 }
04164 }
04165 }
04166
04167 void print_cil_asignment(FILE *fp, LLScriptExpression *exp, LLScriptScopeEntry* function_scope)
04168 {
04169 LLScriptLValue *lvalue = (LLScriptLValue *) exp;
04170 LLScriptIdentifier *ident = lvalue->mIdentifier;
04171 if (lvalue->mAccessor)
04172 {
04173
04174 fprintf(fp, "stfld ");
04175 print_cil_accessor(fp, lvalue);
04176
04177
04178 print_cil_load_address(fp, exp, function_scope);
04179
04180
04181 fprintf(fp, "ldfld ");
04182 print_cil_accessor(fp, lvalue);
04183 }
04184 else
04185 {
04186 if (ident->mScopeEntry->mIDType == LIT_VARIABLE)
04187 {
04188
04189
04190 fprintf(fp, "dup\n");
04191 if(is_parameter(ident, function_scope))
04192 {
04193
04194 fprintf(fp, "starg.s %s\n", ident->mScopeEntry->mIdentifier);
04195 }
04196 else
04197 {
04198
04199 fprintf(fp, "stloc.s %d\n", ident->mScopeEntry->mCount);
04200 }
04201 }
04202 else if (ident->mScopeEntry->mIDType == LIT_GLOBAL)
04203 {
04204
04205 fprintf(fp, "stfld ");
04206 print_cil_member(fp, ident);
04207
04208
04209 print_cil_load_address(fp, exp, function_scope);
04210
04211
04212 fprintf(fp, "ldfld ");
04213 print_cil_member(fp, ident);
04214 }
04215 }
04216 }
04217
04218 void print_cast(FILE *fp, LSCRIPTType ret_type, LSCRIPTType right_type)
04219 {
04220 if (right_type != ret_type)
04221 {
04222 fprintf(fp, "CAST %s->%s\n", LSCRIPTTypeNames[right_type], LSCRIPTTypeNames[ret_type]);
04223 }
04224 }
04225
04226 void cast2stack(LLScriptByteCodeChunk *chunk, LSCRIPTType ret_type, LSCRIPTType right_type)
04227 {
04228 if (right_type != ret_type)
04229 {
04230 chunk->addByte(LSCRIPTOpCodes[LOPC_CAST]);
04231 U8 castbyte = LSCRIPTTypeByte[right_type] | LSCRIPTTypeHi4Bits[ret_type];
04232 chunk->addByte(castbyte);
04233 }
04234 }
04235
04236 void operation2stack(LLScriptByteCodeChunk *chunk, LSCRIPTType ret_type, LSCRIPTType right_type)
04237 {
04238 U8 typebyte = LSCRIPTTypeByte[right_type] | LSCRIPTTypeHi4Bits[ret_type];
04239 chunk->addByte(typebyte);
04240 }
04241
04242 void store2stack(LLScriptExpression *exp, LLScriptExpression *lv, LLScriptByteCodeChunk *chunk, LSCRIPTType right_type)
04243 {
04244 LLScriptLValue *lvalue = (LLScriptLValue *)lv;
04245 LLScriptIdentifier *ident = lvalue->mIdentifier;
04246 LSCRIPTType rettype = exp->mReturnType;
04247
04248 if (exp->mRightType != LST_NULL)
04249 {
04250 if (legal_binary_expression(rettype, exp->mLeftType, exp->mRightType, exp->mType))
04251 cast2stack(chunk, right_type, exp->mReturnType);
04252 }
04253 switch(exp->mReturnType)
04254 {
04255 case LST_INTEGER:
04256 case LST_FLOATINGPOINT:
04257 if (ident->mScopeEntry->mIDType == LIT_VARIABLE)
04258 {
04259 chunk->addByte(LSCRIPTOpCodes[LOPC_STORE]);
04260 }
04261 else
04262 {
04263 chunk->addByte(LSCRIPTOpCodes[LOPC_STOREG]);
04264 }
04265 break;
04266 case LST_KEY:
04267 case LST_STRING:
04268 if (ident->mScopeEntry->mIDType == LIT_VARIABLE)
04269 {
04270 chunk->addByte(LSCRIPTOpCodes[LOPC_STORES]);
04271 }
04272 else
04273 {
04274 chunk->addByte(LSCRIPTOpCodes[LOPC_STOREGS]);
04275 }
04276 break;
04277 case LST_LIST:
04278 if (ident->mScopeEntry->mIDType == LIT_VARIABLE)
04279 {
04280 chunk->addByte(LSCRIPTOpCodes[LOPC_STOREL]);
04281 }
04282 else
04283 {
04284 chunk->addByte(LSCRIPTOpCodes[LOPC_STOREGL]);
04285 }
04286 break;
04287 case LST_VECTOR:
04288 if (ident->mScopeEntry->mIDType == LIT_VARIABLE)
04289 {
04290 chunk->addByte(LSCRIPTOpCodes[LOPC_STOREV]);
04291 }
04292 else
04293 {
04294 chunk->addByte(LSCRIPTOpCodes[LOPC_STOREGV]);
04295 }
04296 break;
04297 case LST_QUATERNION:
04298 if (ident->mScopeEntry->mIDType == LIT_VARIABLE)
04299 {
04300 chunk->addByte(LSCRIPTOpCodes[LOPC_STOREQ]);
04301 }
04302 else
04303 {
04304 chunk->addByte(LSCRIPTOpCodes[LOPC_STOREGQ]);
04305 }
04306 break;
04307 default:
04308 if (ident->mScopeEntry->mIDType == LIT_VARIABLE)
04309 {
04310 chunk->addByte(LSCRIPTOpCodes[LOPC_STORE]);
04311 }
04312 else
04313 {
04314 chunk->addByte(LSCRIPTOpCodes[LOPC_STOREG]);
04315 }
04316 break;
04317 }
04318 S32 address = ident->mScopeEntry->mOffset + lvalue->mOffset;
04319 chunk->addInteger(address);
04320 }
04321
04322 void print_cil_numeric_cast(FILE* fp, LSCRIPTType currentArg, LSCRIPTType otherArg)
04323 {
04324 if((currentArg == LST_INTEGER) && (otherArg == LST_FLOATINGPOINT))
04325 {
04326 print_cil_cast(fp, LST_INTEGER, LST_FLOATINGPOINT);
04327 }
04328 }
04329
04330 void LLScriptAssignment::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
04331 {
04332 if (gErrorToText.getErrors())
04333 {
04334 return;
04335 }
04336 switch(pass)
04337 {
04338 case LSCP_PRETTY_PRINT:
04339 mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04340 fprintf(fp, " = ");
04341 mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04342 break;
04343 case LSCP_EMIT_ASSEMBLY:
04344 {
04345 mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04346 print_cast(fp, mReturnType, mRightType);
04347 print_asignment(fp, mLValue);
04348 }
04349 break;
04350 case LSCP_TYPE:
04351 {
04352 mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04353 mLeftType = type;
04354 mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04355 mRightType = type;
04356 if (!legal_assignment(mLeftType, mRightType))
04357 {
04358 gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
04359 }
04360 type = mReturnType = mLeftType;
04361 }
04362 break;
04363 case LSCP_TO_STACK:
04364 {
04365 mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04366 store2stack(this, mLValue, chunk, mRightType);
04367 }
04368 break;
04369 case LSCP_EMIT_CIL_ASSEMBLY:
04370 {
04371 print_cil_load_address(fp, mLValue, entry);
04372 mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04373 print_cil_numeric_cast(fp, mRightType, mReturnType);
04374 print_cil_asignment(fp, mLValue, entry);
04375 }
04376 break;
04377 default:
04378 mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04379 mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04380 break;
04381 }
04382 gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04383 }
04384
04385 S32 LLScriptAssignment::getSize()
04386 {
04387 return 0;
04388 }
04389
04390 void print_cil_add(FILE* fp, LSCRIPTType left_type, LSCRIPTType right_type)
04391 {
04392 switch(left_type)
04393 {
04394 case LST_INTEGER:
04395 case LST_FLOATINGPOINT:
04396
04397
04398 fprintf(fp, "add\n");
04399 break;
04400
04401 case LST_STRING:
04402 case LST_KEY:
04403
04404
04405 fprintf(fp, "call string valuetype [mscorlib]System.String::Concat(string, string)");
04406 break;
04407
04408 case LST_VECTOR:
04409
04410
04411
04412 fprintf(fp, "call valuetype [LScriptLibrary]LLVector valuetype [LScriptLibrary]LLVector::'add_vec'(valuetype [LScriptLibrary]LLVector, valuetype [LScriptLibrary]LLVector)\n");
04413 break;
04414
04415 case LST_QUATERNION:
04416
04417
04418
04419 fprintf(fp, "call valuetype [LScriptLibrary]LLQuaternion valuetype [LScriptLibrary]LLQuaternion::'add_quat'(valuetype [LScriptLibrary]LLQuaternion, valuetype [LScriptLibrary]LLQuaternion)\n");
04420 break;
04421
04422 case LST_LIST:
04423 print_cil_box(fp, right_type);
04424 fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LScriptLibrary]LScriptInternal::AddReturnList(class [mscorlib]System.Collections.ArrayList, object)\n");
04425 break;
04426
04427 default:
04428 break;
04429 }
04430 }
04431
04432 void LLScriptAddAssignment::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
04433 {
04434 if (gErrorToText.getErrors())
04435 {
04436 return;
04437 }
04438 switch(pass)
04439 {
04440 case LSCP_PRETTY_PRINT:
04441 mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04442 fprintf(fp, " += ");
04443 mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04444 break;
04445 case LSCP_EMIT_ASSEMBLY:
04446 {
04447 mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04448 mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04449 fprintf(fp, "ADD %s, %s\n", LSCRIPTTypeNames[mRightType], LSCRIPTTypeNames[mLeftType]);
04450 print_asignment(fp, mLValue);
04451 }
04452 break;
04453 case LSCP_TYPE:
04454 {
04455 mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04456 mLeftType = type;
04457 mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04458 mRightType = type;
04459 if (!legal_binary_expression(mReturnType, mLeftType, mRightType, mType))
04460 {
04461 gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
04462 }
04463 type = mReturnType;
04464 }
04465 break;
04466 case LSCP_TO_STACK:
04467 {
04468 mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04469 mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04470 chunk->addByte(LSCRIPTOpCodes[LOPC_ADD]);
04471 operation2stack(chunk, mReturnType, mRightType);
04472 store2stack(this, mLValue, chunk, mReturnType);
04473 }
04474 break;
04475 case LSCP_EMIT_CIL_ASSEMBLY:
04476 {
04477 print_cil_load_address(fp, mLValue, entry);
04478 mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04479 print_cil_numeric_cast(fp, mLValue->mReturnType, mRightSide->mReturnType);
04480 mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04481 print_cil_numeric_cast(fp, mRightSide->mReturnType, mLValue->mReturnType);
04482 print_cil_add(fp, mLValue->mReturnType, mRightSide->mReturnType);
04483 print_cil_asignment(fp, mLValue, entry);
04484 }
04485 break;
04486 default:
04487 mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04488 mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04489 break;
04490 }
04491 gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04492 }
04493
04494 S32 LLScriptAddAssignment::getSize()
04495 {
04496 return 0;
04497 }
04498
04499 void print_cil_sub(FILE* fp, LSCRIPTType left_type, LSCRIPTType right_type)
04500 {
04501 switch(left_type)
04502 {
04503 case LST_INTEGER:
04504 case LST_FLOATINGPOINT:
04505
04506
04507 fprintf(fp, "sub\n");
04508 break;
04509
04510 case LST_VECTOR:
04511
04512
04513
04514 fprintf(fp, "call valuetype [LScriptLibrary]LLVector valuetype [LScriptLibrary]LLVector::'subtract_vec'(valuetype [LScriptLibrary]LLVector, valuetype [LScriptLibrary]LLVector)\n");
04515 break;
04516
04517 case LST_QUATERNION:
04518
04519
04520
04521 fprintf(fp, "call valuetype [LScriptLibrary]LLQuaternion valuetype [LScriptLibrary]LLQuaternion::'subtract_quat'(valuetype [LScriptLibrary]LLQuaternion, valuetype [LScriptLibrary]LLQuaternion)\n");
04522 break;
04523
04524 default:
04525
04526
04527 break;
04528 }
04529 }
04530
04531 void LLScriptSubAssignment::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
04532 {
04533 if (gErrorToText.getErrors())
04534 {
04535 return;
04536 }
04537 switch(pass)
04538 {
04539 case LSCP_PRETTY_PRINT:
04540 mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04541 fprintf(fp, " -= ");
04542 mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04543 break;
04544 case LSCP_EMIT_ASSEMBLY:
04545 {
04546 mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04547 mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04548 fprintf(fp, "SUB %s, %s\n", LSCRIPTTypeNames[mRightType], LSCRIPTTypeNames[mLeftType]);
04549 print_asignment(fp, mLValue);
04550 }
04551 break;
04552 case LSCP_TYPE:
04553 {
04554 mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04555 mLeftType = type;
04556 mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04557 mRightType = type;
04558 if (!legal_binary_expression(mReturnType, mLeftType, mRightType, mType))
04559 {
04560 gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
04561 }
04562 type = mReturnType;
04563 }
04564 break;
04565 case LSCP_TO_STACK:
04566 {
04567 mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04568 mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04569 chunk->addByte(LSCRIPTOpCodes[LOPC_SUB]);
04570 operation2stack(chunk, mReturnType, mRightType);
04571 store2stack(this, mLValue, chunk, mReturnType);
04572 }
04573 break;
04574 case LSCP_EMIT_CIL_ASSEMBLY:
04575 {
04576 print_cil_load_address(fp, mLValue, entry);
04577 mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04578 print_cil_numeric_cast(fp, mLValue->mReturnType, mRightSide->mReturnType);
04579 mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04580 print_cil_numeric_cast(fp, mRightSide->mReturnType, mLValue->mReturnType);
04581 print_cil_sub(fp, mLValue->mReturnType, mRightSide->mReturnType);
04582 print_cil_asignment(fp, mLValue, entry);
04583 }
04584 break;
04585 default:
04586 mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04587 mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04588 break;
04589 }
04590 gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04591 }
04592
04593 S32 LLScriptSubAssignment::getSize()
04594 {
04595 return 0;
04596 }
04597
04598 void print_cil_mul(FILE* fp, LSCRIPTType left_type, LSCRIPTType right_type)
04599 {
04600 switch(left_type)
04601 {
04602 case LST_INTEGER:
04603 case LST_FLOATINGPOINT:
04604
04605
04606 fprintf(fp, "mul\n");
04607 break;
04608
04609 case LST_VECTOR:
04610
04611 switch(right_type)
04612 {
04613 case LST_INTEGER:
04614
04615 print_cil_cast(fp, LST_INTEGER, LST_FLOATINGPOINT);
04616
04617 case LST_FLOATINGPOINT:
04618
04619
04620 fprintf(fp, "call valuetype [LScriptLibrary]LLVector valuetype [LScriptLibrary]LLVector::'multiply_float'(valuetype [LScriptLibrary]LLVector, float32)\n");
04621 break;
04622
04623 case LST_VECTOR:
04624
04625
04626 fprintf(fp, "call float32 valuetype [LScriptLibrary]LLVector::'multiply_vec'(valuetype [LScriptLibrary]LLVector, valuetype [LScriptLibrary]LLVector)\n");
04627 break;
04628
04629 case LST_QUATERNION:
04630
04631
04632 fprintf(fp, "call valuetype [LScriptLibrary]LLVector valuetype [LScriptLibrary]LLVector::'multiply_quat'(valuetype [LScriptLibrary]LLVector, valuetype [LScriptLibrary]LLQuaternion)\n");
04633 break;
04634
04635 default:
04636 break;
04637 }
04638 break;
04639
04640 case LST_QUATERNION:
04641
04642
04643 fprintf(fp, "call valuetype [LScriptLibrary]LLQuaternion valuetype [LScriptLibrary]LLQuaternion::'multiply_quat'(valuetype [LScriptLibrary]LLQuaternion, valuetype [LScriptLibrary]LLQuaternion)\n");
04644 break;
04645
04646 default:
04647
04648
04649 break;
04650 }
04651 }
04652
04653 void LLScriptMulAssignment::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
04654 {
04655 if (gErrorToText.getErrors())
04656 {
04657 return;
04658 }
04659 switch(pass)
04660 {
04661 case LSCP_PRETTY_PRINT:
04662 mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04663 fprintf(fp, " *= ");
04664 mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04665 break;
04666 case LSCP_EMIT_ASSEMBLY:
04667 {
04668 mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04669 mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04670 fprintf(fp, "MUL %s, %s\n", LSCRIPTTypeNames[mRightType], LSCRIPTTypeNames[mLeftType]);
04671 print_asignment(fp, mLValue);
04672 }
04673 break;
04674 case LSCP_TYPE:
04675 {
04676 mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04677 mLeftType = type;
04678 mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04679 mRightType = type;
04680 if (!legal_binary_expression(mReturnType, mLeftType, mRightType, mType))
04681 {
04682 gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
04683 }
04684 type = mReturnType;
04685 }
04686 break;
04687 case LSCP_TO_STACK:
04688 {
04689 mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04690 mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04691 chunk->addByte(LSCRIPTOpCodes[LOPC_MUL]);
04692 operation2stack(chunk, mReturnType, mRightType);
04693 store2stack(this, mLValue, chunk, mReturnType);
04694 }
04695 break;
04696 case LSCP_EMIT_CIL_ASSEMBLY:
04697 {
04698 print_cil_load_address(fp, mLValue, entry);
04699 mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04700 print_cil_numeric_cast(fp, mLValue->mReturnType, mRightSide->mReturnType);
04701 mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04702 print_cil_numeric_cast(fp, mRightSide->mReturnType, mLValue->mReturnType);
04703 print_cil_mul(fp, mLValue->mReturnType, mRightSide->mReturnType);
04704 print_cil_asignment(fp, mLValue, entry);
04705 }
04706 break;
04707 default:
04708 mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04709 mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04710 break;
04711 }
04712 gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04713 }
04714
04715 S32 LLScriptMulAssignment::getSize()
04716 {
04717 return 0;
04718 }
04719
04720 void print_cil_div(FILE* fp, LSCRIPTType left_type, LSCRIPTType right_type)
04721 {
04722 switch(left_type)
04723 {
04724 case LST_INTEGER:
04725 case LST_FLOATINGPOINT:
04726
04727
04728 fprintf(fp, "div\n");
04729 break;
04730
04731 case LST_VECTOR:
04732
04733 switch(right_type)
04734 {
04735 case LST_INTEGER:
04736
04737 print_cil_cast(fp, LST_INTEGER, LST_FLOATINGPOINT);
04738
04739 case LST_FLOATINGPOINT:
04740
04741
04742 fprintf(fp, "call valuetype [LScriptLibrary]LLVector valuetype [LScriptLibrary]LLVector::'divide_float'(valuetype [LScriptLibrary]LLVector, float32)\n");
04743 break;
04744
04745 case LST_QUATERNION:
04746
04747
04748 fprintf(fp, "call valuetype [LScriptLibrary]LLVector valuetype [LScriptLibrary]LLVector::'divide_quat'(valuetype [LScriptLibrary]LLVector, valuetype [LScriptLibrary]LLQuaternion)\n");
04749 break;
04750
04751 default:
04752 break;
04753 }
04754 break;
04755
04756 case LST_QUATERNION:
04757
04758 fprintf(fp, "call valuetype [LScriptLibrary]LLQuaternion valuetype [LScriptLibrary]LLQuaternion::'divide_quat'(valuetype [LScriptLibrary]LLQuaternion, valuetype [LScriptLibrary]LLQuaternion)\n");
04759 break;
04760
04761 default:
04762
04763
04764 break;
04765 }
04766 }
04767
04768 void LLScriptDivAssignment::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
04769 {
04770 if (gErrorToText.getErrors())
04771 {
04772 return;
04773 }
04774 switch(pass)
04775 {
04776 case LSCP_PRETTY_PRINT:
04777 mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04778 fprintf(fp, " /= ");
04779 mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04780 break;
04781 case LSCP_EMIT_ASSEMBLY:
04782 {
04783 mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04784 mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04785 fprintf(fp, "DIV %s, %s\n", LSCRIPTTypeNames[mRightType], LSCRIPTTypeNames[mLeftType]);
04786 print_asignment(fp, mLValue);
04787 }
04788 break;
04789 case LSCP_TYPE:
04790 {
04791 mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04792 mLeftType = type;
04793 mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04794 mRightType = type;
04795 if (!legal_binary_expression(mReturnType, mLeftType, mRightType, mType))
04796 {
04797 gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
04798 }
04799 type = mReturnType;
04800 }
04801 break;
04802 case LSCP_TO_STACK:
04803 {
04804 mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04805 mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04806 chunk->addByte(LSCRIPTOpCodes[LOPC_DIV]);
04807 operation2stack(chunk, mReturnType, mRightType);
04808 store2stack(this, mLValue, chunk, mReturnType);
04809 }
04810 break;
04811 case LSCP_EMIT_CIL_ASSEMBLY:
04812 {
04813 print_cil_load_address(fp, mLValue, entry);
04814 mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04815 print_cil_numeric_cast(fp, mLValue->mReturnType, mRightSide->mReturnType);
04816 mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04817 print_cil_numeric_cast(fp, mRightSide->mReturnType, mLValue->mReturnType);
04818 print_cil_div(fp, mLValue->mReturnType, mRightSide->mReturnType);
04819 print_cil_asignment(fp, mLValue, entry);
04820 }
04821 break;
04822 default:
04823 mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04824 mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04825 break;
04826 }
04827 gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04828 }
04829
04830 S32 LLScriptDivAssignment::getSize()
04831 {
04832 return 0;
04833 }
04834
04835 void print_cil_mod(FILE* fp, LSCRIPTType left_type, LSCRIPTType right_type)
04836 {
04837 switch(left_type)
04838 {
04839 case LST_INTEGER:
04840
04841
04842 fprintf(fp, "rem\n");
04843 break;
04844
04845 case LST_VECTOR:
04846
04847
04848 fprintf(fp, "call valuetype [LScriptLibrary]LLVector valuetype [LScriptLibrary]LLVector::'mod_vec'(valuetype [LScriptLibrary]LLVector, valuetype [LScriptLibrary]LLVector)\n");
04849 break;
04850
04851 default:
04852
04853
04854 break;
04855 }
04856 }
04857
04858 void LLScriptModAssignment::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
04859 {
04860 if (gErrorToText.getErrors())
04861 {
04862 return;
04863 }
04864 switch(pass)
04865 {
04866 case LSCP_PRETTY_PRINT:
04867 mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04868 fprintf(fp, " %%= ");
04869 mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04870 break;
04871 case LSCP_EMIT_ASSEMBLY:
04872 {
04873 mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04874 mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04875 fprintf(fp, "MOD %s, %s\n", LSCRIPTTypeNames[mRightType], LSCRIPTTypeNames[mLeftType]);
04876 print_asignment(fp, mLValue);
04877 }
04878 break;
04879 case LSCP_TYPE:
04880 {
04881 mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04882 mLeftType = type;
04883 mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04884 mRightType = type;
04885 if (!legal_binary_expression(mReturnType, mLeftType, mRightType, mType))
04886 {
04887 gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
04888 }
04889 type = mReturnType;
04890 }
04891 break;
04892 case LSCP_TO_STACK:
04893 {
04894 mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04895 mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04896 chunk->addByte(LSCRIPTOpCodes[LOPC_MOD]);
04897 operation2stack(chunk, mReturnType, mRightType);
04898 store2stack(this, mLValue, chunk, mReturnType);
04899 }
04900 break;
04901 case LSCP_EMIT_CIL_ASSEMBLY:
04902 {
04903 print_cil_load_address(fp, mLValue, entry);
04904 mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04905 mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04906 print_cil_mod(fp, mLValue->mReturnType, mRightSide->mReturnType);
04907 print_cil_asignment(fp, mLValue, entry);
04908 }
04909 break;
04910 default:
04911 mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04912 mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04913 break;
04914 }
04915 gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04916 }
04917
04918 S32 LLScriptModAssignment::getSize()
04919 {
04920 return 0;
04921 }
04922
04923 void print_cil_eq(FILE* fp, LSCRIPTType left_type, LSCRIPTType right_type)
04924 {
04925 switch(left_type)
04926 {
04927 case LST_INTEGER:
04928 case LST_FLOATINGPOINT:
04929
04930
04931 fprintf(fp, "ceq\n");
04932 break;
04933
04934 case LST_STRING:
04935 case LST_KEY:
04936
04937
04938 fprintf(fp, "call bool valuetype [mscorlib]System.String::op_Equality(string, string)\n");
04939 break;
04940
04941 case LST_VECTOR:
04942
04943
04944 fprintf(fp, "call bool [LScriptLibrary]LLVector::'equals_vec'(valuetype [LScriptLibrary]LLVector, valuetype [LScriptLibrary]LLVector)\n");
04945 break;
04946
04947 case LST_QUATERNION:
04948
04949
04950 fprintf(fp, "call bool [LScriptLibrary]LLQuaternion::'equals_quat'(valuetype [LScriptLibrary]LLQuaternion, valuetype [LScriptLibrary]LLQuaternion)\n");
04951 break;
04952
04953 case LST_LIST:
04954 fprintf(fp, "call bool [LScriptLibrary]LScriptInternal::EqualsList(class [mscorlib]System.Collections.ArrayList, class [mscorlib]System.Collections.ArrayList)\n");
04955 break;
04956
04957 default:
04958
04959
04960 break;
04961 }
04962 }
04963
04964 void LLScriptEquality::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
04965 {
04966 if (gErrorToText.getErrors())
04967 {
04968 return;
04969 }
04970 switch(pass)
04971 {
04972 case LSCP_PRETTY_PRINT:
04973 mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04974 fprintf(fp, " == ");
04975 mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04976 break;
04977 case LSCP_EMIT_ASSEMBLY:
04978 mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04979 mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04980 fprintf(fp, "EQ %s, %s\n", LSCRIPTTypeNames[mRightType], LSCRIPTTypeNames[mLeftType]);
04981 break;
04982 case LSCP_TYPE:
04983 {
04984 mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04985 mLeftType = type;
04986 mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04987 mRightType = type;
04988 if (!legal_binary_expression(mReturnType, mLeftType, mRightType, mType))
04989 {
04990 gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
04991 }
04992 type = mReturnType;
04993 }
04994 break;
04995 case LSCP_TO_STACK:
04996 {
04997 mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04998 mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
04999 U8 typebyte = LSCRIPTTypeByte[mRightType] | LSCRIPTTypeHi4Bits[mLeftType];
05000 chunk->addByte(LSCRIPTOpCodes[LOPC_EQ]);
05001 chunk->addByte(typebyte);
05002 }
05003 break;
05004 case LSCP_EMIT_CIL_ASSEMBLY:
05005 mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
05006 print_cil_numeric_cast(fp, mLeftSide->mReturnType, mRightSide->mReturnType);
05007 mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
05008 print_cil_numeric_cast(fp, mRightSide->mReturnType, mLeftSide->mReturnType);
05009 print_cil_eq(fp, mLeftSide->mReturnType, mRightSide->mReturnType);
05010 break;
05011 default:
05012 mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
05013 mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
05014 break;
05015 }
05016 gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
05017 }
05018
05019 S32 LLScriptEquality::getSize()
05020 {
05021 return 0;
05022 }
05023
05024 void LLScriptNotEquals::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
05025 {
05026 if (gErrorToText.getErrors())
05027 {
05028 return;
05029 }
05030 switch(pass)
05031 {
05032 case LSCP_PRETTY_PRINT:
05033 mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
05034 fprintf(fp, " != ");
05035 mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
05036 break;
05037 case LSCP_EMIT_ASSEMBLY:
05038 mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
05039 mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
05040 fprintf(fp, "NEQ %s, %s\n", LSCRIPTTypeNames[mRightType], LSCRIPTTypeNames[mLeftType]);
05041 break;
05042 case LSCP_TYPE:
05043 {
05044 mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
05045 mLeftType = type;
05046 mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
05047 mRightType = type;
05048 if (!legal_binary_expression(mReturnType, mLeftType, mRightType, mType))
05049 {
05050 gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
05051 }
05052 type = mReturnType;
05053 }
05054 break;
05055 case LSCP_TO_STACK:
05056 {
05057 mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
05058 mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
05059 U8 typebyte = LSCRIPTTypeByte[mRightType] | LSCRIPTTypeHi4Bits[mLeftType];
05060 chunk->addByte(LSCRIPTOpCodes[LOPC_NEQ]);
05061 chunk->addByte(typebyte);
05062 }
05063 break;
05064 case LSCP_EMIT_CIL_ASSEMBLY:
05065 mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
05066 mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
05067 fprintf(fp, "ceq\n");
05068 fprintf(fp, "ldc.i4.0\n");
05069 fprintf(fp, "ceq\n");
05070 break;
05071 default:
05072 mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
05073 mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
05074 break;
05075 }
05076 gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
05077 }
05078
05079 S32 LLScriptNotEquals::getSize()
05080 {
05081 return 0;
05082 }
05083
05084 void LLScriptLessEquals::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
05085 {
05086 if (gErrorToText.getErrors())
05087 {
05088 return;
05089 }
05090 switch(pass)
05091 {
05092 case LSCP_PRETTY_PRINT:
05093 mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
05094 fprintf(fp, " <= ");
05095 mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
05096 break;
05097 case LSCP_EMIT_ASSEMBLY:
05098 mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
05099 mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
05100 fprintf(fp, "LEQ %s, %s\n", LSCRIPTTypeNames[mRightType], LSCRIPTTypeNames[mLeftType]);
05101 break;
05102 case LSCP_TYPE:
05103 {
05104 mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
05105 mLeftType = type;
05106 mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
05107 mRightType = type;
05108 if (!legal_binary_expression(mReturnType, mLeftType, mRightType, mType))
05109 {
05110 gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
05111 }
05112 type = mReturnType;
05113 }
05114 break;
05115 case LSCP_TO_STACK:
05116 {
05117 mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
05118 mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
05119 U8 typebyte = LSCRIPTTypeByte[mRightType] | LSCRIPTTypeHi4Bits[mLeftType];
05120 chunk->addByte(LSCRIPTOpCodes[LOPC_LEQ]);
05121 chunk->addByte(typebyte);
05122 }
05123 break;
05124 case LSCP_EMIT_CIL_ASSEMBLY:
05125 mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
05126 mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
05127 fprintf(fp, "cgt\n");
05128 fprintf(fp, "ldc.i4.0\n");
05129 fprintf(fp, "ceq\n");
05130 break;
05131 default:
05132 mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
05133 mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
05134 break;
05135 }
05136 gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
05137 }
05138
05139 S32 LLScriptLessEquals::getSize()
05140 {
05141 return 0;
05142 }
05143
05144 void LLScriptGreaterEquals::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
05145 {
05146 if (gErrorToText.getErrors())
05147 {
05148 return;
05149 }
05150 switch(pass)
05151 {
05152 case LSCP_PRETTY_PRINT:
05153 mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
05154 fprintf(fp, " >= ");
05155 mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
05156 break;
05157 case LSCP_EMIT_ASSEMBLY:
05158 mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
05159 mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
05160 fprintf(fp, "GEQ %s, %s\n", LSCRIPTTypeNames[mRightType], LSCRIPTTypeNames[mLeftType]);
05161 break;
05162 case LSCP_TYPE:
05163 {
05164 mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
05165 mLeftType = type;
05166 mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
05167 mRightType = type;
05168 if (!legal_binary_expression(mReturnType, mLeftType, mRightType, mType))
05169 {
05170 gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
05171 }
05172 type = mReturnType;
05173 }
05174 break;
05175 case LSCP_TO_STACK:
05176 {
05177 mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
05178 mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
05179 U8 typebyte = LSCRIPTTypeByte[mRightType] | LSCRIPTTypeHi4Bits[mLeftType];
05180 chunk->addByte(LSCRIPTOpCodes[LOPC_GEQ]);
05181 chunk->addByte(typebyte);
05182 }
05183 break;
05184 case LSCP_EMIT_CIL_ASSEMBLY:
05185 mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
05186 mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
05187 fprintf(fp, "clt\n");
05188 fprintf(fp, "ldc.i4.0\n");
05189 fprintf(fp, "ceq\n");
05190 break;
05191 default:
05192 mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
05193 mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
05194 break;
05195 }
05196 gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
05197 }
05198
05199 S32 LLScriptGreaterEquals::getSize()
05200 {
05201 return 0;
05202 }
05203
05204 void LLScriptLessThan::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
05205 {
05206 if (gErrorToText.getErrors())
05207 {
05208 return;
05209 }
05210 switch(pass)
05211 {
05212 case LSCP_PRETTY_PRINT:
05213 mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
05214 fprintf(fp, " < ");
05215 mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
05216 break;
05217 case LSCP_EMIT_ASSEMBLY:
05218 mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
05219 mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
05220 fprintf(fp, "LESS %s, %s\n", LSCRIPTTypeNames[mRightType], LSCRIPTTypeNames[mLeftType]);
05221 break;
05222 case LSCP_TYPE:
05223 {
05224 mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
05225 mLeftType = type;
05226 mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
05227 mRightType = type;
05228 if (!legal_binary_expression(mReturnType, mLeftType, mRightType, mType))
05229 {
05230 gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
05231 }
05232 type = mReturnType;
05233 }
05234 break;
05235 case LSCP_TO_STACK:
05236 {
05237 mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
05238 mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
05239 U8 typebyte = LSCRIPTTypeByte[mRightType] | LSCRIPTTypeHi4Bits[mLeftType];
05240 chunk->addByte(LSCRIPTOpCodes[LOPC_LESS]);
05241 chunk->addByte(typebyte);
05242 }
05243 break;
05244 case LSCP_EMIT_CIL_ASSEMBLY:
05245 mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
05246 mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
05247 fprintf(fp, "clt\n");
05248 break;
05249 default:
05250 mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
05251 mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
05252 break;
05253 }
05254 gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
05255 }
05256
05257 S32 LLScriptLessThan::getSize()
05258 {
05259 return 0;
05260 }
05261
05262 void LLScriptGreaterThan::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata)
05263 {
05264 if (gErrorToText.getErrors())
05265 {
05266 return;
05267 }
05268 switch(pass)
05269 {
05270 case LSCP_PRETTY_PRINT:
05271 mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
05272 fprintf(fp, " > ");
05273 mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
05274 break;
05275 case LSCP_EMIT_ASSEMBLY:
05276 mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
05277 mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
05278 fprintf(fp, "GREATER %s, %s\n", LSCRIPTTypeNames[mRightType], LSCRIPTTypeNames[mLeftType]);
05279 break;
05280 case LSCP_TYPE:
05281 {
05282 mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
05283 mLeftType = type;
05284 mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
05285 mRightType = type;
05286 if (!legal_binary_expression(mReturnType, mLeftType, mRightType, mType))
05287 {
05288 gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH);
05289 }
05290 type = mReturnType;
05291 }
05292 break;
05293 case LSCP_TO_STACK:
05294 {
05295 mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
05296 mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
05297 U8 typebyte = LSCRIPTTypeByte[mRightType] | LSCRIPTTypeHi4Bits[mLeftType];
05298 chunk->addByte(LSCRIPTOpCodes[LOPC_GREATER]);
05299 chunk->addByte(typebyte);
05300 }
05301 break;
05302 case LSCP_EMIT_CIL_ASSEMBLY:
05303 mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
05304 mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
05305 fprintf(fp, "cgt\n");
05306 break;
05307 default:
05308 mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL);
05309 mRightSide->recurse(fp, tabs, tabs