From d9b9b1651367de4432b22282b21b1b69c1a23141 Mon Sep 17 00:00:00 2001 From: Tedd Hansen Date: Sat, 25 Aug 2007 21:35:03 +0000 Subject: [PATCH] Script compiler should now show error on correct line number in original LSL-script. --- .../Region/ScriptEngine/Common/Executor.cs | 4 ++-- .../DotNetEngine/Compiler/LSL/Compiler.cs | 3 ++- .../Compiler/LSL/LSL2CSConverter.cs | 20 +++++++++---------- .../DotNetEngine/ScriptManager.cs | 2 ++ 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Common/Executor.cs b/OpenSim/Region/ScriptEngine/Common/Executor.cs index 363d81e4ff..e3d574ba11 100644 --- a/OpenSim/Region/ScriptEngine/Common/Executor.cs +++ b/OpenSim/Region/ScriptEngine/Common/Executor.cs @@ -57,7 +57,7 @@ namespace OpenSim.Region.ScriptEngine.Common //type.InvokeMember(EventName, BindingFlags.InvokeMethod, null, m_Script, args); - Console.WriteLine("ScriptEngine Executor.ExecuteEvent: \"" + EventName + "\""); + //Console.WriteLine("ScriptEngine Executor.ExecuteEvent: \"" + EventName + "\""); if (Events.ContainsKey(EventName) == false) { @@ -81,7 +81,7 @@ namespace OpenSim.Region.ScriptEngine.Common if (ev == null) // No event by that name! { - Console.WriteLine("ScriptEngine Can not find any event named: \"" + EventName + "\""); + //Console.WriteLine("ScriptEngine Can not find any event named: \"" + EventName + "\""); return; } diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs index bdeed8f929..a700489f52 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs @@ -87,6 +87,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL //parameters.ReferencedAssemblies.Add("OpenSim.Region.Environment"); parameters.GenerateExecutable = false; parameters.OutputAssembly = OutFile; + //parameters.IncludeDebugInformation = false; CompilerResults results = codeProvider.CompileAssemblyFromSource(parameters, Script); // Go through errors @@ -97,7 +98,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL string errtext = ""; foreach (CompilerError CompErr in results.Errors) { - errtext += "Line number " + CompErr.Line + + errtext += "Line number " + (CompErr.Line - 1) + ", Error Number: " + CompErr.ErrorNumber + ", '" + CompErr.ErrorText + "'\r\n"; } diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs index 2c9031c701..bbb9f06759 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs @@ -152,7 +152,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL in_state = true; current_statename = m.Groups[1].Captures[0].Value; //Console.WriteLine("Current statename: " + current_statename); - cache = Regex.Replace(cache, @"(?![a-zA-Z_]+)\s*([a-zA-Z_]+)[^a-zA-Z_\(\)]*{", "", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); + cache = Regex.Replace(cache, @"(?(?![a-zA-Z_]+)\s*)" + @"([a-zA-Z_]+)(?[^a-zA-Z_\(\)]*){", "${s1}${s2}", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); } ret += cache; cache = ""; @@ -169,7 +169,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL // void dataserver(key query_id, string data) { //cache = Regex.Replace(cache, @"([^a-zA-Z_]\s*)((?!if|switch|for)[a-zA-Z_]+\s*\([^\)]*\)[^{]*{)", "$1" + "" + "$2", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); //Console.WriteLine("Replacing using statename: " + current_statename); - cache = Regex.Replace(cache, @"^(\s*)((?!(if|switch|for)[^a-zA-Z0-9_])[a-zA-Z0-9_]*\s*\([^\)]*\)[^;]*\{)", @"public $1" + current_statename + "_event_$2", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); + cache = Regex.Replace(cache, @"^(\s*)((?!(if|switch|for)[^a-zA-Z0-9_])[a-zA-Z0-9_]*\s*\([^\)]*\)[^;]*\{)", @"$1public " + current_statename + "_event_$2", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); } ret += cache; @@ -202,7 +202,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL } // Add "void" in front of functions that needs it - 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); + Script = Regex.Replace(Script, @"^(\s*public\s+)((?!(if|switch|for)[^a-zA-Z0-9_])[a-zA-Z0-9_]*\s*\([^\)]*\)[^;]*\{)", @"$1void $2", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); // Replace and Script = Regex.Replace(Script, @"<([^,>]*,[^,>]*,[^,>]*,[^,>]*)>", @"new LSL_Types.Quaternion($1)", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); @@ -228,15 +228,15 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL // Add namespace, class name and inheritance Return = "" + - "using System;\r\n" + - "using System.Collections.Generic;\r\n" + - "using System.Text;\r\n" + - "using OpenSim.Region.ScriptEngine.Common;\r\n" + - "namespace SecondLife {\r\n"; + "using System; " + + "using System.Collections.Generic; " + + "using System.Text; " + + "using OpenSim.Region.ScriptEngine.Common; " + + "namespace SecondLife { "; Return += "" + //"[Serializable] " + - "public class Script : OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass {\r\n"; - Return += @"public Script() { }"+"\r\n"; + "public class Script : OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass { "; + Return += @"public Script() { } "; Return += Script; Return += "} }\r\n"; diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs index bf863b8f84..c7c33bb2ac 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs @@ -123,6 +123,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine } catch (ThreadAbortException tae) { + string a = tae.ToString(); + a = ""; // Expected }