aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs34
1 files changed, 30 insertions, 4 deletions
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
76 private static CSharpCodeProvider CScodeProvider = new CSharpCodeProvider(); 76 private static CSharpCodeProvider CScodeProvider = new CSharpCodeProvider();
77 private static VBCodeProvider VBcodeProvider = new VBCodeProvider(); 77 private static VBCodeProvider VBcodeProvider = new VBCodeProvider();
78 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
79 private static YP2CSConverter YP_Converter = new YP2CSConverter(); 80 private static YP2CSConverter YP_Converter = new YP2CSConverter();
80 81
81 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
@@ -118,7 +119,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
118 LanguageMapping.Add(enumCompileType.yp.ToString(), enumCompileType.yp); 119 LanguageMapping.Add(enumCompileType.yp.ToString(), enumCompileType.yp);
119 120
120 // Allowed compilers 121 // Allowed compilers
121 string allowComp = m_scriptEngine.ScriptConfigSource.GetString("AllowedCompilers", "lsl,cs,vb,js"); 122 string allowComp = m_scriptEngine.ScriptConfigSource.GetString("AllowedCompilers", "lsl,cs,vb,js,yp");
122 AllowedCompilers.Clear(); 123 AllowedCompilers.Clear();
123 124
124#if DEBUG 125#if DEBUG
@@ -279,9 +280,10 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
279 280
280 if (l == enumCompileType.yp) 281 if (l == enumCompileType.yp)
281 { 282 {
282 // Its LSL, convert it to C# 283 // Its YP, convert it to C#
283 compileScript = YP_Converter.Convert(Script); 284 compileScript = YP_Converter.Convert(Script);
284 l = enumCompileType.cs; 285 // We have our own processor now
286 //l = enumCompileType.cs;
285 } 287 }
286 288
287 // Insert additional assemblies here 289 // Insert additional assemblies here
@@ -289,7 +291,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
289 //ADAM: Disabled for the moment until it's working right. 291 //ADAM: Disabled for the moment until it's working right.
290 bool enableCommanderLSL = false; 292 bool enableCommanderLSL = false;
291 293
292 if (enableCommanderLSL == true && l == enumCompileType.cs) 294 if (enableCommanderLSL == true && ((l == enumCompileType.cs) || (l == enumCompileType.yp)))
293 { 295 {
294 foreach (KeyValuePair<string, 296 foreach (KeyValuePair<string,
295 ICommander> com 297 ICommander> com
@@ -313,6 +315,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
313 case enumCompileType.js: 315 case enumCompileType.js:
314 compileScript = CreateJSCompilerScript(compileScript); 316 compileScript = CreateJSCompilerScript(compileScript);
315 break; 317 break;
318 case enumCompileType.yp:
319 compileScript = CreateYPCompilerScript(compileScript);
320 break;
316 } 321 }
317 322
318 m_log.Debug("[ScriptEngine.DotNetEngine]: Preparing to compile the following LSL to C# translated code"); 323 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
345 return compileScript; 350 return compileScript;
346 } 351 }
347 352
353 private static string CreateYPCompilerScript(string compileScript)
354 {
355
356
357 compileScript = String.Empty +
358 "using OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog; " +
359 "using OpenSim.Region.ScriptEngine.Common; using System.Collections.Generic;\r\n" +
360 String.Empty + "namespace SecondLife { " +
361 String.Empty + "public class Script : OpenSim.Region.ScriptEngine.Common.BuiltIn_Commands_BaseClass { \r\n" +
362 //@"public Script() { } " +
363 @"static OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog.YP YP=null; " +
364 @"public Script() { YP= new OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog.YP(); } "+
365
366 compileScript +
367 "} }\r\n";
368 return compileScript;
369 }
370
348 private static string CreateVBCompilerScript(string compileScript) 371 private static string CreateVBCompilerScript(string compileScript)
349 { 372 {
350 compileScript = String.Empty + 373 compileScript = String.Empty +
@@ -438,6 +461,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
438 case enumCompileType.js: 461 case enumCompileType.js:
439 results = JScodeProvider.CompileAssemblyFromSource(parameters, Script); 462 results = JScodeProvider.CompileAssemblyFromSource(parameters, Script);
440 break; 463 break;
464 case enumCompileType.yp:
465 results = YPcodeProvider.CompileAssemblyFromSource(parameters, Script);
466 break;
441 default: 467 default:
442 throw new Exception("Compiler is not able to recongnize language type \"" + lang.ToString() + "\""); 468 throw new Exception("Compiler is not able to recongnize language type \"" + lang.ToString() + "\"");
443 } 469 }