From 8f0db68424af54ca42928216224d1172b266250e Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 20 Nov 2009 18:39:39 +0000 Subject: Fix http://opensimulator.org/mantis/view.php?id=3874 - parenthesis in for statements cause script compile failures This fixes a problem in OpenSim where statements of the form for ((i = 0); (i < 10); (++i)) { ... } do not compile even though they are valid lsl. --- OpenSim/Region/Framework/Scenes/Scene.cs | 2 +- .../ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs | 20 +++++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 2e15b86..a430b1e 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1266,7 +1266,7 @@ namespace OpenSim.Region.Framework.Scenes // allocations, and there is no more work to be done until someone logs in GC.Collect(); - m_log.DebugFormat("[REGION]: Enabling Logins for {0}", RegionInfo.RegionName); + m_log.DebugFormat("[REGION]: Enabling logins for {0}", RegionInfo.RegionName); loginsdisabled = false; } } diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs index 41ecfd3..e427f50 100644 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs @@ -722,8 +722,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools if (fls.kids.Top is IdentExpression && 1 == fls.kids.Count) return retstr; - foreach (SYMBOL s in fls.kids) + for (int i = 0; i < fls.kids.Count; i++) { + SYMBOL s = (SYMBOL)fls.kids[i]; + + // Statements surrounded by parentheses in for loops + // + // e.g. for ((i = 0), (j = 7); (i < 10); (++i)) + // + // are legal in LSL but not in C# so we need to discard the parentheses + // + // The following, however, does not appear to be legal in LLS + // + // for ((i = 0, j = 7); (i < 10); (++i)) + // + // As of Friday 20th November 2009, the Linden Lab simulators appear simply never to compile or run this + // script but with no debug or warnings at all! Therefore, we won't deal with this yet (which looks + // like it would be considerably more complicated to handle). + while (s is ParenthesisExpression) + s = (SYMBOL)s.kids.Pop(); + retstr += GenerateNode(s); if (0 < comma--) retstr += Generate(", "); -- cgit v1.1