Mantis#1602. Thank you, Kinoc for a patch to:
Patch to activate YieldProlog on Xengine. Only adds YieldProlog to assembly if required.0.6.0-stable
parent
ca724636d4
commit
cf00df106d
|
@ -355,7 +355,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
|
|||
sourceCode.Append(@"
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using YieldProlog;
|
||||
using OpenSim.Region.ScriptEngine.Shared.YieldProlog;
|
||||
|
||||
namespace Temporary {
|
||||
public class Temporary : YP.IClause {
|
||||
|
|
|
@ -55,7 +55,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
|
|||
lsl = 0,
|
||||
cs = 1,
|
||||
vb = 2,
|
||||
js = 3
|
||||
js = 3,
|
||||
yp = 4
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -75,6 +76,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
|
|||
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
|
||||
private static UInt64 scriptCompileCounter = 0; // And a counter
|
||||
|
@ -112,9 +115,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
|
|||
LanguageMapping.Add(enumCompileType.vb.ToString(), enumCompileType.vb);
|
||||
LanguageMapping.Add(enumCompileType.lsl.ToString(), enumCompileType.lsl);
|
||||
LanguageMapping.Add(enumCompileType.js.ToString(), enumCompileType.js);
|
||||
LanguageMapping.Add(enumCompileType.yp.ToString(), enumCompileType.yp);
|
||||
|
||||
// Allowed compilers
|
||||
string allowComp = m_scriptEngine.Config.GetString("AllowedCompilers", "lsl,cs,vb,js");
|
||||
string allowComp = m_scriptEngine.Config.GetString("AllowedCompilers", "lsl,cs,vb,js,yp");
|
||||
AllowedCompilers.Clear();
|
||||
|
||||
#if DEBUG
|
||||
|
@ -303,6 +307,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
|
|||
if (Script.StartsWith("//js", true, CultureInfo.InvariantCulture))
|
||||
l = enumCompileType.js;
|
||||
|
||||
if (Script.StartsWith("//yp", true, CultureInfo.InvariantCulture))
|
||||
l = enumCompileType.yp;
|
||||
|
||||
if (!AllowedCompilers.ContainsKey(l.ToString()))
|
||||
{
|
||||
// Not allowed to compile to this language!
|
||||
|
@ -320,12 +327,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
|
|||
l = enumCompileType.cs;
|
||||
}
|
||||
|
||||
if (l == enumCompileType.yp)
|
||||
{
|
||||
// Its YP, convert it to C#
|
||||
compileScript = YP_Converter.Convert(Script);
|
||||
// We have our own processor now
|
||||
//l = enumCompileType.cs;
|
||||
}
|
||||
|
||||
// Insert additional assemblies here
|
||||
|
||||
//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
|
||||
|
@ -348,6 +363,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
|
|||
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");
|
||||
|
@ -380,6 +398,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
|
|||
return compileScript;
|
||||
}
|
||||
|
||||
private static string CreateYPCompilerScript(string compileScript)
|
||||
{
|
||||
|
||||
|
||||
compileScript = String.Empty +
|
||||
"using OpenSim.Region.ScriptEngine.Shared.YieldProlog; " +
|
||||
"using OpenSim.Region.ScriptEngine.Shared; using System.Collections.Generic;\r\n" +
|
||||
String.Empty + "namespace SecondLife { " +
|
||||
String.Empty + "public class Script : OpenSim.Region.ScriptEngine.Shared.ScriptBase.ScriptBaseClass { \r\n" +
|
||||
//@"public Script() { } " +
|
||||
@"static OpenSim.Region.ScriptEngine.Shared.YieldProlog.YP YP=null; " +
|
||||
@"public Script() { YP= new OpenSim.Region.ScriptEngine.Shared.YieldProlog.YP(); } " +
|
||||
|
||||
compileScript +
|
||||
"} }\r\n";
|
||||
return compileScript;
|
||||
}
|
||||
|
||||
private static string CreateVBCompilerScript(string compileScript)
|
||||
{
|
||||
compileScript = String.Empty +
|
||||
|
@ -455,6 +491,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
|
|||
parameters.ReferencedAssemblies.Add(Path.Combine(rootPath, "OpenSim.Region.ScriptEngine.Shared.dll"));
|
||||
parameters.ReferencedAssemblies.Add(Path.Combine(rootPath, "OpenSim.Region.ScriptEngine.Shared.Api.Runtime.dll"));
|
||||
|
||||
if (lang == enumCompileType.yp)
|
||||
{
|
||||
parameters.ReferencedAssemblies.Add(Path.Combine(rootPath, "OpenSim.Region.ScriptEngine.Shared.YieldProlog.dll"));
|
||||
}
|
||||
|
||||
parameters.GenerateExecutable = false;
|
||||
parameters.OutputAssembly = OutFile;
|
||||
parameters.IncludeDebugInformation = CompileWithDebugInformation;
|
||||
|
@ -474,6 +515,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
|
|||
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() + "\"");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue