diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine/DotNetEngine/Compiler')
-rw-r--r-- | OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs | 12 | ||||
-rw-r--r-- | OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs | 27 |
2 files changed, 10 insertions, 29 deletions
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs index 1d71182..f661162 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. |
@@ -278,8 +278,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL | |||
278 | 278 | ||
279 | if (enableCommanderLSL == true && l == enumCompileType.cs) | 279 | if (enableCommanderLSL == true && l == enumCompileType.cs) |
280 | { | 280 | { |
281 | foreach (KeyValuePair<string, | 281 | foreach (KeyValuePair<string, |
282 | ICommander> com | 282 | ICommander> com |
283 | in m_scriptEngine.World.GetCommanders()) | 283 | in m_scriptEngine.World.GetCommanders()) |
284 | { | 284 | { |
285 | compileScript = com.Value.GenerateRuntimeAPI() + compileScript; | 285 | compileScript = com.Value.GenerateRuntimeAPI() + compileScript; |
@@ -305,7 +305,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL | |||
305 | m_log.Debug("[ScriptEngine.DotNetEngine]: Preparing to compile the following LSL to C# translated code"); | 305 | m_log.Debug("[ScriptEngine.DotNetEngine]: Preparing to compile the following LSL to C# translated code"); |
306 | m_log.Debug(""); | 306 | m_log.Debug(""); |
307 | m_log.Debug(compileScript); | 307 | m_log.Debug(compileScript); |
308 | 308 | ||
309 | return CompileFromDotNetText(compileScript, l); | 309 | return CompileFromDotNetText(compileScript, l); |
310 | } | 310 | } |
311 | 311 | ||
@@ -322,7 +322,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL | |||
322 | 322 | ||
323 | private static string CreateCSCompilerScript(string compileScript) | 323 | private static string CreateCSCompilerScript(string compileScript) |
324 | { | 324 | { |
325 | 325 | ||
326 | 326 | ||
327 | compileScript = String.Empty + | 327 | compileScript = String.Empty + |
328 | "using OpenSim.Region.ScriptEngine.Common; using System.Collections.Generic;\r\n" + | 328 | "using OpenSim.Region.ScriptEngine.Common; using System.Collections.Generic;\r\n" + |
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs index 2100900..1832864 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs | |||
@@ -23,7 +23,7 @@ | |||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 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 | 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. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | 28 | ||
29 | using System; | 29 | using System; |
@@ -32,17 +32,13 @@ using System.Text.RegularExpressions; | |||
32 | 32 | ||
33 | namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL | 33 | namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL |
34 | { | 34 | { |
35 | |||
36 | public class LSL2CSConverter | 35 | public class LSL2CSConverter |
37 | { | 36 | { |
38 | |||
39 | |||
40 | // Uses regex to convert LSL code to C# code. | 37 | // Uses regex to convert LSL code to C# code. |
41 | 38 | ||
42 | //private Regex rnw = new Regex(@"[a-zA-Z0-9_\-]", RegexOptions.Compiled); | 39 | //private Regex rnw = new Regex(@"[a-zA-Z0-9_\-]", RegexOptions.Compiled); |
43 | private Dictionary<string, string> dataTypes = new Dictionary<string, string>(); | 40 | private Dictionary<string, string> dataTypes = new Dictionary<string, string>(); |
44 | private Dictionary<string, string> quotes = new Dictionary<string, string>(); | 41 | private Dictionary<string, string> quotes = new Dictionary<string, string>(); |
45 | |||
46 | 42 | ||
47 | public LSL2CSConverter() | 43 | public LSL2CSConverter() |
48 | { | 44 | { |
@@ -72,7 +68,6 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL | |||
72 | Script = Regex.Replace(Script, @"\r\n", "\n"); | 68 | Script = Regex.Replace(Script, @"\r\n", "\n"); |
73 | Script = Regex.Replace(Script, @"\n", "\r\n"); | 69 | Script = Regex.Replace(Script, @"\n", "\r\n"); |
74 | 70 | ||
75 | |||
76 | // QUOTE REPLACEMENT | 71 | // QUOTE REPLACEMENT |
77 | // temporarily replace quotes so we can work our magic on the script without | 72 | // temporarily replace quotes so we can work our magic on the script without |
78 | // always considering if we are inside our outside quotes's | 73 | // always considering if we are inside our outside quotes's |
@@ -86,21 +81,16 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL | |||
86 | bool last_was_escape = false; | 81 | bool last_was_escape = false; |
87 | int quote_replaced_count = 0; | 82 | int quote_replaced_count = 0; |
88 | 83 | ||
89 | |||
90 | |||
91 | string[] blocked = new string[] {"Axiom","Db4objects","libsecondlife","log4net","Microsoft", | 84 | string[] blocked = new string[] {"Axiom","Db4objects","libsecondlife","log4net","Microsoft", |
92 | "Modified","Mono","MonoXnaCompactMaths","mscorlib","MySql", | 85 | "Modified","Mono","MonoXnaCompactMaths","mscorlib","MySql", |
93 | "NHibernate","Nini","nunit","Ode","OpenSim","PhysX_Wrapper_Dotnet", | 86 | "NHibernate","Nini","nunit","Ode","OpenSim","PhysX_Wrapper_Dotnet", |
94 | "PumaCode","RAIL","XMLRPC","System"}; | 87 | "PumaCode","RAIL","XMLRPC","System"}; |
95 | |||
96 | 88 | ||
97 | for (int p = 0; p < blocked.Length;p++) | 89 | for (int p = 0; p < blocked.Length;p++) |
98 | { | 90 | { |
99 | |||
100 | Match SecurityM = Regex.Match(Script, "[;}][^\"']+" + blocked[p].Replace(".", "\\.") + "\\.[^\"']", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); | 91 | Match SecurityM = Regex.Match(Script, "[;}][^\"']+" + blocked[p].Replace(".", "\\.") + "\\.[^\"']", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); |
101 | if (SecurityM.Success) | 92 | if (SecurityM.Success) |
102 | throw new Exception("CS0103: 'The name '" + blocked[p] + "' does not exist in the current context'"); | 93 | throw new Exception("CS0103: 'The name '" + blocked[p] + "' does not exist in the current context'"); |
103 | |||
104 | } | 94 | } |
105 | 95 | ||
106 | for (int p = 0; p < Script.Length; p++) | 96 | for (int p = 0; p < Script.Length; p++) |
@@ -166,7 +156,6 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL | |||
166 | // END OF QUOTE REPLACEMENT | 156 | // END OF QUOTE REPLACEMENT |
167 | // | 157 | // |
168 | 158 | ||
169 | |||
170 | // | 159 | // |
171 | // PROCESS STATES | 160 | // PROCESS STATES |
172 | // Remove state definitions and add state names to start of each event within state | 161 | // Remove state definitions and add state names to start of each event within state |
@@ -194,7 +183,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL | |||
194 | // if level == 0, add to return | 183 | // if level == 0, add to return |
195 | if (ilevel == 1 && lastlevel == 0) | 184 | if (ilevel == 1 && lastlevel == 0) |
196 | { | 185 | { |
197 | // 0 => 1: Get last | 186 | // 0 => 1: Get last |
198 | Match m = | 187 | Match m = |
199 | //Regex.Match(cache, @"(?![a-zA-Z_]+)\s*([a-zA-Z_]+)[^a-zA-Z_\(\)]*{", | 188 | //Regex.Match(cache, @"(?![a-zA-Z_]+)\s*([a-zA-Z_]+)[^a-zA-Z_\(\)]*{", |
200 | Regex.Match(cache, @"(?![a-zA-Z_]+)\s*(state\s+)?(?<statename>[a-zA-Z_][a-zA-Z_0-9]*)[^a-zA-Z_0-9\(\)]*{", | 189 | Regex.Match(cache, @"(?![a-zA-Z_]+)\s*(state\s+)?(?<statename>[a-zA-Z_][a-zA-Z_0-9]*)[^a-zA-Z_0-9\(\)]*{", |
@@ -253,7 +242,6 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL | |||
253 | Script = ret; | 242 | Script = ret; |
254 | ret = String.Empty; | 243 | ret = String.Empty; |
255 | 244 | ||
256 | |||
257 | foreach (string key in dataTypes.Keys) | 245 | foreach (string key in dataTypes.Keys) |
258 | { | 246 | { |
259 | string val; | 247 | string val; |
@@ -291,7 +279,6 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL | |||
291 | Regex.Replace(Script, @"\[([^\]]*)\]", @"new LSL_Types.list($1)", | 279 | Regex.Replace(Script, @"\[([^\]]*)\]", @"new LSL_Types.list($1)", |
292 | RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); | 280 | RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); |
293 | 281 | ||
294 | |||
295 | // Replace (string) to .ToString() // | 282 | // Replace (string) to .ToString() // |
296 | Script = | 283 | Script = |
297 | Regex.Replace(Script, @"\(string\)\s*([a-zA-Z0-9_.]+(\s*\([^\)]*\))?)", @"$1.ToString()", | 284 | Regex.Replace(Script, @"\(string\)\s*([a-zA-Z0-9_.]+(\s*\([^\)]*\))?)", @"$1.ToString()", |
@@ -313,12 +300,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL | |||
313 | Script = Script.Replace(key, "\"" + val + "\""); | 300 | Script = Script.Replace(key, "\"" + val + "\""); |
314 | } | 301 | } |
315 | 302 | ||
316 | |||
317 | |||
318 | //System.Console.WriteLine(Script); | 303 | //System.Console.WriteLine(Script); |
319 | Return = String.Empty;// + | 304 | Return = String.Empty;// + |
320 | //"using OpenSim.Region.ScriptEngine.Common; using System.Collections.Generic;"; | 305 | //"using OpenSim.Region.ScriptEngine.Common; using System.Collections.Generic;"; |
321 | |||
322 | 306 | ||
323 | //Return += String.Empty + | 307 | //Return += String.Empty + |
324 | // "namespace SecondLife { "; | 308 | // "namespace SecondLife { "; |
@@ -328,13 +312,10 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL | |||
328 | //Return += @"public Script() { } "; | 312 | //Return += @"public Script() { } "; |
329 | Return += Script; | 313 | Return += Script; |
330 | //Return += "} }\r\n"; | 314 | //Return += "} }\r\n"; |
331 | 315 | ||
332 | quotes.Clear(); | 316 | quotes.Clear(); |
333 | 317 | ||
334 | return Return; | 318 | return Return; |
335 | } | 319 | } |
336 | |||
337 | } | 320 | } |
338 | |||
339 | |||
340 | } | 321 | } |