From e75ff8f0a31a9a0f6855a9d50ef5f37334dea5f3 Mon Sep 17 00:00:00 2001
From: Johan Berntsson
Date: Tue, 8 Jul 2008 02:34:45 +0000
Subject: llscript compiler patch from Mike: adds LSL jumps and implicit
variable initializations
---
.../DotNetEngine/Compiler/LSL/CSCodeGenerator.cs | 30 +++++++++++++++++++++-
1 file changed, 29 insertions(+), 1 deletion(-)
(limited to 'OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/CSCodeGenerator.cs')
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/CSCodeGenerator.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/CSCodeGenerator.cs
index 142e791..ec34a7b 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/CSCodeGenerator.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/CSCodeGenerator.cs
@@ -116,6 +116,10 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
retstr += GenerateStatement((Statement) s);
else if (s is ReturnStatement)
retstr += GenerateReturnStatement((ReturnStatement) s);
+ else if (s is JumpLabel)
+ retstr += GenerateJumpLabel((JumpLabel) s);
+ else if (s is JumpStatement)
+ retstr += GenerateJumpStatement((JumpStatement) s);
else if (s is StateChange)
retstr += GenerateStateChange((StateChange) s);
else if (s is IfStatement)
@@ -354,12 +358,16 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
{
string retstr = String.Empty;
+ // Jump label prints its own colon, we don't need a semicolon.
+ bool printSemicolon = !(s.kids.Top is JumpLabel);
+
retstr += Indent();
foreach (SYMBOL kid in s.kids)
retstr += GenerateNode(kid);
- retstr += ";\n";
+ if (printSemicolon)
+ retstr += ";\n";
return retstr;
}
@@ -399,6 +407,26 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
}
///
+ /// Generates the code for a JumpLabel node.
+ ///
+ /// The JumpLabel node.
+ /// String containing C# code for SYMBOL s.
+ private string GenerateJumpLabel(JumpLabel jl)
+ {
+ return String.Format("{0}:\n", jl.LabelName);
+ }
+
+ ///
+ /// Generates the code for a JumpStatement node.
+ ///
+ /// The JumpStatement node.
+ /// String containing C# code for SYMBOL s.
+ private string GenerateJumpStatement(JumpStatement js)
+ {
+ return String.Format("goto {0}", js.TargetName);
+ }
+
+ ///
/// Generates the code for a IfStatement node.
///
/// The IfStatement node.
--
cgit v1.1