aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorlbsa712008-05-31 18:47:26 +0000
committerlbsa712008-05-31 18:47:26 +0000
commit7f9967d3102983444b4103bee91fa3bc022eb1fe (patch)
tree5110aa7b61a0af0669ae230bcf6b693ff20b4649
parent* minor: Add copyright statement (diff)
downloadopensim-SC_OLD-7f9967d3102983444b4103bee91fa3bc022eb1fe.zip
opensim-SC_OLD-7f9967d3102983444b4103bee91fa3bc022eb1fe.tar.gz
opensim-SC_OLD-7f9967d3102983444b4103bee91fa3bc022eb1fe.tar.bz2
opensim-SC_OLD-7f9967d3102983444b4103bee91fa3bc022eb1fe.tar.xz
* Enabled the Yield Prolog Script Engine
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs33
1 files changed, 25 insertions, 8 deletions
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs
index f661162..81eb86b 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs
@@ -39,9 +39,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
39{ 39{
40 public class Compiler 40 public class Compiler
41 { 41 {
42 private static readonly log4net.ILog m_log 42 private static readonly log4net.ILog m_log
43 = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); 43 = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
44 44
45 // * Uses "LSL2Converter" to convert LSL to C# if necessary. 45 // * Uses "LSL2Converter" to convert LSL to C# if necessary.
46 // * Compiles C#-code into an assembly 46 // * Compiles C#-code into an assembly
47 // * Returns assembly name ready for AppDomain load. 47 // * Returns assembly name ready for AppDomain load.
@@ -54,7 +54,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
54 lsl = 0, 54 lsl = 0,
55 cs = 1, 55 cs = 1,
56 vb = 2, 56 vb = 2,
57 js = 3 57 js = 3,
58 yp = 4
58 } 59 }
59 60
60 /// <summary> 61 /// <summary>
@@ -75,6 +76,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
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 YP2CSConverter YP_Converter = new YP2CSConverter();
78 80
79 private static int instanceID = new Random().Next(0, int.MaxValue); // Unique number to use on our compiled files 81 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 82 private static UInt64 scriptCompileCounter = 0; // And a counter
@@ -113,6 +115,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
113 LanguageMapping.Add(enumCompileType.vb.ToString(), enumCompileType.vb); 115 LanguageMapping.Add(enumCompileType.vb.ToString(), enumCompileType.vb);
114 LanguageMapping.Add(enumCompileType.lsl.ToString(), enumCompileType.lsl); 116 LanguageMapping.Add(enumCompileType.lsl.ToString(), enumCompileType.lsl);
115 LanguageMapping.Add(enumCompileType.js.ToString(), enumCompileType.js); 117 LanguageMapping.Add(enumCompileType.js.ToString(), enumCompileType.js);
118 LanguageMapping.Add(enumCompileType.yp.ToString(), enumCompileType.yp);
116 119
117 // Allowed compilers 120 // Allowed compilers
118 string allowComp = m_scriptEngine.ScriptConfigSource.GetString("AllowedCompilers", "lsl,cs,vb,js"); 121 string allowComp = m_scriptEngine.ScriptConfigSource.GetString("AllowedCompilers", "lsl,cs,vb,js");
@@ -254,6 +257,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
254 if (Script.StartsWith("//js", true, CultureInfo.InvariantCulture)) 257 if (Script.StartsWith("//js", true, CultureInfo.InvariantCulture))
255 l = enumCompileType.js; 258 l = enumCompileType.js;
256 259
260 if (Script.StartsWith("//yp", true, CultureInfo.InvariantCulture))
261 l = enumCompileType.yp;
262
257 if (!AllowedCompilers.ContainsKey(l.ToString())) 263 if (!AllowedCompilers.ContainsKey(l.ToString()))
258 { 264 {
259 // Not allowed to compile to this language! 265 // Not allowed to compile to this language!
@@ -271,6 +277,13 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
271 l = enumCompileType.cs; 277 l = enumCompileType.cs;
272 } 278 }
273 279
280 if (l == enumCompileType.yp)
281 {
282 // Its LSL, convert it to C#
283 compileScript = YP_Converter.Convert(Script);
284 l = enumCompileType.cs;
285 }
286
274 // Insert additional assemblies here 287 // Insert additional assemblies here
275 288
276 //ADAM: Disabled for the moment until it's working right. 289 //ADAM: Disabled for the moment until it's working right.
@@ -278,8 +291,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
278 291
279 if (enableCommanderLSL == true && l == enumCompileType.cs) 292 if (enableCommanderLSL == true && l == enumCompileType.cs)
280 { 293 {
281 foreach (KeyValuePair<string, 294 foreach (KeyValuePair<string,
282 ICommander> com 295 ICommander> com
283 in m_scriptEngine.World.GetCommanders()) 296 in m_scriptEngine.World.GetCommanders())
284 { 297 {
285 compileScript = com.Value.GenerateRuntimeAPI() + compileScript; 298 compileScript = com.Value.GenerateRuntimeAPI() + compileScript;
@@ -305,7 +318,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
305 m_log.Debug("[ScriptEngine.DotNetEngine]: Preparing to compile the following LSL to C# translated code"); 318 m_log.Debug("[ScriptEngine.DotNetEngine]: Preparing to compile the following LSL to C# translated code");
306 m_log.Debug(""); 319 m_log.Debug("");
307 m_log.Debug(compileScript); 320 m_log.Debug(compileScript);
308 321
309 return CompileFromDotNetText(compileScript, l); 322 return CompileFromDotNetText(compileScript, l);
310 } 323 }
311 324
@@ -322,13 +335,17 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
322 335
323 private static string CreateCSCompilerScript(string compileScript) 336 private static string CreateCSCompilerScript(string compileScript)
324 { 337 {
325 338
326 339
327 compileScript = String.Empty + 340 compileScript = String.Empty +
341 "using OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog; " +
328 "using OpenSim.Region.ScriptEngine.Common; using System.Collections.Generic;\r\n" + 342 "using OpenSim.Region.ScriptEngine.Common; using System.Collections.Generic;\r\n" +
329 String.Empty + "namespace SecondLife { " + 343 String.Empty + "namespace SecondLife { " +
330 String.Empty + "public class Script : OpenSim.Region.ScriptEngine.Common.BuiltIn_Commands_BaseClass { \r\n" + 344 String.Empty + "public class Script : OpenSim.Region.ScriptEngine.Common.BuiltIn_Commands_BaseClass { \r\n" +
331 @"public Script() { } " + 345 //@"public Script() { } " +
346 @"static OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog.YP YP=null; " +
347 @"public Script() { YP= new OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog.YP(); } "+
348
332 compileScript + 349 compileScript +
333 "} }\r\n"; 350 "} }\r\n";
334 return compileScript; 351 return compileScript;