From 687090f79a3e5499ffb36a57a14f968325e62497 Mon Sep 17 00:00:00 2001 From: Charles Krinke Date: Wed, 4 Jun 2008 14:40:17 +0000 Subject: 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. --- .../DotNetEngine/Compiler/LSL/Compiler.cs | 34 +++++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs index 7113f1a..3f53456 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs @@ -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 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() + "\""); } -- cgit v1.1