diff options
author | Jeff Ames | 2008-05-16 01:22:11 +0000 |
---|---|---|
committer | Jeff Ames | 2008-05-16 01:22:11 +0000 |
commit | 65c5efe43b68700bad94076d4cd421160203c5de (patch) | |
tree | 589b56649ed02f4942671fd6e51c6dc43f682e0d /OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs | |
parent | Thank you very much, mjm for : (diff) | |
download | opensim-SC-65c5efe43b68700bad94076d4cd421160203c5de.zip opensim-SC-65c5efe43b68700bad94076d4cd421160203c5de.tar.gz opensim-SC-65c5efe43b68700bad94076d4cd421160203c5de.tar.bz2 opensim-SC-65c5efe43b68700bad94076d4cd421160203c5de.tar.xz |
Formatting cleanup.
Diffstat (limited to 'OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs')
-rw-r--r-- | OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs | 27 |
1 files changed, 4 insertions, 23 deletions
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 | } |