From ba16daff7c52edfb4e84300ce2ccaab6af49e712 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Mon, 4 Feb 2008 12:43:07 +0000 Subject: * Added JavaScript support to OpenSim scripting. Totally Untested. Enjoy. :) --- .../DotNetEngine/Compiler/LSL/Compiler.cs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region') 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; using System.Reflection; using Microsoft.CSharp; using Microsoft.VisualBasic; +using Microsoft.JScript; namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL { @@ -51,7 +52,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL { lsl = 0, cs = 1, - vb = 2 + vb = 2, + js = 3 } private enumCompileType DefaultCompileLanguage; private bool WriteScriptSourceToDebugFile; @@ -66,6 +68,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL private static LSL2CSConverter LSL_Converter = new LSL2CSConverter(); private static CSharpCodeProvider CScodeProvider = new CSharpCodeProvider(); private static VBCodeProvider VBcodeProvider = new VBCodeProvider(); + private static JScriptCodeProvider JScodeProvider = new JScriptCodeProvider(); 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 @@ -103,9 +106,10 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL LanguageMapping.Add(enumCompileType.cs.ToString(), enumCompileType.cs); LanguageMapping.Add(enumCompileType.vb.ToString(), enumCompileType.vb); LanguageMapping.Add(enumCompileType.lsl.ToString(), enumCompileType.lsl); + LanguageMapping.Add(enumCompileType.js.ToString(), enumCompileType.js); // Allowed compilers - string allowComp = m_scriptEngine.ScriptConfigSource.GetString("AllowedCompilers", "lsl,cs,vb"); + string allowComp = m_scriptEngine.ScriptConfigSource.GetString("AllowedCompilers", "lsl,cs,vb,js"); AllowedCompilers.Clear(); #if DEBUG @@ -241,6 +245,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL if (Script.StartsWith("//lsl", true, CultureInfo.InvariantCulture)) l = enumCompileType.lsl; + if (Script.StartsWith("//js", true, CultureInfo.InvariantCulture)) + l = enumCompileType.js; if (!AllowedCompilers.ContainsKey(l.ToString())) { @@ -278,6 +284,14 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL @"Public Sub New(): End Sub: " + compileScript + ":End Class :End Namespace\r\n"; + case enumCompileType.js: + compileScript = String.Empty + + "import OpenSim.Region.ScriptEngine.Common; import System.Collections.Generic;" + + "namespace SecondLife { " + + "class Script : OpenSim.Region.ScriptEngine.Common.LSL_BaseClass { " + + @"public Script() { } " + + compileScript + + "} }\r\n"; break; } return CompileFromCSorVBText(compileScript, l); @@ -361,6 +375,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL case enumCompileType.cs: results = CScodeProvider.CompileAssemblyFromSource(parameters, Script); break; + case enumCompileType.js: + results = JScodeProvider.CompileAssemblyFromSource(parameters, Script); + break; default: throw new Exception("Compiler is not able to recongnize language type \"" + lang.ToString() + "\""); } -- cgit v1.1