diff options
author | Mike Mazur | 2008-07-23 06:53:38 +0000 |
---|---|---|
committer | Mike Mazur | 2008-07-23 06:53:38 +0000 |
commit | f9e2f41d7c7906db6e09d3ee4ed6f508df847344 (patch) | |
tree | eb6972df3227206c23d58b65c164eba4f34f821b /OpenSim/Region/ScriptEngine/Shared | |
parent | Thanks, sempuki, for a patch that adds .addin.xml for MSSQL and SQLite users. (diff) | |
download | opensim-SC-f9e2f41d7c7906db6e09d3ee4ed6f508df847344.zip opensim-SC-f9e2f41d7c7906db6e09d3ee4ed6f508df847344.tar.gz opensim-SC-f9e2f41d7c7906db6e09d3ee4ed6f508df847344.tar.bz2 opensim-SC-f9e2f41d7c7906db6e09d3ee4ed6f508df847344.tar.xz |
Enable LSL <-> C# source location mapping when reporing compiler errors to the user in-world. This method is not yet perfect but is an improvement in accuracy over the existing method.
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs index a8c61ed..f7b6d08 100644 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs | |||
@@ -73,6 +73,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
73 | private string ScriptEnginesPath = "ScriptEngines"; | 73 | private string ScriptEnginesPath = "ScriptEngines"; |
74 | 74 | ||
75 | private static ICodeConverter LSL_Converter; | 75 | private static ICodeConverter LSL_Converter; |
76 | private static Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> m_positionMap; // mapping between LSL and C# line/column numbers | ||
76 | private static CSharpCodeProvider CScodeProvider = new CSharpCodeProvider(); | 77 | private static CSharpCodeProvider CScodeProvider = new CSharpCodeProvider(); |
77 | private static VBCodeProvider VBcodeProvider = new VBCodeProvider(); | 78 | private static VBCodeProvider VBcodeProvider = new VBCodeProvider(); |
78 | private static JScriptCodeProvider JScodeProvider = new JScriptCodeProvider(); | 79 | private static JScriptCodeProvider JScodeProvider = new JScriptCodeProvider(); |
@@ -331,6 +332,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
331 | else | 332 | else |
332 | LSL_Converter = (ICodeConverter)new LSL2CSConverter(); | 333 | LSL_Converter = (ICodeConverter)new LSL2CSConverter(); |
333 | compileScript = LSL_Converter.Convert(Script); | 334 | compileScript = LSL_Converter.Convert(Script); |
335 | |||
336 | if (m_UseCompiler) | ||
337 | m_positionMap = ((CSCodeGenerator) LSL_Converter).PositionMap; | ||
338 | |||
334 | l = enumCompileType.cs; | 339 | l = enumCompileType.cs; |
335 | } | 340 | } |
336 | 341 | ||
@@ -540,9 +545,29 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
540 | string errtext = String.Empty; | 545 | string errtext = String.Empty; |
541 | foreach (CompilerError CompErr in results.Errors) | 546 | foreach (CompilerError CompErr in results.Errors) |
542 | { | 547 | { |
543 | errtext += "Line number " + (CompErr.Line - LinesToRemoveOnError) + | 548 | if (m_UseCompiler) |
544 | ", Error Number: " + CompErr.ErrorNumber + | 549 | { |
545 | ", '" + CompErr.ErrorText + "'\r\n"; | 550 | KeyValuePair<int, int> lslPos; |
551 | |||
552 | try | ||
553 | { | ||
554 | lslPos = m_positionMap[new KeyValuePair<int, int>(CompErr.Line, CompErr.Column)]; | ||
555 | } | ||
556 | catch (KeyNotFoundException) // we don't have this line/column mapped | ||
557 | { | ||
558 | lslPos = new KeyValuePair<int, int>(-1, -1); | ||
559 | } | ||
560 | |||
561 | // The Second Life viewer's script editor begins | ||
562 | // countingn lines and columns at 0, so we subtract 1. | ||
563 | errtext += String.Format("Line {0}, column {1}, Error Number: {2}, '{3}'\r\n", lslPos.Key - 1, lslPos.Value - 1, CompErr.ErrorNumber, CompErr.ErrorText); | ||
564 | } | ||
565 | else | ||
566 | { | ||
567 | errtext += "Line number " + (CompErr.Line - LinesToRemoveOnError) + | ||
568 | ", Error Number: " + CompErr.ErrorNumber + | ||
569 | ", '" + CompErr.ErrorText + "'\r\n"; | ||
570 | } | ||
546 | } | 571 | } |
547 | Console.WriteLine("[COMPILER ERROR]:" + errtext); | 572 | Console.WriteLine("[COMPILER ERROR]:" + errtext); |
548 | if (!File.Exists(OutFile)) | 573 | if (!File.Exists(OutFile)) |