diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs | 147 |
1 files changed, 101 insertions, 46 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs index 97dd0f6..9e32f40 100644 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs | |||
@@ -31,7 +31,6 @@ using System.Collections.Generic; | |||
31 | using System.Reflection; | 31 | using System.Reflection; |
32 | using log4net; | 32 | using log4net; |
33 | using Tools; | 33 | using Tools; |
34 | |||
35 | using OpenSim.Region.Framework.Interfaces; | 34 | using OpenSim.Region.Framework.Interfaces; |
36 | 35 | ||
37 | namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | 36 | namespace OpenSim.Region.ScriptEngine.Shared.CodeTools |
@@ -49,6 +48,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
49 | private List<string> m_warnings = new List<string>(); | 48 | private List<string> m_warnings = new List<string>(); |
50 | private IScriptModuleComms m_comms = null; | 49 | private IScriptModuleComms m_comms = null; |
51 | 50 | ||
51 | private bool m_insertCoopTerminationChecks; | ||
52 | private static string m_coopTerminationCheck = "opensim_reserved_CheckForCoopTermination();"; | ||
53 | |||
54 | /// <summary> | ||
55 | /// Keep a record of the previous node when we do the parsing. | ||
56 | /// </summary> | ||
57 | /// <remarks> | ||
58 | /// We do this here because the parser generated by CSTools does not retain a reference to its parent node. | ||
59 | /// The previous node is required so we can correctly insert co-op termination checks when required. | ||
60 | /// </remarks> | ||
61 | // private SYMBOL m_previousNode; | ||
62 | |||
52 | /// <summary> | 63 | /// <summary> |
53 | /// Creates an 'empty' CSCodeGenerator instance. | 64 | /// Creates an 'empty' CSCodeGenerator instance. |
54 | /// </summary> | 65 | /// </summary> |
@@ -58,9 +69,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
58 | ResetCounters(); | 69 | ResetCounters(); |
59 | } | 70 | } |
60 | 71 | ||
61 | public CSCodeGenerator(IScriptModuleComms comms) | 72 | public CSCodeGenerator(IScriptModuleComms comms, bool insertCoopTerminationChecks) |
62 | { | 73 | { |
63 | m_comms = comms; | 74 | m_comms = comms; |
75 | m_insertCoopTerminationChecks = insertCoopTerminationChecks; | ||
64 | ResetCounters(); | 76 | ResetCounters(); |
65 | } | 77 | } |
66 | 78 | ||
@@ -155,7 +167,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
155 | // here's the payload | 167 | // here's the payload |
156 | retstr += GenerateLine(); | 168 | retstr += GenerateLine(); |
157 | foreach (SYMBOL s in m_astRoot.kids) | 169 | foreach (SYMBOL s in m_astRoot.kids) |
158 | retstr += GenerateNode(s); | 170 | retstr += GenerateNode(m_astRoot, s); |
159 | 171 | ||
160 | // close braces! | 172 | // close braces! |
161 | m_braceCount--; | 173 | m_braceCount--; |
@@ -165,7 +177,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
165 | 177 | ||
166 | // Removes all carriage return characters which may be generated in Windows platform. Is there | 178 | // Removes all carriage return characters which may be generated in Windows platform. Is there |
167 | // cleaner way of doing this? | 179 | // cleaner way of doing this? |
168 | retstr=retstr.Replace("\r", ""); | 180 | retstr = retstr.Replace("\r", ""); |
169 | 181 | ||
170 | return retstr; | 182 | return retstr; |
171 | } | 183 | } |
@@ -191,9 +203,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
191 | /// Recursively called to generate each type of node. Will generate this | 203 | /// Recursively called to generate each type of node. Will generate this |
192 | /// node, then all it's children. | 204 | /// node, then all it's children. |
193 | /// </summary> | 205 | /// </summary> |
206 | /// <param name="previousSymbol">The parent node.</param> | ||
194 | /// <param name="s">The current node to generate code for.</param> | 207 | /// <param name="s">The current node to generate code for.</param> |
195 | /// <returns>String containing C# code for SYMBOL s.</returns> | 208 | /// <returns>String containing C# code for SYMBOL s.</returns> |
196 | private string GenerateNode(SYMBOL s) | 209 | private string GenerateNode(SYMBOL previousSymbol, SYMBOL s) |
197 | { | 210 | { |
198 | string retstr = String.Empty; | 211 | string retstr = String.Empty; |
199 | 212 | ||
@@ -207,11 +220,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
207 | else if (s is State) | 220 | else if (s is State) |
208 | retstr += GenerateState((State) s); | 221 | retstr += GenerateState((State) s); |
209 | else if (s is CompoundStatement) | 222 | else if (s is CompoundStatement) |
210 | retstr += GenerateCompoundStatement((CompoundStatement) s); | 223 | retstr += GenerateCompoundStatement(previousSymbol, (CompoundStatement) s); |
211 | else if (s is Declaration) | 224 | else if (s is Declaration) |
212 | retstr += GenerateDeclaration((Declaration) s); | 225 | retstr += GenerateDeclaration((Declaration) s); |
213 | else if (s is Statement) | 226 | else if (s is Statement) |
214 | retstr += GenerateStatement((Statement) s); | 227 | retstr += GenerateStatement(previousSymbol, (Statement) s); |
215 | else if (s is ReturnStatement) | 228 | else if (s is ReturnStatement) |
216 | retstr += GenerateReturnStatement((ReturnStatement) s); | 229 | retstr += GenerateReturnStatement((ReturnStatement) s); |
217 | else if (s is JumpLabel) | 230 | else if (s is JumpLabel) |
@@ -261,7 +274,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
261 | else | 274 | else |
262 | { | 275 | { |
263 | foreach (SYMBOL kid in s.kids) | 276 | foreach (SYMBOL kid in s.kids) |
264 | retstr += GenerateNode(kid); | 277 | retstr += GenerateNode(s, kid); |
265 | } | 278 | } |
266 | 279 | ||
267 | return retstr; | 280 | return retstr; |
@@ -295,7 +308,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
295 | retstr += GenerateLine(")"); | 308 | retstr += GenerateLine(")"); |
296 | 309 | ||
297 | foreach (SYMBOL kid in remainingKids) | 310 | foreach (SYMBOL kid in remainingKids) |
298 | retstr += GenerateNode(kid); | 311 | retstr += GenerateNode(gf, kid); |
299 | 312 | ||
300 | return retstr; | 313 | return retstr; |
301 | } | 314 | } |
@@ -312,7 +325,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
312 | foreach (SYMBOL s in gv.kids) | 325 | foreach (SYMBOL s in gv.kids) |
313 | { | 326 | { |
314 | retstr += Indent(); | 327 | retstr += Indent(); |
315 | retstr += GenerateNode(s); | 328 | retstr += GenerateNode(gv, s); |
316 | retstr += GenerateLine(";"); | 329 | retstr += GenerateLine(";"); |
317 | } | 330 | } |
318 | 331 | ||
@@ -365,7 +378,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
365 | retstr += GenerateLine(")"); | 378 | retstr += GenerateLine(")"); |
366 | 379 | ||
367 | foreach (SYMBOL kid in remainingKids) | 380 | foreach (SYMBOL kid in remainingKids) |
368 | retstr += GenerateNode(kid); | 381 | retstr += GenerateNode(se, kid); |
369 | 382 | ||
370 | return retstr; | 383 | return retstr; |
371 | } | 384 | } |
@@ -404,7 +417,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
404 | 417 | ||
405 | foreach (SYMBOL s in al.kids) | 418 | foreach (SYMBOL s in al.kids) |
406 | { | 419 | { |
407 | retstr += GenerateNode(s); | 420 | retstr += GenerateNode(al, s); |
408 | if (0 < comma--) | 421 | if (0 < comma--) |
409 | retstr += Generate(", "); | 422 | retstr += Generate(", "); |
410 | } | 423 | } |
@@ -417,7 +430,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
417 | /// </summary> | 430 | /// </summary> |
418 | /// <param name="cs">The CompoundStatement node.</param> | 431 | /// <param name="cs">The CompoundStatement node.</param> |
419 | /// <returns>String containing C# code for CompoundStatement cs.</returns> | 432 | /// <returns>String containing C# code for CompoundStatement cs.</returns> |
420 | private string GenerateCompoundStatement(CompoundStatement cs) | 433 | private string GenerateCompoundStatement(SYMBOL previousSymbol, CompoundStatement cs) |
421 | { | 434 | { |
422 | string retstr = String.Empty; | 435 | string retstr = String.Empty; |
423 | 436 | ||
@@ -425,8 +438,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
425 | retstr += GenerateIndentedLine("{"); | 438 | retstr += GenerateIndentedLine("{"); |
426 | m_braceCount++; | 439 | m_braceCount++; |
427 | 440 | ||
441 | if (m_insertCoopTerminationChecks) | ||
442 | { | ||
443 | // We have to check in event functions as well because the user can manually call these. | ||
444 | if (previousSymbol is GlobalFunctionDefinition | ||
445 | || previousSymbol is WhileStatement | ||
446 | || previousSymbol is DoWhileStatement | ||
447 | || previousSymbol is ForLoop | ||
448 | || previousSymbol is StateEvent) | ||
449 | retstr += GenerateIndentedLine(m_coopTerminationCheck); | ||
450 | } | ||
451 | |||
428 | foreach (SYMBOL kid in cs.kids) | 452 | foreach (SYMBOL kid in cs.kids) |
429 | retstr += GenerateNode(kid); | 453 | retstr += GenerateNode(cs, kid); |
430 | 454 | ||
431 | // closing brace | 455 | // closing brace |
432 | m_braceCount--; | 456 | m_braceCount--; |
@@ -450,10 +474,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
450 | /// </summary> | 474 | /// </summary> |
451 | /// <param name="s">The Statement node.</param> | 475 | /// <param name="s">The Statement node.</param> |
452 | /// <returns>String containing C# code for Statement s.</returns> | 476 | /// <returns>String containing C# code for Statement s.</returns> |
453 | private string GenerateStatement(Statement s) | 477 | private string GenerateStatement(SYMBOL previousSymbol, Statement s) |
454 | { | 478 | { |
455 | string retstr = String.Empty; | 479 | string retstr = String.Empty; |
456 | bool printSemicolon = true; | 480 | bool printSemicolon = true; |
481 | bool transformToBlock = false; | ||
482 | |||
483 | if (m_insertCoopTerminationChecks) | ||
484 | { | ||
485 | // A non-braced single line do while structure cannot contain multiple statements. | ||
486 | // So to insert the termination check we change this to a braced control structure instead. | ||
487 | if (previousSymbol is WhileStatement | ||
488 | || previousSymbol is DoWhileStatement | ||
489 | || previousSymbol is ForLoop) | ||
490 | { | ||
491 | transformToBlock = true; | ||
492 | |||
493 | // FIXME: This will be wrongly indented because the previous for/while/dowhile will have already indented. | ||
494 | retstr += GenerateIndentedLine("{"); | ||
495 | |||
496 | retstr += GenerateIndentedLine(m_coopTerminationCheck); | ||
497 | } | ||
498 | } | ||
457 | 499 | ||
458 | retstr += Indent(); | 500 | retstr += Indent(); |
459 | 501 | ||
@@ -466,12 +508,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
466 | // (MONO) error. | 508 | // (MONO) error. |
467 | if (!(s.kids.Top is IdentExpression && 1 == s.kids.Count)) | 509 | if (!(s.kids.Top is IdentExpression && 1 == s.kids.Count)) |
468 | foreach (SYMBOL kid in s.kids) | 510 | foreach (SYMBOL kid in s.kids) |
469 | retstr += GenerateNode(kid); | 511 | retstr += GenerateNode(s, kid); |
470 | } | 512 | } |
471 | 513 | ||
472 | if (printSemicolon) | 514 | if (printSemicolon) |
473 | retstr += GenerateLine(";"); | 515 | retstr += GenerateLine(";"); |
474 | 516 | ||
517 | if (transformToBlock) | ||
518 | { | ||
519 | // FIXME: This will be wrongly indented because the for/while/dowhile is currently handling the unindent | ||
520 | retstr += GenerateIndentedLine("}"); | ||
521 | } | ||
522 | |||
475 | return retstr; | 523 | return retstr; |
476 | } | 524 | } |
477 | 525 | ||
@@ -487,10 +535,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
487 | List<string> identifiers = new List<string>(); | 535 | List<string> identifiers = new List<string>(); |
488 | checkForMultipleAssignments(identifiers, a); | 536 | checkForMultipleAssignments(identifiers, a); |
489 | 537 | ||
490 | retstr += GenerateNode((SYMBOL) a.kids.Pop()); | 538 | retstr += GenerateNode(a, (SYMBOL) a.kids.Pop()); |
491 | retstr += Generate(String.Format(" {0} ", a.AssignmentType), a); | 539 | retstr += Generate(String.Format(" {0} ", a.AssignmentType), a); |
492 | foreach (SYMBOL kid in a.kids) | 540 | foreach (SYMBOL kid in a.kids) |
493 | retstr += GenerateNode(kid); | 541 | retstr += GenerateNode(a, kid); |
494 | 542 | ||
495 | return retstr; | 543 | return retstr; |
496 | } | 544 | } |
@@ -563,7 +611,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
563 | retstr += Generate("return ", rs); | 611 | retstr += Generate("return ", rs); |
564 | 612 | ||
565 | foreach (SYMBOL kid in rs.kids) | 613 | foreach (SYMBOL kid in rs.kids) |
566 | retstr += GenerateNode(kid); | 614 | retstr += GenerateNode(rs, kid); |
567 | 615 | ||
568 | return retstr; | 616 | return retstr; |
569 | } | 617 | } |
@@ -575,7 +623,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
575 | /// <returns>String containing C# code for JumpLabel jl.</returns> | 623 | /// <returns>String containing C# code for JumpLabel jl.</returns> |
576 | private string GenerateJumpLabel(JumpLabel jl) | 624 | private string GenerateJumpLabel(JumpLabel jl) |
577 | { | 625 | { |
578 | return Generate(String.Format("{0}:", CheckName(jl.LabelName)), jl) + " NoOp();\n"; | 626 | string labelStatement; |
627 | |||
628 | if (m_insertCoopTerminationChecks) | ||
629 | labelStatement = m_coopTerminationCheck + "\n"; | ||
630 | else | ||
631 | labelStatement = "NoOp();\n"; | ||
632 | |||
633 | return Generate(String.Format("{0}: ", CheckName(jl.LabelName)), jl) + labelStatement; | ||
579 | } | 634 | } |
580 | 635 | ||
581 | /// <summary> | 636 | /// <summary> |
@@ -598,14 +653,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
598 | string retstr = String.Empty; | 653 | string retstr = String.Empty; |
599 | 654 | ||
600 | retstr += GenerateIndented("if (", ifs); | 655 | retstr += GenerateIndented("if (", ifs); |
601 | retstr += GenerateNode((SYMBOL) ifs.kids.Pop()); | 656 | retstr += GenerateNode(ifs, (SYMBOL) ifs.kids.Pop()); |
602 | retstr += GenerateLine(")"); | 657 | retstr += GenerateLine(")"); |
603 | 658 | ||
604 | // CompoundStatement handles indentation itself but we need to do it | 659 | // CompoundStatement handles indentation itself but we need to do it |
605 | // otherwise. | 660 | // otherwise. |
606 | bool indentHere = ifs.kids.Top is Statement; | 661 | bool indentHere = ifs.kids.Top is Statement; |
607 | if (indentHere) m_braceCount++; | 662 | if (indentHere) m_braceCount++; |
608 | retstr += GenerateNode((SYMBOL) ifs.kids.Pop()); | 663 | retstr += GenerateNode(ifs, (SYMBOL) ifs.kids.Pop()); |
609 | if (indentHere) m_braceCount--; | 664 | if (indentHere) m_braceCount--; |
610 | 665 | ||
611 | if (0 < ifs.kids.Count) // do it again for an else | 666 | if (0 < ifs.kids.Count) // do it again for an else |
@@ -614,7 +669,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
614 | 669 | ||
615 | indentHere = ifs.kids.Top is Statement; | 670 | indentHere = ifs.kids.Top is Statement; |
616 | if (indentHere) m_braceCount++; | 671 | if (indentHere) m_braceCount++; |
617 | retstr += GenerateNode((SYMBOL) ifs.kids.Pop()); | 672 | retstr += GenerateNode(ifs, (SYMBOL) ifs.kids.Pop()); |
618 | if (indentHere) m_braceCount--; | 673 | if (indentHere) m_braceCount--; |
619 | } | 674 | } |
620 | 675 | ||
@@ -641,14 +696,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
641 | string retstr = String.Empty; | 696 | string retstr = String.Empty; |
642 | 697 | ||
643 | retstr += GenerateIndented("while (", ws); | 698 | retstr += GenerateIndented("while (", ws); |
644 | retstr += GenerateNode((SYMBOL) ws.kids.Pop()); | 699 | retstr += GenerateNode(ws, (SYMBOL) ws.kids.Pop()); |
645 | retstr += GenerateLine(")"); | 700 | retstr += GenerateLine(")"); |
646 | 701 | ||
647 | // CompoundStatement handles indentation itself but we need to do it | 702 | // CompoundStatement handles indentation itself but we need to do it |
648 | // otherwise. | 703 | // otherwise. |
649 | bool indentHere = ws.kids.Top is Statement; | 704 | bool indentHere = ws.kids.Top is Statement; |
650 | if (indentHere) m_braceCount++; | 705 | if (indentHere) m_braceCount++; |
651 | retstr += GenerateNode((SYMBOL) ws.kids.Pop()); | 706 | retstr += GenerateNode(ws, (SYMBOL) ws.kids.Pop()); |
652 | if (indentHere) m_braceCount--; | 707 | if (indentHere) m_braceCount--; |
653 | 708 | ||
654 | return retstr; | 709 | return retstr; |
@@ -669,11 +724,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
669 | // otherwise. | 724 | // otherwise. |
670 | bool indentHere = dws.kids.Top is Statement; | 725 | bool indentHere = dws.kids.Top is Statement; |
671 | if (indentHere) m_braceCount++; | 726 | if (indentHere) m_braceCount++; |
672 | retstr += GenerateNode((SYMBOL) dws.kids.Pop()); | 727 | retstr += GenerateNode(dws, (SYMBOL) dws.kids.Pop()); |
673 | if (indentHere) m_braceCount--; | 728 | if (indentHere) m_braceCount--; |
674 | 729 | ||
675 | retstr += GenerateIndented("while (", dws); | 730 | retstr += GenerateIndented("while (", dws); |
676 | retstr += GenerateNode((SYMBOL) dws.kids.Pop()); | 731 | retstr += GenerateNode(dws, (SYMBOL) dws.kids.Pop()); |
677 | retstr += GenerateLine(");"); | 732 | retstr += GenerateLine(");"); |
678 | 733 | ||
679 | return retstr; | 734 | return retstr; |
@@ -702,7 +757,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
702 | retstr += Generate("; "); | 757 | retstr += Generate("; "); |
703 | // for (x = 0; x < 10; x++) | 758 | // for (x = 0; x < 10; x++) |
704 | // ^^^^^^ | 759 | // ^^^^^^ |
705 | retstr += GenerateNode((SYMBOL) fl.kids.Pop()); | 760 | retstr += GenerateNode(fl, (SYMBOL) fl.kids.Pop()); |
706 | retstr += Generate("; "); | 761 | retstr += Generate("; "); |
707 | // for (x = 0; x < 10; x++) | 762 | // for (x = 0; x < 10; x++) |
708 | // ^^^ | 763 | // ^^^ |
@@ -713,7 +768,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
713 | // otherwise. | 768 | // otherwise. |
714 | bool indentHere = fl.kids.Top is Statement; | 769 | bool indentHere = fl.kids.Top is Statement; |
715 | if (indentHere) m_braceCount++; | 770 | if (indentHere) m_braceCount++; |
716 | retstr += GenerateNode((SYMBOL) fl.kids.Pop()); | 771 | retstr += GenerateNode(fl, (SYMBOL) fl.kids.Pop()); |
717 | if (indentHere) m_braceCount--; | 772 | if (indentHere) m_braceCount--; |
718 | 773 | ||
719 | return retstr; | 774 | return retstr; |
@@ -758,7 +813,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
758 | while (s is ParenthesisExpression) | 813 | while (s is ParenthesisExpression) |
759 | s = (SYMBOL)s.kids.Pop(); | 814 | s = (SYMBOL)s.kids.Pop(); |
760 | 815 | ||
761 | retstr += GenerateNode(s); | 816 | retstr += GenerateNode(fls, s); |
762 | if (0 < comma--) | 817 | if (0 < comma--) |
763 | retstr += Generate(", "); | 818 | retstr += Generate(", "); |
764 | } | 819 | } |
@@ -779,20 +834,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
779 | { | 834 | { |
780 | // special case handling for logical and/or, see Mantis 3174 | 835 | // special case handling for logical and/or, see Mantis 3174 |
781 | retstr += "((bool)("; | 836 | retstr += "((bool)("; |
782 | retstr += GenerateNode((SYMBOL)be.kids.Pop()); | 837 | retstr += GenerateNode(be, (SYMBOL)be.kids.Pop()); |
783 | retstr += "))"; | 838 | retstr += "))"; |
784 | retstr += Generate(String.Format(" {0} ", be.ExpressionSymbol.Substring(0,1)), be); | 839 | retstr += Generate(String.Format(" {0} ", be.ExpressionSymbol.Substring(0,1)), be); |
785 | retstr += "((bool)("; | 840 | retstr += "((bool)("; |
786 | foreach (SYMBOL kid in be.kids) | 841 | foreach (SYMBOL kid in be.kids) |
787 | retstr += GenerateNode(kid); | 842 | retstr += GenerateNode(be, kid); |
788 | retstr += "))"; | 843 | retstr += "))"; |
789 | } | 844 | } |
790 | else | 845 | else |
791 | { | 846 | { |
792 | retstr += GenerateNode((SYMBOL)be.kids.Pop()); | 847 | retstr += GenerateNode(be, (SYMBOL)be.kids.Pop()); |
793 | retstr += Generate(String.Format(" {0} ", be.ExpressionSymbol), be); | 848 | retstr += Generate(String.Format(" {0} ", be.ExpressionSymbol), be); |
794 | foreach (SYMBOL kid in be.kids) | 849 | foreach (SYMBOL kid in be.kids) |
795 | retstr += GenerateNode(kid); | 850 | retstr += GenerateNode(be, kid); |
796 | } | 851 | } |
797 | 852 | ||
798 | return retstr; | 853 | return retstr; |
@@ -808,7 +863,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
808 | string retstr = String.Empty; | 863 | string retstr = String.Empty; |
809 | 864 | ||
810 | retstr += Generate(ue.UnarySymbol, ue); | 865 | retstr += Generate(ue.UnarySymbol, ue); |
811 | retstr += GenerateNode((SYMBOL) ue.kids.Pop()); | 866 | retstr += GenerateNode(ue, (SYMBOL) ue.kids.Pop()); |
812 | 867 | ||
813 | return retstr; | 868 | return retstr; |
814 | } | 869 | } |
@@ -824,7 +879,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
824 | 879 | ||
825 | retstr += Generate("("); | 880 | retstr += Generate("("); |
826 | foreach (SYMBOL kid in pe.kids) | 881 | foreach (SYMBOL kid in pe.kids) |
827 | retstr += GenerateNode(kid); | 882 | retstr += GenerateNode(pe, kid); |
828 | retstr += Generate(")"); | 883 | retstr += Generate(")"); |
829 | 884 | ||
830 | return retstr; | 885 | return retstr; |
@@ -861,7 +916,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
861 | 916 | ||
862 | // we wrap all typecasted statements in parentheses | 917 | // we wrap all typecasted statements in parentheses |
863 | retstr += Generate(String.Format("({0}) (", te.TypecastType), te); | 918 | retstr += Generate(String.Format("({0}) (", te.TypecastType), te); |
864 | retstr += GenerateNode((SYMBOL) te.kids.Pop()); | 919 | retstr += GenerateNode(te, (SYMBOL) te.kids.Pop()); |
865 | retstr += Generate(")"); | 920 | retstr += Generate(")"); |
866 | 921 | ||
867 | return retstr; | 922 | return retstr; |
@@ -931,7 +986,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
931 | } | 986 | } |
932 | 987 | ||
933 | foreach (SYMBOL kid in fc.kids) | 988 | foreach (SYMBOL kid in fc.kids) |
934 | retstr += GenerateNode(kid); | 989 | retstr += GenerateNode(fc, kid); |
935 | 990 | ||
936 | retstr += Generate(")"); | 991 | retstr += Generate(")"); |
937 | 992 | ||
@@ -980,11 +1035,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
980 | string retstr = String.Empty; | 1035 | string retstr = String.Empty; |
981 | 1036 | ||
982 | retstr += Generate(String.Format("new {0}(", vc.Type), vc); | 1037 | retstr += Generate(String.Format("new {0}(", vc.Type), vc); |
983 | retstr += GenerateNode((SYMBOL) vc.kids.Pop()); | 1038 | retstr += GenerateNode(vc, (SYMBOL) vc.kids.Pop()); |
984 | retstr += Generate(", "); | 1039 | retstr += Generate(", "); |
985 | retstr += GenerateNode((SYMBOL) vc.kids.Pop()); | 1040 | retstr += GenerateNode(vc, (SYMBOL) vc.kids.Pop()); |
986 | retstr += Generate(", "); | 1041 | retstr += Generate(", "); |
987 | retstr += GenerateNode((SYMBOL) vc.kids.Pop()); | 1042 | retstr += GenerateNode(vc, (SYMBOL) vc.kids.Pop()); |
988 | retstr += Generate(")"); | 1043 | retstr += Generate(")"); |
989 | 1044 | ||
990 | return retstr; | 1045 | return retstr; |
@@ -1000,13 +1055,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
1000 | string retstr = String.Empty; | 1055 | string retstr = String.Empty; |
1001 | 1056 | ||
1002 | retstr += Generate(String.Format("new {0}(", rc.Type), rc); | 1057 | retstr += Generate(String.Format("new {0}(", rc.Type), rc); |
1003 | retstr += GenerateNode((SYMBOL) rc.kids.Pop()); | 1058 | retstr += GenerateNode(rc, (SYMBOL) rc.kids.Pop()); |
1004 | retstr += Generate(", "); | 1059 | retstr += Generate(", "); |
1005 | retstr += GenerateNode((SYMBOL) rc.kids.Pop()); | 1060 | retstr += GenerateNode(rc, (SYMBOL) rc.kids.Pop()); |
1006 | retstr += Generate(", "); | 1061 | retstr += Generate(", "); |
1007 | retstr += GenerateNode((SYMBOL) rc.kids.Pop()); | 1062 | retstr += GenerateNode(rc, (SYMBOL) rc.kids.Pop()); |
1008 | retstr += Generate(", "); | 1063 | retstr += Generate(", "); |
1009 | retstr += GenerateNode((SYMBOL) rc.kids.Pop()); | 1064 | retstr += GenerateNode(rc, (SYMBOL) rc.kids.Pop()); |
1010 | retstr += Generate(")"); | 1065 | retstr += Generate(")"); |
1011 | 1066 | ||
1012 | return retstr; | 1067 | return retstr; |
@@ -1024,7 +1079,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
1024 | retstr += Generate(String.Format("new {0}(", lc.Type), lc); | 1079 | retstr += Generate(String.Format("new {0}(", lc.Type), lc); |
1025 | 1080 | ||
1026 | foreach (SYMBOL kid in lc.kids) | 1081 | foreach (SYMBOL kid in lc.kids) |
1027 | retstr += GenerateNode(kid); | 1082 | retstr += GenerateNode(lc, kid); |
1028 | 1083 | ||
1029 | retstr += Generate(")"); | 1084 | retstr += Generate(")"); |
1030 | 1085 | ||