aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine/DotNetEngine/Compiler')
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs19
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs4
2 files changed, 20 insertions, 3 deletions
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs
index 906b2d3..2c514fc 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs
@@ -20,8 +20,25 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
20 // Output assembly name 20 // Output assembly name
21 string OutFile = Path.GetFileNameWithoutExtension(LSOFileName) + ".dll"; 21 string OutFile = Path.GetFileNameWithoutExtension(LSOFileName) + ".dll";
22 22
23 Common.SendToDebug("Reading source code into memory");
23 // TODO: Add error handling 24 // TODO: Add error handling
24 string CS_Code = LSL_Converter.Convert(File.ReadAllText(LSOFileName)); 25 string CS_Code;
26 switch (System.IO.Path.GetExtension(LSOFileName).ToLower())
27 {
28 case ".txt":
29 case ".lsl":
30 Common.SendToDebug("Source code is LSL, converting to CS");
31 CS_Code = LSL_Converter.Convert(File.ReadAllText(LSOFileName));
32 break;
33 case ".cs":
34 Common.SendToDebug("Source code is CS");
35 CS_Code = File.ReadAllText(LSOFileName);
36 break;
37 default:
38 throw new Exception("Unknown script type.");
39 }
40
41 Common.SendToDebug("Compiling");
25 42
26 // Do actual compile 43 // Do actual compile
27 System.CodeDom.Compiler.CompilerParameters parameters = new CompilerParameters(); 44 System.CodeDom.Compiler.CompilerParameters parameters = new CompilerParameters();
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs
index 99fdb0d..6b0afa9 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs
@@ -162,7 +162,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
162 // void dataserver(key query_id, string data) { 162 // void dataserver(key query_id, string data) {
163 //cache = Regex.Replace(cache, @"([^a-zA-Z_]\s*)((?!if|switch|for)[a-zA-Z_]+\s*\([^\)]*\)[^{]*{)", "$1" + "<STATE>" + "$2", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); 163 //cache = Regex.Replace(cache, @"([^a-zA-Z_]\s*)((?!if|switch|for)[a-zA-Z_]+\s*\([^\)]*\)[^{]*{)", "$1" + "<STATE>" + "$2", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline);
164 //Console.WriteLine("Replacing using statename: " + current_statename); 164 //Console.WriteLine("Replacing using statename: " + current_statename);
165 cache = Regex.Replace(cache, @"^(\s*)((?!if|switch|for)[a-zA-Z0-9_]*\s*\([^\)]*\)[^;]*\{)", @"$1" + current_statename + "_$2", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); 165 cache = Regex.Replace(cache, @"^(\s*)((?!(if|switch|for)[^a-zA-Z0-9_])[a-zA-Z0-9_]*\s*\([^\)]*\)[^;]*\{)", @"$1" + current_statename + "_$2", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline);
166 } 166 }
167 167
168 ret += cache; 168 ret += cache;
@@ -195,7 +195,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
195 } 195 }
196 196
197 // Add "void" in front of functions that needs it 197 // Add "void" in front of functions that needs it
198 Script = Regex.Replace(Script, @"^(\s*)((?!if|switch|for)[a-zA-Z0-9_]*\s*\([^\)]*\)[^;]*\{)", @"$1void $2", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); 198 Script = Regex.Replace(Script, @"^(\s*)((?!(if|switch|for)[^a-zA-Z0-9_])[a-zA-Z0-9_]*\s*\([^\)]*\)[^;]*\{)", @"$1void $2", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline);
199 199
200 // Replace <x,y,z> and <x,y,z,r> 200 // Replace <x,y,z> and <x,y,z,r>
201 Script = Regex.Replace(Script, @"<([^,>]*,[^,>]*,[^,>]*,[^,>]*)>", @"new Axiom.Math.Quaternion($1)", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); 201 Script = Regex.Replace(Script, @"<([^,>]*,[^,>]*,[^,>]*,[^,>]*)>", @"new Axiom.Math.Quaternion($1)", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline);