aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs
diff options
context:
space:
mode:
authorAdam Frisby2008-01-15 02:09:55 +0000
committerAdam Frisby2008-01-15 02:09:55 +0000
commitb25f9f322cdbcde7fd8c043137bf07992e5ef318 (patch)
tree7c1a5115b2849dfe388b825dd271271d347f9574 /OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs
parentSet svn:eol-style. (diff)
downloadopensim-SC-b25f9f322cdbcde7fd8c043137bf07992e5ef318.zip
opensim-SC-b25f9f322cdbcde7fd8c043137bf07992e5ef318.tar.gz
opensim-SC-b25f9f322cdbcde7fd8c043137bf07992e5ef318.tar.bz2
opensim-SC-b25f9f322cdbcde7fd8c043137bf07992e5ef318.tar.xz
* Mother of all commits:
* Cleaned up copyright notices in AssemblyInfo.cs's * Added Copyright headers to a bunch of files missing them * Replaced several common string instances with a static constant to prevent reallocation of the same strings thousands of times. "" -> String.Empty is the first such candidate.
Diffstat (limited to 'OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs')
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs37
1 files changed, 19 insertions, 18 deletions
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs
index 724d8f5..f3302ee 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs
@@ -28,6 +28,7 @@
28 28
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Text.RegularExpressions; 30using System.Text.RegularExpressions;
31using System;
31 32
32namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL 33namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
33{ 34{
@@ -58,7 +59,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
58 public string Convert(string Script) 59 public string Convert(string Script)
59 { 60 {
60 quotes.Clear(); 61 quotes.Clear();
61 string Return = ""; 62 string Return = System.String.Empty;
62 Script = " \r\n" + Script; 63 Script = " \r\n" + Script;
63 64
64 // 65 //
@@ -72,13 +73,13 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
72 73
73 // QUOTE REPLACEMENT 74 // QUOTE REPLACEMENT
74 // temporarily replace quotes so we can work our magic on the script without 75 // temporarily replace quotes so we can work our magic on the script without
75 // always considering if we are inside our outside ""'s 76 // always considering if we are inside our outside String.Empty's
76 string _Script = ""; 77 string _Script = System.String.Empty;
77 string C; 78 string C;
78 bool in_quote = false; 79 bool in_quote = false;
79 bool quote_replaced = false; 80 bool quote_replaced = false;
80 string quote_replacement_string = "Q_U_O_T_E_REPLACEMENT_"; 81 string quote_replacement_string = "Q_U_O_T_E_REPLACEMENT_";
81 string quote = ""; 82 string quote = System.String.Empty;
82 bool last_was_escape = false; 83 bool last_was_escape = false;
83 int quote_replaced_count = 0; 84 int quote_replaced_count = 0;
84 for (int p = 0; p < Script.Length; p++) 85 for (int p = 0; p < Script.Length; p++)
@@ -97,7 +98,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
97 } 98 }
98 else 99 else
99 { 100 {
100 if (quote == "") 101 if (quote == System.String.Empty)
101 { 102 {
102 // We didn't replace quote, probably because of empty string? 103 // We didn't replace quote, probably because of empty string?
103 _Script += quote_replacement_string + 104 _Script += quote_replacement_string +
@@ -107,7 +108,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
107 quotes.Add( 108 quotes.Add(
108 quote_replacement_string + 109 quote_replacement_string +
109 quote_replaced_count.ToString().PadLeft(5, "0".ToCharArray()[0]), quote); 110 quote_replaced_count.ToString().PadLeft(5, "0".ToCharArray()[0]), quote);
110 quote = ""; 111 quote = System.String.Empty;
111 } 112 }
112 break; 113 break;
113 } 114 }
@@ -151,10 +152,10 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
151 // 152 //
152 int ilevel = 0; 153 int ilevel = 0;
153 int lastlevel = 0; 154 int lastlevel = 0;
154 string ret = ""; 155 string ret = System.String.Empty;
155 string cache = ""; 156 string cache = System.String.Empty;
156 bool in_state = false; 157 bool in_state = false;
157 string current_statename = ""; 158 string current_statename = System.String.Empty;
158 for (int p = 0; p < Script.Length; p++) 159 for (int p = 0; p < Script.Length; p++)
159 { 160 {
160 C = Script.Substring(p, 1); 161 C = Script.Substring(p, 1);
@@ -191,7 +192,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
191 RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); 192 RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline);
192 } 193 }
193 ret += cache; 194 ret += cache;
194 cache = ""; 195 cache = String.Empty;
195 } 196 }
196 if (ilevel == 0 && lastlevel == 1) 197 if (ilevel == 0 && lastlevel == 1)
197 { 198 {
@@ -199,7 +200,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
199 if (in_state == true) 200 if (in_state == true)
200 { 201 {
201 cache = cache.Remove(cache.Length - 1, 1); 202 cache = cache.Remove(cache.Length - 1, 1);
202 //cache = Regex.Replace(cache, "}$", "", RegexOptions.Multiline | RegexOptions.Singleline); 203 //cache = Regex.Replace(cache, "}$", String.Empty, RegexOptions.Multiline | RegexOptions.Singleline);
203 204
204 //Replace function names 205 //Replace function names
205 // void dataserver(key query_id, string data) { 206 // void dataserver(key query_id, string data) {
@@ -213,9 +214,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
213 } 214 }
214 215
215 ret += cache; 216 ret += cache;
216 cache = ""; 217 cache = String.Empty;
217 in_state = true; 218 in_state = true;
218 current_statename = ""; 219 current_statename = String.Empty;
219 } 220 }
220 221
221 break; 222 break;
@@ -223,10 +224,10 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
223 lastlevel = ilevel; 224 lastlevel = ilevel;
224 } 225 }
225 ret += cache; 226 ret += cache;
226 cache = ""; 227 cache = String.Empty;
227 228
228 Script = ret; 229 Script = ret;
229 ret = ""; 230 ret = String.Empty;
230 231
231 232
232 foreach (string key in dataTypes.Keys) 233 foreach (string key in dataTypes.Keys)
@@ -287,7 +288,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
287 288
288 // Add namespace, class name and inheritance 289 // Add namespace, class name and inheritance
289 290
290 Return = "" + 291 Return = String.Empty +
291 "using OpenSim.Region.ScriptEngine.Common; using System.Collections.Generic;"; 292 "using OpenSim.Region.ScriptEngine.Common; using System.Collections.Generic;";
292 //"using System; " + 293 //"using System; " +
293 //"using System.Collections.Generic; " + 294 //"using System.Collections.Generic; " +
@@ -309,9 +310,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
309 //} 310 //}
310 311
311 312
312 Return += "" + 313 Return += String.Empty +
313 "namespace SecondLife { "; 314 "namespace SecondLife { ";
314 Return += "" + 315 Return += String.Empty +
315 //"[Serializable] " + 316 //"[Serializable] " +
316 "public class Script : OpenSim.Region.ScriptEngine.Common.LSL_BaseClass { "; 317 "public class Script : OpenSim.Region.ScriptEngine.Common.LSL_BaseClass { ";
317 Return += @"public Script() { } "; 318 Return += @"public Script() { } ";