Mantis#1441. Thank you kindly, Kinoc for a patch that:

This patch adds the prolog interperter helper object ONLY for YP code, 
and not every script compiled. 
Mirrors the other languages like JS and VB more closely.
0.6.0-stable
Charles Krinke 2008-06-04 14:40:17 +00:00
parent e75cccec76
commit 687090f79a
1 changed files with 30 additions and 4 deletions

View File

@ -76,6 +76,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
private static CSharpCodeProvider CScodeProvider = new CSharpCodeProvider();
private static VBCodeProvider VBcodeProvider = new VBCodeProvider();
private static JScriptCodeProvider JScodeProvider = new JScriptCodeProvider();
private static CSharpCodeProvider YPcodeProvider = new CSharpCodeProvider(); // YP is translated into CSharp
private static YP2CSConverter YP_Converter = new YP2CSConverter();
private static int instanceID = new Random().Next(0, int.MaxValue); // Unique number to use on our compiled files
@ -118,7 +119,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
LanguageMapping.Add(enumCompileType.yp.ToString(), enumCompileType.yp);
// Allowed compilers
string allowComp = m_scriptEngine.ScriptConfigSource.GetString("AllowedCompilers", "lsl,cs,vb,js");
string allowComp = m_scriptEngine.ScriptConfigSource.GetString("AllowedCompilers", "lsl,cs,vb,js,yp");
AllowedCompilers.Clear();
#if DEBUG
@ -279,9 +280,10 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
if (l == enumCompileType.yp)
{
// Its LSL, convert it to C#
// Its YP, convert it to C#
compileScript = YP_Converter.Convert(Script);
l = enumCompileType.cs;
// We have our own processor now
//l = enumCompileType.cs;
}
// Insert additional assemblies here
@ -289,7 +291,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
//ADAM: Disabled for the moment until it's working right.
bool enableCommanderLSL = false;
if (enableCommanderLSL == true && l == enumCompileType.cs)
if (enableCommanderLSL == true && ((l == enumCompileType.cs) || (l == enumCompileType.yp)))
{
foreach (KeyValuePair<string,
ICommander> com
@ -313,6 +315,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
case enumCompileType.js:
compileScript = CreateJSCompilerScript(compileScript);
break;
case enumCompileType.yp:
compileScript = CreateYPCompilerScript(compileScript);
break;
}
m_log.Debug("[ScriptEngine.DotNetEngine]: Preparing to compile the following LSL to C# translated code");
@ -345,6 +350,24 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
return compileScript;
}
private static string CreateYPCompilerScript(string compileScript)
{
compileScript = String.Empty +
"using OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog; " +
"using OpenSim.Region.ScriptEngine.Common; using System.Collections.Generic;\r\n" +
String.Empty + "namespace SecondLife { " +
String.Empty + "public class Script : OpenSim.Region.ScriptEngine.Common.BuiltIn_Commands_BaseClass { \r\n" +
//@"public Script() { } " +
@"static OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog.YP YP=null; " +
@"public Script() { YP= new OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog.YP(); } "+
compileScript +
"} }\r\n";
return compileScript;
}
private static string CreateVBCompilerScript(string compileScript)
{
compileScript = String.Empty +
@ -438,6 +461,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
case enumCompileType.js:
results = JScodeProvider.CompileAssemblyFromSource(parameters, Script);
break;
case enumCompileType.yp:
results = YPcodeProvider.CompileAssemblyFromSource(parameters, Script);
break;
default:
throw new Exception("Compiler is not able to recongnize language type \"" + lang.ToString() + "\"");
}