aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs
diff options
context:
space:
mode:
authorMike Mazur2009-06-07 10:22:55 +0000
committerMike Mazur2009-06-07 10:22:55 +0000
commitcda6b2466868cc74367da1b17d676f7168b84f6d (patch)
treef7dd014e4a9544fcf76687fb537163344cef8a3f /OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs
parentAllow empty assignment in for-loop (diff)
downloadopensim-SC_OLD-cda6b2466868cc74367da1b17d676f7168b84f6d.zip
opensim-SC_OLD-cda6b2466868cc74367da1b17d676f7168b84f6d.tar.gz
opensim-SC_OLD-cda6b2466868cc74367da1b17d676f7168b84f6d.tar.bz2
opensim-SC_OLD-cda6b2466868cc74367da1b17d676f7168b84f6d.tar.xz
Skip lone ident statments or for-loop assignments
SL's LSL supports lone idents: integer x; x; as well as lone idents in for-loop assignments: for (x; x < 10; x++) { ... } while those are errors in C# (MONO at least). This patch skips lone idents in such places. Fixes Mantis #3042.
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs17
1 files changed, 14 insertions, 3 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs
index ab9968f..91747af 100644
--- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs
@@ -90,7 +90,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
90 m_warnings.Clear(); 90 m_warnings.Clear();
91 ResetCounters(); 91 ResetCounters();
92 Parser p = new LSLSyntax(new yyLSLSyntax(), new ErrorHandler(true)); 92 Parser p = new LSLSyntax(new yyLSLSyntax(), new ErrorHandler(true));
93 // Obviously this needs to be in a try/except block. 93
94 LSL2CSCodeTransformer codeTransformer; 94 LSL2CSCodeTransformer codeTransformer;
95 try 95 try
96 { 96 {
@@ -446,8 +446,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
446 // Jump label prints its own colon, we don't need a semicolon. 446 // Jump label prints its own colon, we don't need a semicolon.
447 printSemicolon = !(s.kids.Top is JumpLabel); 447 printSemicolon = !(s.kids.Top is JumpLabel);
448 448
449 foreach (SYMBOL kid in s.kids) 449 // If we encounter a lone Ident, we skip it, since that's a C#
450 retstr += GenerateNode(kid); 450 // (MONO) error.
451 if (!(s.kids.Top is IdentExpression && 1 == s.kids.Count))
452 foreach (SYMBOL kid in s.kids)
453 retstr += GenerateNode(kid);
451 } 454 }
452 455
453 if (printSemicolon) 456 if (printSemicolon)
@@ -711,6 +714,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
711 714
712 int comma = fls.kids.Count - 1; // tells us whether to print a comma 715 int comma = fls.kids.Count - 1; // tells us whether to print a comma
713 716
717 // It's possible that all we have is an empty Ident, for example:
718 //
719 // for (x; x < 10; x++) { ... }
720 //
721 // Which is illegal in C# (MONO). We'll skip it.
722 if (fls.kids.Top is IdentExpression && 1 == fls.kids.Count)
723 return retstr;
724
714 foreach (SYMBOL s in fls.kids) 725 foreach (SYMBOL s in fls.kids)
715 { 726 {
716 retstr += GenerateNode(s); 727 retstr += GenerateNode(s);