diff options
author | Charles Krinke | 2008-06-26 13:42:18 +0000 |
---|---|---|
committer | Charles Krinke | 2008-06-26 13:42:18 +0000 |
commit | cf00df106db7e2b9c503232c79d8167f35c91a78 (patch) | |
tree | c9d2980a51fcd91136cc32b0b888464b578dd13f | |
parent | Apply patch from bug #1601 -- more documentation for Data/MySQL. Thanks keru... (diff) | |
download | opensim-SC-cf00df106db7e2b9c503232c79d8167f35c91a78.zip opensim-SC-cf00df106db7e2b9c503232c79d8167f35c91a78.tar.gz opensim-SC-cf00df106db7e2b9c503232c79d8167f35c91a78.tar.bz2 opensim-SC-cf00df106db7e2b9c503232c79d8167f35c91a78.tar.xz |
Mantis#1602. Thank you, Kinoc for a patch to:
Patch to activate YieldProlog on Xengine.
Only adds YieldProlog to assembly if required.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/YPCompiler.cs | 2 | ||||
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs | 50 |
2 files changed, 48 insertions, 4 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/YPCompiler.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/YPCompiler.cs index f2f8145..c2040c9 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/YPCompiler.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/YPCompiler.cs | |||
@@ -355,7 +355,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog | |||
355 | sourceCode.Append(@" | 355 | sourceCode.Append(@" |
356 | using System; | 356 | using System; |
357 | using System.Collections.Generic; | 357 | using System.Collections.Generic; |
358 | using YieldProlog; | 358 | using OpenSim.Region.ScriptEngine.Shared.YieldProlog; |
359 | 359 | ||
360 | namespace Temporary { | 360 | namespace Temporary { |
361 | public class Temporary : YP.IClause { | 361 | public class Temporary : YP.IClause { |
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs index 2edcee0..841ed26 100644 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs | |||
@@ -55,7 +55,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
55 | lsl = 0, | 55 | lsl = 0, |
56 | cs = 1, | 56 | cs = 1, |
57 | vb = 2, | 57 | vb = 2, |
58 | js = 3 | 58 | js = 3, |
59 | yp = 4 | ||
59 | } | 60 | } |
60 | 61 | ||
61 | /// <summary> | 62 | /// <summary> |
@@ -75,6 +76,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
75 | private static CSharpCodeProvider CScodeProvider = new CSharpCodeProvider(); | 76 | private static CSharpCodeProvider CScodeProvider = new CSharpCodeProvider(); |
76 | private static VBCodeProvider VBcodeProvider = new VBCodeProvider(); | 77 | private static VBCodeProvider VBcodeProvider = new VBCodeProvider(); |
77 | private static JScriptCodeProvider JScodeProvider = new JScriptCodeProvider(); | 78 | private static JScriptCodeProvider JScodeProvider = new JScriptCodeProvider(); |
79 | private static CSharpCodeProvider YPcodeProvider = new CSharpCodeProvider(); // YP is translated into CSharp | ||
80 | private static YP2CSConverter YP_Converter = new YP2CSConverter(); | ||
78 | 81 | ||
79 | private static int instanceID = new Random().Next(0, int.MaxValue); // Unique number to use on our compiled files | 82 | private static int instanceID = new Random().Next(0, int.MaxValue); // Unique number to use on our compiled files |
80 | private static UInt64 scriptCompileCounter = 0; // And a counter | 83 | private static UInt64 scriptCompileCounter = 0; // And a counter |
@@ -112,9 +115,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
112 | LanguageMapping.Add(enumCompileType.vb.ToString(), enumCompileType.vb); | 115 | LanguageMapping.Add(enumCompileType.vb.ToString(), enumCompileType.vb); |
113 | LanguageMapping.Add(enumCompileType.lsl.ToString(), enumCompileType.lsl); | 116 | LanguageMapping.Add(enumCompileType.lsl.ToString(), enumCompileType.lsl); |
114 | LanguageMapping.Add(enumCompileType.js.ToString(), enumCompileType.js); | 117 | LanguageMapping.Add(enumCompileType.js.ToString(), enumCompileType.js); |
118 | LanguageMapping.Add(enumCompileType.yp.ToString(), enumCompileType.yp); | ||
115 | 119 | ||
116 | // Allowed compilers | 120 | // Allowed compilers |
117 | string allowComp = m_scriptEngine.Config.GetString("AllowedCompilers", "lsl,cs,vb,js"); | 121 | string allowComp = m_scriptEngine.Config.GetString("AllowedCompilers", "lsl,cs,vb,js,yp"); |
118 | AllowedCompilers.Clear(); | 122 | AllowedCompilers.Clear(); |
119 | 123 | ||
120 | #if DEBUG | 124 | #if DEBUG |
@@ -303,6 +307,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
303 | if (Script.StartsWith("//js", true, CultureInfo.InvariantCulture)) | 307 | if (Script.StartsWith("//js", true, CultureInfo.InvariantCulture)) |
304 | l = enumCompileType.js; | 308 | l = enumCompileType.js; |
305 | 309 | ||
310 | if (Script.StartsWith("//yp", true, CultureInfo.InvariantCulture)) | ||
311 | l = enumCompileType.yp; | ||
312 | |||
306 | if (!AllowedCompilers.ContainsKey(l.ToString())) | 313 | if (!AllowedCompilers.ContainsKey(l.ToString())) |
307 | { | 314 | { |
308 | // Not allowed to compile to this language! | 315 | // Not allowed to compile to this language! |
@@ -320,12 +327,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
320 | l = enumCompileType.cs; | 327 | l = enumCompileType.cs; |
321 | } | 328 | } |
322 | 329 | ||
330 | if (l == enumCompileType.yp) | ||
331 | { | ||
332 | // Its YP, convert it to C# | ||
333 | compileScript = YP_Converter.Convert(Script); | ||
334 | // We have our own processor now | ||
335 | //l = enumCompileType.cs; | ||
336 | } | ||
337 | |||
323 | // Insert additional assemblies here | 338 | // Insert additional assemblies here |
324 | 339 | ||
325 | //ADAM: Disabled for the moment until it's working right. | 340 | //ADAM: Disabled for the moment until it's working right. |
326 | bool enableCommanderLSL = false; | 341 | bool enableCommanderLSL = false; |
327 | 342 | ||
328 | if (enableCommanderLSL == true && l == enumCompileType.cs) | 343 | if (enableCommanderLSL == true && ((l == enumCompileType.cs) || (l == enumCompileType.yp))) |
329 | { | 344 | { |
330 | foreach (KeyValuePair<string, | 345 | foreach (KeyValuePair<string, |
331 | ICommander> com | 346 | ICommander> com |
@@ -348,6 +363,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
348 | case enumCompileType.js: | 363 | case enumCompileType.js: |
349 | compileScript = CreateJSCompilerScript(compileScript); | 364 | compileScript = CreateJSCompilerScript(compileScript); |
350 | break; | 365 | break; |
366 | case enumCompileType.yp: | ||
367 | compileScript = CreateYPCompilerScript(compileScript); | ||
368 | break; | ||
351 | } | 369 | } |
352 | 370 | ||
353 | // m_log.Debug("[ScriptEngine.DotNetEngine]: Preparing to compile the following LSL to C# translated code"); | 371 | // 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 | |||
380 | return compileScript; | 398 | return compileScript; |
381 | } | 399 | } |
382 | 400 | ||
401 | private static string CreateYPCompilerScript(string compileScript) | ||
402 | { | ||
403 | |||
404 | |||
405 | compileScript = String.Empty + | ||
406 | "using OpenSim.Region.ScriptEngine.Shared.YieldProlog; " + | ||
407 | "using OpenSim.Region.ScriptEngine.Shared; using System.Collections.Generic;\r\n" + | ||
408 | String.Empty + "namespace SecondLife { " + | ||
409 | String.Empty + "public class Script : OpenSim.Region.ScriptEngine.Shared.ScriptBase.ScriptBaseClass { \r\n" + | ||
410 | //@"public Script() { } " + | ||
411 | @"static OpenSim.Region.ScriptEngine.Shared.YieldProlog.YP YP=null; " + | ||
412 | @"public Script() { YP= new OpenSim.Region.ScriptEngine.Shared.YieldProlog.YP(); } " + | ||
413 | |||
414 | compileScript + | ||
415 | "} }\r\n"; | ||
416 | return compileScript; | ||
417 | } | ||
418 | |||
383 | private static string CreateVBCompilerScript(string compileScript) | 419 | private static string CreateVBCompilerScript(string compileScript) |
384 | { | 420 | { |
385 | compileScript = String.Empty + | 421 | compileScript = String.Empty + |
@@ -455,6 +491,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
455 | parameters.ReferencedAssemblies.Add(Path.Combine(rootPath, "OpenSim.Region.ScriptEngine.Shared.dll")); | 491 | parameters.ReferencedAssemblies.Add(Path.Combine(rootPath, "OpenSim.Region.ScriptEngine.Shared.dll")); |
456 | parameters.ReferencedAssemblies.Add(Path.Combine(rootPath, "OpenSim.Region.ScriptEngine.Shared.Api.Runtime.dll")); | 492 | parameters.ReferencedAssemblies.Add(Path.Combine(rootPath, "OpenSim.Region.ScriptEngine.Shared.Api.Runtime.dll")); |
457 | 493 | ||
494 | if (lang == enumCompileType.yp) | ||
495 | { | ||
496 | parameters.ReferencedAssemblies.Add(Path.Combine(rootPath, "OpenSim.Region.ScriptEngine.Shared.YieldProlog.dll")); | ||
497 | } | ||
498 | |||
458 | parameters.GenerateExecutable = false; | 499 | parameters.GenerateExecutable = false; |
459 | parameters.OutputAssembly = OutFile; | 500 | parameters.OutputAssembly = OutFile; |
460 | parameters.IncludeDebugInformation = CompileWithDebugInformation; | 501 | parameters.IncludeDebugInformation = CompileWithDebugInformation; |
@@ -474,6 +515,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
474 | case enumCompileType.js: | 515 | case enumCompileType.js: |
475 | results = JScodeProvider.CompileAssemblyFromSource(parameters, Script); | 516 | results = JScodeProvider.CompileAssemblyFromSource(parameters, Script); |
476 | break; | 517 | break; |
518 | case enumCompileType.yp: | ||
519 | results = YPcodeProvider.CompileAssemblyFromSource(parameters, Script); | ||
520 | break; | ||
477 | default: | 521 | default: |
478 | throw new Exception("Compiler is not able to recongnize language type \"" + lang.ToString() + "\""); | 522 | throw new Exception("Compiler is not able to recongnize language type \"" + lang.ToString() + "\""); |
479 | } | 523 | } |