diff options
Diffstat (limited to 'OpenSim/ScriptEngine/Components/DotNetEngine/Compilers')
8 files changed, 418 insertions, 16 deletions
diff --git a/OpenSim/ScriptEngine/Components/DotNetEngine/Compilers/CILCompiler.cs b/OpenSim/ScriptEngine/Components/DotNetEngine/Compilers/CILCompiler.cs new file mode 100644 index 0000000..e221e1b --- /dev/null +++ b/OpenSim/ScriptEngine/Components/DotNetEngine/Compilers/CILCompiler.cs | |||
@@ -0,0 +1,186 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | using System; | ||
28 | using System.CodeDom.Compiler; | ||
29 | using System.Collections.Generic; | ||
30 | using System.IO; | ||
31 | using System.Reflection; | ||
32 | using System.Text.RegularExpressions; | ||
33 | using log4net; | ||
34 | using OpenSim.ScriptEngine.Shared; | ||
35 | using ScriptAssemblies; | ||
36 | |||
37 | namespace OpenSim.ScriptEngine.Components.DotNetEngine.Compilers | ||
38 | { | ||
39 | public abstract class CILCompiler | ||
40 | { | ||
41 | internal static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
42 | private string ScriptEnginesPath = "ScriptEngines"; | ||
43 | private string Name { get { return "SECS.DotNetEngine.CILCompiler"; } } | ||
44 | internal string ScriptAssemblyName { get; set; } | ||
45 | |||
46 | // Default inherit | ||
47 | protected string ScriptInheritFrom = typeof(ScriptAssemblies.ScriptBase).Name; | ||
48 | private readonly System.Security.Cryptography.MD5CryptoServiceProvider MD5Sum = new System.Security.Cryptography.MD5CryptoServiceProvider(); | ||
49 | protected CodeDomProvider CompileProvider; | ||
50 | |||
51 | //private string[] AppDomainAssemblies = new string[] { "OpenSim.Region.ScriptEngine.Shared.dll", "OpenSim.Region.ScriptEngine.Shared.Script.dll", "OpenSim.Region.ScriptEngine.Shared.Api.Runtime.dll" }; | ||
52 | private readonly string[] AppDomainAssemblies = new string[] { | ||
53 | Assembly.GetAssembly(typeof(Int32)).Location, | ||
54 | "OpenSim.ScriptEngine.Shared.dll", | ||
55 | "OpenSim.ScriptEngine.Shared.Script.dll", | ||
56 | Path.Combine("ScriptEngines", "OpenSim.Region.ScriptEngine.Shared.dll") | ||
57 | }; | ||
58 | |||
59 | public abstract string PreProcessScript(ref string script); | ||
60 | |||
61 | public CILCompiler() | ||
62 | { | ||
63 | } | ||
64 | |||
65 | private static readonly Regex FileNameFixer = new Regex(@"[^a-zA-Z0-9\.\-]", RegexOptions.Compiled | RegexOptions.Singleline); | ||
66 | public string Compile(ScriptMetaData data, ref string _script) | ||
67 | { | ||
68 | // Add "using", "inherit", default constructor, etc around script. | ||
69 | string script = PreProcessScript(ref _script); | ||
70 | |||
71 | // Get filename based on content | ||
72 | string md5Sum = System.Convert.ToBase64String( | ||
73 | MD5Sum.ComputeHash( | ||
74 | System.Text.Encoding.ASCII.GetBytes(script) | ||
75 | )); | ||
76 | // Unique name for this assembly | ||
77 | ScriptAssemblyName = "SECS_Script_" + FileNameFixer.Replace(md5Sum, "_"); | ||
78 | |||
79 | string OutFile = Path.Combine(ScriptEnginesPath, ScriptAssemblyName + ".dll"); | ||
80 | |||
81 | // Make sure target dir exist | ||
82 | if (!Directory.Exists(ScriptEnginesPath)) | ||
83 | try { Directory.CreateDirectory(ScriptEnginesPath); } | ||
84 | catch { } | ||
85 | |||
86 | // Already exist? No point in recompiling | ||
87 | if (File.Exists(OutFile)) | ||
88 | return OutFile; | ||
89 | |||
90 | // | ||
91 | // Dump source code | ||
92 | // | ||
93 | string dumpFile = OutFile + ".txt"; | ||
94 | try | ||
95 | { | ||
96 | if (File.Exists(dumpFile)) | ||
97 | File.Delete(dumpFile); | ||
98 | File.WriteAllText(dumpFile, script); | ||
99 | } | ||
100 | catch (Exception e) | ||
101 | { | ||
102 | m_log.DebugFormat("[{0}] Exception trying to dump script source code to file \"{1}\": {2}", Name, dumpFile, e.ToString()); | ||
103 | } | ||
104 | |||
105 | // | ||
106 | // COMPILE | ||
107 | // | ||
108 | |||
109 | CompilerParameters parameters = new CompilerParameters(); | ||
110 | parameters.IncludeDebugInformation = true; | ||
111 | string rootPath = Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory); | ||
112 | |||
113 | foreach (string file in AppDomainAssemblies) | ||
114 | { | ||
115 | parameters.ReferencedAssemblies.Add(file); | ||
116 | m_log.DebugFormat("[{0}] Adding reference for compile: \"{1}\".", Name, file); | ||
117 | } | ||
118 | //lock (commandProvider) | ||
119 | //{ | ||
120 | // foreach (string key in commandProvider.Keys) | ||
121 | // { | ||
122 | // IScriptCommandProvider cp = commandProvider[key]; | ||
123 | // string | ||
124 | // file = cp.GetType().Assembly.Location; | ||
125 | // parameters.ReferencedAssemblies.Add(file); | ||
126 | // m_log.DebugFormat("[{0}] Loading command provider assembly \"{1}\" into AppDomain: \"{2}\".", Name, | ||
127 | // key, file); | ||
128 | // } | ||
129 | //} | ||
130 | |||
131 | parameters.GenerateExecutable = false; | ||
132 | parameters.OutputAssembly = OutFile; | ||
133 | parameters.IncludeDebugInformation = true; | ||
134 | //parameters.WarningLevel = 1; // Should be 4? | ||
135 | parameters.TreatWarningsAsErrors = false; | ||
136 | |||
137 | // Do compile | ||
138 | CompilerResults results = CompileProvider.CompileAssemblyFromSource(parameters, script); | ||
139 | |||
140 | |||
141 | // | ||
142 | // WARNINGS AND ERRORS | ||
143 | // | ||
144 | //TODO | ||
145 | int display = 5; | ||
146 | if (results.Errors.Count > 0) | ||
147 | { | ||
148 | string errtext = String.Empty; | ||
149 | foreach (CompilerError CompErr in results.Errors) | ||
150 | { | ||
151 | // Show 5 errors max | ||
152 | // | ||
153 | if (display <= 0) | ||
154 | break; | ||
155 | display--; | ||
156 | |||
157 | string severity = "Error"; | ||
158 | if (CompErr.IsWarning) | ||
159 | severity = "Warning"; | ||
160 | |||
161 | //TODO: Implement | ||
162 | KeyValuePair<int, int> lslPos = new KeyValuePair<int, int>(); | ||
163 | |||
164 | //lslPos = "NOT IMPLEMENTED";// FindErrorPosition(CompErr.Line, CompErr.Column); | ||
165 | |||
166 | string text = CompErr.ErrorText; | ||
167 | |||
168 | // The Second Life viewer's script editor begins | ||
169 | // countingn lines and columns at 0, so we subtract 1. | ||
170 | errtext += String.Format("Line ({0},{1}): {4} {2}: {3}\n", | ||
171 | lslPos.Key - 1, lslPos.Value - 1, | ||
172 | CompErr.ErrorNumber, text, severity); | ||
173 | } | ||
174 | |||
175 | if (!File.Exists(OutFile)) | ||
176 | { | ||
177 | throw new Exception(errtext); | ||
178 | } | ||
179 | } | ||
180 | |||
181 | // TODO: Process errors | ||
182 | return OutFile; | ||
183 | } | ||
184 | |||
185 | } | ||
186 | } | ||
diff --git a/OpenSim/ScriptEngine/Components/DotNetEngine/Compilers/Compiler_CS.cs b/OpenSim/ScriptEngine/Components/DotNetEngine/Compilers/Compiler_CS.cs index 9c72359..1286dc5 100644 --- a/OpenSim/ScriptEngine/Components/DotNetEngine/Compilers/Compiler_CS.cs +++ b/OpenSim/ScriptEngine/Components/DotNetEngine/Compilers/Compiler_CS.cs | |||
@@ -25,20 +25,46 @@ | |||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | using System; | 27 | using System; |
28 | using System.CodeDom.Compiler; | ||
28 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
29 | using System.Text; | 30 | using System.Text; |
30 | using OpenSim.ApplicationPlugins.ScriptEngine.Components; | 31 | using Microsoft.CSharp; |
32 | using OpenSim.ScriptEngine.Shared; | ||
31 | 33 | ||
32 | namespace OpenSim.ScriptEngine.Components.DotNetEngine.Compilers | 34 | namespace OpenSim.ScriptEngine.Components.DotNetEngine.Compilers |
33 | { | 35 | { |
34 | public class Compiler_CS: CompilerBase | 36 | public class Compiler_CS : CILCompiler, IScriptCompiler |
35 | { | 37 | { |
36 | public override void Start() | 38 | private string[] ScriptUsing = new string[] |
39 | { | ||
40 | "System", | ||
41 | "OpenSim.ScriptEngine.Shared", | ||
42 | "OpenSim.Region.ScriptEngine.Shared", | ||
43 | "System.Collections.Generic" | ||
44 | }; | ||
45 | |||
46 | public Compiler_CS() | ||
37 | { | 47 | { |
48 | CompileProvider = new CSharpCodeProvider(); | ||
38 | } | 49 | } |
39 | 50 | ||
40 | public override void Close() | 51 | public override string PreProcessScript(ref string script) |
41 | { | 52 | { |
53 | string s = ""; | ||
54 | foreach (string u in ScriptUsing) | ||
55 | { | ||
56 | s += "using " + u + ";"; | ||
57 | } | ||
58 | |||
59 | s += "\r\n" | ||
60 | + String.Empty + "namespace ScriptAssemblies { " | ||
61 | + String.Empty + "public class UserScript" + " : " + ScriptInheritFrom + " { \r\n" + | ||
62 | @"public Script() { } " + | ||
63 | script + | ||
64 | "} }\r\n"; | ||
65 | |||
66 | return s; | ||
42 | } | 67 | } |
68 | |||
43 | } | 69 | } |
44 | } | 70 | } |
diff --git a/OpenSim/ScriptEngine/Components/DotNetEngine/Compilers/Compiler_JS.cs b/OpenSim/ScriptEngine/Components/DotNetEngine/Compilers/Compiler_JS.cs index 3dc8d86..5e9bfba 100644 --- a/OpenSim/ScriptEngine/Components/DotNetEngine/Compilers/Compiler_JS.cs +++ b/OpenSim/ScriptEngine/Components/DotNetEngine/Compilers/Compiler_JS.cs | |||
@@ -25,20 +25,32 @@ | |||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | using System; | 27 | using System; |
28 | using System.CodeDom.Compiler; | ||
28 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
29 | using System.Text; | 30 | using System.Text; |
30 | using OpenSim.ApplicationPlugins.ScriptEngine.Components; | 31 | using Microsoft.JScript; |
32 | using OpenSim.ScriptEngine.Shared; | ||
31 | 33 | ||
32 | namespace OpenSim.ScriptEngine.Components.DotNetEngine.Compilers | 34 | namespace OpenSim.ScriptEngine.Components.DotNetEngine.Compilers |
33 | { | 35 | { |
34 | public class Compiler_JS : CompilerBase | 36 | public class Compiler_JS : CILCompiler, IScriptCompiler |
35 | { | 37 | { |
36 | public override void Start() | 38 | |
39 | public Compiler_JS() | ||
37 | { | 40 | { |
41 | CompileProvider = new JScriptCodeProvider() as CodeDomProvider; | ||
38 | } | 42 | } |
39 | 43 | ||
40 | public override void Close() | 44 | public override string PreProcessScript(ref string script) |
41 | { | 45 | { |
46 | return | ||
47 | "import OpenSim.Region.ScriptEngine.Shared; import System.Collections.Generic;\r\n" + | ||
48 | "package SecondLife {\r\n" + | ||
49 | "class Script extends OpenSim.Region.ScriptEngine.Shared.ScriptBase.ScriptBaseClass { \r\n" + | ||
50 | script + | ||
51 | "} }\r\n"; | ||
52 | |||
42 | } | 53 | } |
54 | |||
43 | } | 55 | } |
44 | } | 56 | } |
diff --git a/OpenSim/ScriptEngine/Components/DotNetEngine/Compilers/Compiler_LSL.cs b/OpenSim/ScriptEngine/Components/DotNetEngine/Compilers/Compiler_LSL.cs index 3354ce9..d631c99 100644 --- a/OpenSim/ScriptEngine/Components/DotNetEngine/Compilers/Compiler_LSL.cs +++ b/OpenSim/ScriptEngine/Components/DotNetEngine/Compilers/Compiler_LSL.cs | |||
@@ -26,19 +26,32 @@ | |||
26 | */ | 26 | */ |
27 | using System; | 27 | using System; |
28 | using System.Collections.Generic; | 28 | using System.Collections.Generic; |
29 | using System.Reflection; | ||
29 | using System.Text; | 30 | using System.Text; |
30 | using OpenSim.ApplicationPlugins.ScriptEngine.Components; | 31 | using OpenSim.ScriptEngine.Components.DotNetEngine.Compilers.LSL; |
32 | using OpenSim.ScriptEngine.Shared; | ||
31 | 33 | ||
32 | namespace OpenSim.ScriptEngine.Components.DotNetEngine.Compilers | 34 | namespace OpenSim.ScriptEngine.Components.DotNetEngine.Compilers |
33 | { | 35 | { |
34 | public class Compiler_LSL : CompilerBase | 36 | public class Compiler_LSL : IScriptCompiler |
35 | { | 37 | { |
36 | public override void Start() | 38 | |
39 | |||
40 | private readonly Compiler_CS m_Compiler_CS = new Compiler_CS(); | ||
41 | private readonly LSL2CS m_LSL2CS = new LSL2CS(); | ||
42 | |||
43 | public string Compile(ScriptMetaData scriptMetaData, ref string script) | ||
37 | { | 44 | { |
45 | // Convert script to CS | ||
46 | string scriptCS = m_LSL2CS.Convert(ref script); | ||
47 | // Use CS compiler to compile it | ||
48 | return m_Compiler_CS.Compile(scriptMetaData, ref scriptCS); | ||
38 | } | 49 | } |
39 | 50 | ||
40 | public override void Close() | 51 | public string PreProcessScript(ref string script) |
41 | { | 52 | { |
53 | // This is handled by our converter | ||
54 | return script; | ||
42 | } | 55 | } |
43 | } | 56 | } |
44 | } | 57 | } |
diff --git a/OpenSim/ScriptEngine/Components/DotNetEngine/Compilers/Compiler_VB.cs b/OpenSim/ScriptEngine/Components/DotNetEngine/Compilers/Compiler_VB.cs index c7078cf..3975fa3 100644 --- a/OpenSim/ScriptEngine/Components/DotNetEngine/Compilers/Compiler_VB.cs +++ b/OpenSim/ScriptEngine/Components/DotNetEngine/Compilers/Compiler_VB.cs | |||
@@ -25,20 +25,32 @@ | |||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | using System; | 27 | using System; |
28 | using System.CodeDom.Compiler; | ||
28 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
29 | using System.Text; | 30 | using System.Text; |
30 | using OpenSim.ApplicationPlugins.ScriptEngine.Components; | 31 | using Microsoft.VisualBasic; |
32 | using OpenSim.ScriptEngine.Shared; | ||
31 | 33 | ||
32 | namespace OpenSim.ScriptEngine.Components.DotNetEngine.Compilers | 34 | namespace OpenSim.ScriptEngine.Components.DotNetEngine.Compilers |
33 | { | 35 | { |
34 | public class Compiler_VB : CompilerBase | 36 | public class Compiler_VB : CILCompiler, IScriptCompiler |
35 | { | 37 | { |
36 | public override void Start() | 38 | |
39 | public Compiler_VB() | ||
37 | { | 40 | { |
41 | CompileProvider = new VBCodeProvider() as CodeDomProvider; | ||
38 | } | 42 | } |
39 | 43 | ||
40 | public override void Close() | 44 | public override string PreProcessScript(ref string script) |
41 | { | 45 | { |
46 | return | ||
47 | "Imports OpenSim.Region.ScriptEngine.Shared: Imports System.Collections.Generic: " + | ||
48 | String.Empty + "NameSpace SecondLife:" + | ||
49 | String.Empty + "Public Class Script: Inherits OpenSim.Region.ScriptEngine.Shared.ScriptBase.ScriptBaseClass: " + | ||
50 | "\r\nPublic Sub New()\r\nEnd Sub: " + | ||
51 | script + | ||
52 | ":End Class :End Namespace\r\n"; | ||
42 | } | 53 | } |
43 | } | 54 | } |
44 | } | 55 | } |
56 | |||
diff --git a/OpenSim/ScriptEngine/Components/DotNetEngine/Compilers/Compiler_YP.cs b/OpenSim/ScriptEngine/Components/DotNetEngine/Compilers/Compiler_YP.cs new file mode 100644 index 0000000..c81ad76 --- /dev/null +++ b/OpenSim/ScriptEngine/Components/DotNetEngine/Compilers/Compiler_YP.cs | |||
@@ -0,0 +1,55 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | using System; | ||
28 | using System.Collections.Generic; | ||
29 | using System.Reflection; | ||
30 | using System.Text; | ||
31 | using OpenSim.ScriptEngine.Components.DotNetEngine.Compilers.YP; | ||
32 | using OpenSim.ScriptEngine.Shared; | ||
33 | |||
34 | namespace OpenSim.ScriptEngine.Components.DotNetEngine.Compilers | ||
35 | { | ||
36 | public class Compiler_YP: IScriptCompiler | ||
37 | { | ||
38 | |||
39 | private readonly Compiler_CS m_Compiler_CS = new Compiler_CS(); | ||
40 | |||
41 | public string Compile(ScriptMetaData scriptMetaData, ref string script) | ||
42 | { | ||
43 | // Convert script to CS | ||
44 | string scriptCS = YP2CS.Convert(ref script); | ||
45 | // Use CS compiler to compile it | ||
46 | return m_Compiler_CS.Compile(scriptMetaData, ref scriptCS); | ||
47 | } | ||
48 | |||
49 | public string PreProcessScript(ref string script) | ||
50 | { | ||
51 | // This is handled by our converter | ||
52 | return script; | ||
53 | } | ||
54 | } | ||
55 | } | ||
diff --git a/OpenSim/ScriptEngine/Components/DotNetEngine/Compilers/LSL/LSL2CS.cs b/OpenSim/ScriptEngine/Components/DotNetEngine/Compilers/LSL/LSL2CS.cs new file mode 100644 index 0000000..0e8052d --- /dev/null +++ b/OpenSim/ScriptEngine/Components/DotNetEngine/Compilers/LSL/LSL2CS.cs | |||
@@ -0,0 +1,44 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | using System; | ||
28 | using System.Collections.Generic; | ||
29 | using System.Text; | ||
30 | using OpenSim.Region.ScriptEngine.Shared.CodeTools; | ||
31 | |||
32 | namespace OpenSim.ScriptEngine.Components.DotNetEngine.Compilers.LSL | ||
33 | { | ||
34 | public class LSL2CS | ||
35 | { | ||
36 | private ICodeConverter Converter = new CSCodeGenerator(); | ||
37 | |||
38 | public string Convert(ref string script) | ||
39 | { | ||
40 | //m_positionMap = ((CSCodeGenerator) LSL_Converter).PositionMap; | ||
41 | return Converter.Convert(script); | ||
42 | } | ||
43 | } | ||
44 | } | ||
diff --git a/OpenSim/ScriptEngine/Components/DotNetEngine/Compilers/YP/YP2CS.cs b/OpenSim/ScriptEngine/Components/DotNetEngine/Compilers/YP/YP2CS.cs new file mode 100644 index 0000000..e25a800 --- /dev/null +++ b/OpenSim/ScriptEngine/Components/DotNetEngine/Compilers/YP/YP2CS.cs | |||
@@ -0,0 +1,54 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | using System; | ||
28 | using System.Collections.Generic; | ||
29 | using System.Text; | ||
30 | |||
31 | namespace OpenSim.ScriptEngine.Components.DotNetEngine.Compilers.YP | ||
32 | { | ||
33 | public class YP2CS | ||
34 | { | ||
35 | public static string Convert(ref string script) | ||
36 | { | ||
37 | return script; | ||
38 | } | ||
39 | |||
40 | public string PreProcessScript(ref string script) | ||
41 | { | ||
42 | return | ||
43 | "using OpenSim.Region.ScriptEngine.Shared.YieldProlog; " + | ||
44 | "using OpenSim.Region.ScriptEngine.Shared; using System.Collections.Generic;\r\n" + | ||
45 | String.Empty + "namespace SecondLife { " + | ||
46 | String.Empty + "public class Script : OpenSim.Region.ScriptEngine.Shared.ScriptBase.ScriptBaseClass { \r\n" + | ||
47 | //@"public Script() { } " + | ||
48 | @"static OpenSim.Region.ScriptEngine.Shared.YieldProlog.YP YP=null; " + | ||
49 | @"public Script() { YP= new OpenSim.Region.ScriptEngine.Shared.YieldProlog.YP(); } " + | ||
50 | script + | ||
51 | "} }\r\n"; | ||
52 | } | ||
53 | } | ||
54 | } | ||