llscript compiler patch from Mike: adds LSL jumps and implicit variable initializations

This commit is contained in:
Johan Berntsson
2008-07-08 02:34:45 +00:00
parent 1122f3f693
commit e75ff8f0a3
4 changed files with 7754 additions and 7374 deletions

View File

@@ -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;
}
@@ -398,6 +406,26 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
return retstr;
}
/// <summary>
/// Generates the code for a JumpLabel node.
/// </summary>
/// <param name="jl">The JumpLabel node.</param>
/// <returns>String containing C# code for SYMBOL s.</returns>
private string GenerateJumpLabel(JumpLabel jl)
{
return String.Format("{0}:\n", jl.LabelName);
}
/// <summary>
/// Generates the code for a JumpStatement node.
/// </summary>
/// <param name="js">The JumpStatement node.</param>
/// <returns>String containing C# code for SYMBOL s.</returns>
private string GenerateJumpStatement(JumpStatement js)
{
return String.Format("goto {0}", js.TargetName);
}
/// <summary>
/// Generates the code for a IfStatement node.
/// </summary>