diff options
author | Justin Clark-Casey (justincc) | 2013-01-30 03:44:56 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2013-01-30 03:52:22 +0000 |
commit | 5ac84a37935d8e1c62484032259d09f5ac95c0e7 (patch) | |
tree | 00917b383828319d974202e6f9c184808da68660 /OpenSim/Region/ScriptEngine/Shared/CodeTools | |
parent | BulletSim: fix physics repositioning when under ground to only happen (diff) | |
download | opensim-SC-5ac84a37935d8e1c62484032259d09f5ac95c0e7.zip opensim-SC-5ac84a37935d8e1c62484032259d09f5ac95c0e7.tar.gz opensim-SC-5ac84a37935d8e1c62484032259d09f5ac95c0e7.tar.bz2 opensim-SC-5ac84a37935d8e1c62484032259d09f5ac95c0e7.tar.xz |
Fix issue where lsl -> c# generation in co-operative termination mode did not correctly handle single statement versions of for, while and do-while loops.
Add regression tests to validate the fix.
This problem will not affect the default abort termination mode.
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/CodeTools')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs index 985e598..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 |
@@ -479,20 +478,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
479 | { | 478 | { |
480 | string retstr = String.Empty; | 479 | string retstr = String.Empty; |
481 | bool printSemicolon = true; | 480 | bool printSemicolon = true; |
482 | 481 | bool transformToBlock = false; | |
483 | retstr += Indent(); | ||
484 | 482 | ||
485 | if (m_insertCoopTerminationChecks) | 483 | if (m_insertCoopTerminationChecks) |
486 | { | 484 | { |
487 | // We have to check in event functions as well because the user can manually call these. | 485 | // A non-braced single line do while structure cannot contain multiple statements. |
488 | if (previousSymbol is GlobalFunctionDefinition | 486 | // So to insert the termination check we change this to a braced control structure instead. |
489 | || previousSymbol is WhileStatement | 487 | if (previousSymbol is WhileStatement |
490 | || previousSymbol is DoWhileStatement | 488 | || previousSymbol is DoWhileStatement |
491 | || previousSymbol is ForLoop | 489 | || previousSymbol is ForLoop) |
492 | || previousSymbol is StateEvent) | 490 | { |
493 | retstr += Generate(m_coopTerminationCheck); | 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 | } | ||
494 | } | 498 | } |
495 | 499 | ||
500 | retstr += Indent(); | ||
501 | |||
496 | if (0 < s.kids.Count) | 502 | if (0 < s.kids.Count) |
497 | { | 503 | { |
498 | // Jump label prints its own colon, we don't need a semicolon. | 504 | // Jump label prints its own colon, we don't need a semicolon. |
@@ -508,6 +514,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
508 | if (printSemicolon) | 514 | if (printSemicolon) |
509 | retstr += GenerateLine(";"); | 515 | retstr += GenerateLine(";"); |
510 | 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 | |||
511 | return retstr; | 523 | return retstr; |
512 | } | 524 | } |
513 | 525 | ||