diff options
author | Adam Frisby | 2008-02-04 12:43:07 +0000 |
---|---|---|
committer | Adam Frisby | 2008-02-04 12:43:07 +0000 |
commit | ba16daff7c52edfb4e84300ce2ccaab6af49e712 (patch) | |
tree | a82e1cbcb7a402aa8820aecfb41237bb071ceb32 /OpenSim/Region/ScriptEngine | |
parent | First part of avatar persistence, currently only really works in standalone m... (diff) | |
download | opensim-SC_OLD-ba16daff7c52edfb4e84300ce2ccaab6af49e712.zip opensim-SC_OLD-ba16daff7c52edfb4e84300ce2ccaab6af49e712.tar.gz opensim-SC_OLD-ba16daff7c52edfb4e84300ce2ccaab6af49e712.tar.bz2 opensim-SC_OLD-ba16daff7c52edfb4e84300ce2ccaab6af49e712.tar.xz |
* Added JavaScript support to OpenSim scripting. Totally Untested. Enjoy. :)
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs index c994fea..a8cdbd5 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs | |||
@@ -34,6 +34,7 @@ using System.IO; | |||
34 | using System.Reflection; | 34 | using System.Reflection; |
35 | using Microsoft.CSharp; | 35 | using Microsoft.CSharp; |
36 | using Microsoft.VisualBasic; | 36 | using Microsoft.VisualBasic; |
37 | using Microsoft.JScript; | ||
37 | 38 | ||
38 | namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL | 39 | namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL |
39 | { | 40 | { |
@@ -51,7 +52,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL | |||
51 | { | 52 | { |
52 | lsl = 0, | 53 | lsl = 0, |
53 | cs = 1, | 54 | cs = 1, |
54 | vb = 2 | 55 | vb = 2, |
56 | js = 3 | ||
55 | } | 57 | } |
56 | private enumCompileType DefaultCompileLanguage; | 58 | private enumCompileType DefaultCompileLanguage; |
57 | private bool WriteScriptSourceToDebugFile; | 59 | private bool WriteScriptSourceToDebugFile; |
@@ -66,6 +68,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL | |||
66 | private static LSL2CSConverter LSL_Converter = new LSL2CSConverter(); | 68 | private static LSL2CSConverter LSL_Converter = new LSL2CSConverter(); |
67 | private static CSharpCodeProvider CScodeProvider = new CSharpCodeProvider(); | 69 | private static CSharpCodeProvider CScodeProvider = new CSharpCodeProvider(); |
68 | private static VBCodeProvider VBcodeProvider = new VBCodeProvider(); | 70 | private static VBCodeProvider VBcodeProvider = new VBCodeProvider(); |
71 | private static JScriptCodeProvider JScodeProvider = new JScriptCodeProvider(); | ||
69 | 72 | ||
70 | private static int instanceID = new Random().Next(0, int.MaxValue); // Unique number to use on our compiled files | 73 | private static int instanceID = new Random().Next(0, int.MaxValue); // Unique number to use on our compiled files |
71 | private static UInt64 scriptCompileCounter = 0; // And a counter | 74 | private static UInt64 scriptCompileCounter = 0; // And a counter |
@@ -103,9 +106,10 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL | |||
103 | LanguageMapping.Add(enumCompileType.cs.ToString(), enumCompileType.cs); | 106 | LanguageMapping.Add(enumCompileType.cs.ToString(), enumCompileType.cs); |
104 | LanguageMapping.Add(enumCompileType.vb.ToString(), enumCompileType.vb); | 107 | LanguageMapping.Add(enumCompileType.vb.ToString(), enumCompileType.vb); |
105 | LanguageMapping.Add(enumCompileType.lsl.ToString(), enumCompileType.lsl); | 108 | LanguageMapping.Add(enumCompileType.lsl.ToString(), enumCompileType.lsl); |
109 | LanguageMapping.Add(enumCompileType.js.ToString(), enumCompileType.js); | ||
106 | 110 | ||
107 | // Allowed compilers | 111 | // Allowed compilers |
108 | string allowComp = m_scriptEngine.ScriptConfigSource.GetString("AllowedCompilers", "lsl,cs,vb"); | 112 | string allowComp = m_scriptEngine.ScriptConfigSource.GetString("AllowedCompilers", "lsl,cs,vb,js"); |
109 | AllowedCompilers.Clear(); | 113 | AllowedCompilers.Clear(); |
110 | 114 | ||
111 | #if DEBUG | 115 | #if DEBUG |
@@ -241,6 +245,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL | |||
241 | if (Script.StartsWith("//lsl", true, CultureInfo.InvariantCulture)) | 245 | if (Script.StartsWith("//lsl", true, CultureInfo.InvariantCulture)) |
242 | l = enumCompileType.lsl; | 246 | l = enumCompileType.lsl; |
243 | 247 | ||
248 | if (Script.StartsWith("//js", true, CultureInfo.InvariantCulture)) | ||
249 | l = enumCompileType.js; | ||
244 | 250 | ||
245 | if (!AllowedCompilers.ContainsKey(l.ToString())) | 251 | if (!AllowedCompilers.ContainsKey(l.ToString())) |
246 | { | 252 | { |
@@ -278,6 +284,14 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL | |||
278 | @"Public Sub New(): End Sub: " + | 284 | @"Public Sub New(): End Sub: " + |
279 | compileScript + | 285 | compileScript + |
280 | ":End Class :End Namespace\r\n"; | 286 | ":End Class :End Namespace\r\n"; |
287 | case enumCompileType.js: | ||
288 | compileScript = String.Empty + | ||
289 | "import OpenSim.Region.ScriptEngine.Common; import System.Collections.Generic;" + | ||
290 | "namespace SecondLife { " + | ||
291 | "class Script : OpenSim.Region.ScriptEngine.Common.LSL_BaseClass { " + | ||
292 | @"public Script() { } " + | ||
293 | compileScript + | ||
294 | "} }\r\n"; | ||
281 | break; | 295 | break; |
282 | } | 296 | } |
283 | return CompileFromCSorVBText(compileScript, l); | 297 | return CompileFromCSorVBText(compileScript, l); |
@@ -361,6 +375,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL | |||
361 | case enumCompileType.cs: | 375 | case enumCompileType.cs: |
362 | results = CScodeProvider.CompileAssemblyFromSource(parameters, Script); | 376 | results = CScodeProvider.CompileAssemblyFromSource(parameters, Script); |
363 | break; | 377 | break; |
378 | case enumCompileType.js: | ||
379 | results = JScodeProvider.CompileAssemblyFromSource(parameters, Script); | ||
380 | break; | ||
364 | default: | 381 | default: |
365 | throw new Exception("Compiler is not able to recongnize language type \"" + lang.ToString() + "\""); | 382 | throw new Exception("Compiler is not able to recongnize language type \"" + lang.ToString() + "\""); |
366 | } | 383 | } |