Script compiler should now show error on correct line number in original LSL-script.

afrisby
Tedd Hansen 2007-08-25 21:35:03 +00:00
parent 2fd0e53425
commit d9b9b16513
4 changed files with 16 additions and 13 deletions

View File

@ -57,7 +57,7 @@ namespace OpenSim.Region.ScriptEngine.Common
//type.InvokeMember(EventName, BindingFlags.InvokeMethod, null, m_Script, args); //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) if (Events.ContainsKey(EventName) == false)
{ {
@ -81,7 +81,7 @@ namespace OpenSim.Region.ScriptEngine.Common
if (ev == null) // No event by that name! 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; return;
} }

View File

@ -87,6 +87,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
//parameters.ReferencedAssemblies.Add("OpenSim.Region.Environment"); //parameters.ReferencedAssemblies.Add("OpenSim.Region.Environment");
parameters.GenerateExecutable = false; parameters.GenerateExecutable = false;
parameters.OutputAssembly = OutFile; parameters.OutputAssembly = OutFile;
//parameters.IncludeDebugInformation = false;
CompilerResults results = codeProvider.CompileAssemblyFromSource(parameters, Script); CompilerResults results = codeProvider.CompileAssemblyFromSource(parameters, Script);
// Go through errors // Go through errors
@ -97,7 +98,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
string errtext = ""; string errtext = "";
foreach (CompilerError CompErr in results.Errors) foreach (CompilerError CompErr in results.Errors)
{ {
errtext += "Line number " + CompErr.Line + errtext += "Line number " + (CompErr.Line - 1) +
", Error Number: " + CompErr.ErrorNumber + ", Error Number: " + CompErr.ErrorNumber +
", '" + CompErr.ErrorText + "'\r\n"; ", '" + CompErr.ErrorText + "'\r\n";
} }

View File

@ -152,7 +152,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
in_state = true; in_state = true;
current_statename = m.Groups[1].Captures[0].Value; current_statename = m.Groups[1].Captures[0].Value;
//Console.WriteLine("Current statename: " + current_statename); //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, @"(?<s1>(?![a-zA-Z_]+)\s*)" + @"([a-zA-Z_]+)(?<s2>[^a-zA-Z_\(\)]*){", "${s1}${s2}", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline);
} }
ret += cache; ret += cache;
cache = ""; cache = "";
@ -169,7 +169,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
// void dataserver(key query_id, string data) { // void dataserver(key query_id, string data) {
//cache = Regex.Replace(cache, @"([^a-zA-Z_]\s*)((?!if|switch|for)[a-zA-Z_]+\s*\([^\)]*\)[^{]*{)", "$1" + "<STATE>" + "$2", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); //cache = Regex.Replace(cache, @"([^a-zA-Z_]\s*)((?!if|switch|for)[a-zA-Z_]+\s*\([^\)]*\)[^{]*{)", "$1" + "<STATE>" + "$2", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline);
//Console.WriteLine("Replacing using statename: " + current_statename); //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; ret += cache;
@ -202,7 +202,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
} }
// Add "void" in front of functions that needs it // 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 <x,y,z> and <x,y,z,r> // Replace <x,y,z> and <x,y,z,r>
Script = Regex.Replace(Script, @"<([^,>]*,[^,>]*,[^,>]*,[^,>]*)>", @"new LSL_Types.Quaternion($1)", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); 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 // Add namespace, class name and inheritance
Return = "" + Return = "" +
"using System;\r\n" + "using System; " +
"using System.Collections.Generic;\r\n" + "using System.Collections.Generic; " +
"using System.Text;\r\n" + "using System.Text; " +
"using OpenSim.Region.ScriptEngine.Common;\r\n" + "using OpenSim.Region.ScriptEngine.Common; " +
"namespace SecondLife {\r\n"; "namespace SecondLife { ";
Return += "" + Return += "" +
//"[Serializable] " + //"[Serializable] " +
"public class Script : OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass {\r\n"; "public class Script : OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass { ";
Return += @"public Script() { }"+"\r\n"; Return += @"public Script() { } ";
Return += Script; Return += Script;
Return += "} }\r\n"; Return += "} }\r\n";

View File

@ -123,6 +123,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
} }
catch (ThreadAbortException tae) catch (ThreadAbortException tae)
{ {
string a = tae.ToString();
a = "";
// Expected // Expected
} }