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 | |
parent | Thanks, sempuki, for a patch that adds .addin.xml for MSSQL and SQLite users. (diff) | |
download | opensim-SC_OLD-f9e2f41d7c7906db6e09d3ee4ed6f508df847344.zip opensim-SC_OLD-f9e2f41d7c7906db6e09d3ee4ed6f508df847344.tar.gz opensim-SC_OLD-f9e2f41d7c7906db6e09d3ee4ed6f508df847344.tar.bz2 opensim-SC_OLD-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 '')
-rw-r--r-- | OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs | 16 | ||||
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs | 31 |
2 files changed, 44 insertions, 3 deletions
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs index 73894d5..e2e8d36 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs | |||
@@ -74,6 +74,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL | |||
74 | 74 | ||
75 | private static LSL2CSConverter LSL_Converter = new LSL2CSConverter(); | 75 | private static LSL2CSConverter LSL_Converter = new LSL2CSConverter(); |
76 | //private static CSCodeGenerator LSL_Converter = new CSCodeGenerator(); | 76 | //private static CSCodeGenerator LSL_Converter = new CSCodeGenerator(); |
77 | //private static Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> m_positionMap; // mapping between LSL and C# line/column numbers | ||
77 | private static CSharpCodeProvider CScodeProvider = new CSharpCodeProvider(); | 78 | private static CSharpCodeProvider CScodeProvider = new CSharpCodeProvider(); |
78 | private static VBCodeProvider VBcodeProvider = new VBCodeProvider(); | 79 | private static VBCodeProvider VBcodeProvider = new VBCodeProvider(); |
79 | private static JScriptCodeProvider JScodeProvider = new JScriptCodeProvider(); | 80 | private static JScriptCodeProvider JScodeProvider = new JScriptCodeProvider(); |
@@ -277,6 +278,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL | |||
277 | // Its LSL, convert it to C# | 278 | // Its LSL, convert it to C# |
278 | compileScript = LSL_Converter.Convert(Script); | 279 | compileScript = LSL_Converter.Convert(Script); |
279 | //compileScript = LSL_Converter.Convert(Script); | 280 | //compileScript = LSL_Converter.Convert(Script); |
281 | //m_positionMap = LSL_Converter.PositionMap; | ||
280 | l = enumCompileType.cs; | 282 | l = enumCompileType.cs; |
281 | } | 283 | } |
282 | 284 | ||
@@ -481,6 +483,20 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL | |||
481 | string errtext = String.Empty; | 483 | string errtext = String.Empty; |
482 | foreach (CompilerError CompErr in results.Errors) | 484 | foreach (CompilerError CompErr in results.Errors) |
483 | { | 485 | { |
486 | //KeyValuePair<int, int> lslPos; | ||
487 | |||
488 | //try | ||
489 | //{ | ||
490 | // lslPos = m_positionMap[new KeyValuePair<int, int>(CompErr.Line, CompErr.Column)]; | ||
491 | //} | ||
492 | //catch (KeyNotFoundException) // we don't have this line/column mapped | ||
493 | //{ | ||
494 | // lslPos = new KeyValuePair<int, int>(-1, -1); | ||
495 | //} | ||
496 | |||
497 | // The Second Life viewer's script editor begins | ||
498 | // countingn lines and columns at 0, so we subtract 1. | ||
499 | //errtext += String.Format("Line {0}, column {1}, Error Number: {2}, '{3}'\r\n", lslPos.Key - 1, lslPos.Value - 1, CompErr.ErrorNumber, CompErr.ErrorText); | ||
484 | errtext += "Line number " + (CompErr.Line - LinesToRemoveOnError) + | 500 | errtext += "Line number " + (CompErr.Line - LinesToRemoveOnError) + |
485 | ", Error Number: " + CompErr.ErrorNumber + | 501 | ", Error Number: " + CompErr.ErrorNumber + |
486 | ", '" + CompErr.ErrorText + "'\r\n"; | 502 | ", '" + CompErr.ErrorText + "'\r\n"; |
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)) |