diff options
Diffstat (limited to 'linden/indra/lscript/lscript_compile/lscript_tree.cpp')
-rw-r--r-- | linden/indra/lscript/lscript_compile/lscript_tree.cpp | 1743 |
1 files changed, 1237 insertions, 506 deletions
diff --git a/linden/indra/lscript/lscript_compile/lscript_tree.cpp b/linden/indra/lscript/lscript_compile/lscript_tree.cpp index 204f738..71e7f19 100644 --- a/linden/indra/lscript/lscript_compile/lscript_tree.cpp +++ b/linden/indra/lscript/lscript_compile/lscript_tree.cpp | |||
@@ -43,7 +43,8 @@ | |||
43 | 43 | ||
44 | //#define LSL_INCLUDE_DEBUG_INFO | 44 | //#define LSL_INCLUDE_DEBUG_INFO |
45 | 45 | ||
46 | void print_cil_box(LLFILE* fp, LSCRIPTType type) | 46 | |
47 | static void print_cil_box(LLFILE* fp, LSCRIPTType type) | ||
47 | { | 48 | { |
48 | switch(type) | 49 | switch(type) |
49 | { | 50 | { |
@@ -51,24 +52,28 @@ void print_cil_box(LLFILE* fp, LSCRIPTType type) | |||
51 | fprintf(fp, "box [mscorlib]System.Int32\n"); | 52 | fprintf(fp, "box [mscorlib]System.Int32\n"); |
52 | break; | 53 | break; |
53 | case LST_FLOATINGPOINT: | 54 | case LST_FLOATINGPOINT: |
54 | fprintf(fp, "box [mscorlib]System.Double\n"); | 55 | fprintf(fp, "box [mscorlib]System.Single\n"); |
55 | break; | 56 | break; |
56 | case LST_STRING: | 57 | case LST_STRING: |
58 | // System.String is not a System.ValueType, | ||
59 | // so does not need to be boxed. | ||
60 | break; | ||
57 | case LST_KEY: | 61 | case LST_KEY: |
58 | fprintf(fp, "box [mscorlib]System.String\n"); | 62 | fprintf(fp, "box [ScriptTypes]LindenLab.SecondLife.Key\n"); |
59 | break; | 63 | break; |
60 | case LST_VECTOR: | 64 | case LST_VECTOR: |
61 | fprintf(fp, "box [LScriptLibrary]LLVector\n"); | 65 | fprintf(fp, "box [ScriptTypes]LindenLab.SecondLife.Vector\n"); |
62 | break; | 66 | break; |
63 | case LST_QUATERNION: | 67 | case LST_QUATERNION: |
64 | fprintf(fp, "box [LScriptLibrary]LLQuaternion\n"); | 68 | fprintf(fp, "box [ScriptTypes]LindenLab.SecondLife.Quaternion\n"); |
65 | break; | 69 | break; |
66 | default: | 70 | default: |
71 | llassert(false); | ||
67 | break; | 72 | break; |
68 | } | 73 | } |
69 | } | 74 | } |
70 | 75 | ||
71 | void print_cil_type(LLFILE* fp, LSCRIPTType type) | 76 | static void print_cil_type(LLFILE* fp, LSCRIPTType type) |
72 | { | 77 | { |
73 | switch(type) | 78 | switch(type) |
74 | { | 79 | { |
@@ -79,14 +84,16 @@ void print_cil_type(LLFILE* fp, LSCRIPTType type) | |||
79 | fprintf(fp, "float32"); | 84 | fprintf(fp, "float32"); |
80 | break; | 85 | break; |
81 | case LST_STRING: | 86 | case LST_STRING: |
82 | case LST_KEY: | ||
83 | fprintf(fp, "string"); | 87 | fprintf(fp, "string"); |
88 | break; | ||
89 | case LST_KEY: | ||
90 | fprintf(fp, "valuetype [ScriptTypes]LindenLab.SecondLife.Key"); | ||
84 | break; | 91 | break; |
85 | case LST_VECTOR: | 92 | case LST_VECTOR: |
86 | fprintf(fp, "valuetype [LScriptLibrary]LLVector"); | 93 | fprintf(fp, "class [ScriptTypes]LindenLab.SecondLife.Vector"); |
87 | break; | 94 | break; |
88 | case LST_QUATERNION: | 95 | case LST_QUATERNION: |
89 | fprintf(fp, "valuetype [LScriptLibrary]LLQuaternion"); | 96 | fprintf(fp, "class [ScriptTypes]LindenLab.SecondLife.Quaternion"); |
90 | break; | 97 | break; |
91 | case LST_LIST: | 98 | case LST_LIST: |
92 | fprintf(fp, "class [mscorlib]System.Collections.ArrayList"); | 99 | fprintf(fp, "class [mscorlib]System.Collections.ArrayList"); |
@@ -189,6 +196,7 @@ void LLScriptConstantInteger::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPT | |||
189 | break; | 196 | break; |
190 | case LSCP_EMIT_CIL_ASSEMBLY: | 197 | case LSCP_EMIT_CIL_ASSEMBLY: |
191 | fprintf(fp, "ldc.i4 %d\n", mValue); | 198 | fprintf(fp, "ldc.i4 %d\n", mValue); |
199 | type = mType; | ||
192 | break; | 200 | break; |
193 | default: | 201 | default: |
194 | break; | 202 | break; |
@@ -236,7 +244,13 @@ void LLScriptConstantFloat::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCo | |||
236 | } | 244 | } |
237 | break; | 245 | break; |
238 | case LSCP_EMIT_CIL_ASSEMBLY: | 246 | case LSCP_EMIT_CIL_ASSEMBLY: |
239 | fprintf(fp, "ldc.r8 %5.5f\n", mValue); // NOTE: Precision? | 247 | { |
248 | double v = (double)mValue; | ||
249 | U8 * p = (U8 *)&v; // See ECMA-335 Partition VI, Appendix C.4.6 Examples, line 4 | ||
250 | fprintf(fp, "ldc.r8 (%02x %02x %02x %02x %02x %02x %02x %02x)\n", p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7]); | ||
251 | type = mType; | ||
252 | } | ||
253 | break; | ||
240 | default: | 254 | default: |
241 | break; | 255 | break; |
242 | } | 256 | } |
@@ -247,16 +261,34 @@ S32 LLScriptConstantFloat::getSize() | |||
247 | return LSCRIPTDataSize[LST_FLOATINGPOINT]; | 261 | return LSCRIPTDataSize[LST_FLOATINGPOINT]; |
248 | } | 262 | } |
249 | 263 | ||
250 | void print_escape_quotes(LLFILE* fp, const char* str) | 264 | void print_escaped(LLFILE* fp, const char* str) |
251 | { | 265 | { |
252 | putc('"', fp); | 266 | putc('"', fp); |
253 | for(const char* c = str; *c != '\0'; ++c) | 267 | for(const char* c = str; *c != '\0'; ++c) |
254 | { | 268 | { |
255 | if(*c == '"') | 269 | switch(*c) |
256 | { | 270 | { |
257 | putc('\\', fp); | 271 | case '"': |
272 | putc('\\', fp); | ||
273 | putc(*c, fp); | ||
274 | break; | ||
275 | case '\n': | ||
276 | putc('\\', fp); | ||
277 | putc('n', fp); | ||
278 | break; | ||
279 | case '\t': | ||
280 | putc(' ', fp); | ||
281 | putc(' ', fp); | ||
282 | putc(' ', fp); | ||
283 | putc(' ', fp); | ||
284 | break; | ||
285 | case '\\': | ||
286 | putc('\\', fp); | ||
287 | putc('\\', fp); | ||
288 | break; | ||
289 | default: | ||
290 | putc(*c, fp); | ||
258 | } | 291 | } |
259 | putc(*c, fp); | ||
260 | } | 292 | } |
261 | putc('"', fp); | 293 | putc('"', fp); |
262 | } | 294 | } |
@@ -293,7 +325,7 @@ void LLScriptConstantString::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTC | |||
293 | case LSCP_TO_STACK: | 325 | case LSCP_TO_STACK: |
294 | { | 326 | { |
295 | chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHARGS]); | 327 | chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHARGS]); |
296 | chunk->addBytes(mValue, (S32)strlen(mValue) + 1); /*Flawfinder: ignore*/ | 328 | chunk->addBytes(mValue, (S32)strlen(mValue) + 1); |
297 | type = mType; | 329 | type = mType; |
298 | } | 330 | } |
299 | break; | 331 | break; |
@@ -304,7 +336,7 @@ void LLScriptConstantString::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTC | |||
304 | break; | 336 | break; |
305 | case LSCP_EMIT_CIL_ASSEMBLY: | 337 | case LSCP_EMIT_CIL_ASSEMBLY: |
306 | fprintf(fp, "ldstr "); | 338 | fprintf(fp, "ldstr "); |
307 | print_escape_quotes(fp, mValue); | 339 | print_escaped(fp, mValue); |
308 | fprintf(fp, "\n"); | 340 | fprintf(fp, "\n"); |
309 | default: | 341 | default: |
310 | break; | 342 | break; |
@@ -313,10 +345,9 @@ void LLScriptConstantString::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTC | |||
313 | 345 | ||
314 | S32 LLScriptConstantString::getSize() | 346 | S32 LLScriptConstantString::getSize() |
315 | { | 347 | { |
316 | return (S32)strlen(mValue) + 1; /*Flawfinder: ignore*/ | 348 | return (S32)strlen(mValue) + 1; |
317 | } | 349 | } |
318 | 350 | ||
319 | |||
320 | void LLScriptIdentifier::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata) | 351 | void LLScriptIdentifier::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata) |
321 | { | 352 | { |
322 | if (gErrorToText.getErrors()) | 353 | if (gErrorToText.getErrors()) |
@@ -388,7 +419,7 @@ void LLScriptIdentifier::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompi | |||
388 | } | 419 | } |
389 | break; | 420 | break; |
390 | case LSCP_EMIT_CIL_ASSEMBLY: | 421 | case LSCP_EMIT_CIL_ASSEMBLY: |
391 | fprintf(fp, "%s", mName); | 422 | fprintf(fp, "'%s'", mName); |
392 | break; | 423 | break; |
393 | default: | 424 | default: |
394 | break; | 425 | break; |
@@ -428,6 +459,12 @@ S32 LLScriptSimpleAssignable::getSize() | |||
428 | return 0; | 459 | return 0; |
429 | } | 460 | } |
430 | 461 | ||
462 | static void print_cil_member(LLFILE* fp, LLScriptIdentifier *ident) | ||
463 | { | ||
464 | print_cil_type(fp, ident->mScopeEntry->mType); | ||
465 | fprintf(fp, " %s::'%s'\n", gScriptp->getClassName(), ident->mScopeEntry->mIdentifier); | ||
466 | } | ||
467 | |||
431 | void LLScriptSAIdentifier::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata) | 468 | void LLScriptSAIdentifier::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata) |
432 | { | 469 | { |
433 | if (gErrorToText.getErrors()) | 470 | if (gErrorToText.getErrors()) |
@@ -497,6 +534,19 @@ void LLScriptSAIdentifier::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCom | |||
497 | } | 534 | } |
498 | } | 535 | } |
499 | break; | 536 | break; |
537 | |||
538 | case LSCP_EMIT_CIL_ASSEMBLY: | ||
539 | { | ||
540 | fprintf(fp, "ldarg.0\n"); | ||
541 | fprintf(fp, "ldfld "); | ||
542 | print_cil_member(fp, mIdentifier); | ||
543 | fprintf(fp, "\n"); | ||
544 | if (mNextp) | ||
545 | { | ||
546 | mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
547 | } | ||
548 | break; | ||
549 | } | ||
500 | default: | 550 | default: |
501 | mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 551 | mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
502 | if (mNextp) | 552 | if (mNextp) |
@@ -553,7 +603,8 @@ S32 LLScriptSAConstant::getSize() | |||
553 | return mConstant->getSize(); | 603 | return mConstant->getSize(); |
554 | } | 604 | } |
555 | 605 | ||
556 | void print_cil_cast(LLFILE* fp, LSCRIPTType srcType, LSCRIPTType targetType) | 606 | |
607 | static void print_cil_cast(LLFILE* fp, LSCRIPTType srcType, LSCRIPTType targetType) | ||
557 | { | 608 | { |
558 | switch(srcType) | 609 | switch(srcType) |
559 | { | 610 | { |
@@ -567,9 +618,8 @@ void print_cil_cast(LLFILE* fp, LSCRIPTType srcType, LSCRIPTType targetType) | |||
567 | fprintf(fp, "call string class [mscorlib]System.Convert::ToString(int32)\n"); | 618 | fprintf(fp, "call string class [mscorlib]System.Convert::ToString(int32)\n"); |
568 | break; | 619 | break; |
569 | case LST_LIST: | 620 | case LST_LIST: |
570 | fprintf(fp, "box [mscorlib]System.Int32\n"); | 621 | print_cil_box(fp, LST_INTEGER); |
571 | fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LScriptLibrary]LScriptInternal::CreateList()\n"); | 622 | fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::CreateList(object)\n"); |
572 | fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LScriptLibrary]LScriptInternal::AddReturnList(object, class [mscorlib]System.Collections.ArrayList)\n"); | ||
573 | break; | 623 | break; |
574 | default: | 624 | default: |
575 | break; | 625 | break; |
@@ -582,10 +632,11 @@ void print_cil_cast(LLFILE* fp, LSCRIPTType srcType, LSCRIPTType targetType) | |||
582 | fprintf(fp, "conv.i4\n"); | 632 | fprintf(fp, "conv.i4\n"); |
583 | break; | 633 | break; |
584 | case LST_STRING: | 634 | case LST_STRING: |
585 | fprintf(fp, "call string class [mscorlib]System.Convert::ToString(float32)\n"); | 635 | fprintf(fp, "call string [LslLibrary]LindenLab.SecondLife.LslRunTime::ToString(float32)\n"); |
586 | break; | 636 | break; |
587 | case LST_LIST: | 637 | case LST_LIST: |
588 | fprintf(fp, "call class [mscorlib]System.Collections.ArrayList [LScriptLibrary]LScriptInternal::CreateList(object)\n"); | 638 | print_cil_box(fp, LST_FLOATINGPOINT); |
639 | fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::CreateList(object)\n"); | ||
589 | break; | 640 | break; |
590 | default: | 641 | default: |
591 | break; | 642 | break; |
@@ -595,19 +646,22 @@ void print_cil_cast(LLFILE* fp, LSCRIPTType srcType, LSCRIPTType targetType) | |||
595 | switch(targetType) | 646 | switch(targetType) |
596 | { | 647 | { |
597 | case LST_INTEGER: | 648 | case LST_INTEGER: |
598 | fprintf(fp, "call int32 valuetype [mscorlib]System.Int32::Parse(string)\n"); | 649 | fprintf(fp, "call int32 [LslLibrary]LindenLab.SecondLife.LslRunTime::StringToInt(string)\n"); |
599 | break; | 650 | break; |
600 | case LST_FLOATINGPOINT: | 651 | case LST_FLOATINGPOINT: |
601 | fprintf(fp, "call float64 valuetype [mscorlib]System.Double::Parse(string)\n"); | 652 | fprintf(fp, "call float32 [LslLibrary]LindenLab.SecondLife.LslRunTime::StringToFloat(string)\n"); |
602 | break; | 653 | break; |
654 | case LST_KEY: | ||
655 | fprintf(fp, "call valuetype [ScriptTypes]LindenLab.SecondLife.Key class [LslUserScript]LindenLab.SecondLife.LslUserScript::'CreateKey'(string)\n"); | ||
656 | break; | ||
603 | case LST_LIST: | 657 | case LST_LIST: |
604 | fprintf(fp, "call class [mscorlib]System.Collections.ArrayList [LScriptLibrary]LScriptInternal::CreateList(object)\n"); | 658 | fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::CreateList(object)\n"); |
605 | break; | 659 | break; |
606 | case LST_VECTOR: | 660 | case LST_VECTOR: |
607 | fprintf(fp, "call valuetype [LScriptLibrary]LLVector valuetype [LScriptLibrary]LLVector::'Parse'(string)\n"); | 661 | fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Vector class [LslUserScript]LindenLab.SecondLife.LslUserScript::'ParseVector'(string)\n"); |
608 | break; | 662 | break; |
609 | case LST_QUATERNION: | 663 | case LST_QUATERNION: |
610 | fprintf(fp, "call valuetype [LScriptLibrary]LLQuaternion valuetype [LScriptLibrary]LLQuaternion::'Parse'(string)\n"); | 664 | fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Quaternion class [LslUserScript]LindenLab.SecondLife.LslUserScript::'ParseQuaternion'(string)\n"); |
611 | break; | 665 | break; |
612 | default: | 666 | default: |
613 | break; | 667 | break; |
@@ -619,9 +673,11 @@ void print_cil_cast(LLFILE* fp, LSCRIPTType srcType, LSCRIPTType targetType) | |||
619 | case LST_KEY: | 673 | case LST_KEY: |
620 | break; | 674 | break; |
621 | case LST_STRING: | 675 | case LST_STRING: |
676 | fprintf(fp, "call string [LslUserScript]LindenLab.SecondLife.LslUserScript::'ToString'(valuetype [ScriptTypes]LindenLab.SecondLife.Key)\n"); | ||
622 | break; | 677 | break; |
623 | case LST_LIST: | 678 | case LST_LIST: |
624 | fprintf(fp, "call class [mscorlib]System.Collections.ArrayList [LScriptLibrary]LScriptInternal::CreateList(object)\n"); | 679 | print_cil_box(fp, LST_KEY); |
680 | fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::CreateList(object)\n"); | ||
625 | break; | 681 | break; |
626 | default: | 682 | default: |
627 | break; | 683 | break; |
@@ -633,10 +689,11 @@ void print_cil_cast(LLFILE* fp, LSCRIPTType srcType, LSCRIPTType targetType) | |||
633 | case LST_VECTOR: | 689 | case LST_VECTOR: |
634 | break; | 690 | break; |
635 | case LST_STRING: | 691 | case LST_STRING: |
636 | fprintf(fp, "call string valuetype [LScriptLibrary]LLVector::'ToString'(valuetype [LScriptLibrary]LLVector)\n"); | 692 | fprintf(fp, "call string [LslUserScript]LindenLab.SecondLife.LslUserScript::'ToString'(valuetype [ScriptTypes]LindenLab.SecondLife.Vector)\n"); |
637 | break; | 693 | break; |
638 | case LST_LIST: | 694 | case LST_LIST: |
639 | fprintf(fp, "call class [mscorlib]System.Collections.ArrayList [LScriptLibrary]LScriptInternal::CreateList(object)\n"); | 695 | print_cil_box(fp, LST_VECTOR); |
696 | fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::CreateList(object)\n"); | ||
640 | break; | 697 | break; |
641 | default: | 698 | default: |
642 | break; | 699 | break; |
@@ -648,10 +705,11 @@ void print_cil_cast(LLFILE* fp, LSCRIPTType srcType, LSCRIPTType targetType) | |||
648 | case LST_QUATERNION: | 705 | case LST_QUATERNION: |
649 | break; | 706 | break; |
650 | case LST_STRING: | 707 | case LST_STRING: |
651 | fprintf(fp, "call string valuetype [LScriptLibrary]LLQuaternion::'ToString'(valuetype [LScriptLibrary]LLQuaternion)\n"); | 708 | fprintf(fp, "call string [LslUserScript]LindenLab.SecondLife.LslUserScript::'ToString'(valuetype [ScriptTypes]LindenLab.SecondLife.Quaternion)\n"); |
652 | break; | 709 | break; |
653 | case LST_LIST: | 710 | case LST_LIST: |
654 | fprintf(fp, "call class [mscorlib]System.Collections.ArrayList [LScriptLibrary]LScriptInternal::CreateList(object)\n"); | 711 | print_cil_box(fp, LST_QUATERNION); |
712 | fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::CreateList(object)\n"); | ||
655 | break; | 713 | break; |
656 | default: | 714 | default: |
657 | break; | 715 | break; |
@@ -663,7 +721,7 @@ void print_cil_cast(LLFILE* fp, LSCRIPTType srcType, LSCRIPTType targetType) | |||
663 | case LST_LIST: | 721 | case LST_LIST: |
664 | break; | 722 | break; |
665 | case LST_STRING: | 723 | case LST_STRING: |
666 | fprintf(fp, "call string [LScriptLibrary]LScriptInternal::ListToString(class [mscorlib]System.Collections.ArrayList)\n"); | 724 | fprintf(fp, "call string [LslLibrary]LindenLab.SecondLife.LslRunTime::ListToString(class [mscorlib]System.Collections.ArrayList)\n"); |
667 | break; | 725 | break; |
668 | default: | 726 | default: |
669 | break; | 727 | break; |
@@ -674,10 +732,57 @@ void print_cil_cast(LLFILE* fp, LSCRIPTType srcType, LSCRIPTType targetType) | |||
674 | } | 732 | } |
675 | } | 733 | } |
676 | 734 | ||
677 | bool is_SA_constant_integer(LLScriptSimpleAssignable* sa) | 735 | static void print_cil_numeric_cast(LLFILE* fp, LSCRIPTType currentArg, LSCRIPTType otherArg) |
678 | { | 736 | { |
679 | // HACK: Downcast based on type. | 737 | if((currentArg == LST_INTEGER) && ((otherArg == LST_FLOATINGPOINT) || (otherArg == LST_VECTOR))) |
680 | return (sa->mType == LSSAT_CONSTANT && ((LLScriptSAConstant*) sa)->mConstant->mType == LST_INTEGER); | 738 | { |
739 | print_cil_cast(fp, LST_INTEGER, LST_FLOATINGPOINT); | ||
740 | } | ||
741 | } | ||
742 | |||
743 | static void print_cil_assignment_cast(LLFILE* fp, LSCRIPTType src, | ||
744 | LSCRIPTType dest) | ||
745 | { | ||
746 | if (LST_STRING == src && LST_KEY == dest) | ||
747 | { | ||
748 | print_cil_cast(fp, src, dest); | ||
749 | } | ||
750 | else if(LST_KEY == src && LST_STRING == dest) | ||
751 | { | ||
752 | print_cil_cast(fp, src, dest); | ||
753 | } | ||
754 | else | ||
755 | { | ||
756 | print_cil_numeric_cast(fp, src, dest); | ||
757 | } | ||
758 | } | ||
759 | |||
760 | // HACK! Babbage: should be converted to virtual on LSCRIPTSimpleAssignableType to avoid downcasts. | ||
761 | LSCRIPTType get_type(LLScriptSimpleAssignable* sa) | ||
762 | { | ||
763 | LSCRIPTType result = LST_NULL; | ||
764 | switch(sa->mType) | ||
765 | { | ||
766 | case LSSAT_IDENTIFIER: | ||
767 | result = ((LLScriptSAIdentifier*) sa)->mIdentifier->mScopeEntry->mType; | ||
768 | break; | ||
769 | case LSSAT_CONSTANT: | ||
770 | result = ((LLScriptSAConstant*) sa)->mConstant->mType; | ||
771 | break; | ||
772 | case LSSAT_VECTOR_CONSTANT: | ||
773 | result = LST_VECTOR; | ||
774 | break; | ||
775 | case LSSAT_QUATERNION_CONSTANT: | ||
776 | result = LST_QUATERNION; | ||
777 | break; | ||
778 | case LSSAT_LIST_CONSTANT: | ||
779 | result = LST_LIST; | ||
780 | break; | ||
781 | default: | ||
782 | result = LST_UNDEFINED; | ||
783 | break; | ||
784 | } | ||
785 | return result; | ||
681 | } | 786 | } |
682 | 787 | ||
683 | void LLScriptSAVector::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata) | 788 | void LLScriptSAVector::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata) |
@@ -786,23 +891,23 @@ void LLScriptSAVector::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompile | |||
786 | 891 | ||
787 | // Load arguments. | 892 | // Load arguments. |
788 | mEntry1->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 893 | mEntry1->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
789 | if(is_SA_constant_integer(mEntry1)) | 894 | if(LST_INTEGER == get_type(mEntry1)) |
790 | { | 895 | { |
791 | print_cil_cast(fp, LST_INTEGER, LST_FLOATINGPOINT); | 896 | print_cil_cast(fp, LST_INTEGER, LST_FLOATINGPOINT); |
792 | } | 897 | } |
793 | mEntry2->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 898 | mEntry2->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
794 | if(is_SA_constant_integer(mEntry3)) | 899 | if(LST_INTEGER == get_type(mEntry2)) |
795 | { | 900 | { |
796 | print_cil_cast(fp, LST_INTEGER, LST_FLOATINGPOINT); | 901 | print_cil_cast(fp, LST_INTEGER, LST_FLOATINGPOINT); |
797 | } | 902 | } |
798 | mEntry3->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 903 | mEntry3->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
799 | if(is_SA_constant_integer(mEntry3)) | 904 | if(LST_INTEGER == get_type(mEntry3)) |
800 | { | 905 | { |
801 | print_cil_cast(fp, LST_INTEGER, LST_FLOATINGPOINT); | 906 | print_cil_cast(fp, LST_INTEGER, LST_FLOATINGPOINT); |
802 | } | 907 | } |
803 | 908 | ||
804 | // Call named ctor, which leaves new Vector on stack, so it can be saved in to local or argument just like a primitive type. | 909 | // Call named ctor, which leaves new Vector on stack, so it can be saved in to local or argument just like a primitive type. |
805 | fprintf(fp, "call valuetype [LScriptLibrary]LLVector valuetype [LScriptLibrary]LLVector::'create'(float32, float32, float32)\n"); | 910 | fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Vector class [LslUserScript]LindenLab.SecondLife.LslUserScript::'CreateVector'(float32, float32, float32)\n"); |
806 | 911 | ||
807 | // Next. | 912 | // Next. |
808 | if (mNextp) | 913 | if (mNextp) |
@@ -952,28 +1057,28 @@ void LLScriptSAQuaternion::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCom | |||
952 | 1057 | ||
953 | // Load arguments. | 1058 | // Load arguments. |
954 | mEntry1->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 1059 | mEntry1->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
955 | if(is_SA_constant_integer(mEntry1)) | 1060 | if(LST_INTEGER == get_type(mEntry1)) |
956 | { | 1061 | { |
957 | print_cil_cast(fp, LST_INTEGER, LST_FLOATINGPOINT); | 1062 | print_cil_cast(fp, LST_INTEGER, LST_FLOATINGPOINT); |
958 | } | 1063 | } |
959 | mEntry2->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 1064 | mEntry2->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
960 | if(is_SA_constant_integer(mEntry2)) | 1065 | if(LST_INTEGER == get_type(mEntry2)) |
961 | { | 1066 | { |
962 | print_cil_cast(fp, LST_INTEGER, LST_FLOATINGPOINT); | 1067 | print_cil_cast(fp, LST_INTEGER, LST_FLOATINGPOINT); |
963 | } | 1068 | } |
964 | mEntry3->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 1069 | mEntry3->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
965 | if(is_SA_constant_integer(mEntry3)) | 1070 | if(LST_INTEGER == get_type(mEntry3)) |
966 | { | 1071 | { |
967 | print_cil_cast(fp, LST_INTEGER, LST_FLOATINGPOINT); | 1072 | print_cil_cast(fp, LST_INTEGER, LST_FLOATINGPOINT); |
968 | } | 1073 | } |
969 | mEntry4->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 1074 | mEntry4->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
970 | if(is_SA_constant_integer(mEntry4)) | 1075 | if(LST_INTEGER == get_type(mEntry4)) |
971 | { | 1076 | { |
972 | print_cil_cast(fp, LST_INTEGER, LST_FLOATINGPOINT); | 1077 | print_cil_cast(fp, LST_INTEGER, LST_FLOATINGPOINT); |
973 | } | 1078 | } |
974 | 1079 | ||
975 | // Call named ctor, which leaves new Vector on stack, so it can be saved in to local or argument just like a primitive type. | 1080 | // Call named ctor, which leaves new Vector on stack, so it can be saved in to local or argument just like a primitive type. |
976 | fprintf(fp, "call valuetype [LScriptLibrary]LLQuaternion valuetype [LScriptLibrary]LLQuaternion::'create'(float32, float32, float32, float32)\n"); | 1081 | fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Quaternion class [LslUserScript]LindenLab.SecondLife.LslUserScript::'CreateQuaternion'(float32, float32, float32, float32)\n"); |
977 | 1082 | ||
978 | // Next. | 1083 | // Next. |
979 | if (mNextp) | 1084 | if (mNextp) |
@@ -1049,6 +1154,40 @@ void LLScriptSAList::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePa | |||
1049 | } | 1154 | } |
1050 | } | 1155 | } |
1051 | break; | 1156 | break; |
1157 | case LSCP_EMIT_CIL_ASSEMBLY: | ||
1158 | { | ||
1159 | // Create list. | ||
1160 | fprintf(fp, "call class [mscorlib]System.Collections.ArrayList [LslUserScript]LindenLab.SecondLife.LslUserScript::CreateList()\n"); | ||
1161 | |||
1162 | // Add elements. | ||
1163 | LLScriptSimpleAssignable* current_entry = mEntryList; | ||
1164 | LLScriptSimpleAssignable* next_entry = NULL; | ||
1165 | while(NULL != current_entry) | ||
1166 | { | ||
1167 | next_entry = current_entry->mNextp; | ||
1168 | |||
1169 | // Null mNextp pointer, so only current list element is processed. | ||
1170 | current_entry->mNextp = NULL; | ||
1171 | current_entry->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
1172 | |||
1173 | // Restore mNextp pointer. | ||
1174 | current_entry->mNextp = next_entry; | ||
1175 | |||
1176 | // Box element and store in list. | ||
1177 | print_cil_box(fp, get_type(current_entry)); | ||
1178 | fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::Append(class [mscorlib]System.Collections.ArrayList, object)\n"); | ||
1179 | |||
1180 | // Process next element. | ||
1181 | current_entry = next_entry; | ||
1182 | } | ||
1183 | |||
1184 | // Process next list. | ||
1185 | if (mNextp) | ||
1186 | { | ||
1187 | mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
1188 | } | ||
1189 | } | ||
1190 | break; | ||
1052 | default: | 1191 | default: |
1053 | if (mEntryList) | 1192 | if (mEntryList) |
1054 | mEntryList->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, ldata); | 1193 | mEntryList->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, ldata); |
@@ -1093,6 +1232,45 @@ void LLScriptGlobalVariable::gonext(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCo | |||
1093 | } | 1232 | } |
1094 | } | 1233 | } |
1095 | 1234 | ||
1235 | // Push initialised variable of type on to stack. | ||
1236 | static void print_cil_init_variable(LLFILE* fp, LSCRIPTType type) | ||
1237 | { | ||
1238 | switch(type) | ||
1239 | { | ||
1240 | case LST_INTEGER: | ||
1241 | fprintf(fp, "ldc.i4.0\n"); | ||
1242 | break; | ||
1243 | case LST_FLOATINGPOINT: | ||
1244 | fprintf(fp, "ldc.r8 0\n"); | ||
1245 | break; | ||
1246 | case LST_STRING: | ||
1247 | fprintf(fp, "ldstr \"\"\n"); | ||
1248 | break; | ||
1249 | case LST_KEY: | ||
1250 | fprintf(fp, "ldstr \"\"\n"); | ||
1251 | fprintf(fp, "call valuetype [ScriptTypes]LindenLab.SecondLife.Key class [LslUserScript]LindenLab.SecondLife.LslUserScript::'CreateKey'(string)\n"); | ||
1252 | break; | ||
1253 | case LST_VECTOR: | ||
1254 | fprintf(fp, "ldc.r8 0\n"); | ||
1255 | fprintf(fp, "ldc.r8 0\n"); | ||
1256 | fprintf(fp, "ldc.r8 0\n"); | ||
1257 | fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Vector class [LslUserScript]LindenLab.SecondLife.LslUserScript::'CreateVector'(float32, float32, float32)\n"); | ||
1258 | break; | ||
1259 | case LST_QUATERNION: | ||
1260 | fprintf(fp, "ldc.r8 1\n"); | ||
1261 | fprintf(fp, "ldc.r8 0\n"); | ||
1262 | fprintf(fp, "ldc.r8 0\n"); | ||
1263 | fprintf(fp, "ldc.r8 0\n"); | ||
1264 | fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Quaternion class [LslUserScript]LindenLab.SecondLife.LslUserScript::'CreateQuaternion'(float32, float32, float32, float32)\n"); | ||
1265 | break; | ||
1266 | case LST_LIST: | ||
1267 | fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::CreateList()\n"); | ||
1268 | break; | ||
1269 | default: | ||
1270 | break; | ||
1271 | } | ||
1272 | } | ||
1273 | |||
1096 | void LLScriptGlobalVariable::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata) | 1274 | void LLScriptGlobalVariable::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata) |
1097 | { | 1275 | { |
1098 | if (gErrorToText.getErrors()) | 1276 | if (gErrorToText.getErrors()) |
@@ -1164,7 +1342,7 @@ void LLScriptGlobalVariable::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTC | |||
1164 | // it also includes the name of the variable as well as the type | 1342 | // it also includes the name of the variable as well as the type |
1165 | // plus 4 bytes of offset from it's apparent address to the actual data | 1343 | // plus 4 bytes of offset from it's apparent address to the actual data |
1166 | #ifdef LSL_INCLUDE_DEBUG_INFO | 1344 | #ifdef LSL_INCLUDE_DEBUG_INFO |
1167 | count += strlen(mIdentifier->mName) + 1 + 1 + 4; /*Flawfinder: ignore*/ | 1345 | count += strlen(mIdentifier->mName) + 1 + 1 + 4; |
1168 | #else | 1346 | #else |
1169 | count += 1 + 1 + 4; | 1347 | count += 1 + 1 + 4; |
1170 | #endif | 1348 | #endif |
@@ -1187,7 +1365,7 @@ void LLScriptGlobalVariable::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTC | |||
1187 | chunk->addBytes(&vtype, 1); | 1365 | chunk->addBytes(&vtype, 1); |
1188 | // null terminated name | 1366 | // null terminated name |
1189 | #ifdef LSL_INCLUDE_DEBUG_INFO | 1367 | #ifdef LSL_INCLUDE_DEBUG_INFO |
1190 | chunk->addBytes(mIdentifier->mName, strlen(mIdentifier->mName) + 1); /*Flawfinder: ignore*/ | 1368 | chunk->addBytes(mIdentifier->mName, strlen(mIdentifier->mName) + 1); |
1191 | #else | 1369 | #else |
1192 | chunk->addBytes(1); | 1370 | chunk->addBytes(1); |
1193 | #endif | 1371 | #endif |
@@ -1257,16 +1435,27 @@ void LLScriptGlobalVariable::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTC | |||
1257 | case LSCP_EMIT_CIL_ASSEMBLY: | 1435 | case LSCP_EMIT_CIL_ASSEMBLY: |
1258 | 1436 | ||
1259 | // Initialisation inside ctor. | 1437 | // Initialisation inside ctor. |
1438 | fprintf(fp, "ldarg.0\n"); | ||
1260 | if (mAssignable) | 1439 | if (mAssignable) |
1261 | { | 1440 | { |
1262 | fprintf(fp, "ldarg.0\n"); | 1441 | // Initialise to value. |
1263 | mAssignable->recurse(fp, tabs, tabsize, LSCP_EMIT_CIL_ASSEMBLY, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 1442 | mAssignable->recurse(fp, tabs, tabsize, LSCP_EMIT_CIL_ASSEMBLY, |
1264 | fprintf(fp, "stfld "); | 1443 | ptype, prunearg, scope, type, basetype, |
1265 | mType->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 1444 | count, chunk, heap, stacksize, entry, |
1266 | fprintf(fp," LSL::"); | 1445 | entrycount, NULL); |
1267 | mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 1446 | print_cil_assignment_cast(fp, get_type(mAssignable), mType->mType); |
1268 | fprintf(fp, "\n"); | 1447 | } |
1448 | else | ||
1449 | { | ||
1450 | // Initialise to zero. | ||
1451 | print_cil_init_variable(fp, mType->mType); | ||
1269 | } | 1452 | } |
1453 | // Store value. | ||
1454 | fprintf(fp, "stfld "); | ||
1455 | mType->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
1456 | fprintf(fp," %s::", gScriptp->getClassName()); | ||
1457 | mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
1458 | fprintf(fp, "\n"); | ||
1270 | break; | 1459 | break; |
1271 | default: | 1460 | default: |
1272 | mType->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 1461 | mType->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
@@ -1298,6 +1487,20 @@ S32 LLScriptEvent::getSize() | |||
1298 | printf("Event Base Class -- should never get here!\n"); | 1487 | printf("Event Base Class -- should never get here!\n"); |
1299 | return 0; | 1488 | return 0; |
1300 | } | 1489 | } |
1490 | static void checkForDuplicateHandler(LLFILE *fp, LLScriptFilePosition *pos, | ||
1491 | LLScriptScope *scope, | ||
1492 | const char* name) | ||
1493 | { | ||
1494 | LLScriptScope *parent = scope->mParentScope; | ||
1495 | if (parent->checkEntry((char*)name)) | ||
1496 | { | ||
1497 | gErrorToText.writeError(fp, pos, LSERROR_DUPLICATE_NAME); | ||
1498 | } | ||
1499 | else | ||
1500 | { | ||
1501 | parent->addEntry(((char*)name), LIT_HANDLER, LST_NULL); | ||
1502 | } | ||
1503 | } | ||
1301 | 1504 | ||
1302 | void LLScriptStateEntryEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata) | 1505 | void LLScriptStateEntryEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata) |
1303 | { | 1506 | { |
@@ -1314,11 +1517,14 @@ void LLScriptStateEntryEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPT | |||
1314 | case LSCP_EMIT_ASSEMBLY: | 1517 | case LSCP_EMIT_ASSEMBLY: |
1315 | fprintf(fp, "state_entry()\n"); | 1518 | fprintf(fp, "state_entry()\n"); |
1316 | break; | 1519 | break; |
1520 | case LSCP_SCOPE_PASS1: | ||
1521 | checkForDuplicateHandler(fp, this, scope, "state_entry"); | ||
1522 | break; | ||
1317 | case LSCP_EMIT_BYTE_CODE: | 1523 | case LSCP_EMIT_BYTE_CODE: |
1318 | { | 1524 | { |
1319 | #ifdef LSL_INCLUDE_DEBUG_INFO | 1525 | #ifdef LSL_INCLUDE_DEBUG_INFO |
1320 | char name[] = "state_entry"; | 1526 | char name[] = "state_entry"; |
1321 | chunk->addBytes(name, strlen(name) + 1); /*Flawfinder: ignore*/ | 1527 | chunk->addBytes(name, strlen(name) + 1); |
1322 | #endif | 1528 | #endif |
1323 | } | 1529 | } |
1324 | break; | 1530 | break; |
@@ -1347,6 +1553,9 @@ void LLScriptStateExitEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTC | |||
1347 | fdotabs(fp, tabs, tabsize); | 1553 | fdotabs(fp, tabs, tabsize); |
1348 | fprintf(fp, "state_exit()\n"); | 1554 | fprintf(fp, "state_exit()\n"); |
1349 | break; | 1555 | break; |
1556 | case LSCP_SCOPE_PASS1: | ||
1557 | checkForDuplicateHandler(fp, this, scope, "state_exit"); | ||
1558 | break; | ||
1350 | case LSCP_EMIT_ASSEMBLY: | 1559 | case LSCP_EMIT_ASSEMBLY: |
1351 | fprintf(fp, "state_exit()\n"); | 1560 | fprintf(fp, "state_exit()\n"); |
1352 | break; | 1561 | break; |
@@ -1354,7 +1563,7 @@ void LLScriptStateExitEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTC | |||
1354 | { | 1563 | { |
1355 | #ifdef LSL_INCLUDE_DEBUG_INFO | 1564 | #ifdef LSL_INCLUDE_DEBUG_INFO |
1356 | char name[] = "state_exit"; | 1565 | char name[] = "state_exit"; |
1357 | chunk->addBytes(name, strlen(name) + 1); /*Flawfinder: ignore*/ | 1566 | chunk->addBytes(name, strlen(name) + 1); |
1358 | #endif | 1567 | #endif |
1359 | } | 1568 | } |
1360 | break; | 1569 | break; |
@@ -1388,6 +1597,7 @@ void LLScriptTouchStartEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPT | |||
1388 | break; | 1597 | break; |
1389 | break; | 1598 | break; |
1390 | case LSCP_SCOPE_PASS1: | 1599 | case LSCP_SCOPE_PASS1: |
1600 | checkForDuplicateHandler(fp, this, scope, "touch_start"); | ||
1391 | if (scope->checkEntry(mCount->mName)) | 1601 | if (scope->checkEntry(mCount->mName)) |
1392 | { | 1602 | { |
1393 | gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME); | 1603 | gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME); |
@@ -1412,11 +1622,18 @@ void LLScriptTouchStartEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPT | |||
1412 | { | 1622 | { |
1413 | #ifdef LSL_INCLUDE_DEBUG_INFO | 1623 | #ifdef LSL_INCLUDE_DEBUG_INFO |
1414 | char name[] = "touch_start"; | 1624 | char name[] = "touch_start"; |
1415 | chunk->addBytes(name, strlen(name) + 1); /*Flawfinder: ignore*/ | 1625 | chunk->addBytes(name, strlen(name) + 1); |
1416 | chunk->addBytes(mCount->mName, strlen(mCount->mName) + 1); /*Flawfinder: ignore*/ | 1626 | chunk->addBytes(mCount->mName, strlen(mCount->mName) + 1); |
1417 | #endif | 1627 | #endif |
1418 | } | 1628 | } |
1419 | break; | 1629 | break; |
1630 | case LSCP_EMIT_CIL_ASSEMBLY: | ||
1631 | fdotabs(fp, tabs, tabsize); | ||
1632 | fprintf(fp, "touch_start( int32 "); | ||
1633 | mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
1634 | fprintf(fp, " )"); | ||
1635 | break; | ||
1636 | break; | ||
1420 | default: | 1637 | default: |
1421 | mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 1638 | mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
1422 | break; | 1639 | break; |
@@ -1446,6 +1663,7 @@ void LLScriptTouchEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompi | |||
1446 | break; | 1663 | break; |
1447 | break; | 1664 | break; |
1448 | case LSCP_SCOPE_PASS1: | 1665 | case LSCP_SCOPE_PASS1: |
1666 | checkForDuplicateHandler(fp, this, scope, "touch"); | ||
1449 | if (scope->checkEntry(mCount->mName)) | 1667 | if (scope->checkEntry(mCount->mName)) |
1450 | { | 1668 | { |
1451 | gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME); | 1669 | gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME); |
@@ -1470,11 +1688,18 @@ void LLScriptTouchEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompi | |||
1470 | { | 1688 | { |
1471 | #ifdef LSL_INCLUDE_DEBUG_INFO | 1689 | #ifdef LSL_INCLUDE_DEBUG_INFO |
1472 | char name[] = "touch"; | 1690 | char name[] = "touch"; |
1473 | chunk->addBytes(name, strlen(name) + 1); /*Flawfinder: ignore*/ | 1691 | chunk->addBytes(name, strlen(name) + 1); |
1474 | chunk->addBytes(mCount->mName, strlen(mCount->mName) + 1); /*Flawfinder: ignore*/ | 1692 | chunk->addBytes(mCount->mName, strlen(mCount->mName) + 1); |
1475 | #endif | 1693 | #endif |
1476 | } | 1694 | } |
1477 | break; | 1695 | break; |
1696 | case LSCP_EMIT_CIL_ASSEMBLY: | ||
1697 | fdotabs(fp, tabs, tabsize); | ||
1698 | fprintf(fp, "touch( int32 "); | ||
1699 | mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
1700 | fprintf(fp, " )"); | ||
1701 | break; | ||
1702 | break; | ||
1478 | default: | 1703 | default: |
1479 | mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 1704 | mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
1480 | break; | 1705 | break; |
@@ -1504,6 +1729,7 @@ void LLScriptTouchEndEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCo | |||
1504 | break; | 1729 | break; |
1505 | break; | 1730 | break; |
1506 | case LSCP_SCOPE_PASS1: | 1731 | case LSCP_SCOPE_PASS1: |
1732 | checkForDuplicateHandler(fp, this, scope, "touch_end"); | ||
1507 | if (scope->checkEntry(mCount->mName)) | 1733 | if (scope->checkEntry(mCount->mName)) |
1508 | { | 1734 | { |
1509 | gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME); | 1735 | gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME); |
@@ -1528,11 +1754,18 @@ void LLScriptTouchEndEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCo | |||
1528 | { | 1754 | { |
1529 | #ifdef LSL_INCLUDE_DEBUG_INFO | 1755 | #ifdef LSL_INCLUDE_DEBUG_INFO |
1530 | char name[] = "touch_end"; | 1756 | char name[] = "touch_end"; |
1531 | chunk->addBytes(name, strlen(name) + 1); /*Flawfinder: ignore*/ | 1757 | chunk->addBytes(name, strlen(name) + 1); |
1532 | chunk->addBytes(mCount->mName, strlen(mCount->mName) + 1); /*Flawfinder: ignore*/ | 1758 | chunk->addBytes(mCount->mName, strlen(mCount->mName) + 1); |
1533 | #endif | 1759 | #endif |
1534 | } | 1760 | } |
1535 | break; | 1761 | break; |
1762 | case LSCP_EMIT_CIL_ASSEMBLY: | ||
1763 | fdotabs(fp, tabs, tabsize); | ||
1764 | fprintf(fp, "touch_end( int32 "); | ||
1765 | mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
1766 | fprintf(fp, " )"); | ||
1767 | break; | ||
1768 | break; | ||
1536 | default: | 1769 | default: |
1537 | mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 1770 | mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
1538 | break; | 1771 | break; |
@@ -1562,6 +1795,7 @@ void LLScriptCollisionStartEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSC | |||
1562 | break; | 1795 | break; |
1563 | break; | 1796 | break; |
1564 | case LSCP_SCOPE_PASS1: | 1797 | case LSCP_SCOPE_PASS1: |
1798 | checkForDuplicateHandler(fp, this, scope, "collision_start"); | ||
1565 | if (scope->checkEntry(mCount->mName)) | 1799 | if (scope->checkEntry(mCount->mName)) |
1566 | { | 1800 | { |
1567 | gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME); | 1801 | gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME); |
@@ -1586,11 +1820,17 @@ void LLScriptCollisionStartEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSC | |||
1586 | { | 1820 | { |
1587 | #ifdef LSL_INCLUDE_DEBUG_INFO | 1821 | #ifdef LSL_INCLUDE_DEBUG_INFO |
1588 | char name[] = "collision_start"; | 1822 | char name[] = "collision_start"; |
1589 | chunk->addBytes(name, (S32)strlen(name) + 1); /*Flawfinder: ignore*/ | 1823 | chunk->addBytes(name, (S32)strlen(name) + 1); |
1590 | chunk->addBytes(mCount->mName, (S32)strlen(mCount->mName) + 1); /*Flawfinder: ignore*/ | 1824 | chunk->addBytes(mCount->mName, (S32)strlen(mCount->mName) + 1); |
1591 | #endif | 1825 | #endif |
1592 | } | 1826 | } |
1593 | break; | 1827 | break; |
1828 | case LSCP_EMIT_CIL_ASSEMBLY: | ||
1829 | fdotabs(fp, tabs, tabsize); | ||
1830 | fprintf(fp, "collision_start( int32 "); | ||
1831 | mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
1832 | fprintf(fp, " )"); | ||
1833 | break; | ||
1594 | default: | 1834 | default: |
1595 | mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 1835 | mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
1596 | break; | 1836 | break; |
@@ -1620,6 +1860,7 @@ void LLScriptCollisionEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTC | |||
1620 | break; | 1860 | break; |
1621 | break; | 1861 | break; |
1622 | case LSCP_SCOPE_PASS1: | 1862 | case LSCP_SCOPE_PASS1: |
1863 | checkForDuplicateHandler(fp, this, scope, "collision"); | ||
1623 | if (scope->checkEntry(mCount->mName)) | 1864 | if (scope->checkEntry(mCount->mName)) |
1624 | { | 1865 | { |
1625 | gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME); | 1866 | gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME); |
@@ -1644,11 +1885,16 @@ void LLScriptCollisionEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTC | |||
1644 | { | 1885 | { |
1645 | #ifdef LSL_INCLUDE_DEBUG_INFO | 1886 | #ifdef LSL_INCLUDE_DEBUG_INFO |
1646 | char name[] = "collision"; | 1887 | char name[] = "collision"; |
1647 | chunk->addBytes(name, strlen(name) + 1); /*Flawfinder: ignore*/ | 1888 | chunk->addBytes(name, strlen(name) + 1); |
1648 | chunk->addBytes(mCount->mName, strlen(mCount->mName) + 1); /*Flawfinder: ignore*/ | 1889 | chunk->addBytes(mCount->mName, strlen(mCount->mName) + 1); |
1649 | #endif | 1890 | #endif |
1650 | } | 1891 | } |
1651 | break; | 1892 | break; |
1893 | case LSCP_EMIT_CIL_ASSEMBLY: | ||
1894 | fprintf(fp, "collision( int32 "); | ||
1895 | mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
1896 | fprintf(fp, " )"); | ||
1897 | break; | ||
1652 | default: | 1898 | default: |
1653 | mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 1899 | mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
1654 | break; | 1900 | break; |
@@ -1678,6 +1924,7 @@ void LLScriptCollisionEndEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRI | |||
1678 | break; | 1924 | break; |
1679 | break; | 1925 | break; |
1680 | case LSCP_SCOPE_PASS1: | 1926 | case LSCP_SCOPE_PASS1: |
1927 | checkForDuplicateHandler(fp, this, scope, "collision_end"); | ||
1681 | if (scope->checkEntry(mCount->mName)) | 1928 | if (scope->checkEntry(mCount->mName)) |
1682 | { | 1929 | { |
1683 | gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME); | 1930 | gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME); |
@@ -1702,11 +1949,17 @@ void LLScriptCollisionEndEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRI | |||
1702 | { | 1949 | { |
1703 | #ifdef LSL_INCLUDE_DEBUG_INFO | 1950 | #ifdef LSL_INCLUDE_DEBUG_INFO |
1704 | char name[] = "collision_end"; | 1951 | char name[] = "collision_end"; |
1705 | chunk->addBytes(name, strlen(name) + 1); /*Flawfinder: ignore*/ | 1952 | chunk->addBytes(name, strlen(name) + 1); |
1706 | chunk->addBytes(mCount->mName, strlen(mCount->mName) + 1); /*Flawfinder: ignore*/ | 1953 | chunk->addBytes(mCount->mName, strlen(mCount->mName) + 1); |
1707 | #endif | 1954 | #endif |
1708 | } | 1955 | } |
1709 | break; | 1956 | break; |
1957 | case LSCP_EMIT_CIL_ASSEMBLY: | ||
1958 | fdotabs(fp, tabs, tabsize); | ||
1959 | fprintf(fp, "collision_end( int32 "); | ||
1960 | mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
1961 | fprintf(fp, " )"); | ||
1962 | break; | ||
1710 | default: | 1963 | default: |
1711 | mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 1964 | mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
1712 | break; | 1965 | break; |
@@ -1735,6 +1988,7 @@ void LLScriptLandCollisionStartEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, | |||
1735 | fprintf(fp, " )\n"); | 1988 | fprintf(fp, " )\n"); |
1736 | break; | 1989 | break; |
1737 | case LSCP_SCOPE_PASS1: | 1990 | case LSCP_SCOPE_PASS1: |
1991 | checkForDuplicateHandler(fp, this, scope, "land_collision_start"); | ||
1738 | if (scope->checkEntry(mPosition->mName)) | 1992 | if (scope->checkEntry(mPosition->mName)) |
1739 | { | 1993 | { |
1740 | gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME); | 1994 | gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME); |
@@ -1759,11 +2013,17 @@ void LLScriptLandCollisionStartEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, | |||
1759 | { | 2013 | { |
1760 | #ifdef LSL_INCLUDE_DEBUG_INFO | 2014 | #ifdef LSL_INCLUDE_DEBUG_INFO |
1761 | char name[] = "land_collision_start"; | 2015 | char name[] = "land_collision_start"; |
1762 | chunk->addBytes(name, strlen(name) + 1); /*Flawfinder: ignore*/ | 2016 | chunk->addBytes(name, strlen(name) + 1); |
1763 | chunk->addBytes(mPosition->mName, strlen(mPosition->mName) + 1); /*Flawfinder: ignore*/ | 2017 | chunk->addBytes(mPosition->mName, strlen(mPosition->mName) + 1); |
1764 | #endif | 2018 | #endif |
1765 | } | 2019 | } |
1766 | break; | 2020 | break; |
2021 | case LSCP_EMIT_CIL_ASSEMBLY: | ||
2022 | fdotabs(fp, tabs, tabsize); | ||
2023 | fprintf(fp, "land_collision_start( class [ScriptTypes]LindenLab.SecondLife.Vector "); | ||
2024 | mPosition->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
2025 | fprintf(fp, " )"); | ||
2026 | break; | ||
1767 | default: | 2027 | default: |
1768 | mPosition->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 2028 | mPosition->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
1769 | break; | 2029 | break; |
@@ -1794,6 +2054,7 @@ void LLScriptLandCollisionEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCR | |||
1794 | fprintf(fp, " )\n"); | 2054 | fprintf(fp, " )\n"); |
1795 | break; | 2055 | break; |
1796 | case LSCP_SCOPE_PASS1: | 2056 | case LSCP_SCOPE_PASS1: |
2057 | checkForDuplicateHandler(fp, this, scope, "land_collision"); | ||
1797 | if (scope->checkEntry(mPosition->mName)) | 2058 | if (scope->checkEntry(mPosition->mName)) |
1798 | { | 2059 | { |
1799 | gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME); | 2060 | gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME); |
@@ -1818,11 +2079,17 @@ void LLScriptLandCollisionEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCR | |||
1818 | { | 2079 | { |
1819 | #ifdef LSL_INCLUDE_DEBUG_INFO | 2080 | #ifdef LSL_INCLUDE_DEBUG_INFO |
1820 | char name[] = "land_collision"; | 2081 | char name[] = "land_collision"; |
1821 | chunk->addBytes(name, strlen(name) + 1); /*Flawfinder: ignore*/ | 2082 | chunk->addBytes(name, strlen(name) + 1); |
1822 | chunk->addBytes(mPosition->mName, strlen(mPosition->mName) + 1); /*Flawfinder: ignore*/ | 2083 | chunk->addBytes(mPosition->mName, strlen(mPosition->mName) + 1); |
1823 | #endif | 2084 | #endif |
1824 | } | 2085 | } |
1825 | break; | 2086 | break; |
2087 | case LSCP_EMIT_CIL_ASSEMBLY: | ||
2088 | fdotabs(fp, tabs, tabsize); | ||
2089 | fprintf(fp, "land_collision( class [ScriptTypes]LindenLab.SecondLife.Vector "); | ||
2090 | mPosition->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
2091 | fprintf(fp, " )"); | ||
2092 | break; | ||
1826 | default: | 2093 | default: |
1827 | mPosition->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 2094 | mPosition->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
1828 | break; | 2095 | break; |
@@ -1852,6 +2119,7 @@ void LLScriptLandCollisionEndEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, L | |||
1852 | fprintf(fp, " )\n"); | 2119 | fprintf(fp, " )\n"); |
1853 | break; | 2120 | break; |
1854 | case LSCP_SCOPE_PASS1: | 2121 | case LSCP_SCOPE_PASS1: |
2122 | checkForDuplicateHandler(fp, this, scope, "land_collision_end"); | ||
1855 | if (scope->checkEntry(mPosition->mName)) | 2123 | if (scope->checkEntry(mPosition->mName)) |
1856 | { | 2124 | { |
1857 | gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME); | 2125 | gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME); |
@@ -1875,12 +2143,18 @@ void LLScriptLandCollisionEndEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, L | |||
1875 | case LSCP_EMIT_BYTE_CODE: | 2143 | case LSCP_EMIT_BYTE_CODE: |
1876 | { | 2144 | { |
1877 | #ifdef LSL_INCLUDE_DEBUG_INFO | 2145 | #ifdef LSL_INCLUDE_DEBUG_INFO |
1878 | char name[] = "land_collision_end"; /*Flawfinder: ignore*/ | 2146 | char name[] = "land_collision_end"; |
1879 | chunk->addBytes(name, strlen(name) + 1); /*Flawfinder: ignore*/ | 2147 | chunk->addBytes(name, strlen(name) + 1); |
1880 | chunk->addBytes(mPosition->mName, strlen(mPosition->mName) + 1); /*Flawfinder: ignore*/ | 2148 | chunk->addBytes(mPosition->mName, strlen(mPosition->mName) + 1); |
1881 | #endif | 2149 | #endif |
1882 | } | 2150 | } |
1883 | break; | 2151 | break; |
2152 | case LSCP_EMIT_CIL_ASSEMBLY: | ||
2153 | fdotabs(fp, tabs, tabsize); | ||
2154 | fprintf(fp, "land_collision_end( class [ScriptTypes]LindenLab.SecondLife.Vector "); | ||
2155 | mPosition->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
2156 | fprintf(fp, " )"); | ||
2157 | break; | ||
1884 | default: | 2158 | default: |
1885 | mPosition->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 2159 | mPosition->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
1886 | break; | 2160 | break; |
@@ -1910,6 +2184,7 @@ void LLScriptInventoryEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTC | |||
1910 | fprintf(fp, " )\n"); | 2184 | fprintf(fp, " )\n"); |
1911 | break; | 2185 | break; |
1912 | case LSCP_SCOPE_PASS1: | 2186 | case LSCP_SCOPE_PASS1: |
2187 | checkForDuplicateHandler(fp, this, scope, "changed"); | ||
1913 | if (scope->checkEntry(mChange->mName)) | 2188 | if (scope->checkEntry(mChange->mName)) |
1914 | { | 2189 | { |
1915 | gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME); | 2190 | gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME); |
@@ -1934,11 +2209,17 @@ void LLScriptInventoryEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTC | |||
1934 | { | 2209 | { |
1935 | #ifdef LSL_INCLUDE_DEBUG_INFO | 2210 | #ifdef LSL_INCLUDE_DEBUG_INFO |
1936 | char name[] = "changed"; | 2211 | char name[] = "changed"; |
1937 | chunk->addBytes(name, strlen(name) + 1); /*Flawfinder: ignore*/ | 2212 | chunk->addBytes(name, strlen(name) + 1); |
1938 | chunk->addBytes(mChange->mName, strlen(mChange->mName) + 1); /*Flawfinder: ignore*/ | 2213 | chunk->addBytes(mChange->mName, strlen(mChange->mName) + 1); |
1939 | #endif | 2214 | #endif |
1940 | } | 2215 | } |
1941 | break; | 2216 | break; |
2217 | case LSCP_EMIT_CIL_ASSEMBLY: | ||
2218 | fdotabs(fp, tabs, tabsize); | ||
2219 | fprintf(fp, "changed( int32 "); | ||
2220 | mChange->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
2221 | fprintf(fp, " )"); | ||
2222 | break; | ||
1942 | default: | 2223 | default: |
1943 | mChange->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 2224 | mChange->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
1944 | break; | 2225 | break; |
@@ -1967,6 +2248,7 @@ void LLScriptAttachEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTComp | |||
1967 | fprintf(fp, " )\n"); | 2248 | fprintf(fp, " )\n"); |
1968 | break; | 2249 | break; |
1969 | case LSCP_SCOPE_PASS1: | 2250 | case LSCP_SCOPE_PASS1: |
2251 | checkForDuplicateHandler(fp, this, scope, "attach"); | ||
1970 | if (scope->checkEntry(mAttach->mName)) | 2252 | if (scope->checkEntry(mAttach->mName)) |
1971 | { | 2253 | { |
1972 | gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME); | 2254 | gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME); |
@@ -1991,11 +2273,17 @@ void LLScriptAttachEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTComp | |||
1991 | { | 2273 | { |
1992 | #ifdef LSL_INCLUDE_DEBUG_INFO | 2274 | #ifdef LSL_INCLUDE_DEBUG_INFO |
1993 | char name[] = "attach"; | 2275 | char name[] = "attach"; |
1994 | chunk->addBytes(name, strlen(name) + 1); /*Flawfinder: ignore*/ | 2276 | chunk->addBytes(name, strlen(name) + 1); |
1995 | chunk->addBytes(mAttach->mName, strlen(mAttach->mName) + 1); /*Flawfinder: ignore*/ | 2277 | chunk->addBytes(mAttach->mName, strlen(mAttach->mName) + 1); |
1996 | #endif | 2278 | #endif |
1997 | } | 2279 | } |
1998 | break; | 2280 | break; |
2281 | case LSCP_EMIT_CIL_ASSEMBLY: | ||
2282 | fdotabs(fp, tabs, tabsize); | ||
2283 | fprintf(fp, "attach( valuetype [ScriptTypes]LindenLab.SecondLife.Key "); | ||
2284 | mAttach->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
2285 | fprintf(fp, " )\n"); | ||
2286 | break; | ||
1999 | default: | 2287 | default: |
2000 | mAttach->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 2288 | mAttach->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
2001 | break; | 2289 | break; |
@@ -2026,6 +2314,7 @@ void LLScriptDataserverEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPT | |||
2026 | fprintf(fp, " )\n"); | 2314 | fprintf(fp, " )\n"); |
2027 | break; | 2315 | break; |
2028 | case LSCP_SCOPE_PASS1: | 2316 | case LSCP_SCOPE_PASS1: |
2317 | checkForDuplicateHandler(fp, this, scope, "dataserver"); | ||
2029 | if (scope->checkEntry(mID->mName)) | 2318 | if (scope->checkEntry(mID->mName)) |
2030 | { | 2319 | { |
2031 | gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME); | 2320 | gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME); |
@@ -2061,12 +2350,20 @@ void LLScriptDataserverEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPT | |||
2061 | { | 2350 | { |
2062 | #ifdef LSL_INCLUDE_DEBUG_INFO | 2351 | #ifdef LSL_INCLUDE_DEBUG_INFO |
2063 | char name[] = "dataserver"; | 2352 | char name[] = "dataserver"; |
2064 | chunk->addBytes(name, strlen(name) + 1); /*Flawfinder: ignore*/ | 2353 | chunk->addBytes(name, strlen(name) + 1); |
2065 | chunk->addBytes(mID->mName, strlen(mID->mName) + 1); /*Flawfinder: ignore*/ | 2354 | chunk->addBytes(mID->mName, strlen(mID->mName) + 1); |
2066 | chunk->addBytes(mData->mName, strlen(mData->mName) + 1); /*Flawfinder: ignore*/ | 2355 | chunk->addBytes(mData->mName, strlen(mData->mName) + 1); |
2067 | #endif | 2356 | #endif |
2068 | } | 2357 | } |
2069 | break; | 2358 | break; |
2359 | case LSCP_EMIT_CIL_ASSEMBLY: | ||
2360 | fdotabs(fp, tabs, tabsize); | ||
2361 | fprintf(fp, "dataserver( valuetype [ScriptTypes]LindenLab.SecondLife.Key "); | ||
2362 | mID->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
2363 | fprintf(fp, ", string "); | ||
2364 | mData->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
2365 | fprintf(fp, " )"); | ||
2366 | break; | ||
2070 | default: | 2367 | default: |
2071 | mID->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 2368 | mID->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
2072 | mData->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 2369 | mData->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
@@ -2095,14 +2392,21 @@ void LLScriptTimerEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompi | |||
2095 | case LSCP_EMIT_ASSEMBLY: | 2392 | case LSCP_EMIT_ASSEMBLY: |
2096 | fprintf(fp, "timer()\n"); | 2393 | fprintf(fp, "timer()\n"); |
2097 | break; | 2394 | break; |
2395 | case LSCP_SCOPE_PASS1: | ||
2396 | checkForDuplicateHandler(fp, this, scope, "timer"); | ||
2397 | break; | ||
2398 | |||
2098 | case LSCP_EMIT_BYTE_CODE: | 2399 | case LSCP_EMIT_BYTE_CODE: |
2099 | { | 2400 | { |
2100 | #ifdef LSL_INCLUDE_DEBUG_INFO | 2401 | #ifdef LSL_INCLUDE_DEBUG_INFO |
2101 | char name[] = "timer"; | 2402 | char name[] = "timer"; |
2102 | chunk->addBytes(name, strlen(name) + 1); /*Flawfinder: ignore*/ | 2403 | chunk->addBytes(name, strlen(name) + 1); |
2103 | #endif | 2404 | #endif |
2104 | } | 2405 | } |
2105 | break; | 2406 | break; |
2407 | case LSCP_EMIT_CIL_ASSEMBLY: | ||
2408 | fprintf(fp, "timer()"); | ||
2409 | break; | ||
2106 | default: | 2410 | default: |
2107 | break; | 2411 | break; |
2108 | } | 2412 | } |
@@ -2126,14 +2430,21 @@ void LLScriptMovingStartEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIP | |||
2126 | fdotabs(fp, tabs, tabsize); | 2430 | fdotabs(fp, tabs, tabsize); |
2127 | fprintf(fp, "moving_start()\n"); | 2431 | fprintf(fp, "moving_start()\n"); |
2128 | break; | 2432 | break; |
2433 | case LSCP_SCOPE_PASS1: | ||
2434 | checkForDuplicateHandler(fp, this, scope, "moving_start"); | ||
2435 | break; | ||
2436 | |||
2129 | case LSCP_EMIT_BYTE_CODE: | 2437 | case LSCP_EMIT_BYTE_CODE: |
2130 | { | 2438 | { |
2131 | #ifdef LSL_INCLUDE_DEBUG_INFO | 2439 | #ifdef LSL_INCLUDE_DEBUG_INFO |
2132 | char name[] = "moving_start"; | 2440 | char name[] = "moving_start"; |
2133 | chunk->addBytes(name, strlen(name) + 1); /*Flawfinder: ignore*/ | 2441 | chunk->addBytes(name, strlen(name) + 1); |
2134 | #endif | 2442 | #endif |
2135 | } | 2443 | } |
2136 | break; | 2444 | break; |
2445 | case LSCP_EMIT_CIL_ASSEMBLY: | ||
2446 | fprintf(fp, "moving_start()"); | ||
2447 | break; | ||
2137 | default: | 2448 | default: |
2138 | break; | 2449 | break; |
2139 | } | 2450 | } |
@@ -2157,14 +2468,21 @@ void LLScriptMovingEndEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTC | |||
2157 | fdotabs(fp, tabs, tabsize); | 2468 | fdotabs(fp, tabs, tabsize); |
2158 | fprintf(fp, "moving_end()\n"); | 2469 | fprintf(fp, "moving_end()\n"); |
2159 | break; | 2470 | break; |
2471 | case LSCP_SCOPE_PASS1: | ||
2472 | checkForDuplicateHandler(fp, this, scope, "moving_end"); | ||
2473 | break; | ||
2474 | |||
2160 | case LSCP_EMIT_BYTE_CODE: | 2475 | case LSCP_EMIT_BYTE_CODE: |
2161 | { | 2476 | { |
2162 | #ifdef LSL_INCLUDE_DEBUG_INFO | 2477 | #ifdef LSL_INCLUDE_DEBUG_INFO |
2163 | char name[] = "moving_end"; | 2478 | char name[] = "moving_end"; |
2164 | chunk->addBytes(name, strlen(name) + 1); /*Flawfinder: ignore*/ | 2479 | chunk->addBytes(name, strlen(name) + 1); |
2165 | #endif | 2480 | #endif |
2166 | } | 2481 | } |
2167 | break; | 2482 | break; |
2483 | case LSCP_EMIT_CIL_ASSEMBLY: | ||
2484 | fprintf(fp, "moving_end()"); | ||
2485 | break; | ||
2168 | default: | 2486 | default: |
2169 | break; | 2487 | break; |
2170 | } | 2488 | } |
@@ -2191,6 +2509,7 @@ void LLScriptRTPEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompile | |||
2191 | fprintf(fp, " )\n"); | 2509 | fprintf(fp, " )\n"); |
2192 | break; | 2510 | break; |
2193 | case LSCP_SCOPE_PASS1: | 2511 | case LSCP_SCOPE_PASS1: |
2512 | checkForDuplicateHandler(fp, this, scope, "run_time_perms"); | ||
2194 | if (scope->checkEntry(mRTPermissions->mName)) | 2513 | if (scope->checkEntry(mRTPermissions->mName)) |
2195 | { | 2514 | { |
2196 | gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME); | 2515 | gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME); |
@@ -2215,11 +2534,18 @@ void LLScriptRTPEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompile | |||
2215 | { | 2534 | { |
2216 | #ifdef LSL_INCLUDE_DEBUG_INFO | 2535 | #ifdef LSL_INCLUDE_DEBUG_INFO |
2217 | char name[] = "chat"; | 2536 | char name[] = "chat"; |
2218 | chunk->addBytes(name, strlen(name) + 1); /*Flawfinder: ignore*/ | 2537 | chunk->addBytes(name, strlen(name) + 1); |
2219 | chunk->addBytes(mRTPermissions->mName, strlen(mRTPermissions->mName) + 1); /*Flawfinder: ignore*/ | 2538 | chunk->addBytes(mRTPermissions->mName, strlen(mRTPermissions->mName) + 1); |
2220 | #endif | 2539 | #endif |
2221 | } | 2540 | } |
2222 | break; | 2541 | break; |
2542 | case LSCP_EMIT_CIL_ASSEMBLY: | ||
2543 | // NOTE: Not replicating LSL2 bug by calling RTP event hander "chat" | ||
2544 | fdotabs(fp, tabs, tabsize); | ||
2545 | fprintf(fp, "run_time_perms( int32 "); | ||
2546 | mRTPermissions->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
2547 | fprintf(fp, " )"); | ||
2548 | break; | ||
2223 | default: | 2549 | default: |
2224 | mRTPermissions->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 2550 | mRTPermissions->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
2225 | break; | 2551 | break; |
@@ -2254,6 +2580,7 @@ void LLScriptChatEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompil | |||
2254 | fprintf(fp, " )\n"); | 2580 | fprintf(fp, " )\n"); |
2255 | break; | 2581 | break; |
2256 | case LSCP_SCOPE_PASS1: | 2582 | case LSCP_SCOPE_PASS1: |
2583 | checkForDuplicateHandler(fp, this, scope, "listen"); // note: this is actually listen in lsl source | ||
2257 | if (scope->checkEntry(mChannel->mName)) | 2584 | if (scope->checkEntry(mChannel->mName)) |
2258 | { | 2585 | { |
2259 | gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME); | 2586 | gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME); |
@@ -2311,14 +2638,26 @@ void LLScriptChatEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompil | |||
2311 | { | 2638 | { |
2312 | #ifdef LSL_INCLUDE_DEBUG_INFO | 2639 | #ifdef LSL_INCLUDE_DEBUG_INFO |
2313 | char name[] = "chat"; | 2640 | char name[] = "chat"; |
2314 | chunk->addBytes(name, strlen(name) + 1); /*Flawfinder: ignore*/ | 2641 | chunk->addBytes(name, strlen(name) + 1); |
2315 | chunk->addBytes(mChannel->mName, strlen(mChannel->mName) + 1); /*Flawfinder: ignore*/ | 2642 | chunk->addBytes(mChannel->mName, strlen(mChannel->mName) + 1); |
2316 | chunk->addBytes(mName->mName, strlen(mName->mName) + 1); /*Flawfinder: ignore*/ | 2643 | chunk->addBytes(mName->mName, strlen(mName->mName) + 1); |
2317 | chunk->addBytes(mID->mName, strlen(mID->mName) + 1); /*Flawfinder: ignore*/ | 2644 | chunk->addBytes(mID->mName, strlen(mID->mName) + 1); |
2318 | chunk->addBytes(mMessage->mName, strlen(mMessage->mName) + 1); /*Flawfinder: ignore*/ | 2645 | chunk->addBytes(mMessage->mName, strlen(mMessage->mName) + 1); |
2319 | #endif | 2646 | #endif |
2320 | } | 2647 | } |
2321 | break; | 2648 | break; |
2649 | case LSCP_EMIT_CIL_ASSEMBLY: | ||
2650 | fdotabs(fp, tabs, tabsize); | ||
2651 | fprintf(fp, "chat( int32 "); | ||
2652 | mChannel->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
2653 | fprintf(fp, ", string "); | ||
2654 | mName->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
2655 | fprintf(fp, ", valuetype [ScriptTypes]LindenLab.SecondLife.Key "); | ||
2656 | mID->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
2657 | fprintf(fp, ", string "); | ||
2658 | mMessage->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
2659 | fprintf(fp, " )"); | ||
2660 | break; | ||
2322 | default: | 2661 | default: |
2323 | mChannel->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 2662 | mChannel->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
2324 | mName->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 2663 | mName->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
@@ -2350,6 +2689,7 @@ void LLScriptSensorEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTComp | |||
2350 | fprintf(fp, " )\n"); | 2689 | fprintf(fp, " )\n"); |
2351 | break; | 2690 | break; |
2352 | case LSCP_SCOPE_PASS1: | 2691 | case LSCP_SCOPE_PASS1: |
2692 | checkForDuplicateHandler(fp, this, scope, "sensor"); | ||
2353 | if (scope->checkEntry(mNumber->mName)) | 2693 | if (scope->checkEntry(mNumber->mName)) |
2354 | { | 2694 | { |
2355 | gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME); | 2695 | gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME); |
@@ -2374,11 +2714,17 @@ void LLScriptSensorEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTComp | |||
2374 | { | 2714 | { |
2375 | #ifdef LSL_INCLUDE_DEBUG_INFO | 2715 | #ifdef LSL_INCLUDE_DEBUG_INFO |
2376 | char name[] = "sensor"; | 2716 | char name[] = "sensor"; |
2377 | chunk->addBytes(name, strlen(name) + 1); /*Flawfinder: ignore*/ | 2717 | chunk->addBytes(name, strlen(name) + 1); |
2378 | chunk->addBytes(mNumber->mName, strlen(mNumber->mName) + 1); /*Flawfinder: ignore*/ | 2718 | chunk->addBytes(mNumber->mName, strlen(mNumber->mName) + 1); |
2379 | #endif | 2719 | #endif |
2380 | } | 2720 | } |
2381 | break; | 2721 | break; |
2722 | case LSCP_EMIT_CIL_ASSEMBLY: | ||
2723 | fdotabs(fp, tabs, tabsize); | ||
2724 | fprintf(fp, "sensor( int32 "); | ||
2725 | mNumber->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
2726 | fprintf(fp, " )"); | ||
2727 | break; | ||
2382 | default: | 2728 | default: |
2383 | mNumber->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 2729 | mNumber->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
2384 | break; | 2730 | break; |
@@ -2407,6 +2753,7 @@ void LLScriptObjectRezEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTC | |||
2407 | fprintf(fp, " )\n"); | 2753 | fprintf(fp, " )\n"); |
2408 | break; | 2754 | break; |
2409 | case LSCP_SCOPE_PASS1: | 2755 | case LSCP_SCOPE_PASS1: |
2756 | checkForDuplicateHandler(fp, this, scope, "object_rez"); | ||
2410 | if (scope->checkEntry(mID->mName)) | 2757 | if (scope->checkEntry(mID->mName)) |
2411 | { | 2758 | { |
2412 | gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME); | 2759 | gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME); |
@@ -2431,11 +2778,17 @@ void LLScriptObjectRezEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTC | |||
2431 | { | 2778 | { |
2432 | #ifdef LSL_INCLUDE_DEBUG_INFO | 2779 | #ifdef LSL_INCLUDE_DEBUG_INFO |
2433 | char name[] = "sensor"; | 2780 | char name[] = "sensor"; |
2434 | chunk->addBytes(name, strlen(name) + 1); /*Flawfinder: ignore*/ | 2781 | chunk->addBytes(name, strlen(name) + 1); |
2435 | chunk->addBytes(mID->mName, strlen(mID->mName) + 1); /*Flawfinder: ignore*/ | 2782 | chunk->addBytes(mID->mName, strlen(mID->mName) + 1); |
2436 | #endif | 2783 | #endif |
2437 | } | 2784 | } |
2438 | break; | 2785 | break; |
2786 | case LSCP_EMIT_CIL_ASSEMBLY: | ||
2787 | fdotabs(fp, tabs, tabsize); | ||
2788 | fprintf(fp, "object_rez( valuetype [ScriptTypes]LindenLab.SecondLife.Key "); | ||
2789 | mID->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
2790 | fprintf(fp, " )"); | ||
2791 | break; | ||
2439 | default: | 2792 | default: |
2440 | mID->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 2793 | mID->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
2441 | break; | 2794 | break; |
@@ -2468,6 +2821,7 @@ void LLScriptControlEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCom | |||
2468 | fprintf(fp, " )\n"); | 2821 | fprintf(fp, " )\n"); |
2469 | break; | 2822 | break; |
2470 | case LSCP_SCOPE_PASS1: | 2823 | case LSCP_SCOPE_PASS1: |
2824 | checkForDuplicateHandler(fp, this, scope, "control"); | ||
2471 | if (scope->checkEntry(mName->mName)) | 2825 | if (scope->checkEntry(mName->mName)) |
2472 | { | 2826 | { |
2473 | gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME); | 2827 | gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME); |
@@ -2514,13 +2868,23 @@ void LLScriptControlEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCom | |||
2514 | { | 2868 | { |
2515 | #ifdef LSL_INCLUDE_DEBUG_INFO | 2869 | #ifdef LSL_INCLUDE_DEBUG_INFO |
2516 | char name[] = "control"; | 2870 | char name[] = "control"; |
2517 | chunk->addBytes(name, strlen(name) + 1); /*Flawfinder: ignore*/ | 2871 | chunk->addBytes(name, strlen(name) + 1); |
2518 | chunk->addBytes(mName->mName, strlen(mName->mName) + 1); /*Flawfinder: ignore*/ | 2872 | chunk->addBytes(mName->mName, strlen(mName->mName) + 1); |
2519 | chunk->addBytes(mLevels->mName, strlen(mLevels->mName) + 1); /*Flawfinder: ignore*/ | 2873 | chunk->addBytes(mLevels->mName, strlen(mLevels->mName) + 1); |
2520 | chunk->addBytes(mEdges->mName, strlen(mEdges->mName) + 1); /*Flawfinder: ignore*/ | 2874 | chunk->addBytes(mEdges->mName, strlen(mEdges->mName) + 1); |
2521 | #endif | 2875 | #endif |
2522 | } | 2876 | } |
2523 | break; | 2877 | break; |
2878 | case LSCP_EMIT_CIL_ASSEMBLY: | ||
2879 | fdotabs(fp, tabs, tabsize); | ||
2880 | fprintf(fp, "control( valuetype [ScriptTypes]LindenLab.SecondLife.Key "); | ||
2881 | mName->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
2882 | fprintf(fp, ", int32 "); | ||
2883 | mLevels->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
2884 | fprintf(fp, ", int32 "); | ||
2885 | mEdges->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
2886 | fprintf(fp, " )"); | ||
2887 | break; | ||
2524 | default: | 2888 | default: |
2525 | mName->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 2889 | mName->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
2526 | mLevels->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 2890 | mLevels->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
@@ -2557,6 +2921,7 @@ void LLScriptLinkMessageEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIP | |||
2557 | fprintf(fp, " )\n"); | 2921 | fprintf(fp, " )\n"); |
2558 | break; | 2922 | break; |
2559 | case LSCP_SCOPE_PASS1: | 2923 | case LSCP_SCOPE_PASS1: |
2924 | checkForDuplicateHandler(fp, this, scope, "link_message"); | ||
2560 | if (scope->checkEntry(mSender->mName)) | 2925 | if (scope->checkEntry(mSender->mName)) |
2561 | { | 2926 | { |
2562 | gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME); | 2927 | gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME); |
@@ -2614,14 +2979,26 @@ void LLScriptLinkMessageEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIP | |||
2614 | { | 2979 | { |
2615 | #ifdef LSL_INCLUDE_DEBUG_INFO | 2980 | #ifdef LSL_INCLUDE_DEBUG_INFO |
2616 | char name[] = "link_message"; | 2981 | char name[] = "link_message"; |
2617 | chunk->addBytes(name, strlen(name) + 1); /*Flawfinder: ignore*/ | 2982 | chunk->addBytes(name, strlen(name) + 1); |
2618 | chunk->addBytes(mSender->mName, strlen(mSender->mName) + 1); /*Flawfinder: ignore*/ | 2983 | chunk->addBytes(mSender->mName, strlen(mSender->mName) + 1); |
2619 | chunk->addBytes(mNum->mName, strlen(mNum->mName) + 1); /*Flawfinder: ignore*/ | 2984 | chunk->addBytes(mNum->mName, strlen(mNum->mName) + 1); |
2620 | chunk->addBytes(mStr->mName, strlen(mStr->mName) + 1); /*Flawfinder: ignore*/ | 2985 | chunk->addBytes(mStr->mName, strlen(mStr->mName) + 1); |
2621 | chunk->addBytes(mID->mName, strlen(mID->mName) + 1); /*Flawfinder: ignore*/ | 2986 | chunk->addBytes(mID->mName, strlen(mID->mName) + 1); |
2622 | #endif | 2987 | #endif |
2623 | } | 2988 | } |
2624 | break; | 2989 | break; |
2990 | case LSCP_EMIT_CIL_ASSEMBLY: | ||
2991 | fdotabs(fp, tabs, tabsize); | ||
2992 | fprintf(fp, "link_message( int32 "); | ||
2993 | mSender->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
2994 | fprintf(fp, ", int32 "); | ||
2995 | mNum->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
2996 | fprintf(fp, ", string "); | ||
2997 | mStr->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
2998 | fprintf(fp, ", valuetype [ScriptTypes]LindenLab.SecondLife.Key "); | ||
2999 | mID->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
3000 | fprintf(fp, " )"); | ||
3001 | break; | ||
2625 | default: | 3002 | default: |
2626 | mSender->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 3003 | mSender->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
2627 | mNum->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 3004 | mNum->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
@@ -2663,6 +3040,7 @@ void LLScriptRemoteEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTComp | |||
2663 | fprintf(fp, " )\n"); | 3040 | fprintf(fp, " )\n"); |
2664 | break; | 3041 | break; |
2665 | case LSCP_SCOPE_PASS1: | 3042 | case LSCP_SCOPE_PASS1: |
3043 | checkForDuplicateHandler(fp, this, scope, "remote_event"); | ||
2666 | if (scope->checkEntry(mType->mName)) | 3044 | if (scope->checkEntry(mType->mName)) |
2667 | { | 3045 | { |
2668 | gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME); | 3046 | gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME); |
@@ -2742,16 +3120,32 @@ void LLScriptRemoteEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTComp | |||
2742 | { | 3120 | { |
2743 | #ifdef LSL_INCLUDE_DEBUG_INFO | 3121 | #ifdef LSL_INCLUDE_DEBUG_INFO |
2744 | char name[] = "remote_event"; | 3122 | char name[] = "remote_event"; |
2745 | chunk->addBytes(name, strlen(name) + 1); /*Flawfinder: ignore*/ | 3123 | chunk->addBytes(name, strlen(name) + 1); |
2746 | chunk->addBytes(mType->mName, strlen(mType->mName) + 1); /*Flawfinder: ignore*/ | 3124 | chunk->addBytes(mType->mName, strlen(mType->mName) + 1); |
2747 | chunk->addBytes(mChannel->mName, strlen(mChannel->mName) + 1); /*Flawfinder: ignore*/ | 3125 | chunk->addBytes(mChannel->mName, strlen(mChannel->mName) + 1); |
2748 | chunk->addBytes(mMessageID->mName, strlen(mMessageID->mName) + 1); /*Flawfinder: ignore*/ | 3126 | chunk->addBytes(mMessageID->mName, strlen(mMessageID->mName) + 1); |
2749 | chunk->addBytes(mSender->mName, strlen(mSender->mName) + 1); /*Flawfinder: ignore*/ | 3127 | chunk->addBytes(mSender->mName, strlen(mSender->mName) + 1); |
2750 | chunk->addBytes(mIntVal->mName, strlen(mIntVal->mName) + 1); /*Flawfinder: ignore*/ | 3128 | chunk->addBytes(mIntVal->mName, strlen(mIntVal->mName) + 1); |
2751 | chunk->addBytes(mStrVal->mName, strlen(mStrVal->mName) + 1); /*Flawfinder: ignore*/ | 3129 | chunk->addBytes(mStrVal->mName, strlen(mStrVal->mName) + 1); |
2752 | #endif | 3130 | #endif |
2753 | } | 3131 | } |
2754 | break; | 3132 | break; |
3133 | case LSCP_EMIT_CIL_ASSEMBLY: | ||
3134 | fdotabs(fp, tabs, tabsize); | ||
3135 | fprintf(fp, "remote_event( int32 "); | ||
3136 | mType->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
3137 | fprintf(fp, ", valuetype [ScriptTypes]LindenLab.SecondLife.Key "); | ||
3138 | mChannel->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
3139 | fprintf(fp, ", valuetype [ScriptTypes]LindenLab.SecondLife.Key "); | ||
3140 | mMessageID->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
3141 | fprintf(fp, ", string "); | ||
3142 | mSender->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
3143 | fprintf(fp, ", int32 "); | ||
3144 | mIntVal->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
3145 | fprintf(fp, ", string "); | ||
3146 | mStrVal->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
3147 | fprintf(fp, " )"); | ||
3148 | break; | ||
2755 | default: | 3149 | default: |
2756 | mType->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 3150 | mType->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
2757 | mChannel->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 3151 | mChannel->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
@@ -2784,7 +3178,7 @@ void LLScriptHTTPResponseEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRI | |||
2784 | mRequestId->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 3178 | mRequestId->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
2785 | fprintf(fp, ", integer "); | 3179 | fprintf(fp, ", integer "); |
2786 | mStatus->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 3180 | mStatus->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
2787 | fprintf(fp, ", list "); | 3181 | fprintf(fp, ", class [mscorlib]System.Collections.ArrayList "); |
2788 | mMetadata->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 3182 | mMetadata->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
2789 | fprintf(fp, ", string "); | 3183 | fprintf(fp, ", string "); |
2790 | mBody->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 3184 | mBody->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
@@ -2792,6 +3186,7 @@ void LLScriptHTTPResponseEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRI | |||
2792 | break; | 3186 | break; |
2793 | 3187 | ||
2794 | case LSCP_SCOPE_PASS1: | 3188 | case LSCP_SCOPE_PASS1: |
3189 | checkForDuplicateHandler(fp, this, scope, "http_response"); | ||
2795 | if (scope->checkEntry(mRequestId->mName)) | 3190 | if (scope->checkEntry(mRequestId->mName)) |
2796 | { | 3191 | { |
2797 | gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME); | 3192 | gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME); |
@@ -2857,15 +3252,26 @@ void LLScriptHTTPResponseEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRI | |||
2857 | { | 3252 | { |
2858 | #ifdef LSL_INCLUDE_DEBUG_INFO | 3253 | #ifdef LSL_INCLUDE_DEBUG_INFO |
2859 | char name[] = "http_response"; | 3254 | char name[] = "http_response"; |
2860 | chunk->addBytes(name, strlen(name) + 1); /*Flawfinder: ignore*/ | 3255 | chunk->addBytes(name, strlen(name) + 1); |
2861 | chunk->addBytes(mRequestId->mName, strlen(mRequestId->mName) + 1); /*Flawfinder: ignore*/ | 3256 | chunk->addBytes(mRequestId->mName, strlen(mRequestId->mName) + 1); |
2862 | chunk->addBytes(mStatus->mName, strlen(mStatus->mName) + 1); /*Flawfinder: ignore*/ | 3257 | chunk->addBytes(mStatus->mName, strlen(mStatus->mName) + 1); |
2863 | chunk->addBytes(mMetadata->mName, strlen(mMetadata->mName) + 1); /*Flawfinder: ignore*/ | 3258 | chunk->addBytes(mMetadata->mName, strlen(mMetadata->mName) + 1); |
2864 | chunk->addBytes(mBody->mName, strlen(mBody->mName) + 1); /*Flawfinder: ignore*/ | 3259 | chunk->addBytes(mBody->mName, strlen(mBody->mName) + 1); |
2865 | #endif | 3260 | #endif |
2866 | } | 3261 | } |
2867 | break; | 3262 | break; |
2868 | 3263 | case LSCP_EMIT_CIL_ASSEMBLY: | |
3264 | fdotabs(fp, tabs, tabsize); | ||
3265 | fprintf(fp, "http_response( valuetype [ScriptTypes]LindenLab.SecondLife.Key "); | ||
3266 | mRequestId->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
3267 | fprintf(fp, ", int32 "); | ||
3268 | mStatus->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
3269 | fprintf(fp, ", class [mscorlib]System.Collections.ArrayList "); | ||
3270 | mMetadata->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
3271 | fprintf(fp, ", string "); | ||
3272 | mBody->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
3273 | fprintf(fp, " )\n"); | ||
3274 | break; | ||
2869 | default: | 3275 | default: |
2870 | mRequestId->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 3276 | mRequestId->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
2871 | mStatus->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 3277 | mStatus->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
@@ -2900,6 +3306,7 @@ void LLScriptMoneyEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompi | |||
2900 | fprintf(fp, " )\n"); | 3306 | fprintf(fp, " )\n"); |
2901 | break; | 3307 | break; |
2902 | case LSCP_SCOPE_PASS1: | 3308 | case LSCP_SCOPE_PASS1: |
3309 | checkForDuplicateHandler(fp, this, scope, "money"); | ||
2903 | if (scope->checkEntry(mName->mName)) | 3310 | if (scope->checkEntry(mName->mName)) |
2904 | { | 3311 | { |
2905 | gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME); | 3312 | gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME); |
@@ -2935,12 +3342,20 @@ void LLScriptMoneyEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompi | |||
2935 | { | 3342 | { |
2936 | #ifdef LSL_INCLUDE_DEBUG_INFO | 3343 | #ifdef LSL_INCLUDE_DEBUG_INFO |
2937 | char name[] = "money"; | 3344 | char name[] = "money"; |
2938 | chunk->addBytes(name, strlen(name) + 1); /*Flawfinder: ignore*/ | 3345 | chunk->addBytes(name, strlen(name) + 1); |
2939 | chunk->addBytes(mName->mName, strlen(mName->mName) + 1); /*Flawfinder: ignore*/ | 3346 | chunk->addBytes(mName->mName, strlen(mName->mName) + 1); |
2940 | chunk->addBytes(mAmount->mName, strlen(mAmount->mName) + 1); /*Flawfinder: ignore*/ | 3347 | chunk->addBytes(mAmount->mName, strlen(mAmount->mName) + 1); |
2941 | #endif | 3348 | #endif |
2942 | } | 3349 | } |
2943 | break; | 3350 | break; |
3351 | case LSCP_EMIT_CIL_ASSEMBLY: | ||
3352 | fdotabs(fp, tabs, tabsize); | ||
3353 | fprintf(fp, "money( valuetype [ScriptTypes]LindenLab.SecondLife.Key "); | ||
3354 | mName->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
3355 | fprintf(fp, ", int32 "); | ||
3356 | mAmount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
3357 | fprintf(fp, " )"); | ||
3358 | break; | ||
2944 | default: | 3359 | default: |
2945 | mName->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 3360 | mName->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
2946 | mAmount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 3361 | mAmount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
@@ -2978,6 +3393,7 @@ void LLScriptEmailEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompi | |||
2978 | fprintf(fp, " )\n"); | 3393 | fprintf(fp, " )\n"); |
2979 | break; | 3394 | break; |
2980 | case LSCP_SCOPE_PASS1: | 3395 | case LSCP_SCOPE_PASS1: |
3396 | checkForDuplicateHandler(fp, this, scope, "email"); | ||
2981 | if (scope->checkEntry(mTime->mName)) | 3397 | if (scope->checkEntry(mTime->mName)) |
2982 | { | 3398 | { |
2983 | gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME); | 3399 | gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME); |
@@ -3046,15 +3462,29 @@ void LLScriptEmailEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompi | |||
3046 | { | 3462 | { |
3047 | #ifdef LSL_INCLUDE_DEBUG_INFO | 3463 | #ifdef LSL_INCLUDE_DEBUG_INFO |
3048 | char name[] = "email"; | 3464 | char name[] = "email"; |
3049 | chunk->addBytes(name, strlen(name) + 1); /*Flawfinder: ignore*/ | 3465 | chunk->addBytes(name, strlen(name) + 1); |
3050 | chunk->addBytes(mTime->mName, strlen(mTime->mName) + 1); /*Flawfinder: ignore*/ | 3466 | chunk->addBytes(mTime->mName, strlen(mTime->mName) + 1); |
3051 | chunk->addBytes(mAddress->mName, strlen(mAddress->mName) + 1); /*Flawfinder: ignore*/ | 3467 | chunk->addBytes(mAddress->mName, strlen(mAddress->mName) + 1); |
3052 | chunk->addBytes(mSubject->mName, strlen(mSubject->mName) + 1); /*Flawfinder: ignore*/ | 3468 | chunk->addBytes(mSubject->mName, strlen(mSubject->mName) + 1); |
3053 | chunk->addBytes(mBody->mName, strlen(mBody->mName) + 1); /*Flawfinder: ignore*/ | 3469 | chunk->addBytes(mBody->mName, strlen(mBody->mName) + 1); |
3054 | chunk->addBytes(mNumber->mName, strlen(mNumber->mName) + 1); /*Flawfinder: ignore*/ | 3470 | chunk->addBytes(mNumber->mName, strlen(mNumber->mName) + 1); |
3055 | #endif | 3471 | #endif |
3056 | } | 3472 | } |
3057 | break; | 3473 | break; |
3474 | case LSCP_EMIT_CIL_ASSEMBLY: | ||
3475 | fdotabs(fp, tabs, tabsize); | ||
3476 | fprintf(fp, "email( string "); | ||
3477 | mTime->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
3478 | fprintf(fp, ", string "); | ||
3479 | mAddress->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
3480 | fprintf(fp, ", string "); | ||
3481 | mSubject->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
3482 | fprintf(fp, ", string "); | ||
3483 | mBody->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
3484 | fprintf(fp, ", int32 "); | ||
3485 | mNumber->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
3486 | fprintf(fp, " )"); | ||
3487 | break; | ||
3058 | default: | 3488 | default: |
3059 | mTime->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 3489 | mTime->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
3060 | mAddress->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 3490 | mAddress->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
@@ -3087,6 +3517,7 @@ void LLScriptRezEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompile | |||
3087 | fprintf(fp, " )\n"); | 3517 | fprintf(fp, " )\n"); |
3088 | break; | 3518 | break; |
3089 | case LSCP_SCOPE_PASS1: | 3519 | case LSCP_SCOPE_PASS1: |
3520 | checkForDuplicateHandler(fp, this, scope, "rez"); | ||
3090 | if (scope->checkEntry(mStartParam->mName)) | 3521 | if (scope->checkEntry(mStartParam->mName)) |
3091 | { | 3522 | { |
3092 | gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME); | 3523 | gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME); |
@@ -3111,11 +3542,17 @@ void LLScriptRezEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompile | |||
3111 | { | 3542 | { |
3112 | #ifdef LSL_INCLUDE_DEBUG_INFO | 3543 | #ifdef LSL_INCLUDE_DEBUG_INFO |
3113 | char name[] = "rez"; | 3544 | char name[] = "rez"; |
3114 | chunk->addBytes(name, strlen(name) + 1); /*Flawfinder: ignore*/ | 3545 | chunk->addBytes(name, strlen(name) + 1); |
3115 | chunk->addBytes(mStartParam->mName, strlen(mStartParam->mName) + 1); /*Flawfinder: ignore*/ | 3546 | chunk->addBytes(mStartParam->mName, strlen(mStartParam->mName) + 1); |
3116 | #endif | 3547 | #endif |
3117 | } | 3548 | } |
3118 | break; | 3549 | break; |
3550 | case LSCP_EMIT_CIL_ASSEMBLY: | ||
3551 | fdotabs(fp, tabs, tabsize); | ||
3552 | fprintf(fp, "rez( int32 "); | ||
3553 | mStartParam->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
3554 | fprintf(fp, " )"); | ||
3555 | break; | ||
3119 | default: | 3556 | default: |
3120 | mStartParam->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 3557 | mStartParam->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
3121 | break; | 3558 | break; |
@@ -3143,14 +3580,20 @@ void LLScriptNoSensorEvent::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCo | |||
3143 | case LSCP_EMIT_ASSEMBLY: | 3580 | case LSCP_EMIT_ASSEMBLY: |
3144 | fprintf(fp, "no_sensor()\n"); | 3581 | fprintf(fp, "no_sensor()\n"); |
3145 | break; | 3582 | break; |
3146 | case LSCP_EMIT_BYTE_CODE: | 3583 | case LSCP_SCOPE_PASS1: |
3584 | checkForDuplicateHandler(fp, this, scope, "no_sensor"); | ||
3585 | break; | ||
3586 | case LSCP_EMIT_BYTE_CODE: | ||
3147 | { | 3587 | { |
3148 | #ifdef LSL_INCLUDE_DEBUG_INFO | 3588 | #ifdef LSL_INCLUDE_DEBUG_INFO |
3149 | char name[] = "no_sensor"; | 3589 | char name[] = "no_sensor"; |
3150 | chunk->addBytes(name, strlen(name) + 1); /*Flawfinder: ignore*/ | 3590 | chunk->addBytes(name, strlen(name) + 1); |
3151 | #endif | 3591 | #endif |
3152 | } | 3592 | } |
3153 | break; | 3593 | break; |
3594 | case LSCP_EMIT_CIL_ASSEMBLY: | ||
3595 | fprintf(fp, "no_sensor()"); | ||
3596 | break; | ||
3154 | default: | 3597 | default: |
3155 | break; | 3598 | break; |
3156 | } | 3599 | } |
@@ -3181,6 +3624,7 @@ void LLScriptAtTarget::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompile | |||
3181 | fprintf(fp, " )\n"); | 3624 | fprintf(fp, " )\n"); |
3182 | break; | 3625 | break; |
3183 | case LSCP_SCOPE_PASS1: | 3626 | case LSCP_SCOPE_PASS1: |
3627 | checkForDuplicateHandler(fp, this, scope, "at_target"); | ||
3184 | if (scope->checkEntry(mTargetNumber->mName)) | 3628 | if (scope->checkEntry(mTargetNumber->mName)) |
3185 | { | 3629 | { |
3186 | gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME); | 3630 | gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME); |
@@ -3226,14 +3670,24 @@ void LLScriptAtTarget::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompile | |||
3226 | case LSCP_EMIT_BYTE_CODE: | 3670 | case LSCP_EMIT_BYTE_CODE: |
3227 | { | 3671 | { |
3228 | #ifdef LSL_INCLUDE_DEBUG_INFO | 3672 | #ifdef LSL_INCLUDE_DEBUG_INFO |
3229 | char name[] = "at_target"; /*Flawfinder: ignore*/ | 3673 | char name[] = "at_target"; |
3230 | chunk->addBytes(name, strlen(name) + 1); /*Flawfinder: ignore*/ | 3674 | chunk->addBytes(name, strlen(name) + 1); |
3231 | chunk->addBytes(mTargetNumber->mName, strlen(mTargetNumber->mName) + 1); /*Flawfinder: ignore*/ | 3675 | chunk->addBytes(mTargetNumber->mName, strlen(mTargetNumber->mName) + 1); |
3232 | chunk->addBytes(mTargetPosition->mName, strlen(mTargetPosition->mName) + 1); /*Flawfinder: ignore*/ | 3676 | chunk->addBytes(mTargetPosition->mName, strlen(mTargetPosition->mName) + 1); |
3233 | chunk->addBytes(mOurPosition->mName, strlen(mOurPosition->mName) + 1); /*Flawfinder: ignore*/ | 3677 | chunk->addBytes(mOurPosition->mName, strlen(mOurPosition->mName) + 1); |
3234 | #endif | 3678 | #endif |
3235 | } | 3679 | } |
3236 | break; | 3680 | break; |
3681 | case LSCP_EMIT_CIL_ASSEMBLY: | ||
3682 | fdotabs(fp, tabs, tabsize); | ||
3683 | fprintf(fp, "at_target( int32 "); | ||
3684 | mTargetNumber->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
3685 | fprintf(fp, ", class [ScriptTypes]LindenLab.SecondLife.Vector "); | ||
3686 | mTargetPosition->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
3687 | fprintf(fp, ", class [ScriptTypes]LindenLab.SecondLife.Vector "); | ||
3688 | mOurPosition->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
3689 | fprintf(fp, " )"); | ||
3690 | break; | ||
3237 | default: | 3691 | default: |
3238 | mTargetNumber->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 3692 | mTargetNumber->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
3239 | mTargetPosition->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 3693 | mTargetPosition->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
@@ -3265,14 +3719,21 @@ void LLScriptNotAtTarget::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTComp | |||
3265 | case LSCP_EMIT_ASSEMBLY: | 3719 | case LSCP_EMIT_ASSEMBLY: |
3266 | fprintf(fp, "not_at_target()\n"); | 3720 | fprintf(fp, "not_at_target()\n"); |
3267 | break; | 3721 | break; |
3722 | case LSCP_SCOPE_PASS1: | ||
3723 | checkForDuplicateHandler(fp, this, scope, "not_at_target"); | ||
3724 | break; | ||
3725 | |||
3268 | case LSCP_EMIT_BYTE_CODE: | 3726 | case LSCP_EMIT_BYTE_CODE: |
3269 | { | 3727 | { |
3270 | #ifdef LSL_INCLUDE_DEBUG_INFO | 3728 | #ifdef LSL_INCLUDE_DEBUG_INFO |
3271 | char name[] = "not_at_target"; /*Flawfinder: ignore*/ | 3729 | char name[] = "not_at_target"; |
3272 | chunk->addBytes(name, strlen(name) + 1); /*Flawfinder: ignore*/ | 3730 | chunk->addBytes(name, strlen(name) + 1); |
3273 | #endif | 3731 | #endif |
3274 | } | 3732 | } |
3275 | break; | 3733 | break; |
3734 | case LSCP_EMIT_CIL_ASSEMBLY: | ||
3735 | fprintf(fp, "not_at_target()"); | ||
3736 | break; | ||
3276 | default: | 3737 | default: |
3277 | break; | 3738 | break; |
3278 | } | 3739 | } |
@@ -3294,7 +3755,7 @@ void LLScriptAtRotTarget::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTComp | |||
3294 | case LSCP_PRETTY_PRINT: | 3755 | case LSCP_PRETTY_PRINT: |
3295 | case LSCP_EMIT_ASSEMBLY: | 3756 | case LSCP_EMIT_ASSEMBLY: |
3296 | fdotabs(fp, tabs, tabsize); | 3757 | fdotabs(fp, tabs, tabsize); |
3297 | fprintf(fp, "at_target( integer "); | 3758 | fprintf(fp, "at_rot_target( integer "); |
3298 | mTargetNumber->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 3759 | mTargetNumber->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
3299 | fprintf(fp, ", quaternion "); | 3760 | fprintf(fp, ", quaternion "); |
3300 | mTargetRotation->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 3761 | mTargetRotation->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
@@ -3303,6 +3764,7 @@ void LLScriptAtRotTarget::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTComp | |||
3303 | fprintf(fp, " )\n"); | 3764 | fprintf(fp, " )\n"); |
3304 | break; | 3765 | break; |
3305 | case LSCP_SCOPE_PASS1: | 3766 | case LSCP_SCOPE_PASS1: |
3767 | checkForDuplicateHandler(fp, this, scope, "at_rot_target"); | ||
3306 | if (scope->checkEntry(mTargetNumber->mName)) | 3768 | if (scope->checkEntry(mTargetNumber->mName)) |
3307 | { | 3769 | { |
3308 | gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME); | 3770 | gErrorToText.writeError(fp, this, LSERROR_DUPLICATE_NAME); |
@@ -3349,13 +3811,23 @@ void LLScriptAtRotTarget::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTComp | |||
3349 | { | 3811 | { |
3350 | #ifdef LSL_INCLUDE_DEBUG_INFO | 3812 | #ifdef LSL_INCLUDE_DEBUG_INFO |
3351 | char name[] = "at_rot_target"; | 3813 | char name[] = "at_rot_target"; |
3352 | chunk->addBytes(name, strlen(name) + 1); /*Flawfinder: ignore*/ | 3814 | chunk->addBytes(name, strlen(name) + 1); |
3353 | chunk->addBytes(mTargetNumber->mName, strlen(mTargetNumber->mName) + 1); /*Flawfinder: ignore*/ | 3815 | chunk->addBytes(mTargetNumber->mName, strlen(mTargetNumber->mName) + 1); |
3354 | chunk->addBytes(mTargetRotation->mName, strlen(mTargetRotation->mName) + 1); /*Flawfinder: ignore*/ | 3816 | chunk->addBytes(mTargetRotation->mName, strlen(mTargetRotation->mName) + 1); |
3355 | chunk->addBytes(mOurRotation->mName, strlen(mOurRotation->mName) + 1); /*Flawfinder: ignore*/ | 3817 | chunk->addBytes(mOurRotation->mName, strlen(mOurRotation->mName) + 1); |
3356 | #endif | 3818 | #endif |
3357 | } | 3819 | } |
3358 | break; | 3820 | break; |
3821 | case LSCP_EMIT_CIL_ASSEMBLY: | ||
3822 | fdotabs(fp, tabs, tabsize); | ||
3823 | fprintf(fp, "at_rot_target( int32 "); | ||
3824 | mTargetNumber->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
3825 | fprintf(fp, ", class [ScriptTypes]LindenLab.SecondLife.Quaternion "); | ||
3826 | mTargetRotation->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
3827 | fprintf(fp, ", class [ScriptTypes]LindenLab.SecondLife.Quaternion "); | ||
3828 | mOurRotation->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
3829 | fprintf(fp, " )"); | ||
3830 | break; | ||
3359 | default: | 3831 | default: |
3360 | mTargetNumber->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 3832 | mTargetNumber->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
3361 | mTargetRotation->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 3833 | mTargetRotation->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
@@ -3391,10 +3863,17 @@ void LLScriptNotAtRotTarget::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTC | |||
3391 | { | 3863 | { |
3392 | #ifdef LSL_INCLUDE_DEBUG_INFO | 3864 | #ifdef LSL_INCLUDE_DEBUG_INFO |
3393 | char name[] = "not_at_rot_target"; | 3865 | char name[] = "not_at_rot_target"; |
3394 | chunk->addBytes(name, strlen(name) + 1); /*Flawfinder: ignore*/ | 3866 | chunk->addBytes(name, strlen(name) + 1); |
3395 | #endif | 3867 | #endif |
3396 | } | 3868 | } |
3397 | break; | 3869 | break; |
3870 | case LSCP_SCOPE_PASS1: | ||
3871 | checkForDuplicateHandler(fp, this, scope, "not_at_rot_target"); | ||
3872 | break; | ||
3873 | |||
3874 | case LSCP_EMIT_CIL_ASSEMBLY: | ||
3875 | fprintf(fp, "not_at_rot_target()"); | ||
3876 | break; | ||
3398 | default: | 3877 | default: |
3399 | break; | 3878 | break; |
3400 | } | 3879 | } |
@@ -3563,6 +4042,25 @@ S32 LLScriptForExpressionList::getSize() | |||
3563 | return 0; | 4042 | return 0; |
3564 | } | 4043 | } |
3565 | 4044 | ||
4045 | // CIL code generation requires both caller and callee scope entries, so cannot use normal recurse signature. | ||
4046 | // TODO: Refactor general purpose recurse calls in to pass specific virtuals using visitor pattern to select method by pass and node type. | ||
4047 | static void print_cil_func_expression_list(LLScriptFuncExpressionList* self, LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata, LLScriptScopeEntry *callee_entry) | ||
4048 | { | ||
4049 | self->mFirstp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
4050 | LSCRIPTType argtype = callee_entry->mFunctionArgs.getType(entrycount); | ||
4051 | if (argtype != self->mFirstp->mReturnType) | ||
4052 | { | ||
4053 | print_cil_cast(fp, self->mFirstp->mReturnType, argtype); | ||
4054 | } | ||
4055 | entrycount++; | ||
4056 | if (self->mSecondp) | ||
4057 | { | ||
4058 | llassert(LET_FUNC_EXPRESSION_LIST == self->mSecondp->mType); | ||
4059 | print_cil_func_expression_list((LLScriptFuncExpressionList*) self->mSecondp, fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL, callee_entry); | ||
4060 | |||
4061 | } | ||
4062 | } | ||
4063 | |||
3566 | void LLScriptFuncExpressionList::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata) | 4064 | void LLScriptFuncExpressionList::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata) |
3567 | { | 4065 | { |
3568 | if (gErrorToText.getErrors()) | 4066 | if (gErrorToText.getErrors()) |
@@ -3660,31 +4158,6 @@ void LLScriptFuncExpressionList::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCR | |||
3660 | } | 4158 | } |
3661 | } | 4159 | } |
3662 | break; | 4160 | break; |
3663 | /* TODO: Fix conflict between global/local variable determination needing caller scope and cast determination here needs callee scope... | ||
3664 | case LSCP_EMIT_CIL_ASSEMBLY: | ||
3665 | { | ||
3666 | mFirstp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
3667 | LSCRIPTType argtype = entry->mFunctionArgs.getType(entrycount); | ||
3668 | if (argtype != mFirstp->mReturnType) | ||
3669 | { | ||
3670 | print_cil_cast(fp, mFirstp->mReturnType, argtype); | ||
3671 | } | ||
3672 | entrycount++; | ||
3673 | if (mSecondp) | ||
3674 | { | ||
3675 | mSecondp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
3676 | if (mSecondp->mReturnType) | ||
3677 | { | ||
3678 | argtype = entry->mFunctionArgs.getType(entrycount); | ||
3679 | if (argtype != mSecondp->mReturnType) | ||
3680 | { | ||
3681 | print_cil_cast(fp, mFirstp->mReturnType, argtype); | ||
3682 | } | ||
3683 | } | ||
3684 | } | ||
3685 | } | ||
3686 | break; | ||
3687 | */ | ||
3688 | default: | 4161 | default: |
3689 | mFirstp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 4162 | mFirstp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
3690 | if (mSecondp) | 4163 | if (mSecondp) |
@@ -3753,8 +4226,13 @@ void LLScriptListExpressionList::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCR | |||
3753 | } | 4226 | } |
3754 | break; | 4227 | break; |
3755 | case LSCP_EMIT_CIL_ASSEMBLY: | 4228 | case LSCP_EMIT_CIL_ASSEMBLY: |
3756 | // Evaluate expressions in reverse order so first expression is on top of stack. | 4229 | mFirstp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
3757 | // Results can then be popped and appended to list to result in list with correct order. | 4230 | if (mFirstp->mType != LET_LIST_EXPRESSION_LIST) |
4231 | { | ||
4232 | // Box value. | ||
4233 | print_cil_box(fp, mFirstp->mReturnType); | ||
4234 | ++count; | ||
4235 | } | ||
3758 | if (mSecondp) | 4236 | if (mSecondp) |
3759 | { | 4237 | { |
3760 | mSecondp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 4238 | mSecondp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
@@ -3762,18 +4240,9 @@ void LLScriptListExpressionList::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCR | |||
3762 | { | 4240 | { |
3763 | // Box value. | 4241 | // Box value. |
3764 | print_cil_box(fp, mSecondp->mReturnType); | 4242 | print_cil_box(fp, mSecondp->mReturnType); |
3765 | |||
3766 | ++count; | 4243 | ++count; |
3767 | } | 4244 | } |
3768 | } | 4245 | } |
3769 | mFirstp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
3770 | if (mFirstp->mType != LET_LIST_EXPRESSION_LIST) | ||
3771 | { | ||
3772 | // Box value. | ||
3773 | print_cil_box(fp, mFirstp->mReturnType); | ||
3774 | |||
3775 | ++count; | ||
3776 | } | ||
3777 | break; | 4246 | break; |
3778 | default: | 4247 | default: |
3779 | mFirstp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 4248 | mFirstp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
@@ -3793,14 +4262,22 @@ S32 LLScriptListExpressionList::getSize() | |||
3793 | // Returns true if identifier is a parameter and false if identifier is a local variable within function_scope. | 4262 | // Returns true if identifier is a parameter and false if identifier is a local variable within function_scope. |
3794 | bool is_parameter(LLScriptIdentifier* identifier, LLScriptScopeEntry* function_scope) | 4263 | bool is_parameter(LLScriptIdentifier* identifier, LLScriptScopeEntry* function_scope) |
3795 | { | 4264 | { |
3796 | // Function offset stores offset of first local. | 4265 | // Function stores offset of first local. |
3797 | // Compare variable offset with function offset to | 4266 | if(0 == function_scope->mOffset) |
3798 | // determine whether variable is local or parameter. | 4267 | { |
3799 | return (identifier->mScopeEntry->mOffset < function_scope->mOffset); | 4268 | // Function offset 0 -> no parameters -> identifier is a local. |
4269 | return false; | ||
4270 | } | ||
4271 | else | ||
4272 | { | ||
4273 | // Compare variable offset with function offset to | ||
4274 | // determine whether variable is local or parameter. | ||
4275 | return (identifier->mScopeEntry->mOffset < function_scope->mOffset); | ||
4276 | } | ||
3800 | } | 4277 | } |
3801 | 4278 | ||
3802 | // If assignment is to global variable, pushes this pointer on to stack. | 4279 | // If assignment is to global variable, pushes this pointer on to stack. |
3803 | void print_cil_load_address(LLFILE* fp, LLScriptExpression* exp, LLScriptScopeEntry* function_scope) | 4280 | static void print_cil_load_address(LLFILE* fp, LLScriptExpression* exp, LLScriptScopeEntry* function_scope) |
3804 | { | 4281 | { |
3805 | LLScriptLValue *lvalue = (LLScriptLValue *) exp; | 4282 | LLScriptLValue *lvalue = (LLScriptLValue *) exp; |
3806 | LLScriptIdentifier *ident = lvalue->mIdentifier; | 4283 | LLScriptIdentifier *ident = lvalue->mIdentifier; |
@@ -3811,7 +4288,7 @@ void print_cil_load_address(LLFILE* fp, LLScriptExpression* exp, LLScriptScopeEn | |||
3811 | fprintf(fp, "ldarg.0\n"); | 4288 | fprintf(fp, "ldarg.0\n"); |
3812 | } | 4289 | } |
3813 | 4290 | ||
3814 | // If accessor, load address of object. | 4291 | // If accessor, load value type address, consumed by ldfld. |
3815 | if(lvalue->mAccessor) | 4292 | if(lvalue->mAccessor) |
3816 | { | 4293 | { |
3817 | if(ident->mScopeEntry->mIDType == LIT_VARIABLE) | 4294 | if(ident->mScopeEntry->mIDType == LIT_VARIABLE) |
@@ -3819,7 +4296,7 @@ void print_cil_load_address(LLFILE* fp, LLScriptExpression* exp, LLScriptScopeEn | |||
3819 | if(is_parameter(ident, function_scope)) | 4296 | if(is_parameter(ident, function_scope)) |
3820 | { | 4297 | { |
3821 | // Parameter, load by name. | 4298 | // Parameter, load by name. |
3822 | fprintf(fp, "ldarga.s %s\n", ident->mScopeEntry->mIdentifier); | 4299 | fprintf(fp, "ldarga.s '%s'\n", ident->mScopeEntry->mIdentifier); |
3823 | } | 4300 | } |
3824 | else | 4301 | else |
3825 | { | 4302 | { |
@@ -3830,13 +4307,13 @@ void print_cil_load_address(LLFILE* fp, LLScriptExpression* exp, LLScriptScopeEn | |||
3830 | else if (ident->mScopeEntry->mIDType == LIT_GLOBAL) | 4307 | else if (ident->mScopeEntry->mIDType == LIT_GLOBAL) |
3831 | { | 4308 | { |
3832 | fprintf(fp, "ldflda "); | 4309 | fprintf(fp, "ldflda "); |
3833 | print_cil_type(fp, ident->mScopeEntry->mType); | 4310 | print_cil_member(fp, ident); |
3834 | fprintf(fp, " LSL::%s\n", ident->mScopeEntry->mIdentifier); | ||
3835 | } | 4311 | } |
3836 | } | 4312 | } |
3837 | } | 4313 | } |
3838 | 4314 | ||
3839 | void print_cil_accessor(LLFILE* fp, LLScriptLValue *lvalue) | 4315 | static void print_cil_accessor(LLFILE* fp, LLScriptLValue *lvalue) |
4316 | |||
3840 | { | 4317 | { |
3841 | LLScriptIdentifier *ident = lvalue->mIdentifier; | 4318 | LLScriptIdentifier *ident = lvalue->mIdentifier; |
3842 | print_cil_type(fp, lvalue->mReturnType); | 4319 | print_cil_type(fp, lvalue->mReturnType); |
@@ -3845,12 +4322,6 @@ void print_cil_accessor(LLFILE* fp, LLScriptLValue *lvalue) | |||
3845 | fprintf(fp, "::%s\n", lvalue->mAccessor->mName); | 4322 | fprintf(fp, "::%s\n", lvalue->mAccessor->mName); |
3846 | } | 4323 | } |
3847 | 4324 | ||
3848 | void print_cil_member(LLFILE* fp, LLScriptIdentifier *ident) | ||
3849 | { | ||
3850 | print_cil_type(fp, ident->mScopeEntry->mType); | ||
3851 | fprintf(fp, " LSL::%s\n", ident->mScopeEntry->mIdentifier); | ||
3852 | } | ||
3853 | |||
3854 | void LLScriptLValue::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata) | 4325 | void LLScriptLValue::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata) |
3855 | { | 4326 | { |
3856 | if (gErrorToText.getErrors()) | 4327 | if (gErrorToText.getErrors()) |
@@ -4106,7 +4577,7 @@ void LLScriptLValue::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePa | |||
4106 | if(is_parameter(mIdentifier, entry)) | 4577 | if(is_parameter(mIdentifier, entry)) |
4107 | { | 4578 | { |
4108 | // Parameter, load by name. | 4579 | // Parameter, load by name. |
4109 | fprintf(fp, "ldarg.s %s\n", mIdentifier->mScopeEntry->mIdentifier); | 4580 | fprintf(fp, "ldarg.s '%s'\n", mIdentifier->mScopeEntry->mIdentifier); |
4110 | } | 4581 | } |
4111 | else | 4582 | else |
4112 | { | 4583 | { |
@@ -4136,7 +4607,7 @@ S32 LLScriptLValue::getSize() | |||
4136 | return 0; | 4607 | return 0; |
4137 | } | 4608 | } |
4138 | 4609 | ||
4139 | void print_asignment(LLFILE *fp, LLScriptExpression *exp) | 4610 | static void print_assignment(LLFILE *fp, LLScriptExpression *exp) |
4140 | { | 4611 | { |
4141 | LLScriptLValue *lvalue = (LLScriptLValue *)exp; | 4612 | LLScriptLValue *lvalue = (LLScriptLValue *)exp; |
4142 | LLScriptIdentifier *ident = lvalue->mIdentifier; | 4613 | LLScriptIdentifier *ident = lvalue->mIdentifier; |
@@ -4164,7 +4635,7 @@ void print_asignment(LLFILE *fp, LLScriptExpression *exp) | |||
4164 | } | 4635 | } |
4165 | } | 4636 | } |
4166 | 4637 | ||
4167 | void print_cil_asignment(LLFILE *fp, LLScriptExpression *exp, LLScriptScopeEntry* function_scope) | 4638 | static void print_cil_assignment(LLFILE *fp, LLScriptExpression *exp, LLScriptScopeEntry* function_scope) |
4168 | { | 4639 | { |
4169 | LLScriptLValue *lvalue = (LLScriptLValue *) exp; | 4640 | LLScriptLValue *lvalue = (LLScriptLValue *) exp; |
4170 | LLScriptIdentifier *ident = lvalue->mIdentifier; | 4641 | LLScriptIdentifier *ident = lvalue->mIdentifier; |
@@ -4191,7 +4662,7 @@ void print_cil_asignment(LLFILE *fp, LLScriptExpression *exp, LLScriptScopeEntry | |||
4191 | if(is_parameter(ident, function_scope)) | 4662 | if(is_parameter(ident, function_scope)) |
4192 | { | 4663 | { |
4193 | // Parameter, store by name. | 4664 | // Parameter, store by name. |
4194 | fprintf(fp, "starg.s %s\n", ident->mScopeEntry->mIdentifier); | 4665 | fprintf(fp, "starg.s '%s'\n", ident->mScopeEntry->mIdentifier); |
4195 | } | 4666 | } |
4196 | else | 4667 | else |
4197 | { | 4668 | { |
@@ -4319,14 +4790,6 @@ void store2stack(LLScriptExpression *exp, LLScriptExpression *lv, LLScriptByteCo | |||
4319 | chunk->addInteger(address); | 4790 | chunk->addInteger(address); |
4320 | } | 4791 | } |
4321 | 4792 | ||
4322 | void print_cil_numeric_cast(LLFILE* fp, LSCRIPTType currentArg, LSCRIPTType otherArg) | ||
4323 | { | ||
4324 | if((currentArg == LST_INTEGER) && (otherArg == LST_FLOATINGPOINT)) | ||
4325 | { | ||
4326 | print_cil_cast(fp, LST_INTEGER, LST_FLOATINGPOINT); | ||
4327 | } | ||
4328 | } | ||
4329 | |||
4330 | void LLScriptAssignment::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata) | 4793 | void LLScriptAssignment::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata) |
4331 | { | 4794 | { |
4332 | if (gErrorToText.getErrors()) | 4795 | if (gErrorToText.getErrors()) |
@@ -4344,7 +4807,7 @@ void LLScriptAssignment::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompi | |||
4344 | { | 4807 | { |
4345 | mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 4808 | mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
4346 | print_cast(fp, mReturnType, mRightType); | 4809 | print_cast(fp, mReturnType, mRightType); |
4347 | print_asignment(fp, mLValue); | 4810 | print_assignment(fp, mLValue); |
4348 | } | 4811 | } |
4349 | break; | 4812 | break; |
4350 | case LSCP_TYPE: | 4813 | case LSCP_TYPE: |
@@ -4370,8 +4833,8 @@ void LLScriptAssignment::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompi | |||
4370 | { | 4833 | { |
4371 | print_cil_load_address(fp, mLValue, entry); | 4834 | print_cil_load_address(fp, mLValue, entry); |
4372 | mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 4835 | mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
4373 | print_cil_numeric_cast(fp, mRightType, mReturnType); | 4836 | print_cil_assignment_cast(fp, mRightType, mReturnType); |
4374 | print_cil_asignment(fp, mLValue, entry); | 4837 | print_cil_assignment(fp, mLValue, entry); |
4375 | } | 4838 | } |
4376 | break; | 4839 | break; |
4377 | default: | 4840 | default: |
@@ -4387,8 +4850,15 @@ S32 LLScriptAssignment::getSize() | |||
4387 | return 0; | 4850 | return 0; |
4388 | } | 4851 | } |
4389 | 4852 | ||
4390 | void print_cil_add(LLFILE* fp, LSCRIPTType left_type, LSCRIPTType right_type) | 4853 | static void print_cil_add(LLFILE* fp, LSCRIPTType left_type, LSCRIPTType right_type) |
4391 | { | 4854 | { |
4855 | if(LST_LIST == right_type && LST_LIST != left_type) | ||
4856 | { | ||
4857 | print_cil_box(fp, left_type); | ||
4858 | fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::Prepend(class [mscorlib]System.Collections.ArrayList, object)\n"); | ||
4859 | return; | ||
4860 | } | ||
4861 | |||
4392 | switch(left_type) | 4862 | switch(left_type) |
4393 | { | 4863 | { |
4394 | case LST_INTEGER: | 4864 | case LST_INTEGER: |
@@ -4402,27 +4872,49 @@ void print_cil_add(LLFILE* fp, LSCRIPTType left_type, LSCRIPTType right_type) | |||
4402 | case LST_KEY: | 4872 | case LST_KEY: |
4403 | 4873 | ||
4404 | // String concatenation. | 4874 | // String concatenation. |
4405 | fprintf(fp, "call string valuetype [mscorlib]System.String::Concat(string, string)"); | 4875 | fprintf(fp, "call string valuetype [LslUserScript]LindenLab.SecondLife.LslUserScript::Add(string, string)\n"); |
4406 | break; | 4876 | break; |
4407 | 4877 | ||
4408 | case LST_VECTOR: | 4878 | case LST_VECTOR: |
4409 | 4879 | ||
4410 | // Vector addition. | 4880 | // Vector addition. |
4411 | // TODO: Inline (requires temporary variables, which must be identified in earlier pass). | 4881 | fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Vector class [LslUserScript]LindenLab.SecondLife.LslUserScript::'Add'(class [ScriptTypes]LindenLab.SecondLife.Vector, class [ScriptTypes]LindenLab.SecondLife.Vector)\n"); |
4412 | fprintf(fp, "call valuetype [LScriptLibrary]LLVector valuetype [LScriptLibrary]LLVector::'add_vec'(valuetype [LScriptLibrary]LLVector, valuetype [LScriptLibrary]LLVector)\n"); | ||
4413 | break; | 4882 | break; |
4414 | 4883 | ||
4415 | case LST_QUATERNION: | 4884 | case LST_QUATERNION: |
4416 | 4885 | ||
4417 | // Rotation addition. | 4886 | // Rotation addition. |
4418 | // TODO: Inline (requires temporary variables, which must be identified in earlier pass). | 4887 | fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Quaternion class [LslUserScript]LindenLab.SecondLife.LslUserScript::'Add'(class [ScriptTypes]LindenLab.SecondLife.Quaternion, class [ScriptTypes]LindenLab.SecondLife.Quaternion)\n"); |
4419 | fprintf(fp, "call valuetype [LScriptLibrary]LLQuaternion valuetype [LScriptLibrary]LLQuaternion::'add_quat'(valuetype [LScriptLibrary]LLQuaternion, valuetype [LScriptLibrary]LLQuaternion)\n"); | ||
4420 | break; | 4888 | break; |
4421 | 4889 | ||
4422 | case LST_LIST: | 4890 | case LST_LIST: |
4423 | print_cil_box(fp, right_type); | 4891 | switch(right_type) |
4424 | fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LScriptLibrary]LScriptInternal::AddReturnList(class [mscorlib]System.Collections.ArrayList, object)\n"); | 4892 | { |
4425 | break; | 4893 | case LST_LIST: |
4894 | // Concatenate lists. | ||
4895 | fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::Append(class [mscorlib]System.Collections.ArrayList, class [mscorlib]System.Collections.ArrayList)\n"); | ||
4896 | break; | ||
4897 | case LST_INTEGER: | ||
4898 | fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::Append(int32, class [mscorlib]System.Collections.ArrayList)\n"); | ||
4899 | break; | ||
4900 | case LST_FLOATINGPOINT: | ||
4901 | fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::Append(float32, class [mscorlib]System.Collections.ArrayList)\n"); | ||
4902 | break; | ||
4903 | case LST_STRING: | ||
4904 | fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::Append(string, class [mscorlib]System.Collections.ArrayList)\n"); | ||
4905 | break; | ||
4906 | case LST_KEY: | ||
4907 | fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::Append(valuetype [ScriptTypes]LindenLab.SecondLife.Key, class [mscorlib]System.Collections.ArrayList)\n"); | ||
4908 | break; | ||
4909 | case LST_VECTOR: | ||
4910 | fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::Append(valuetype [ScriptTypes]LindenLab.SecondLife.Vector, class [mscorlib]System.Collections.ArrayList)\n"); | ||
4911 | break; | ||
4912 | case LST_QUATERNION: | ||
4913 | fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::Append(valuetype [ScriptTypes]LindenLab.SecondLife.Quaternion, class [mscorlib]System.Collections.ArrayList)\n"); | ||
4914 | break; | ||
4915 | default: | ||
4916 | break; | ||
4917 | } | ||
4426 | 4918 | ||
4427 | default: | 4919 | default: |
4428 | break; | 4920 | break; |
@@ -4447,7 +4939,7 @@ void LLScriptAddAssignment::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCo | |||
4447 | mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 4939 | mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
4448 | mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 4940 | mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
4449 | fprintf(fp, "ADD %s, %s\n", LSCRIPTTypeNames[mRightType], LSCRIPTTypeNames[mLeftType]); | 4941 | fprintf(fp, "ADD %s, %s\n", LSCRIPTTypeNames[mRightType], LSCRIPTTypeNames[mLeftType]); |
4450 | print_asignment(fp, mLValue); | 4942 | print_assignment(fp, mLValue); |
4451 | } | 4943 | } |
4452 | break; | 4944 | break; |
4453 | case LSCP_TYPE: | 4945 | case LSCP_TYPE: |
@@ -4475,12 +4967,12 @@ void LLScriptAddAssignment::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCo | |||
4475 | case LSCP_EMIT_CIL_ASSEMBLY: | 4967 | case LSCP_EMIT_CIL_ASSEMBLY: |
4476 | { | 4968 | { |
4477 | print_cil_load_address(fp, mLValue, entry); | 4969 | print_cil_load_address(fp, mLValue, entry); |
4478 | mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
4479 | print_cil_numeric_cast(fp, mLValue->mReturnType, mRightSide->mReturnType); | ||
4480 | mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 4970 | mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
4481 | print_cil_numeric_cast(fp, mRightSide->mReturnType, mLValue->mReturnType); | 4971 | print_cil_numeric_cast(fp, mRightSide->mReturnType, mLValue->mReturnType); |
4972 | mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
4973 | print_cil_numeric_cast(fp, mLValue->mReturnType, mRightSide->mReturnType); | ||
4482 | print_cil_add(fp, mLValue->mReturnType, mRightSide->mReturnType); | 4974 | print_cil_add(fp, mLValue->mReturnType, mRightSide->mReturnType); |
4483 | print_cil_asignment(fp, mLValue, entry); | 4975 | print_cil_assignment(fp, mLValue, entry); |
4484 | } | 4976 | } |
4485 | break; | 4977 | break; |
4486 | default: | 4978 | default: |
@@ -4496,29 +4988,30 @@ S32 LLScriptAddAssignment::getSize() | |||
4496 | return 0; | 4988 | return 0; |
4497 | } | 4989 | } |
4498 | 4990 | ||
4499 | void print_cil_sub(LLFILE* fp, LSCRIPTType left_type, LSCRIPTType right_type) | 4991 | static void print_cil_sub(LLFILE* fp, LSCRIPTType left_type, LSCRIPTType right_type) |
4500 | { | 4992 | { |
4501 | switch(left_type) | 4993 | switch(left_type) |
4502 | { | 4994 | { |
4503 | case LST_INTEGER: | 4995 | case LST_INTEGER: |
4996 | if(LST_INTEGER == right_type) | ||
4997 | { | ||
4998 | fprintf(fp, "call int32 [LslUserScript]LindenLab.SecondLife.LslUserScript::Subtract(int32, int32)\n"); | ||
4999 | break; | ||
5000 | } | ||
4504 | case LST_FLOATINGPOINT: | 5001 | case LST_FLOATINGPOINT: |
4505 | |||
4506 | // Numeric subtraction. | 5002 | // Numeric subtraction. |
4507 | fprintf(fp, "sub\n"); | 5003 | fprintf(fp, "call float64 [LslUserScript]LindenLab.SecondLife.LslUserScript::Subtract(float64, float64)\n"); |
4508 | break; | 5004 | break; |
4509 | |||
4510 | case LST_VECTOR: | 5005 | case LST_VECTOR: |
4511 | 5006 | ||
4512 | // Vector subtraction. | 5007 | // Vector subtraction. |
4513 | // TODO: Inline (requires temporary variables, which must be identified in earlier pass). | 5008 | fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Vector class [LslUserScript]LindenLab.SecondLife.LslUserScript::'Subtract'(class [ScriptTypes]LindenLab.SecondLife.Vector, class [ScriptTypes]LindenLab.SecondLife.Vector)\n"); |
4514 | fprintf(fp, "call valuetype [LScriptLibrary]LLVector valuetype [LScriptLibrary]LLVector::'subtract_vec'(valuetype [LScriptLibrary]LLVector, valuetype [LScriptLibrary]LLVector)\n"); | ||
4515 | break; | 5009 | break; |
4516 | 5010 | ||
4517 | case LST_QUATERNION: | 5011 | case LST_QUATERNION: |
4518 | 5012 | ||
4519 | // Rotation subtraction. | 5013 | // Rotation subtraction. |
4520 | // TODO: Inline (requires temporary variables, which must be identified in earlier pass). | 5014 | fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Quaternion class [LslUserScript]LindenLab.SecondLife.LslUserScript::'Subtract'(class [ScriptTypes]LindenLab.SecondLife.Quaternion, class [ScriptTypes]LindenLab.SecondLife.Quaternion)\n"); |
4521 | fprintf(fp, "call valuetype [LScriptLibrary]LLQuaternion valuetype [LScriptLibrary]LLQuaternion::'subtract_quat'(valuetype [LScriptLibrary]LLQuaternion, valuetype [LScriptLibrary]LLQuaternion)\n"); | ||
4522 | break; | 5015 | break; |
4523 | 5016 | ||
4524 | default: | 5017 | default: |
@@ -4546,7 +5039,7 @@ void LLScriptSubAssignment::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCo | |||
4546 | mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 5039 | mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
4547 | mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 5040 | mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
4548 | fprintf(fp, "SUB %s, %s\n", LSCRIPTTypeNames[mRightType], LSCRIPTTypeNames[mLeftType]); | 5041 | fprintf(fp, "SUB %s, %s\n", LSCRIPTTypeNames[mRightType], LSCRIPTTypeNames[mLeftType]); |
4549 | print_asignment(fp, mLValue); | 5042 | print_assignment(fp, mLValue); |
4550 | } | 5043 | } |
4551 | break; | 5044 | break; |
4552 | case LSCP_TYPE: | 5045 | case LSCP_TYPE: |
@@ -4574,12 +5067,12 @@ void LLScriptSubAssignment::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCo | |||
4574 | case LSCP_EMIT_CIL_ASSEMBLY: | 5067 | case LSCP_EMIT_CIL_ASSEMBLY: |
4575 | { | 5068 | { |
4576 | print_cil_load_address(fp, mLValue, entry); | 5069 | print_cil_load_address(fp, mLValue, entry); |
4577 | mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
4578 | print_cil_numeric_cast(fp, mLValue->mReturnType, mRightSide->mReturnType); | ||
4579 | mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 5070 | mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
4580 | print_cil_numeric_cast(fp, mRightSide->mReturnType, mLValue->mReturnType); | 5071 | print_cil_numeric_cast(fp, mRightSide->mReturnType, mLValue->mReturnType); |
5072 | mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
5073 | print_cil_numeric_cast(fp, mLValue->mReturnType, mRightSide->mReturnType); | ||
4581 | print_cil_sub(fp, mLValue->mReturnType, mRightSide->mReturnType); | 5074 | print_cil_sub(fp, mLValue->mReturnType, mRightSide->mReturnType); |
4582 | print_cil_asignment(fp, mLValue, entry); | 5075 | print_cil_assignment(fp, mLValue, entry); |
4583 | } | 5076 | } |
4584 | break; | 5077 | break; |
4585 | default: | 5078 | default: |
@@ -4595,41 +5088,93 @@ S32 LLScriptSubAssignment::getSize() | |||
4595 | return 0; | 5088 | return 0; |
4596 | } | 5089 | } |
4597 | 5090 | ||
4598 | void print_cil_mul(LLFILE* fp, LSCRIPTType left_type, LSCRIPTType right_type) | 5091 | static void print_cil_neg(LLFILE* fp, LSCRIPTType type) |
4599 | { | 5092 | { |
4600 | switch(left_type) | 5093 | switch(type) |
4601 | { | 5094 | { |
4602 | case LST_INTEGER: | 5095 | case LST_INTEGER: |
4603 | case LST_FLOATINGPOINT: | 5096 | case LST_FLOATINGPOINT: |
5097 | fprintf(fp, "neg\n"); | ||
5098 | break; | ||
5099 | case LST_VECTOR: | ||
5100 | fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Vector class [LslUserScript]LindenLab.SecondLife.LslUserScript::'Negate'(class [ScriptTypes]LindenLab.SecondLife.Vector)\n"); | ||
5101 | break; | ||
5102 | case LST_QUATERNION: | ||
5103 | fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Quaternion class [LslUserScript]LindenLab.SecondLife.LslUserScript::'Negate'(class [ScriptTypes]LindenLab.SecondLife.Quaternion)\n"); | ||
5104 | break; | ||
5105 | default: | ||
5106 | break; | ||
5107 | } | ||
5108 | } | ||
4604 | 5109 | ||
4605 | // Numeric multiplication. | 5110 | static void print_cil_mul(LLFILE* fp, LSCRIPTType left_type, LSCRIPTType right_type) |
4606 | fprintf(fp, "mul\n"); | 5111 | { |
5112 | switch(left_type) | ||
5113 | { | ||
5114 | case LST_INTEGER: | ||
5115 | |||
5116 | switch(right_type) | ||
5117 | { | ||
5118 | case LST_INTEGER: | ||
5119 | case LST_FLOATINGPOINT: | ||
5120 | |||
5121 | // Numeric multiplication. | ||
5122 | fprintf(fp, "mul\n"); | ||
5123 | break; | ||
5124 | |||
5125 | case LST_VECTOR: | ||
5126 | |||
5127 | // Vector scaling. | ||
5128 | fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Vector class [LslUserScript]LindenLab.SecondLife.LslUserScript::'Multiply'(class [ScriptTypes]LindenLab.SecondLife.Vector, float32)\n"); | ||
5129 | break; | ||
5130 | default: | ||
5131 | break; | ||
5132 | } | ||
4607 | break; | 5133 | break; |
4608 | 5134 | ||
4609 | case LST_VECTOR: | 5135 | case LST_FLOATINGPOINT: |
4610 | 5136 | ||
4611 | switch(right_type) | 5137 | switch(right_type) |
4612 | { | 5138 | { |
4613 | case LST_INTEGER: | 5139 | case LST_INTEGER: |
5140 | case LST_FLOATINGPOINT: | ||
4614 | 5141 | ||
4615 | print_cil_cast(fp, LST_INTEGER, LST_FLOATINGPOINT); | 5142 | // Numeric multiplication. |
5143 | fprintf(fp, "mul\n"); | ||
5144 | break; | ||
5145 | |||
5146 | case LST_VECTOR: | ||
5147 | |||
5148 | // Vector scaling. | ||
5149 | fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Vector class [LslUserScript]LindenLab.SecondLife.LslUserScript::'Multiply'(class [ScriptTypes]LindenLab.SecondLife.Vector, float32)\n"); | ||
5150 | break; | ||
5151 | |||
5152 | default: | ||
5153 | break; | ||
5154 | } | ||
5155 | break; | ||
5156 | |||
5157 | case LST_VECTOR: | ||
4616 | 5158 | ||
5159 | switch(right_type) | ||
5160 | { | ||
5161 | case LST_INTEGER: | ||
4617 | case LST_FLOATINGPOINT: | 5162 | case LST_FLOATINGPOINT: |
4618 | 5163 | ||
4619 | // Vector scaling. | 5164 | // Vector scaling. |
4620 | fprintf(fp, "call valuetype [LScriptLibrary]LLVector valuetype [LScriptLibrary]LLVector::'multiply_float'(valuetype [LScriptLibrary]LLVector, float32)\n"); | 5165 | fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Vector class [LslUserScript]LindenLab.SecondLife.LslUserScript::'Multiply'(float32, class [ScriptTypes]LindenLab.SecondLife.Vector)\n"); |
4621 | break; | 5166 | break; |
4622 | 5167 | ||
4623 | case LST_VECTOR: | 5168 | case LST_VECTOR: |
4624 | 5169 | ||
4625 | // Dot product. | 5170 | // Dot product. |
4626 | fprintf(fp, "call float32 valuetype [LScriptLibrary]LLVector::'multiply_vec'(valuetype [LScriptLibrary]LLVector, valuetype [LScriptLibrary]LLVector)\n"); | 5171 | fprintf(fp, "call float32 class [LslUserScript]LindenLab.SecondLife.LslUserScript::'Multiply'(class [ScriptTypes]LindenLab.SecondLife.Vector, class [ScriptTypes]LindenLab.SecondLife.Vector)\n"); |
4627 | break; | 5172 | break; |
4628 | 5173 | ||
4629 | case LST_QUATERNION: | 5174 | case LST_QUATERNION: |
4630 | 5175 | ||
4631 | // Vector rotation. | 5176 | // Vector rotation. |
4632 | fprintf(fp, "call valuetype [LScriptLibrary]LLVector valuetype [LScriptLibrary]LLVector::'multiply_quat'(valuetype [LScriptLibrary]LLVector, valuetype [LScriptLibrary]LLQuaternion)\n"); | 5177 | fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Vector class [LslUserScript]LindenLab.SecondLife.LslUserScript::'Multiply'(class [ScriptTypes]LindenLab.SecondLife.Quaternion, class [ScriptTypes]LindenLab.SecondLife.Vector)\n"); |
4633 | break; | 5178 | break; |
4634 | 5179 | ||
4635 | default: | 5180 | default: |
@@ -4640,7 +5185,7 @@ void print_cil_mul(LLFILE* fp, LSCRIPTType left_type, LSCRIPTType right_type) | |||
4640 | case LST_QUATERNION: | 5185 | case LST_QUATERNION: |
4641 | 5186 | ||
4642 | // Rotation multiplication. | 5187 | // Rotation multiplication. |
4643 | fprintf(fp, "call valuetype [LScriptLibrary]LLQuaternion valuetype [LScriptLibrary]LLQuaternion::'multiply_quat'(valuetype [LScriptLibrary]LLQuaternion, valuetype [LScriptLibrary]LLQuaternion)\n"); | 5188 | fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Quaternion class [LslUserScript]LindenLab.SecondLife.LslUserScript::'Multiply'(class [ScriptTypes]LindenLab.SecondLife.Quaternion, class [ScriptTypes]LindenLab.SecondLife.Quaternion)\n"); |
4644 | break; | 5189 | break; |
4645 | 5190 | ||
4646 | default: | 5191 | default: |
@@ -4668,7 +5213,7 @@ void LLScriptMulAssignment::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCo | |||
4668 | mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 5213 | mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
4669 | mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 5214 | mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
4670 | fprintf(fp, "MUL %s, %s\n", LSCRIPTTypeNames[mRightType], LSCRIPTTypeNames[mLeftType]); | 5215 | fprintf(fp, "MUL %s, %s\n", LSCRIPTTypeNames[mRightType], LSCRIPTTypeNames[mLeftType]); |
4671 | print_asignment(fp, mLValue); | 5216 | print_assignment(fp, mLValue); |
4672 | } | 5217 | } |
4673 | break; | 5218 | break; |
4674 | case LSCP_TYPE: | 5219 | case LSCP_TYPE: |
@@ -4677,7 +5222,7 @@ void LLScriptMulAssignment::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCo | |||
4677 | mLeftType = type; | 5222 | mLeftType = type; |
4678 | mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 5223 | mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
4679 | mRightType = type; | 5224 | mRightType = type; |
4680 | if (!legal_binary_expression(mReturnType, mLeftType, mRightType, mType)) | 5225 | if (!legal_binary_expression(mReturnType, mLeftType, mRightType, mType) /*|| !legal_assignment(mLValue->mReturnType, mReturnType)*/) |
4681 | { | 5226 | { |
4682 | gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH); | 5227 | gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH); |
4683 | } | 5228 | } |
@@ -4696,12 +5241,17 @@ void LLScriptMulAssignment::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCo | |||
4696 | case LSCP_EMIT_CIL_ASSEMBLY: | 5241 | case LSCP_EMIT_CIL_ASSEMBLY: |
4697 | { | 5242 | { |
4698 | print_cil_load_address(fp, mLValue, entry); | 5243 | print_cil_load_address(fp, mLValue, entry); |
4699 | mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
4700 | print_cil_numeric_cast(fp, mLValue->mReturnType, mRightSide->mReturnType); | ||
4701 | mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 5244 | mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
4702 | print_cil_numeric_cast(fp, mRightSide->mReturnType, mLValue->mReturnType); | 5245 | print_cil_numeric_cast(fp, mRightSide->mReturnType, mLValue->mReturnType); |
5246 | mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
5247 | print_cil_numeric_cast(fp, mLValue->mReturnType, mRightSide->mReturnType); | ||
4703 | print_cil_mul(fp, mLValue->mReturnType, mRightSide->mReturnType); | 5248 | print_cil_mul(fp, mLValue->mReturnType, mRightSide->mReturnType); |
4704 | print_cil_asignment(fp, mLValue, entry); | 5249 | if((mLValue->mReturnType == LST_INTEGER) && |
5250 | (mRightSide->mReturnType == LST_FLOATINGPOINT)) | ||
5251 | { | ||
5252 | print_cil_cast(fp, LST_FLOATINGPOINT, LST_INTEGER); | ||
5253 | } | ||
5254 | print_cil_assignment(fp, mLValue, entry); | ||
4705 | } | 5255 | } |
4706 | break; | 5256 | break; |
4707 | default: | 5257 | default: |
@@ -4717,15 +5267,20 @@ S32 LLScriptMulAssignment::getSize() | |||
4717 | return 0; | 5267 | return 0; |
4718 | } | 5268 | } |
4719 | 5269 | ||
4720 | void print_cil_div(LLFILE* fp, LSCRIPTType left_type, LSCRIPTType right_type) | 5270 | static void print_cil_div(LLFILE* fp, LSCRIPTType left_type, LSCRIPTType right_type) |
4721 | { | 5271 | { |
4722 | switch(left_type) | 5272 | switch(left_type) |
4723 | { | 5273 | { |
4724 | case LST_INTEGER: | 5274 | case LST_INTEGER: |
5275 | if(LST_INTEGER == right_type) | ||
5276 | { | ||
5277 | fprintf(fp, "call int32 [LslUserScript]LindenLab.SecondLife.LslUserScript::Divide(int32, int32)\n"); | ||
5278 | break; | ||
5279 | } | ||
4725 | case LST_FLOATINGPOINT: | 5280 | case LST_FLOATINGPOINT: |
4726 | 5281 | ||
4727 | // Numeric addition. | 5282 | // Numeric division. |
4728 | fprintf(fp, "div\n"); | 5283 | fprintf(fp, "call float64 [LslUserScript]LindenLab.SecondLife.LslUserScript::Divide(float64, float64)\n"); |
4729 | break; | 5284 | break; |
4730 | 5285 | ||
4731 | case LST_VECTOR: | 5286 | case LST_VECTOR: |
@@ -4733,19 +5288,16 @@ void print_cil_div(LLFILE* fp, LSCRIPTType left_type, LSCRIPTType right_type) | |||
4733 | switch(right_type) | 5288 | switch(right_type) |
4734 | { | 5289 | { |
4735 | case LST_INTEGER: | 5290 | case LST_INTEGER: |
4736 | |||
4737 | print_cil_cast(fp, LST_INTEGER, LST_FLOATINGPOINT); | ||
4738 | |||
4739 | case LST_FLOATINGPOINT: | 5291 | case LST_FLOATINGPOINT: |
4740 | 5292 | ||
4741 | // Scale. | 5293 | // Scale. |
4742 | fprintf(fp, "call valuetype [LScriptLibrary]LLVector valuetype [LScriptLibrary]LLVector::'divide_float'(valuetype [LScriptLibrary]LLVector, float32)\n"); | 5294 | fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Vector class [LslUserScript]LindenLab.SecondLife.LslUserScript::'Divide'(float32, class [ScriptTypes]LindenLab.SecondLife.Vector)\n"); |
4743 | break; | 5295 | break; |
4744 | 5296 | ||
4745 | case LST_QUATERNION: | 5297 | case LST_QUATERNION: |
4746 | 5298 | ||
4747 | // Inverse rotation. | 5299 | // Inverse rotation. |
4748 | fprintf(fp, "call valuetype [LScriptLibrary]LLVector valuetype [LScriptLibrary]LLVector::'divide_quat'(valuetype [LScriptLibrary]LLVector, valuetype [LScriptLibrary]LLQuaternion)\n"); | 5300 | fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Vector class [LslUserScript]LindenLab.SecondLife.LslUserScript::'Divide'(class [ScriptTypes]LindenLab.SecondLife.Quaternion, class [ScriptTypes]LindenLab.SecondLife.Vector)\n"); |
4749 | break; | 5301 | break; |
4750 | 5302 | ||
4751 | default: | 5303 | default: |
@@ -4755,7 +5307,7 @@ void print_cil_div(LLFILE* fp, LSCRIPTType left_type, LSCRIPTType right_type) | |||
4755 | 5307 | ||
4756 | case LST_QUATERNION: | 5308 | case LST_QUATERNION: |
4757 | 5309 | ||
4758 | fprintf(fp, "call valuetype [LScriptLibrary]LLQuaternion valuetype [LScriptLibrary]LLQuaternion::'divide_quat'(valuetype [LScriptLibrary]LLQuaternion, valuetype [LScriptLibrary]LLQuaternion)\n"); | 5310 | fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Quaternion class [LslUserScript]LindenLab.SecondLife.LslUserScript::'Divide'(class [ScriptTypes]LindenLab.SecondLife.Quaternion, class [ScriptTypes]LindenLab.SecondLife.Quaternion)\n"); |
4759 | break; | 5311 | break; |
4760 | 5312 | ||
4761 | default: | 5313 | default: |
@@ -4783,7 +5335,7 @@ void LLScriptDivAssignment::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCo | |||
4783 | mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 5335 | mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
4784 | mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 5336 | mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
4785 | fprintf(fp, "DIV %s, %s\n", LSCRIPTTypeNames[mRightType], LSCRIPTTypeNames[mLeftType]); | 5337 | fprintf(fp, "DIV %s, %s\n", LSCRIPTTypeNames[mRightType], LSCRIPTTypeNames[mLeftType]); |
4786 | print_asignment(fp, mLValue); | 5338 | print_assignment(fp, mLValue); |
4787 | } | 5339 | } |
4788 | break; | 5340 | break; |
4789 | case LSCP_TYPE: | 5341 | case LSCP_TYPE: |
@@ -4811,12 +5363,12 @@ void LLScriptDivAssignment::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCo | |||
4811 | case LSCP_EMIT_CIL_ASSEMBLY: | 5363 | case LSCP_EMIT_CIL_ASSEMBLY: |
4812 | { | 5364 | { |
4813 | print_cil_load_address(fp, mLValue, entry); | 5365 | print_cil_load_address(fp, mLValue, entry); |
4814 | mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
4815 | print_cil_numeric_cast(fp, mLValue->mReturnType, mRightSide->mReturnType); | ||
4816 | mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 5366 | mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
4817 | print_cil_numeric_cast(fp, mRightSide->mReturnType, mLValue->mReturnType); | 5367 | print_cil_numeric_cast(fp, mRightSide->mReturnType, mLValue->mReturnType); |
5368 | mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
5369 | print_cil_numeric_cast(fp, mLValue->mReturnType, mRightSide->mReturnType); | ||
4818 | print_cil_div(fp, mLValue->mReturnType, mRightSide->mReturnType); | 5370 | print_cil_div(fp, mLValue->mReturnType, mRightSide->mReturnType); |
4819 | print_cil_asignment(fp, mLValue, entry); | 5371 | print_cil_assignment(fp, mLValue, entry); |
4820 | } | 5372 | } |
4821 | break; | 5373 | break; |
4822 | default: | 5374 | default: |
@@ -4832,20 +5384,20 @@ S32 LLScriptDivAssignment::getSize() | |||
4832 | return 0; | 5384 | return 0; |
4833 | } | 5385 | } |
4834 | 5386 | ||
4835 | void print_cil_mod(LLFILE* fp, LSCRIPTType left_type, LSCRIPTType right_type) | 5387 | static void print_cil_mod(LLFILE* fp, LSCRIPTType left_type, LSCRIPTType right_type) |
4836 | { | 5388 | { |
4837 | switch(left_type) | 5389 | switch(left_type) |
4838 | { | 5390 | { |
4839 | case LST_INTEGER: | 5391 | case LST_INTEGER: |
4840 | 5392 | ||
4841 | // Numeric remainder. | 5393 | // Numeric remainder. |
4842 | fprintf(fp, "rem\n"); | 5394 | fprintf(fp, "call int32 [LslUserScript]LindenLab.SecondLife.LslUserScript::Modulo(int32, int32)\n"); |
4843 | break; | 5395 | break; |
4844 | 5396 | ||
4845 | case LST_VECTOR: | 5397 | case LST_VECTOR: |
4846 | 5398 | ||
4847 | // Vector cross product. | 5399 | // Vector cross product. |
4848 | fprintf(fp, "call valuetype [LScriptLibrary]LLVector valuetype [LScriptLibrary]LLVector::'mod_vec'(valuetype [LScriptLibrary]LLVector, valuetype [LScriptLibrary]LLVector)\n"); | 5400 | fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Vector class [LslUserScript]LindenLab.SecondLife.LslUserScript::'Modulo'(class [ScriptTypes]LindenLab.SecondLife.Vector, class [ScriptTypes]LindenLab.SecondLife.Vector)\n"); |
4849 | break; | 5401 | break; |
4850 | 5402 | ||
4851 | default: | 5403 | default: |
@@ -4873,7 +5425,7 @@ void LLScriptModAssignment::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCo | |||
4873 | mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 5425 | mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
4874 | mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 5426 | mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
4875 | fprintf(fp, "MOD %s, %s\n", LSCRIPTTypeNames[mRightType], LSCRIPTTypeNames[mLeftType]); | 5427 | fprintf(fp, "MOD %s, %s\n", LSCRIPTTypeNames[mRightType], LSCRIPTTypeNames[mLeftType]); |
4876 | print_asignment(fp, mLValue); | 5428 | print_assignment(fp, mLValue); |
4877 | } | 5429 | } |
4878 | break; | 5430 | break; |
4879 | case LSCP_TYPE: | 5431 | case LSCP_TYPE: |
@@ -4901,10 +5453,10 @@ void LLScriptModAssignment::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCo | |||
4901 | case LSCP_EMIT_CIL_ASSEMBLY: | 5453 | case LSCP_EMIT_CIL_ASSEMBLY: |
4902 | { | 5454 | { |
4903 | print_cil_load_address(fp, mLValue, entry); | 5455 | print_cil_load_address(fp, mLValue, entry); |
4904 | mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
4905 | mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 5456 | mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
5457 | mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
4906 | print_cil_mod(fp, mLValue->mReturnType, mRightSide->mReturnType); | 5458 | print_cil_mod(fp, mLValue->mReturnType, mRightSide->mReturnType); |
4907 | print_cil_asignment(fp, mLValue, entry); | 5459 | print_cil_assignment(fp, mLValue, entry); |
4908 | } | 5460 | } |
4909 | break; | 5461 | break; |
4910 | default: | 5462 | default: |
@@ -4920,9 +5472,10 @@ S32 LLScriptModAssignment::getSize() | |||
4920 | return 0; | 5472 | return 0; |
4921 | } | 5473 | } |
4922 | 5474 | ||
4923 | void print_cil_eq(LLFILE* fp, LSCRIPTType left_type, LSCRIPTType right_type) | 5475 | static void print_cil_eq(LLFILE* fp, LSCRIPTType left_type, LSCRIPTType right_type) |
4924 | { | 5476 | { |
4925 | switch(left_type) | 5477 | |
5478 | switch(right_type) | ||
4926 | { | 5479 | { |
4927 | case LST_INTEGER: | 5480 | case LST_INTEGER: |
4928 | case LST_FLOATINGPOINT: | 5481 | case LST_FLOATINGPOINT: |
@@ -4932,26 +5485,36 @@ void print_cil_eq(LLFILE* fp, LSCRIPTType left_type, LSCRIPTType right_type) | |||
4932 | break; | 5485 | break; |
4933 | 5486 | ||
4934 | case LST_STRING: | 5487 | case LST_STRING: |
4935 | case LST_KEY: | 5488 | // NOTE: babbage: strings and keys can be compared, so a cast |
4936 | 5489 | // may be required | |
5490 | print_cil_cast(fp, left_type, right_type); | ||
4937 | // String equality. | 5491 | // String equality. |
4938 | fprintf(fp, "call bool valuetype [mscorlib]System.String::op_Equality(string, string)\n"); | 5492 | fprintf(fp, "call bool valuetype [mscorlib]System.String::op_Equality(string, string)\n"); |
4939 | break; | 5493 | break; |
5494 | |||
5495 | case LST_KEY: | ||
5496 | // NOTE: babbage: strings and keys can be compared, so a cast | ||
5497 | // may be required | ||
5498 | print_cil_cast(fp, left_type, right_type); | ||
5499 | |||
5500 | // Key equality. | ||
5501 | fprintf(fp, "call int32 [LslUserScript]LindenLab.SecondLife.LslUserScript::'Equals'(valuetype [ScriptTypes]LindenLab.SecondLife.Key, valuetype [ScriptTypes]LindenLab.SecondLife.Key)\n"); | ||
5502 | break; | ||
4940 | 5503 | ||
4941 | case LST_VECTOR: | 5504 | case LST_VECTOR: |
4942 | 5505 | ||
4943 | // Vector equality. | 5506 | // Vector equality. |
4944 | fprintf(fp, "call bool [LScriptLibrary]LLVector::'equals_vec'(valuetype [LScriptLibrary]LLVector, valuetype [LScriptLibrary]LLVector)\n"); | 5507 | fprintf(fp, "call int32 [LslUserScript]LindenLab.SecondLife.LslUserScript::'Equals'(class [ScriptTypes]LindenLab.SecondLife.Vector, class [ScriptTypes]LindenLab.SecondLife.Vector)\n"); |
4945 | break; | 5508 | break; |
4946 | 5509 | ||
4947 | case LST_QUATERNION: | 5510 | case LST_QUATERNION: |
4948 | 5511 | ||
4949 | // Rotation equality. | 5512 | // Rotation equality. |
4950 | fprintf(fp, "call bool [LScriptLibrary]LLQuaternion::'equals_quat'(valuetype [LScriptLibrary]LLQuaternion, valuetype [LScriptLibrary]LLQuaternion)\n"); | 5513 | fprintf(fp, "call int32 [LslUserScript]LindenLab.SecondLife.LslUserScript::'Equals'(class [ScriptTypes]LindenLab.SecondLife.Quaternion, class [ScriptTypes]LindenLab.SecondLife.Quaternion)\n"); |
4951 | break; | 5514 | break; |
4952 | 5515 | ||
4953 | case LST_LIST: | 5516 | case LST_LIST: |
4954 | fprintf(fp, "call bool [LScriptLibrary]LScriptInternal::EqualsList(class [mscorlib]System.Collections.ArrayList, class [mscorlib]System.Collections.ArrayList)\n"); | 5517 | fprintf(fp, "call int32 [LslUserScript]LindenLab.SecondLife.LslUserScript::Equals(class [mscorlib]System.Collections.ArrayList, class [mscorlib]System.Collections.ArrayList)\n"); |
4955 | break; | 5518 | break; |
4956 | 5519 | ||
4957 | default: | 5520 | default: |
@@ -5002,10 +5565,10 @@ void LLScriptEquality::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompile | |||
5002 | } | 5565 | } |
5003 | break; | 5566 | break; |
5004 | case LSCP_EMIT_CIL_ASSEMBLY: | 5567 | case LSCP_EMIT_CIL_ASSEMBLY: |
5005 | mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
5006 | print_cil_numeric_cast(fp, mLeftSide->mReturnType, mRightSide->mReturnType); | ||
5007 | mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 5568 | mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
5008 | print_cil_numeric_cast(fp, mRightSide->mReturnType, mLeftSide->mReturnType); | 5569 | print_cil_numeric_cast(fp, mRightSide->mReturnType, mLeftSide->mReturnType); |
5570 | mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
5571 | print_cil_numeric_cast(fp, mLeftSide->mReturnType, mRightSide->mReturnType); | ||
5009 | print_cil_eq(fp, mLeftSide->mReturnType, mRightSide->mReturnType); | 5572 | print_cil_eq(fp, mLeftSide->mReturnType, mRightSide->mReturnType); |
5010 | break; | 5573 | break; |
5011 | default: | 5574 | default: |
@@ -5063,10 +5626,19 @@ void LLScriptNotEquals::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompil | |||
5063 | break; | 5626 | break; |
5064 | case LSCP_EMIT_CIL_ASSEMBLY: | 5627 | case LSCP_EMIT_CIL_ASSEMBLY: |
5065 | mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 5628 | mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
5629 | print_cil_numeric_cast(fp, mRightSide->mReturnType, mLeftSide->mReturnType); | ||
5066 | mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 5630 | mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
5067 | fprintf(fp, "ceq\n"); | 5631 | print_cil_numeric_cast(fp, mLeftSide->mReturnType, mRightSide->mReturnType); |
5068 | fprintf(fp, "ldc.i4.0\n"); | 5632 | if (LST_LIST == mLeftSide->mReturnType) |
5069 | fprintf(fp, "ceq\n"); // Compare result of first compare equal with 0 to get compare not equal. | 5633 | { |
5634 | fprintf(fp, "call int32 [LslUserScript]LindenLab.SecondLife.LslUserScript::NotEquals(class [mscorlib]System.Collections.ArrayList, class [mscorlib]System.Collections.ArrayList)\n"); | ||
5635 | } | ||
5636 | else | ||
5637 | { | ||
5638 | print_cil_eq(fp, mLeftSide->mReturnType, mRightSide->mReturnType); | ||
5639 | fprintf(fp, "ldc.i4.0\n"); | ||
5640 | fprintf(fp, "ceq\n"); // Compare result of first compare equal with 0 to get compare not equal. | ||
5641 | } | ||
5070 | break; | 5642 | break; |
5071 | default: | 5643 | default: |
5072 | mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 5644 | mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
@@ -5081,6 +5653,14 @@ S32 LLScriptNotEquals::getSize() | |||
5081 | return 0; | 5653 | return 0; |
5082 | } | 5654 | } |
5083 | 5655 | ||
5656 | static void print_cil_lte(LLFILE* fp) | ||
5657 | { | ||
5658 | // NOTE: LSL pushes operands backwards, so <= becomes >= | ||
5659 | fprintf(fp, "clt\n"); | ||
5660 | fprintf(fp, "ldc.i4.0\n"); | ||
5661 | fprintf(fp, "ceq\n"); | ||
5662 | } | ||
5663 | |||
5084 | void LLScriptLessEquals::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata) | 5664 | void LLScriptLessEquals::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata) |
5085 | { | 5665 | { |
5086 | if (gErrorToText.getErrors()) | 5666 | if (gErrorToText.getErrors()) |
@@ -5122,11 +5702,11 @@ void LLScriptLessEquals::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompi | |||
5122 | } | 5702 | } |
5123 | break; | 5703 | break; |
5124 | case LSCP_EMIT_CIL_ASSEMBLY: | 5704 | case LSCP_EMIT_CIL_ASSEMBLY: |
5125 | mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
5126 | mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 5705 | mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
5127 | fprintf(fp, "cgt\n"); // Test greater than. | 5706 | print_cil_numeric_cast(fp, mRightSide->mReturnType, mLeftSide->mReturnType); |
5128 | fprintf(fp, "ldc.i4.0\n"); // Use (b == 0) implementation of boolean not. | 5707 | mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
5129 | fprintf(fp, "ceq\n"); // Apply boolean not to greater than. If not greater than, then less or equal. | 5708 | print_cil_numeric_cast(fp, mLeftSide->mReturnType, mRightSide->mReturnType); |
5709 | print_cil_lte(fp); | ||
5130 | break; | 5710 | break; |
5131 | default: | 5711 | default: |
5132 | mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 5712 | mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
@@ -5141,6 +5721,14 @@ S32 LLScriptLessEquals::getSize() | |||
5141 | return 0; | 5721 | return 0; |
5142 | } | 5722 | } |
5143 | 5723 | ||
5724 | static void print_cil_gte(LLFILE* fp) | ||
5725 | { | ||
5726 | // NOTE: LSL pushes operands backwards, so >= becomes <= | ||
5727 | fprintf(fp, "cgt\n"); | ||
5728 | fprintf(fp, "ldc.i4.0\n"); | ||
5729 | fprintf(fp, "ceq\n"); | ||
5730 | } | ||
5731 | |||
5144 | void LLScriptGreaterEquals::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata) | 5732 | void LLScriptGreaterEquals::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata) |
5145 | { | 5733 | { |
5146 | if (gErrorToText.getErrors()) | 5734 | if (gErrorToText.getErrors()) |
@@ -5182,11 +5770,11 @@ void LLScriptGreaterEquals::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCo | |||
5182 | } | 5770 | } |
5183 | break; | 5771 | break; |
5184 | case LSCP_EMIT_CIL_ASSEMBLY: | 5772 | case LSCP_EMIT_CIL_ASSEMBLY: |
5185 | mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
5186 | mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 5773 | mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
5187 | fprintf(fp, "clt\n"); // Test less than. | 5774 | print_cil_numeric_cast(fp, mRightSide->mReturnType, mLeftSide->mReturnType); |
5188 | fprintf(fp, "ldc.i4.0\n"); // Use (b == 0) implementation of boolean not. | 5775 | mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
5189 | fprintf(fp, "ceq\n"); // Apply boolean not to less than. If not less than, then greater or equal. | 5776 | print_cil_numeric_cast(fp, mLeftSide->mReturnType, mRightSide->mReturnType); |
5777 | print_cil_gte(fp); | ||
5190 | break; | 5778 | break; |
5191 | default: | 5779 | default: |
5192 | mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 5780 | mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
@@ -5201,6 +5789,12 @@ S32 LLScriptGreaterEquals::getSize() | |||
5201 | return 0; | 5789 | return 0; |
5202 | } | 5790 | } |
5203 | 5791 | ||
5792 | static void print_cil_lt(LLFILE* fp) | ||
5793 | { | ||
5794 | // NOTE: LSL pushes operands backwards, so < becomes > | ||
5795 | fprintf(fp, "cgt\n"); | ||
5796 | } | ||
5797 | |||
5204 | void LLScriptLessThan::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata) | 5798 | void LLScriptLessThan::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata) |
5205 | { | 5799 | { |
5206 | if (gErrorToText.getErrors()) | 5800 | if (gErrorToText.getErrors()) |
@@ -5242,9 +5836,11 @@ void LLScriptLessThan::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompile | |||
5242 | } | 5836 | } |
5243 | break; | 5837 | break; |
5244 | case LSCP_EMIT_CIL_ASSEMBLY: | 5838 | case LSCP_EMIT_CIL_ASSEMBLY: |
5245 | mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
5246 | mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 5839 | mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
5247 | fprintf(fp, "clt\n"); | 5840 | print_cil_numeric_cast(fp, mRightSide->mReturnType, mLeftSide->mReturnType); |
5841 | mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
5842 | print_cil_numeric_cast(fp, mLeftSide->mReturnType, mRightSide->mReturnType); | ||
5843 | print_cil_lt(fp); | ||
5248 | break; | 5844 | break; |
5249 | default: | 5845 | default: |
5250 | mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 5846 | mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
@@ -5259,6 +5855,12 @@ S32 LLScriptLessThan::getSize() | |||
5259 | return 0; | 5855 | return 0; |
5260 | } | 5856 | } |
5261 | 5857 | ||
5858 | static void print_cil_gt(LLFILE* fp) | ||
5859 | { | ||
5860 | // NOTE: LSL pushes operands backwards, so > becomes < | ||
5861 | fprintf(fp, "clt\n"); | ||
5862 | } | ||
5863 | |||
5262 | void LLScriptGreaterThan::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata) | 5864 | void LLScriptGreaterThan::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata) |
5263 | { | 5865 | { |
5264 | if (gErrorToText.getErrors()) | 5866 | if (gErrorToText.getErrors()) |
@@ -5300,9 +5902,11 @@ void LLScriptGreaterThan::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTComp | |||
5300 | } | 5902 | } |
5301 | break; | 5903 | break; |
5302 | case LSCP_EMIT_CIL_ASSEMBLY: | 5904 | case LSCP_EMIT_CIL_ASSEMBLY: |
5303 | mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
5304 | mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 5905 | mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
5305 | fprintf(fp, "cgt\n"); | 5906 | print_cil_numeric_cast(fp, mRightSide->mReturnType, mLeftSide->mReturnType); |
5907 | mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
5908 | print_cil_numeric_cast(fp, mLeftSide->mReturnType, mRightSide->mReturnType); | ||
5909 | print_cil_gt(fp); | ||
5306 | break; | 5910 | break; |
5307 | default: | 5911 | default: |
5308 | mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 5912 | mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
@@ -5358,10 +5962,10 @@ void LLScriptPlus::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass | |||
5358 | } | 5962 | } |
5359 | break; | 5963 | break; |
5360 | case LSCP_EMIT_CIL_ASSEMBLY: | 5964 | case LSCP_EMIT_CIL_ASSEMBLY: |
5361 | mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
5362 | print_cil_numeric_cast(fp, mLeftSide->mReturnType, mRightSide->mReturnType); | ||
5363 | mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 5965 | mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
5364 | print_cil_numeric_cast(fp, mRightSide->mReturnType, mLeftSide->mReturnType); | 5966 | print_cil_numeric_cast(fp, mRightSide->mReturnType, mLeftSide->mReturnType); |
5967 | mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
5968 | print_cil_numeric_cast(fp, mLeftSide->mReturnType, mRightSide->mReturnType); | ||
5365 | print_cil_add(fp, mLeftSide->mReturnType, mRightSide->mReturnType); | 5969 | print_cil_add(fp, mLeftSide->mReturnType, mRightSide->mReturnType); |
5366 | break; | 5970 | break; |
5367 | default: | 5971 | default: |
@@ -5418,10 +6022,10 @@ void LLScriptMinus::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePas | |||
5418 | } | 6022 | } |
5419 | break; | 6023 | break; |
5420 | case LSCP_EMIT_CIL_ASSEMBLY: | 6024 | case LSCP_EMIT_CIL_ASSEMBLY: |
5421 | mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
5422 | print_cil_numeric_cast(fp, mLeftSide->mReturnType, mRightSide->mReturnType); | ||
5423 | mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 6025 | mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
5424 | print_cil_numeric_cast(fp, mRightSide->mReturnType, mLeftSide->mReturnType); | 6026 | print_cil_numeric_cast(fp, mRightSide->mReturnType, mLeftSide->mReturnType); |
6027 | mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
6028 | print_cil_numeric_cast(fp, mLeftSide->mReturnType, mRightSide->mReturnType); | ||
5425 | print_cil_sub(fp, mLeftSide->mReturnType, mRightSide->mReturnType); | 6029 | print_cil_sub(fp, mLeftSide->mReturnType, mRightSide->mReturnType); |
5426 | break; | 6030 | break; |
5427 | default: | 6031 | default: |
@@ -5478,10 +6082,10 @@ void LLScriptTimes::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePas | |||
5478 | } | 6082 | } |
5479 | break; | 6083 | break; |
5480 | case LSCP_EMIT_CIL_ASSEMBLY: | 6084 | case LSCP_EMIT_CIL_ASSEMBLY: |
5481 | mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
5482 | print_cil_numeric_cast(fp, mLeftSide->mReturnType, mRightSide->mReturnType); | ||
5483 | mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 6085 | mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
5484 | print_cil_numeric_cast(fp, mRightSide->mReturnType, mLeftSide->mReturnType); | 6086 | print_cil_numeric_cast(fp, mRightSide->mReturnType, mLeftSide->mReturnType); |
6087 | mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
6088 | print_cil_numeric_cast(fp, mLeftSide->mReturnType, mRightSide->mReturnType); | ||
5485 | print_cil_mul(fp, mLeftSide->mReturnType, mRightSide->mReturnType); | 6089 | print_cil_mul(fp, mLeftSide->mReturnType, mRightSide->mReturnType); |
5486 | break; | 6090 | break; |
5487 | default: | 6091 | default: |
@@ -5538,10 +6142,10 @@ void LLScriptDivide::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePa | |||
5538 | } | 6142 | } |
5539 | break; | 6143 | break; |
5540 | case LSCP_EMIT_CIL_ASSEMBLY: | 6144 | case LSCP_EMIT_CIL_ASSEMBLY: |
5541 | mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
5542 | print_cil_numeric_cast(fp, mLeftSide->mReturnType, mRightSide->mReturnType); | ||
5543 | mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 6145 | mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
5544 | print_cil_numeric_cast(fp, mRightSide->mReturnType, mLeftSide->mReturnType); | 6146 | print_cil_numeric_cast(fp, mRightSide->mReturnType, mLeftSide->mReturnType); |
6147 | mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
6148 | print_cil_numeric_cast(fp, mLeftSide->mReturnType, mRightSide->mReturnType); | ||
5545 | print_cil_div(fp, mLeftSide->mReturnType, mRightSide->mReturnType); | 6149 | print_cil_div(fp, mLeftSide->mReturnType, mRightSide->mReturnType); |
5546 | break; | 6150 | break; |
5547 | default: | 6151 | default: |
@@ -5598,8 +6202,8 @@ void LLScriptMod::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass | |||
5598 | } | 6202 | } |
5599 | break; | 6203 | break; |
5600 | case LSCP_EMIT_CIL_ASSEMBLY: | 6204 | case LSCP_EMIT_CIL_ASSEMBLY: |
5601 | mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
5602 | mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 6205 | mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
6206 | mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
5603 | print_cil_mod(fp, mLeftSide->mReturnType, mRightSide->mReturnType); | 6207 | print_cil_mod(fp, mLeftSide->mReturnType, mRightSide->mReturnType); |
5604 | break; | 6208 | break; |
5605 | default: | 6209 | default: |
@@ -5654,8 +6258,8 @@ void LLScriptBitAnd::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePa | |||
5654 | } | 6258 | } |
5655 | break; | 6259 | break; |
5656 | case LSCP_EMIT_CIL_ASSEMBLY: | 6260 | case LSCP_EMIT_CIL_ASSEMBLY: |
5657 | mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
5658 | mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 6261 | mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
6262 | mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
5659 | fprintf(fp, "and\n"); | 6263 | fprintf(fp, "and\n"); |
5660 | break; | 6264 | break; |
5661 | default: | 6265 | default: |
@@ -5710,8 +6314,8 @@ void LLScriptBitOr::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePas | |||
5710 | } | 6314 | } |
5711 | break; | 6315 | break; |
5712 | case LSCP_EMIT_CIL_ASSEMBLY: | 6316 | case LSCP_EMIT_CIL_ASSEMBLY: |
5713 | mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
5714 | mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 6317 | mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
6318 | mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
5715 | fprintf(fp, "or\n"); | 6319 | fprintf(fp, "or\n"); |
5716 | break; | 6320 | break; |
5717 | default: | 6321 | default: |
@@ -5766,8 +6370,8 @@ void LLScriptBitXor::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePa | |||
5766 | } | 6370 | } |
5767 | break; | 6371 | break; |
5768 | case LSCP_EMIT_CIL_ASSEMBLY: | 6372 | case LSCP_EMIT_CIL_ASSEMBLY: |
5769 | mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
5770 | mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 6373 | mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
6374 | mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
5771 | fprintf(fp, "xor\n"); | 6375 | fprintf(fp, "xor\n"); |
5772 | break; | 6376 | break; |
5773 | default: | 6377 | default: |
@@ -5822,9 +6426,15 @@ void LLScriptBooleanAnd::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompi | |||
5822 | } | 6426 | } |
5823 | break; | 6427 | break; |
5824 | case LSCP_EMIT_CIL_ASSEMBLY: | 6428 | case LSCP_EMIT_CIL_ASSEMBLY: |
5825 | mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
5826 | mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 6429 | mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
5827 | fprintf(fp, "and\n"); | 6430 | fprintf(fp, "ldc.i4.0\n"); |
6431 | fprintf(fp, "ceq\n"); | ||
6432 | mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
6433 | fprintf(fp, "ldc.i4.0\n"); | ||
6434 | fprintf(fp, "ceq\n"); | ||
6435 | fprintf(fp, "or\n"); | ||
6436 | fprintf(fp, "ldc.i4.0\n"); | ||
6437 | fprintf(fp, "ceq\n"); | ||
5828 | break; | 6438 | break; |
5829 | default: | 6439 | default: |
5830 | mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 6440 | mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
@@ -5881,6 +6491,10 @@ void LLScriptBooleanOr::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompil | |||
5881 | mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 6491 | mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
5882 | mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 6492 | mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
5883 | fprintf(fp, "or\n"); | 6493 | fprintf(fp, "or\n"); |
6494 | fprintf(fp, "ldc.i4.0\n"); | ||
6495 | fprintf(fp, "ceq\n"); | ||
6496 | fprintf(fp, "ldc.i4.0\n"); | ||
6497 | fprintf(fp, "ceq\n"); | ||
5884 | break; | 6498 | break; |
5885 | default: | 6499 | default: |
5886 | mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 6500 | mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
@@ -5934,9 +6548,9 @@ void LLScriptShiftLeft::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompil | |||
5934 | } | 6548 | } |
5935 | break; | 6549 | break; |
5936 | case LSCP_EMIT_CIL_ASSEMBLY: | 6550 | case LSCP_EMIT_CIL_ASSEMBLY: |
5937 | mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
5938 | mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 6551 | mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
5939 | fprintf(fp, "shl\n"); | 6552 | mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
6553 | fprintf(fp, "call int32 [LslUserScript]LindenLab.SecondLife.LslUserScript::ShiftLeft(int32, int32)\n"); | ||
5940 | break; | 6554 | break; |
5941 | default: | 6555 | default: |
5942 | mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 6556 | mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
@@ -5991,9 +6605,9 @@ void LLScriptShiftRight::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompi | |||
5991 | } | 6605 | } |
5992 | break; | 6606 | break; |
5993 | case LSCP_EMIT_CIL_ASSEMBLY: | 6607 | case LSCP_EMIT_CIL_ASSEMBLY: |
5994 | mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
5995 | mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 6608 | mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
5996 | fprintf(fp, "shr\n"); | 6609 | mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
6610 | fprintf(fp, "call int32 [LslUserScript]LindenLab.SecondLife.LslUserScript::ShiftRight(int32, int32)\n"); | ||
5997 | break; | 6611 | break; |
5998 | default: | 6612 | default: |
5999 | mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 6613 | mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
@@ -6076,6 +6690,12 @@ void LLScriptUnaryMinus::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompi | |||
6076 | chunk->addByte(typebyte); | 6690 | chunk->addByte(typebyte); |
6077 | } | 6691 | } |
6078 | break; | 6692 | break; |
6693 | case LSCP_EMIT_CIL_ASSEMBLY: | ||
6694 | { | ||
6695 | mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
6696 | print_cil_neg(fp, mLeftType); | ||
6697 | } | ||
6698 | break; | ||
6079 | default: | 6699 | default: |
6080 | mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 6700 | mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
6081 | break; | 6701 | break; |
@@ -6219,7 +6839,7 @@ void LLScriptPreIncrement::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCom | |||
6219 | { | 6839 | { |
6220 | fprintf(fp, "Unexpected Type\n"); | 6840 | fprintf(fp, "Unexpected Type\n"); |
6221 | } | 6841 | } |
6222 | print_asignment(fp, mExpression); | 6842 | print_assignment(fp, mExpression); |
6223 | } | 6843 | } |
6224 | break; | 6844 | break; |
6225 | case LSCP_TYPE: | 6845 | case LSCP_TYPE: |
@@ -6266,21 +6886,21 @@ void LLScriptPreIncrement::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCom | |||
6266 | print_cil_load_address(fp, mExpression, entry); | 6886 | print_cil_load_address(fp, mExpression, entry); |
6267 | if (mReturnType == LST_INTEGER) | 6887 | if (mReturnType == LST_INTEGER) |
6268 | { | 6888 | { |
6269 | fprintf(fp, "ldc.i4.1\n"); | ||
6270 | mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 6889 | mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
6890 | fprintf(fp, "ldc.i4.1\n"); | ||
6271 | fprintf(fp, "add\n"); | 6891 | fprintf(fp, "add\n"); |
6272 | } | 6892 | } |
6273 | else if (mReturnType == LST_FLOATINGPOINT) | 6893 | else if (mReturnType == LST_FLOATINGPOINT) |
6274 | { | 6894 | { |
6275 | fprintf(fp, "ldc.r8.1\n"); | ||
6276 | mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 6895 | mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
6896 | fprintf(fp, "ldc.r8 1\n"); | ||
6277 | fprintf(fp, "add\n"); | 6897 | fprintf(fp, "add\n"); |
6278 | } | 6898 | } |
6279 | else | 6899 | else |
6280 | { | 6900 | { |
6281 | fprintf(fp, "Unexpected Type\n"); | 6901 | fprintf(fp, "Unexpected Type\n"); |
6282 | } | 6902 | } |
6283 | print_cil_asignment(fp, mExpression, entry); | 6903 | print_cil_assignment(fp, mExpression, entry); |
6284 | } | 6904 | } |
6285 | break; | 6905 | break; |
6286 | default: | 6906 | default: |
@@ -6327,7 +6947,7 @@ void LLScriptPreDecrement::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCom | |||
6327 | { | 6947 | { |
6328 | fprintf(fp, "Unexpected Type\n"); | 6948 | fprintf(fp, "Unexpected Type\n"); |
6329 | } | 6949 | } |
6330 | print_asignment(fp, mExpression); | 6950 | print_assignment(fp, mExpression); |
6331 | } | 6951 | } |
6332 | break; | 6952 | break; |
6333 | case LSCP_TYPE: | 6953 | case LSCP_TYPE: |
@@ -6374,21 +6994,21 @@ void LLScriptPreDecrement::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCom | |||
6374 | print_cil_load_address(fp, mExpression, entry); | 6994 | print_cil_load_address(fp, mExpression, entry); |
6375 | if (mReturnType == LST_INTEGER) | 6995 | if (mReturnType == LST_INTEGER) |
6376 | { | 6996 | { |
6377 | fprintf(fp, "ldc.i4.1\n"); | ||
6378 | mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 6997 | mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
6998 | fprintf(fp, "ldc.i4.1\n"); | ||
6379 | fprintf(fp, "sub\n"); | 6999 | fprintf(fp, "sub\n"); |
6380 | } | 7000 | } |
6381 | else if (mReturnType == LST_FLOATINGPOINT) | 7001 | else if (mReturnType == LST_FLOATINGPOINT) |
6382 | { | 7002 | { |
6383 | fprintf(fp, "ldc.r8.1\n"); | ||
6384 | mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 7003 | mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
7004 | fprintf(fp, "ldc.r8 1\n"); | ||
6385 | fprintf(fp, "sub\n"); | 7005 | fprintf(fp, "sub\n"); |
6386 | } | 7006 | } |
6387 | else | 7007 | else |
6388 | { | 7008 | { |
6389 | fprintf(fp, "Unexpected Type\n"); | 7009 | fprintf(fp, "Unexpected Type\n"); |
6390 | } | 7010 | } |
6391 | print_cil_asignment(fp, mExpression, entry); | 7011 | print_cil_assignment(fp, mExpression, entry); |
6392 | } | 7012 | } |
6393 | break; | 7013 | break; |
6394 | default: | 7014 | default: |
@@ -6555,7 +7175,7 @@ void LLScriptVectorInitializer::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRI | |||
6555 | print_cil_cast(fp, mExpression3->mReturnType, LST_FLOATINGPOINT); | 7175 | print_cil_cast(fp, mExpression3->mReturnType, LST_FLOATINGPOINT); |
6556 | } | 7176 | } |
6557 | // Call named ctor, which leaves new Vector on stack, so it can be saved in to local or argument just like a primitive type. | 7177 | // Call named ctor, which leaves new Vector on stack, so it can be saved in to local or argument just like a primitive type. |
6558 | fprintf(fp, "call valuetype [LScriptLibrary]LLVector valuetype [LScriptLibrary]LLVector::'create'(float32, float32, float32)\n"); | 7178 | fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Vector class [LslUserScript]LindenLab.SecondLife.LslUserScript::'CreateVector'(float32, float32, float32)\n"); |
6559 | break; | 7179 | break; |
6560 | default: | 7180 | default: |
6561 | mExpression1->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 7181 | mExpression1->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
@@ -6696,7 +7316,7 @@ void LLScriptQuaternionInitializer::recurse(LLFILE *fp, S32 tabs, S32 tabsize, L | |||
6696 | } | 7316 | } |
6697 | 7317 | ||
6698 | // Call named ctor, which leaves new Vector on stack, so it can be saved in to local or argument just like a primitive type. | 7318 | // Call named ctor, which leaves new Vector on stack, so it can be saved in to local or argument just like a primitive type. |
6699 | fprintf(fp, "call valuetype [LScriptLibrary]LLQuaternion valuetype [LScriptLibrary]LLQuaternion::'create'(float32, float32, float32, float32)\n"); | 7319 | fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Quaternion class [LslUserScript]LindenLab.SecondLife.LslUserScript::'CreateQuaternion'(float32, float32, float32, float32)\n"); |
6700 | break; | 7320 | break; |
6701 | default: | 7321 | default: |
6702 | mExpression1->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 7322 | mExpression1->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
@@ -6743,14 +7363,15 @@ void LLScriptListInitializer::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPT | |||
6743 | mReturnType = type = LST_LIST; | 7363 | mReturnType = type = LST_LIST; |
6744 | break; | 7364 | break; |
6745 | case LSCP_TO_STACK: | 7365 | case LSCP_TO_STACK: |
7366 | { | ||
6746 | if (mExpressionList) | 7367 | if (mExpressionList) |
6747 | { | 7368 | { |
6748 | pass = LSCP_TO_STACK; | 7369 | pass = LSCP_TO_STACK; |
6749 | count = 0; | 7370 | U64 list_element_count = 0; |
6750 | mExpressionList->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 7371 | mExpressionList->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, list_element_count, chunk, heap, stacksize, entry, entrycount, NULL); |
6751 | chunk->addByte(LSCRIPTOpCodes[LOPC_STACKTOL]); | 7372 | chunk->addByte(LSCRIPTOpCodes[LOPC_STACKTOL]); |
6752 | chunk->addInteger((S32)count); | 7373 | chunk->addInteger((S32)list_element_count); |
6753 | count = 0; | 7374 | |
6754 | } | 7375 | } |
6755 | else | 7376 | else |
6756 | { | 7377 | { |
@@ -6758,26 +7379,26 @@ void LLScriptListInitializer::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPT | |||
6758 | chunk->addInteger(0); | 7379 | chunk->addInteger(0); |
6759 | } | 7380 | } |
6760 | break; | 7381 | break; |
7382 | } | ||
6761 | case LSCP_EMIT_CIL_ASSEMBLY: | 7383 | case LSCP_EMIT_CIL_ASSEMBLY: |
6762 | 7384 | { | |
6763 | // Push boxed elements on stack. | 7385 | // Push boxed elements on stack. |
6764 | count = 0; | 7386 | U64 list_element_count = 0; |
6765 | if (mExpressionList) | 7387 | if (mExpressionList) |
6766 | { | 7388 | { |
6767 | mExpressionList->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 7389 | mExpressionList->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, list_element_count, chunk, heap, stacksize, entry, entrycount, NULL); |
6768 | } | 7390 | } |
6769 | 7391 | ||
6770 | // Create list on stack, consuming first boxed element. | 7392 | // Create list on stack. |
6771 | fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LScriptLibrary]LScriptInternal::CreateList()\n"); | 7393 | fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::CreateList()\n"); |
6772 | 7394 | ||
6773 | // Call AddReturnList to add remaining boxed expressions. | 7395 | // Call Prepend to add remaining boxed expressions. |
6774 | for(U64 i = 0; i < count; i++) | 7396 | for(U64 i = 0; i < list_element_count; i++) |
6775 | { | 7397 | { |
6776 | fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LScriptLibrary]LScriptInternal::AddReturnList(object, class [mscorlib]System.Collections.ArrayList)\n"); | 7398 | fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::Prepend(object, class [mscorlib]System.Collections.ArrayList)\n"); |
6777 | } | 7399 | } |
6778 | count = 0; | ||
6779 | |||
6780 | break; | 7400 | break; |
7401 | } | ||
6781 | default: | 7402 | default: |
6782 | if (mExpressionList) | 7403 | if (mExpressionList) |
6783 | { | 7404 | { |
@@ -6824,7 +7445,7 @@ void LLScriptPostIncrement::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCo | |||
6824 | { | 7445 | { |
6825 | fprintf(fp, "Unexpected Type\n"); | 7446 | fprintf(fp, "Unexpected Type\n"); |
6826 | } | 7447 | } |
6827 | print_asignment(fp, mExpression); | 7448 | print_assignment(fp, mExpression); |
6828 | fprintf(fp, "%s\n", LSCRIPTTypePop[mReturnType]); | 7449 | fprintf(fp, "%s\n", LSCRIPTTypePop[mReturnType]); |
6829 | } | 7450 | } |
6830 | break; | 7451 | break; |
@@ -6893,24 +7514,34 @@ void LLScriptPostIncrement::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCo | |||
6893 | break; | 7514 | break; |
6894 | case LSCP_EMIT_CIL_ASSEMBLY: | 7515 | case LSCP_EMIT_CIL_ASSEMBLY: |
6895 | { | 7516 | { |
7517 | // Push original value on to stack. | ||
7518 | mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
7519 | |||
7520 | // Load address if needed for store. | ||
6896 | print_cil_load_address(fp, mExpression, entry); | 7521 | print_cil_load_address(fp, mExpression, entry); |
7522 | |||
7523 | // Load value again. | ||
7524 | // TODO: Work out if sideeffects can result in 2 evaluations of expression giving different values. | ||
7525 | // Original LSL2 uses this method, so any bugs due to side effects will probably be identical ;-) | ||
6897 | mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 7526 | mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
6898 | fprintf(fp,"dup\n"); // Copy expression result to use as increment operand. | ||
6899 | if (mReturnType == LST_INTEGER) | 7527 | if (mReturnType == LST_INTEGER) |
6900 | { | 7528 | { |
6901 | fprintf(fp, "ldc.i4.1\n"); | 7529 | fprintf(fp, "ldc.i4.1\n"); |
6902 | } | 7530 | } |
6903 | else if (mReturnType == LST_FLOATINGPOINT) | 7531 | else if (mReturnType == LST_FLOATINGPOINT) |
6904 | { | 7532 | { |
6905 | fprintf(fp, "ldc.r8.1\n"); | 7533 | fprintf(fp, "ldc.r8 1\n"); |
6906 | } | 7534 | } |
6907 | else | 7535 | else |
6908 | { | 7536 | { |
6909 | fprintf(fp, "Unexpected Type\n"); | 7537 | fprintf(fp, "Unexpected Type\n"); |
6910 | } | 7538 | } |
6911 | fprintf(fp, "add\n"); | 7539 | fprintf(fp, "add\n"); |
6912 | print_cil_asignment(fp, mExpression, entry); | 7540 | print_cil_assignment(fp, mExpression, entry); |
6913 | fprintf(fp, "pop\n"); // Pop assignment result to leave original expression result on stack. TODO: Optimise away redundant pop/dup pairs. | 7541 | |
7542 | // Pop assignment result to leave original expression result on stack. | ||
7543 | // TODO: Optimise away redundant pop/dup pairs. | ||
7544 | fprintf(fp, "pop\n"); | ||
6914 | } | 7545 | } |
6915 | break; | 7546 | break; |
6916 | default: | 7547 | default: |
@@ -6956,7 +7587,7 @@ void LLScriptPostDecrement::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCo | |||
6956 | { | 7587 | { |
6957 | fprintf(fp, "Unexpected Type\n"); | 7588 | fprintf(fp, "Unexpected Type\n"); |
6958 | } | 7589 | } |
6959 | print_asignment(fp, mExpression); | 7590 | print_assignment(fp, mExpression); |
6960 | fprintf(fp, "%s\n", LSCRIPTTypePop[mReturnType]); | 7591 | fprintf(fp, "%s\n", LSCRIPTTypePop[mReturnType]); |
6961 | } | 7592 | } |
6962 | break; | 7593 | break; |
@@ -7025,24 +7656,34 @@ void LLScriptPostDecrement::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCo | |||
7025 | break; | 7656 | break; |
7026 | case LSCP_EMIT_CIL_ASSEMBLY: | 7657 | case LSCP_EMIT_CIL_ASSEMBLY: |
7027 | { | 7658 | { |
7659 | // Push original value on to stack. | ||
7660 | mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
7661 | |||
7662 | // Load address if needed for store. | ||
7028 | print_cil_load_address(fp, mExpression, entry); | 7663 | print_cil_load_address(fp, mExpression, entry); |
7664 | |||
7665 | // Load value again. | ||
7666 | // TODO: Work out if sideeffects can result in 2 evaluations of expression giving different values. | ||
7667 | // Original LSL2 uses this method, so any bugs due to side effects will probably be identical ;-) | ||
7029 | mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 7668 | mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
7030 | fprintf(fp,"dup\n"); // Copy expression result to use as decrement operand. | ||
7031 | if (mReturnType == LST_INTEGER) | 7669 | if (mReturnType == LST_INTEGER) |
7032 | { | 7670 | { |
7033 | fprintf(fp, "ldc.i4.1\n"); | 7671 | fprintf(fp, "ldc.i4.1\n"); |
7034 | } | 7672 | } |
7035 | else if (mReturnType == LST_FLOATINGPOINT) | 7673 | else if (mReturnType == LST_FLOATINGPOINT) |
7036 | { | 7674 | { |
7037 | fprintf(fp, "ldc.r8.1\n"); | 7675 | fprintf(fp, "ldc.r8 1\n"); |
7038 | } | 7676 | } |
7039 | else | 7677 | else |
7040 | { | 7678 | { |
7041 | fprintf(fp, "Unexpected Type\n"); | 7679 | fprintf(fp, "Unexpected Type\n"); |
7042 | } | 7680 | } |
7043 | fprintf(fp, "sub\n"); | 7681 | fprintf(fp, "sub\n"); |
7044 | print_cil_asignment(fp, mExpression, entry); | 7682 | print_cil_assignment(fp, mExpression, entry); |
7045 | fprintf(fp, "pop\n"); // Pop assignment result to leave original expression result on stack. TODO: Optimise away redundant pop/dup pairs. | 7683 | |
7684 | // Pop assignment result to leave original expression result on stack. | ||
7685 | // TODO: Optimise away redundant pop/dup pairs. | ||
7686 | fprintf(fp, "pop\n"); | ||
7046 | } | 7687 | } |
7047 | break; | 7688 | break; |
7048 | default: | 7689 | default: |
@@ -7058,16 +7699,19 @@ S32 LLScriptPostDecrement::getSize() | |||
7058 | } | 7699 | } |
7059 | 7700 | ||
7060 | // Generate arg list. | 7701 | // Generate arg list. |
7061 | void print_cil_arg_list(LLFILE *fp, LLScriptFuncExpressionList* exp_list) | 7702 | static void print_cil_arg_list(LLFILE *fp, LLScriptArgString& args) |
7062 | { | 7703 | { |
7063 | // Print first argument. | 7704 | int i = 0; |
7064 | print_cil_type(fp, exp_list->mFirstp->mReturnType); | 7705 | bool finished = (i >= args.getNumber()); |
7065 | 7706 | while(! finished) | |
7066 | // Recursively print next arguments. | ||
7067 | if(exp_list->mSecondp != NULL) | ||
7068 | { | 7707 | { |
7069 | fprintf(fp, ", "); | 7708 | print_cil_type(fp, args.getType(i)); |
7070 | print_cil_arg_list(fp, (LLScriptFuncExpressionList*) exp_list->mSecondp); | 7709 | ++i; |
7710 | finished = (i >= args.getNumber()); | ||
7711 | if(! finished) | ||
7712 | { | ||
7713 | fprintf(fp, ", "); | ||
7714 | } | ||
7071 | } | 7715 | } |
7072 | } | 7716 | } |
7073 | 7717 | ||
@@ -7146,7 +7790,7 @@ void LLScriptFunctionCall::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCom | |||
7146 | gErrorToText.writeError(fp, this, LSERROR_FUNCTION_TYPE_ERROR); | 7790 | gErrorToText.writeError(fp, this, LSERROR_FUNCTION_TYPE_ERROR); |
7147 | } | 7791 | } |
7148 | } | 7792 | } |
7149 | else if (argcount != strlen(mIdentifier->mScopeEntry->mFunctionArgs.mString)) /*Flawfinder: ignore*/ | 7793 | else if (argcount != strlen(mIdentifier->mScopeEntry->mFunctionArgs.mString)) |
7150 | { | 7794 | { |
7151 | gErrorToText.writeError(fp, this, LSERROR_FUNCTION_TYPE_ERROR); | 7795 | gErrorToText.writeError(fp, this, LSERROR_FUNCTION_TYPE_ERROR); |
7152 | } | 7796 | } |
@@ -7217,13 +7861,15 @@ void LLScriptFunctionCall::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCom | |||
7217 | // Load args on to stack. | 7861 | // Load args on to stack. |
7218 | if (mExpressionList) | 7862 | if (mExpressionList) |
7219 | { | 7863 | { |
7220 | mExpressionList->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry /* Needed for is_parameter calls */, 0, NULL); | 7864 | //mExpressionList->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry /* Needed for is_parameter calls */, 0, NULL); |
7865 | llassert(LET_FUNC_EXPRESSION_LIST == mExpressionList->mType); | ||
7866 | print_cil_func_expression_list((LLScriptFuncExpressionList*) mExpressionList, fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry /* Caller entry needed for is_parameter calls */, 0, NULL, mIdentifier->mScopeEntry /* Callee entry needed for argument casting */); | ||
7221 | } | 7867 | } |
7222 | 7868 | ||
7223 | // Make call. | 7869 | // Make call. |
7224 | if (! library_call) | 7870 | if (! library_call) |
7225 | { | 7871 | { |
7226 | fprintf(fp, "callvirt instance "); | 7872 | fprintf(fp, "call instance "); |
7227 | } | 7873 | } |
7228 | else | 7874 | else |
7229 | { | 7875 | { |
@@ -7233,16 +7879,18 @@ void LLScriptFunctionCall::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCom | |||
7233 | fprintf(fp, " class "); | 7879 | fprintf(fp, " class "); |
7234 | if (library_call) | 7880 | if (library_call) |
7235 | { | 7881 | { |
7236 | fprintf(fp, "[LScriptLibrary]LScriptLibrary"); | 7882 | fprintf(fp, "[LslLibrary]LindenLab.SecondLife.Library::'"); |
7237 | } | 7883 | } |
7238 | else | 7884 | else |
7239 | { | 7885 | { |
7240 | fprintf(fp, "LSL"); | 7886 | // Prefix function name with g to distinguish from |
7887 | // event handlers. | ||
7888 | fprintf(fp, gScriptp->getClassName()); | ||
7889 | fprintf(fp, "::'g"); | ||
7241 | } | 7890 | } |
7242 | fprintf(fp, "::"); | 7891 | fprintf(fp, mIdentifier->mName); |
7243 | mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 7892 | fprintf(fp, "'("); |
7244 | fprintf(fp, "("); | 7893 | print_cil_arg_list(fp, mIdentifier->mScopeEntry->mFunctionArgs); |
7245 | if (mExpressionList) {print_cil_arg_list(fp, (LLScriptFuncExpressionList*) mExpressionList);} | ||
7246 | fprintf(fp, ")\n"); | 7894 | fprintf(fp, ")\n"); |
7247 | } | 7895 | } |
7248 | break; | 7896 | break; |
@@ -7287,6 +7935,11 @@ void LLScriptPrint::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePas | |||
7287 | chunk->addByte(LSCRIPTOpCodes[LOPC_PRINT]); | 7935 | chunk->addByte(LSCRIPTOpCodes[LOPC_PRINT]); |
7288 | chunk->addByte(LSCRIPTTypeByte[mLeftType]); | 7936 | chunk->addByte(LSCRIPTTypeByte[mLeftType]); |
7289 | break; | 7937 | break; |
7938 | case LSCP_EMIT_CIL_ASSEMBLY: | ||
7939 | mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | ||
7940 | print_cil_cast(fp, mLeftType, LST_STRING); | ||
7941 | fprintf(fp, "call void class [LslLibrary]LindenLab.SecondLife.Library::Print(string)"); | ||
7942 | break; | ||
7290 | default: | 7943 | default: |
7291 | mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 7944 | mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
7292 | break; | 7945 | break; |
@@ -7404,8 +8057,19 @@ void LLScriptStatementSequence::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRI | |||
7404 | mFirstp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 8057 | mFirstp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
7405 | if (prunearg) | 8058 | if (prunearg) |
7406 | { | 8059 | { |
8060 | // babbage: only warn on first dead code block found. | ||
8061 | if(ptype != LSPRUNE_DEAD_CODE) | ||
8062 | { | ||
8063 | gErrorToText.writeWarning(fp, this, LSWARN_DEAD_CODE); | ||
8064 | } | ||
8065 | |||
8066 | // babbage: set prune type to LSPRUNE_DEAD_CODE to mask other | ||
8067 | // prune errors. | ||
7407 | ptype = LSPRUNE_DEAD_CODE; | 8068 | ptype = LSPRUNE_DEAD_CODE; |
7408 | gErrorToText.writeWarning(fp, this, LSWARN_DEAD_CODE); | 8069 | |
8070 | // babbage: reset prunearg, to track whether return needed at | ||
8071 | // end of dead code path as CIL always needs a return/throw. | ||
8072 | prunearg = FALSE; | ||
7409 | } | 8073 | } |
7410 | mSecondp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 8074 | mSecondp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
7411 | break; | 8075 | break; |
@@ -7444,10 +8108,7 @@ void LLScriptNOOP::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass | |||
7444 | fprintf(fp, ";\n"); | 8108 | fprintf(fp, ";\n"); |
7445 | break; | 8109 | break; |
7446 | case LSCP_PRUNE: | 8110 | case LSCP_PRUNE: |
7447 | if (ptype == LSPRUNE_DEAD_CODE) | 8111 | prunearg = FALSE; |
7448 | prunearg = TRUE; | ||
7449 | else | ||
7450 | prunearg = FALSE; | ||
7451 | break; | 8112 | break; |
7452 | default: | 8113 | default: |
7453 | break; | 8114 | break; |
@@ -7462,7 +8123,7 @@ void add_exit_pops(LLScriptByteCodeChunk *chunk, LLScriptScopeEntry *entry) | |||
7462 | 8123 | ||
7463 | if (entry->mLocals.mString) | 8124 | if (entry->mLocals.mString) |
7464 | { | 8125 | { |
7465 | number = (S32)strlen(entry->mLocals.mString); /*Flawfinder: ignore*/ | 8126 | number = (S32)strlen(entry->mLocals.mString); |
7466 | for (i = number - 1; i >= 0; i--) | 8127 | for (i = number - 1; i >= 0; i--) |
7467 | { | 8128 | { |
7468 | switch(entry->mLocals.getType(i)) | 8129 | switch(entry->mLocals.getType(i)) |
@@ -7495,7 +8156,7 @@ void add_exit_pops(LLScriptByteCodeChunk *chunk, LLScriptScopeEntry *entry) | |||
7495 | 8156 | ||
7496 | if (entry->mFunctionArgs.mString) | 8157 | if (entry->mFunctionArgs.mString) |
7497 | { | 8158 | { |
7498 | number = (S32)strlen(entry->mFunctionArgs.mString); /*Flawfinder: ignore*/ | 8159 | number = (S32)strlen(entry->mFunctionArgs.mString); |
7499 | for (i = number - 1; i >= 0; i--) | 8160 | for (i = number - 1; i >= 0; i--) |
7500 | { | 8161 | { |
7501 | switch(entry->mFunctionArgs.getType(i)) | 8162 | switch(entry->mFunctionArgs.getType(i)) |
@@ -7534,7 +8195,7 @@ void print_exit_pops(LLFILE *fp, LLScriptScopeEntry *entry) | |||
7534 | 8195 | ||
7535 | if (entry->mLocals.mString) | 8196 | if (entry->mLocals.mString) |
7536 | { | 8197 | { |
7537 | number = (S32)strlen(entry->mLocals.mString); /*Flawfinder: ignore*/ | 8198 | number = (S32)strlen(entry->mLocals.mString); |
7538 | for (i = number - 1; i >= 0; i--) | 8199 | for (i = number - 1; i >= 0; i--) |
7539 | { | 8200 | { |
7540 | fprintf(fp, "%s", LSCRIPTTypePop[entry->mLocals.getType(i)]); | 8201 | fprintf(fp, "%s", LSCRIPTTypePop[entry->mLocals.getType(i)]); |
@@ -7543,7 +8204,7 @@ void print_exit_pops(LLFILE *fp, LLScriptScopeEntry *entry) | |||
7543 | 8204 | ||
7544 | if (entry->mFunctionArgs.mString) | 8205 | if (entry->mFunctionArgs.mString) |
7545 | { | 8206 | { |
7546 | number = (S32)strlen(entry->mFunctionArgs.mString); /*Flawfinder: ignore*/ | 8207 | number = (S32)strlen(entry->mFunctionArgs.mString); |
7547 | for (i = number - 1; i >= 0; i--) | 8208 | for (i = number - 1; i >= 0; i--) |
7548 | { | 8209 | { |
7549 | fprintf(fp, "%s", LSCRIPTTypePop[entry->mFunctionArgs.getType(i)]); | 8210 | fprintf(fp, "%s", LSCRIPTTypePop[entry->mFunctionArgs.getType(i)]); |
@@ -7583,10 +8244,7 @@ void LLScriptStateChange::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTComp | |||
7583 | { | 8244 | { |
7584 | gErrorToText.writeError(fp, this, LSERROR_STATE_CHANGE_IN_GLOBAL); | 8245 | gErrorToText.writeError(fp, this, LSERROR_STATE_CHANGE_IN_GLOBAL); |
7585 | } | 8246 | } |
7586 | if (ptype == LSPRUNE_DEAD_CODE) | 8247 | prunearg = FALSE; |
7587 | prunearg = TRUE; | ||
7588 | else | ||
7589 | prunearg = FALSE; | ||
7590 | break; | 8248 | break; |
7591 | case LSCP_SCOPE_PASS2: | 8249 | case LSCP_SCOPE_PASS2: |
7592 | { | 8250 | { |
@@ -7610,10 +8268,10 @@ void LLScriptStateChange::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTComp | |||
7610 | } | 8268 | } |
7611 | break; | 8269 | break; |
7612 | case LSCP_EMIT_CIL_ASSEMBLY: | 8270 | case LSCP_EMIT_CIL_ASSEMBLY: |
7613 | fprintf(fp, "ldstr \""); | 8271 | fprintf(fp, "ldarg.0\n"); |
7614 | mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 8272 | fprintf(fp, "ldstr \"%s\"\n", mIdentifier->mName); |
7615 | fprintf(fp, "\"\n"); | 8273 | fprintf(fp, "call instance void class [LslUserScript]LindenLab.SecondLife.LslUserScript::ChangeState(string)\n"); |
7616 | fprintf(fp, "call void class [LScriptLibrary]LScriptInternal::change_state(string)\n"); | 8274 | fprintf(fp, "ret\n"); |
7617 | break; | 8275 | break; |
7618 | default: | 8276 | default: |
7619 | mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 8277 | mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
@@ -7647,10 +8305,7 @@ void LLScriptJump::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass | |||
7647 | fprintf(fp, "\n"); | 8305 | fprintf(fp, "\n"); |
7648 | break; | 8306 | break; |
7649 | case LSCP_PRUNE: | 8307 | case LSCP_PRUNE: |
7650 | if (ptype == LSPRUNE_DEAD_CODE) | 8308 | prunearg = FALSE; |
7651 | prunearg = TRUE; | ||
7652 | else | ||
7653 | prunearg = FALSE; | ||
7654 | break; | 8309 | break; |
7655 | case LSCP_SCOPE_PASS2: | 8310 | case LSCP_SCOPE_PASS2: |
7656 | { | 8311 | { |
@@ -7820,6 +8475,10 @@ void LLScriptReturn::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePa | |||
7820 | mType = basetype; | 8475 | mType = basetype; |
7821 | } | 8476 | } |
7822 | } | 8477 | } |
8478 | else if (basetype != LST_NULL) | ||
8479 | { | ||
8480 | gErrorToText.writeError(fp, this, LSERROR_TYPE_MISMATCH); | ||
8481 | } | ||
7823 | break; | 8482 | break; |
7824 | case LSCP_EMIT_BYTE_CODE: | 8483 | case LSCP_EMIT_BYTE_CODE: |
7825 | if (mExpression) | 8484 | if (mExpression) |
@@ -7863,6 +8522,7 @@ void LLScriptReturn::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePa | |||
7863 | if (mExpression) | 8522 | if (mExpression) |
7864 | { | 8523 | { |
7865 | mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 8524 | mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
8525 | print_cil_cast(fp, mExpression->mReturnType, mType); | ||
7866 | } | 8526 | } |
7867 | fprintf(fp, "ret\n"); | 8527 | fprintf(fp, "ret\n"); |
7868 | break; | 8528 | break; |
@@ -7902,10 +8562,7 @@ void LLScriptExpressionStatement::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSC | |||
7902 | } | 8562 | } |
7903 | break; | 8563 | break; |
7904 | case LSCP_PRUNE: | 8564 | case LSCP_PRUNE: |
7905 | if (ptype == LSPRUNE_DEAD_CODE) | 8565 | prunearg = FALSE; |
7906 | prunearg = TRUE; | ||
7907 | else | ||
7908 | prunearg = FALSE; | ||
7909 | break; | 8566 | break; |
7910 | case LSCP_EMIT_BYTE_CODE: | 8567 | case LSCP_EMIT_BYTE_CODE: |
7911 | mExpression->recurse(fp, tabs, tabsize, LSCP_TO_STACK, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 8568 | mExpression->recurse(fp, tabs, tabsize, LSCP_TO_STACK, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
@@ -7951,6 +8608,58 @@ S32 LLScriptIf::getSize() | |||
7951 | return 0; | 8608 | return 0; |
7952 | } | 8609 | } |
7953 | 8610 | ||
8611 | static void print_cil_if_test(LLFILE* fp, LSCRIPTType type) | ||
8612 | { | ||
8613 | switch(type) | ||
8614 | { | ||
8615 | case LST_INTEGER: | ||
8616 | break; | ||
8617 | case LST_FLOATINGPOINT: | ||
8618 | fprintf(fp, "ldc.r8 0\n"); | ||
8619 | fprintf(fp, "ceq\n"); | ||
8620 | fprintf(fp, "ldc.i4.0\n"); | ||
8621 | fprintf(fp, "ceq\n"); | ||
8622 | break; | ||
8623 | case LST_VECTOR: | ||
8624 | fprintf(fp, "ldc.r8 0\n"); | ||
8625 | fprintf(fp, "ldc.r8 0\n"); | ||
8626 | fprintf(fp, "ldc.r8 0\n"); | ||
8627 | fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Vector class [LslUserScript]LindenLab.SecondLife.LslUserScript::'CreateVector'(float32, float32, float32)\n"); | ||
8628 | fprintf(fp, "call bool [LslUserScript]LindenLab.SecondLife.LslUserScript::'Equals'(class [ScriptTypes]LindenLab.SecondLife.Vector, class [ScriptTypes]LindenLab.SecondLife.Vector)\n"); | ||
8629 | fprintf(fp, "ldc.i4.0\n"); | ||
8630 | fprintf(fp, "ceq\n"); | ||
8631 | break; | ||
8632 | case LST_QUATERNION: | ||
8633 | fprintf(fp, "ldc.r8 0\n"); | ||
8634 | fprintf(fp, "ldc.r8 0\n"); | ||
8635 | fprintf(fp, "ldc.r8 0\n"); | ||
8636 | fprintf(fp, "ldc.r8 1\n"); | ||
8637 | fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Quaternion class [LslUserScript]LindenLab.SecondLife.LslUserScript::'CreateQuaternion'(float32, float32, float32, float32)\n"); | ||
8638 | fprintf(fp, "call bool [LslUserScript]LindenLab.SecondLife.LslUserScript::'Equals'(class [ScriptTypes]LindenLab.SecondLife.Quaternion, class [ScriptTypes]LindenLab.SecondLife.Quaternion)\n"); | ||
8639 | fprintf(fp, "ldc.i4.0\n"); | ||
8640 | fprintf(fp, "ceq\n"); | ||
8641 | break; | ||
8642 | case LST_KEY: | ||
8643 | fprintf(fp, "call bool [LslUserScript]LindenLab.SecondLife.LslUserScript::'IsNonNullUuid'(valuetype [ScriptTypes]LindenLab.SecondLife.Key)\n"); | ||
8644 | break; | ||
8645 | case LST_STRING: | ||
8646 | fprintf(fp, "ldstr \"\"\n"); | ||
8647 | fprintf(fp, "call bool string::op_Equality(string, string)\n"); | ||
8648 | fprintf(fp, "ldc.i4.0\n"); | ||
8649 | fprintf(fp, "ceq\n"); | ||
8650 | break; | ||
8651 | case LST_LIST: | ||
8652 | fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::CreateList()\n"); | ||
8653 | fprintf(fp, "call bool [LslUserScript]LindenLab.SecondLife.LslUserScript::Equals(class [mscorlib]System.Collections.ArrayList, class [mscorlib]System.Collections.ArrayList)\n"); | ||
8654 | fprintf(fp, "ldc.i4.0\n"); | ||
8655 | fprintf(fp, "ceq\n"); | ||
8656 | break; | ||
8657 | default: | ||
8658 | break; | ||
8659 | } | ||
8660 | |||
8661 | } | ||
8662 | |||
7954 | void LLScriptIf::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata) | 8663 | void LLScriptIf::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata) |
7955 | { | 8664 | { |
7956 | if (gErrorToText.getErrors()) | 8665 | if (gErrorToText.getErrors()) |
@@ -7976,10 +8685,7 @@ void LLScriptIf::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass p | |||
7976 | } | 8685 | } |
7977 | break; | 8686 | break; |
7978 | case LSCP_PRUNE: | 8687 | case LSCP_PRUNE: |
7979 | if (ptype == LSPRUNE_DEAD_CODE) | 8688 | prunearg = FALSE; |
7980 | prunearg = TRUE; | ||
7981 | else | ||
7982 | prunearg = FALSE; | ||
7983 | break; | 8689 | break; |
7984 | case LSCP_TYPE: | 8690 | case LSCP_TYPE: |
7985 | mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 8691 | mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
@@ -8004,6 +8710,7 @@ void LLScriptIf::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass p | |||
8004 | { | 8710 | { |
8005 | S32 tjump = gTempJumpCount++; | 8711 | S32 tjump = gTempJumpCount++; |
8006 | mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 8712 | mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
8713 | print_cil_if_test(fp, mExpression->mReturnType); | ||
8007 | fprintf(fp, "brfalse LabelTempJump%d\n", tjump); | 8714 | fprintf(fp, "brfalse LabelTempJump%d\n", tjump); |
8008 | mStatement->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 8715 | mStatement->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
8009 | fprintf(fp, "LabelTempJump%d:\n", tjump); | 8716 | fprintf(fp, "LabelTempJump%d:\n", tjump); |
@@ -8093,6 +8800,7 @@ void LLScriptIfElse::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePa | |||
8093 | S32 tjump1 = gTempJumpCount++; | 8800 | S32 tjump1 = gTempJumpCount++; |
8094 | S32 tjump2 = gTempJumpCount++; | 8801 | S32 tjump2 = gTempJumpCount++; |
8095 | mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 8802 | mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
8803 | print_cil_if_test(fp, mExpression->mReturnType); | ||
8096 | fprintf(fp, "brfalse LabelTempJump%d\n", tjump1); | 8804 | fprintf(fp, "brfalse LabelTempJump%d\n", tjump1); |
8097 | mStatement1->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 8805 | mStatement1->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
8098 | fprintf(fp, "br LabelTempJump%d\n", tjump2); | 8806 | fprintf(fp, "br LabelTempJump%d\n", tjump2); |
@@ -8155,10 +8863,7 @@ void LLScriptFor::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass | |||
8155 | } | 8863 | } |
8156 | break; | 8864 | break; |
8157 | case LSCP_PRUNE: | 8865 | case LSCP_PRUNE: |
8158 | if (ptype == LSPRUNE_DEAD_CODE) | 8866 | prunearg = FALSE; |
8159 | prunearg = TRUE; | ||
8160 | else | ||
8161 | prunearg = FALSE; | ||
8162 | break; | 8867 | break; |
8163 | case LSCP_TYPE: | 8868 | case LSCP_TYPE: |
8164 | if(mSequence) | 8869 | if(mSequence) |
@@ -8203,6 +8908,7 @@ void LLScriptFor::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass | |||
8203 | mSequence->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 8908 | mSequence->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
8204 | fprintf(fp, "LabelTempJump%d:\n", tjump1); | 8909 | fprintf(fp, "LabelTempJump%d:\n", tjump1); |
8205 | mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 8910 | mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
8911 | print_cil_if_test(fp, mExpression->mReturnType); | ||
8206 | fprintf(fp, "brfalse LabelTempJump%d\n", tjump2); | 8912 | fprintf(fp, "brfalse LabelTempJump%d\n", tjump2); |
8207 | if(mStatement) | 8913 | if(mStatement) |
8208 | mStatement->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 8914 | mStatement->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
@@ -8257,10 +8963,7 @@ void LLScriptDoWhile::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompileP | |||
8257 | } | 8963 | } |
8258 | break; | 8964 | break; |
8259 | case LSCP_PRUNE: | 8965 | case LSCP_PRUNE: |
8260 | if (ptype == LSPRUNE_DEAD_CODE) | 8966 | prunearg = FALSE; |
8261 | prunearg = TRUE; | ||
8262 | else | ||
8263 | prunearg = FALSE; | ||
8264 | break; | 8967 | break; |
8265 | case LSCP_TYPE: | 8968 | case LSCP_TYPE: |
8266 | mStatement->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 8969 | mStatement->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
@@ -8287,6 +8990,7 @@ void LLScriptDoWhile::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompileP | |||
8287 | fprintf(fp, "LabelTempJump%d:\n", tjump1); | 8990 | fprintf(fp, "LabelTempJump%d:\n", tjump1); |
8288 | mStatement->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 8991 | mStatement->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
8289 | mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 8992 | mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
8993 | print_cil_if_test(fp, mExpression->mReturnType); | ||
8290 | fprintf(fp, "brtrue LabelTempJump%d\n", tjump1); | 8994 | fprintf(fp, "brtrue LabelTempJump%d\n", tjump1); |
8291 | } | 8995 | } |
8292 | break; | 8996 | break; |
@@ -8331,10 +9035,7 @@ void LLScriptWhile::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePas | |||
8331 | } | 9035 | } |
8332 | break; | 9036 | break; |
8333 | case LSCP_PRUNE: | 9037 | case LSCP_PRUNE: |
8334 | if (ptype == LSPRUNE_DEAD_CODE) | 9038 | prunearg = FALSE; |
8335 | prunearg = TRUE; | ||
8336 | else | ||
8337 | prunearg = FALSE; | ||
8338 | break; | 9039 | break; |
8339 | case LSCP_TYPE: | 9040 | case LSCP_TYPE: |
8340 | mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 9041 | mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
@@ -8367,6 +9068,7 @@ void LLScriptWhile::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePas | |||
8367 | S32 tjump2 = gTempJumpCount++; | 9068 | S32 tjump2 = gTempJumpCount++; |
8368 | fprintf(fp, "LabelTempJump%d:\n", tjump1); | 9069 | fprintf(fp, "LabelTempJump%d:\n", tjump1); |
8369 | mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 9070 | mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
9071 | print_cil_if_test(fp, mExpression->mReturnType); | ||
8370 | fprintf(fp, "brfalse LabelTempJump%d\n", tjump2); | 9072 | fprintf(fp, "brfalse LabelTempJump%d\n", tjump2); |
8371 | mStatement->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 9073 | mStatement->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
8372 | fprintf(fp, "br LabelTempJump%d\n", tjump1); | 9074 | fprintf(fp, "br LabelTempJump%d\n", tjump1); |
@@ -8429,10 +9131,7 @@ void LLScriptDeclaration::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTComp | |||
8429 | } | 9131 | } |
8430 | break; | 9132 | break; |
8431 | case LSCP_PRUNE: | 9133 | case LSCP_PRUNE: |
8432 | if (ptype == LSPRUNE_DEAD_CODE) | 9134 | prunearg = FALSE; |
8433 | prunearg = TRUE; | ||
8434 | else | ||
8435 | prunearg = FALSE; | ||
8436 | break; | 9135 | break; |
8437 | case LSCP_SCOPE_PASS1: | 9136 | case LSCP_SCOPE_PASS1: |
8438 | // Check to see if a declaration is valid here. | 9137 | // Check to see if a declaration is valid here. |
@@ -8604,24 +9303,13 @@ void LLScriptDeclaration::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTComp | |||
8604 | if (mExpression) | 9303 | if (mExpression) |
8605 | { | 9304 | { |
8606 | mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 9305 | mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
8607 | if (mIdentifier->mScopeEntry->mIDType == LIT_VARIABLE) | 9306 | print_cil_cast(fp, mExpression->mReturnType, mIdentifier->mScopeEntry->mType); |
8608 | { | 9307 | } |
8609 | if(is_parameter(mIdentifier, entry)) | 9308 | else |
8610 | { | 9309 | { |
8611 | // Parameter, store by name. | 9310 | print_cil_init_variable(fp, mIdentifier->mScopeEntry->mType); |
8612 | fprintf(fp, "starg.s %s\n", mIdentifier->mScopeEntry->mIdentifier); | ||
8613 | } | ||
8614 | else | ||
8615 | { | ||
8616 | // Local, store by index. | ||
8617 | fprintf(fp, "stloc.s %d\n", mIdentifier->mScopeEntry->mCount); | ||
8618 | } | ||
8619 | } | ||
8620 | else if (mIdentifier->mScopeEntry->mIDType == LIT_GLOBAL) | ||
8621 | { | ||
8622 | gErrorToText.writeError(fp, this, LSERROR_UNDEFINED_NAME); | ||
8623 | } | ||
8624 | } | 9311 | } |
9312 | fprintf(fp, "stloc.s %d\n", mIdentifier->mScopeEntry->mCount); | ||
8625 | break; | 9313 | break; |
8626 | default: | 9314 | default: |
8627 | if (mExpression) | 9315 | if (mExpression) |
@@ -8751,7 +9439,7 @@ S32 LLScriptEventHandler::getSize() | |||
8751 | 9439 | ||
8752 | U64 gCurrentHandler = 0; | 9440 | U64 gCurrentHandler = 0; |
8753 | 9441 | ||
8754 | void print_cil_local_init(LLFILE* fp, LLScriptScopeEntry* scopeEntry) | 9442 | static void print_cil_local_init(LLFILE* fp, LLScriptScopeEntry* scopeEntry) |
8755 | { | 9443 | { |
8756 | if(scopeEntry->mLocals.getNumber() > 0) | 9444 | if(scopeEntry->mLocals.getNumber() > 0) |
8757 | { | 9445 | { |
@@ -8956,6 +9644,10 @@ void LLScriptEventHandler::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCom | |||
8956 | // first determine resource counts for globals | 9644 | // first determine resource counts for globals |
8957 | count = 0; | 9645 | count = 0; |
8958 | mEventp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 9646 | mEventp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
9647 | |||
9648 | // Store offset of first local as with global functions, so locals and arguments can be distinguished with is_parameter when compiling to CIL. | ||
9649 | mScopeEntry->mOffset = (S32) count; | ||
9650 | |||
8959 | if (mStatement) | 9651 | if (mStatement) |
8960 | { | 9652 | { |
8961 | entrycount = 0; | 9653 | entrycount = 0; |
@@ -9024,8 +9716,11 @@ void LLScriptEventHandler::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCom | |||
9024 | // Method signature prefix. | 9716 | // Method signature prefix. |
9025 | fprintf(fp, ".method public hidebysig instance default void "); | 9717 | fprintf(fp, ".method public hidebysig instance default void "); |
9026 | 9718 | ||
9027 | // Mangle event handler name by prefixing it with state name. Allows state changing by finding handlers prefixed with new state name. | 9719 | // Mangle event handler name by prefixing it with state name. |
9028 | fprintf(fp, entry->mIdentifier); /*Flawfinder: ignore*/ | 9720 | // Allows state changing by finding handlers prefixed with new |
9721 | // state name. Prefix disambiguates functions and event handlers. | ||
9722 | fprintf(fp, "e"); | ||
9723 | fprintf(fp, entry->mIdentifier); | ||
9029 | 9724 | ||
9030 | // Handler name and arguments. | 9725 | // Handler name and arguments. |
9031 | mEventp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 9726 | mEventp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
@@ -9047,7 +9742,11 @@ void LLScriptEventHandler::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCom | |||
9047 | } | 9742 | } |
9048 | 9743 | ||
9049 | // Function footer. | 9744 | // Function footer. |
9050 | fprintf(fp, "\nret\n"); // TODO: Check whether return needed? | 9745 | if (mbNeedTrailingReturn) |
9746 | { | ||
9747 | // TODO: throw exception? | ||
9748 | fprintf(fp, "ret\n"); | ||
9749 | } | ||
9051 | fprintf(fp, "}\n"); | 9750 | fprintf(fp, "}\n"); |
9052 | 9751 | ||
9053 | break; | 9752 | break; |
@@ -9161,7 +9860,7 @@ void LLScriptFunctionDec::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTComp | |||
9161 | chunk->addBytes(&typereturn, 1); | 9860 | chunk->addBytes(&typereturn, 1); |
9162 | // name | 9861 | // name |
9163 | #ifdef LSL_INCLUDE_DEBUG_INFO | 9862 | #ifdef LSL_INCLUDE_DEBUG_INFO |
9164 | chunk->addBytes(mIdentifier->mName, strlen(mIdentifier->mName) + 1); /*Flawfinder: ignore*/ | 9863 | chunk->addBytes(mIdentifier->mName, strlen(mIdentifier->mName) + 1); |
9165 | #else | 9864 | #else |
9166 | chunk->addBytes(1); | 9865 | chunk->addBytes(1); |
9167 | #endif | 9866 | #endif |
@@ -9176,6 +9875,10 @@ void LLScriptFunctionDec::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTComp | |||
9176 | mType->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 9875 | mType->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
9177 | fprintf(fp, " "); | 9876 | fprintf(fp, " "); |
9178 | mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 9877 | mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
9878 | if(NULL != mNextp) | ||
9879 | { | ||
9880 | fprintf(fp, ","); | ||
9881 | } | ||
9179 | break; | 9882 | break; |
9180 | default: | 9883 | default: |
9181 | mType->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 9884 | mType->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
@@ -9398,7 +10101,7 @@ void LLScriptGlobalFunctions::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPT | |||
9398 | 10101 | ||
9399 | // null terminated function name | 10102 | // null terminated function name |
9400 | #ifdef LSL_INCLUDE_DEBUG_INFO | 10103 | #ifdef LSL_INCLUDE_DEBUG_INFO |
9401 | chunk->addBytes(mIdentifier->mName, strlen(mIdentifier->mName) + 1); /*Flawfinder: ignore*/ | 10104 | chunk->addBytes(mIdentifier->mName, strlen(mIdentifier->mName) + 1); |
9402 | #else | 10105 | #else |
9403 | chunk->addBytes(1); | 10106 | chunk->addBytes(1); |
9404 | #endif | 10107 | #endif |
@@ -9444,11 +10147,13 @@ void LLScriptGlobalFunctions::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPT | |||
9444 | break; | 10147 | break; |
9445 | case LSCP_EMIT_CIL_ASSEMBLY: | 10148 | case LSCP_EMIT_CIL_ASSEMBLY: |
9446 | { | 10149 | { |
9447 | // Function header. | 10150 | // Function header. Prefix function name with g to distinguish |
10151 | // from event handlers. | ||
9448 | fprintf(fp, ".method public hidebysig instance default "); | 10152 | fprintf(fp, ".method public hidebysig instance default "); |
9449 | print_cil_type(fp, mType ? mType->mType : LST_NULL); | 10153 | print_cil_type(fp, mType ? mType->mType : LST_NULL); |
9450 | fprintf(fp, " "); | 10154 | fprintf(fp, " 'g"); |
9451 | mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 10155 | fprintf(fp, mIdentifier->mName); |
10156 | fprintf(fp, "'"); | ||
9452 | if (mParameters) | 10157 | if (mParameters) |
9453 | { | 10158 | { |
9454 | fprintf(fp, "( "); | 10159 | fprintf(fp, "( "); |
@@ -9473,6 +10178,7 @@ void LLScriptGlobalFunctions::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPT | |||
9473 | // Function footer. | 10178 | // Function footer. |
9474 | if (mbNeedTrailingReturn) | 10179 | if (mbNeedTrailingReturn) |
9475 | { | 10180 | { |
10181 | // TODO: throw exception? | ||
9476 | fprintf(fp, "ret\n"); | 10182 | fprintf(fp, "ret\n"); |
9477 | } | 10183 | } |
9478 | fprintf(fp, "}\n"); | 10184 | fprintf(fp, "}\n"); |
@@ -9587,10 +10293,12 @@ void LLScriptState::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePas | |||
9587 | { | 10293 | { |
9588 | mIdentifier->mScopeEntry = scope->addEntry(mIdentifier->mName, LIT_STATE, LST_NULL); | 10294 | mIdentifier->mScopeEntry = scope->addEntry(mIdentifier->mName, LIT_STATE, LST_NULL); |
9589 | } | 10295 | } |
10296 | mStateScope = new LLScriptScope(gScopeStringTable); | ||
10297 | mStateScope->addParentScope(scope); | ||
9590 | // now do the events | 10298 | // now do the events |
9591 | if (mEvent) | 10299 | if (mEvent) |
9592 | { | 10300 | { |
9593 | mEvent->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 10301 | mEvent->recurse(fp, tabs, tabsize, pass, ptype, prunearg, mStateScope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
9594 | } | 10302 | } |
9595 | break; | 10303 | break; |
9596 | case LSCP_SCOPE_PASS2: | 10304 | case LSCP_SCOPE_PASS2: |
@@ -9649,7 +10357,7 @@ void LLScriptState::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePas | |||
9649 | 10357 | ||
9650 | // null terminated state name | 10358 | // null terminated state name |
9651 | #ifdef LSL_INCLUDE_DEBUG_INFO | 10359 | #ifdef LSL_INCLUDE_DEBUG_INFO |
9652 | chunk->addBytes(mIdentifier->mName, strlen(mIdentifier->mName) + 1); /*Flawfinder: ignore*/ | 10360 | chunk->addBytes(mIdentifier->mName, strlen(mIdentifier->mName) + 1); |
9653 | #else | 10361 | #else |
9654 | chunk->addBytes(1); | 10362 | chunk->addBytes(1); |
9655 | #endif | 10363 | #endif |
@@ -9693,6 +10401,38 @@ void LLScriptState::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePas | |||
9693 | gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 10401 | gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
9694 | } | 10402 | } |
9695 | 10403 | ||
10404 | // Converts string to a valid CIL class name and stores the result | ||
10405 | // in the supplied buffer, which should be at least 32 chars long. | ||
10406 | // If the string starts with a UUID, all characters in the UUID are included | ||
10407 | // in the generated name. | ||
10408 | void to_class_name(char* buffer, const char* string) | ||
10409 | { | ||
10410 | strcpy(buffer, "LSL-"); | ||
10411 | strcat(buffer, string); | ||
10412 | char* current_char = buffer; | ||
10413 | while((*current_char) != 0) | ||
10414 | { | ||
10415 | if(isalnum(*current_char)) | ||
10416 | { | ||
10417 | ++current_char; | ||
10418 | } | ||
10419 | else if((*current_char) == '-') | ||
10420 | { | ||
10421 | (*current_char) = '_'; | ||
10422 | ++current_char; | ||
10423 | } | ||
10424 | else | ||
10425 | { | ||
10426 | (*current_char) = 0; | ||
10427 | } | ||
10428 | } | ||
10429 | } | ||
10430 | |||
10431 | void LLScriptScript::setClassName(const char* class_name) | ||
10432 | { | ||
10433 | to_class_name(mClassName, class_name); | ||
10434 | } | ||
10435 | |||
9696 | S32 LLScriptScript::getSize() | 10436 | S32 LLScriptScript::getSize() |
9697 | { | 10437 | { |
9698 | return 0; | 10438 | return 0; |
@@ -9704,8 +10444,8 @@ LLScriptScript::LLScriptScript(LLScritpGlobalStorage *globals, | |||
9704 | mStates(states), mGlobalScope(NULL), mGlobals(NULL), mGlobalFunctions(NULL), mGodLike(FALSE) | 10444 | mStates(states), mGlobalScope(NULL), mGlobals(NULL), mGlobalFunctions(NULL), mGodLike(FALSE) |
9705 | { | 10445 | { |
9706 | const char DEFAULT_BYTECODE_FILENAME[] = "lscript.lso"; | 10446 | const char DEFAULT_BYTECODE_FILENAME[] = "lscript.lso"; |
9707 | strncpy(mBytecodeDest, DEFAULT_BYTECODE_FILENAME, sizeof(mBytecodeDest) -1); /*Flawfinder: ignore*/ | 10447 | |
9708 | mBytecodeDest[MAX_STRING-1] = '\0'; | 10448 | mBytecodeDest = DEFAULT_BYTECODE_FILENAME; |
9709 | LLScriptGlobalVariable *tvar; | 10449 | LLScriptGlobalVariable *tvar; |
9710 | LLScriptGlobalFunctions *tfunc; | 10450 | LLScriptGlobalFunctions *tfunc; |
9711 | LLScritpGlobalStorage *temp; | 10451 | LLScritpGlobalStorage *temp; |
@@ -9751,17 +10491,14 @@ LLScriptScript::LLScriptScript(LLScritpGlobalStorage *globals, | |||
9751 | 10491 | ||
9752 | void LLScriptScript::setBytecodeDest(const char* dst_filename) | 10492 | void LLScriptScript::setBytecodeDest(const char* dst_filename) |
9753 | { | 10493 | { |
9754 | strncpy(mBytecodeDest, dst_filename, MAX_STRING); /*Flawfinder: ignore*/ | 10494 | mBytecodeDest = ll_safe_string(dst_filename); |
9755 | mBytecodeDest[MAX_STRING-1] = '\0'; | ||
9756 | } | 10495 | } |
9757 | 10496 | ||
9758 | void print_cil_globals(LLFILE* fp, LLScriptGlobalVariable* global) | 10497 | static void print_cil_globals(LLFILE* fp, LLScriptGlobalVariable* global) |
9759 | { | 10498 | { |
9760 | fprintf(fp, ".field private "); | 10499 | fprintf(fp, ".field public "); |
9761 | print_cil_type(fp, global->mType->mType); | 10500 | print_cil_type(fp, global->mType->mType); |
9762 | fprintf(fp, " "); | 10501 | fprintf(fp, " '%s'\n", global->mIdentifier->mName); |
9763 | fprintf(fp, global->mIdentifier->mName); /*Flawfinder: ignore*/ | ||
9764 | fprintf(fp, "\n"); | ||
9765 | if(NULL != global->mNextp) | 10502 | if(NULL != global->mNextp) |
9766 | { | 10503 | { |
9767 | print_cil_globals(fp, global->mNextp); | 10504 | print_cil_globals(fp, global->mNextp); |
@@ -9804,7 +10541,7 @@ void LLScriptScript::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePa | |||
9804 | mGlobalScope = new LLScriptScope(gScopeStringTable); | 10541 | mGlobalScope = new LLScriptScope(gScopeStringTable); |
9805 | // zeroth, add library functions to global scope | 10542 | // zeroth, add library functions to global scope |
9806 | S32 i; | 10543 | S32 i; |
9807 | char *arg; | 10544 | const char *arg; |
9808 | LLScriptScopeEntry *sentry; | 10545 | LLScriptScopeEntry *sentry; |
9809 | for (i = 0; i < gScriptLibrary.mNextNumber; i++) | 10546 | for (i = 0; i < gScriptLibrary.mNextNumber; i++) |
9810 | { | 10547 | { |
@@ -9948,72 +10685,66 @@ void LLScriptScript::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePa | |||
9948 | } | 10685 | } |
9949 | break; | 10686 | break; |
9950 | case LSCP_EMIT_CIL_ASSEMBLY: | 10687 | case LSCP_EMIT_CIL_ASSEMBLY: |
10688 | { | ||
10689 | LLFILE *bcfp = LLFile::fopen(mBytecodeDest, "wb"); | ||
9951 | 10690 | ||
9952 | // Output dependencies. | 10691 | // Output dependencies. |
9953 | fprintf(fp, ".assembly extern mscorlib {.ver 1:0:5000:0}\n"); | 10692 | fprintf(bcfp, ".assembly extern mscorlib {.ver 1:0:5000:0}\n"); |
9954 | fprintf(fp, ".assembly extern LScriptLibrary {.ver 0:0:0:0}\n"); | 10693 | fprintf(bcfp, ".assembly extern LslLibrary {.ver 0:1:0:0}\n"); |
10694 | fprintf(bcfp, ".assembly extern LslUserScript {.ver 0:1:0:0}\n"); | ||
10695 | fprintf(bcfp, ".assembly extern ScriptTypes {.ver 0:1:0:0}\n"); | ||
9955 | 10696 | ||
9956 | // Output assembly name. | 10697 | // Output assembly name. |
9957 | fprintf(fp, ".assembly 'lsl' {.ver 0:0:0:0}\n"); | 10698 | fprintf(bcfp, ".assembly '%s' {.ver 0:0:0:0}\n", gScriptp->getClassName()); |
9958 | 10699 | ||
9959 | // Output class header. | 10700 | // Output class header. |
9960 | fprintf(fp, ".class public auto ansi beforefieldinit LSL extends [mscorlib]System.Object\n"); | 10701 | fprintf(bcfp, ".class public auto ansi serializable beforefieldinit %s extends [LslUserScript]LindenLab.SecondLife.LslUserScript\n", gScriptp->getClassName()); |
9961 | fprintf(fp, "{\n"); | 10702 | fprintf(bcfp, "{\n"); |
9962 | 10703 | ||
9963 | // Output globals as members. | 10704 | // Output globals as members. |
9964 | if(NULL != mGlobals) | 10705 | if(NULL != mGlobals) |
9965 | { | 10706 | { |
9966 | print_cil_globals(fp, mGlobals); | 10707 | print_cil_globals(bcfp, mGlobals); |
9967 | } | 10708 | } |
9968 | |||
9969 | // Output "runtime". Only needed to allow stand alone execution. Not needed when compiling to DLL and using embedded runtime. | ||
9970 | fprintf(fp, ".method public static hidebysig default void Main () cil managed\n"); | ||
9971 | fprintf(fp, "{\n"); | ||
9972 | fprintf(fp, ".entrypoint\n"); | ||
9973 | fprintf(fp, ".maxstack 2\n"); | ||
9974 | fprintf(fp, ".locals init (class LSL V_0)\n"); | ||
9975 | fprintf(fp, "newobj instance void class LSL::.ctor()\n"); | ||
9976 | fprintf(fp, "stloc.0\n"); | ||
9977 | fprintf(fp, "ldloc.0\n"); | ||
9978 | fprintf(fp, "callvirt instance void class LSL::defaultstate_entry()\n"); | ||
9979 | fprintf(fp, "ret\n"); | ||
9980 | fprintf(fp, "}\n"); | ||
9981 | 10709 | ||
9982 | // Output ctor header. | 10710 | // Output ctor header. |
9983 | fprintf(fp, ".method public hidebysig specialname rtspecialname instance default void .ctor () cil managed\n"); | 10711 | fprintf(bcfp, ".method public hidebysig specialname rtspecialname instance default void .ctor () cil managed\n"); |
9984 | fprintf(fp, "{\n"); | 10712 | fprintf(bcfp, "{\n"); |
9985 | fprintf(fp, ".maxstack 500\n"); | 10713 | fprintf(bcfp, ".maxstack 500\n"); |
9986 | 10714 | ||
9987 | // Initialise globals as members in ctor. | 10715 | // Initialise globals as members in ctor. |
9988 | if (mGlobals) | 10716 | if (mGlobals) |
9989 | { | 10717 | { |
9990 | fdotabs(fp, tabs, tabsize); | 10718 | fdotabs(bcfp, tabs, tabsize); |
9991 | mGlobals->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 10719 | mGlobals->recurse(bcfp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
9992 | fprintf(fp, "\n"); | 10720 | fprintf(bcfp, "\n"); |
9993 | } | 10721 | } |
9994 | 10722 | ||
9995 | // Output ctor footer. | 10723 | // Output ctor footer. |
9996 | fprintf(fp, "ldarg.0\n"); | 10724 | fprintf(bcfp, "ldarg.0\n"); |
9997 | fprintf(fp, "call instance void valuetype [mscorlib]System.Object::.ctor()\n"); | 10725 | fprintf(bcfp, "call instance void [LslUserScript]LindenLab.SecondLife.LslUserScript::.ctor()\n"); |
9998 | fprintf(fp, "ret\n"); | 10726 | fprintf(bcfp, "ret\n"); |
9999 | fprintf(fp, "}\n"); | 10727 | fprintf(bcfp, "}\n"); |
10000 | 10728 | ||
10001 | // Output functions as methods. | 10729 | // Output functions as methods. |
10002 | if (mGlobalFunctions) | 10730 | if (mGlobalFunctions) |
10003 | { | 10731 | { |
10004 | fdotabs(fp, tabs, tabsize); | 10732 | fdotabs(bcfp, tabs, tabsize); |
10005 | mGlobalFunctions->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 10733 | mGlobalFunctions->recurse(bcfp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
10006 | fprintf(fp, "\n"); | 10734 | fprintf(bcfp, "\n"); |
10007 | } | 10735 | } |
10008 | 10736 | ||
10009 | // Output states as name mangled methods. | 10737 | // Output states as name mangled methods. |
10010 | fdotabs(fp, tabs, tabsize); | 10738 | fdotabs(bcfp, tabs, tabsize); |
10011 | mStates->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); | 10739 | mStates->recurse(bcfp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); |
10012 | fprintf(fp, "\n"); | 10740 | fprintf(bcfp, "\n"); |
10013 | 10741 | ||
10014 | // Output class footer. | 10742 | // Output class footer. |
10015 | fprintf(fp, "}\n"); | 10743 | fprintf(bcfp, "}\n"); |
10016 | 10744 | ||
10745 | // Close file. | ||
10746 | fclose(bcfp); | ||
10747 | } | ||
10017 | break; | 10748 | break; |
10018 | default: | 10749 | default: |
10019 | if (mGlobals) | 10750 | if (mGlobals) |