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.
parent
6256078876
commit
f9e2f41d7c
|
@ -74,6 +74,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
|
||||||
|
|
||||||
private static LSL2CSConverter LSL_Converter = new LSL2CSConverter();
|
private static LSL2CSConverter LSL_Converter = new LSL2CSConverter();
|
||||||
//private static CSCodeGenerator LSL_Converter = new CSCodeGenerator();
|
//private static CSCodeGenerator LSL_Converter = new CSCodeGenerator();
|
||||||
|
//private static Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> m_positionMap; // mapping between LSL and C# line/column numbers
|
||||||
private static CSharpCodeProvider CScodeProvider = new CSharpCodeProvider();
|
private static CSharpCodeProvider CScodeProvider = new CSharpCodeProvider();
|
||||||
private static VBCodeProvider VBcodeProvider = new VBCodeProvider();
|
private static VBCodeProvider VBcodeProvider = new VBCodeProvider();
|
||||||
private static JScriptCodeProvider JScodeProvider = new JScriptCodeProvider();
|
private static JScriptCodeProvider JScodeProvider = new JScriptCodeProvider();
|
||||||
|
@ -277,6 +278,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
|
||||||
// Its LSL, convert it to C#
|
// Its LSL, convert it to C#
|
||||||
compileScript = LSL_Converter.Convert(Script);
|
compileScript = LSL_Converter.Convert(Script);
|
||||||
//compileScript = LSL_Converter.Convert(Script);
|
//compileScript = LSL_Converter.Convert(Script);
|
||||||
|
//m_positionMap = LSL_Converter.PositionMap;
|
||||||
l = enumCompileType.cs;
|
l = enumCompileType.cs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -481,6 +483,20 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
|
||||||
string errtext = String.Empty;
|
string errtext = String.Empty;
|
||||||
foreach (CompilerError CompErr in results.Errors)
|
foreach (CompilerError CompErr in results.Errors)
|
||||||
{
|
{
|
||||||
|
//KeyValuePair<int, int> lslPos;
|
||||||
|
|
||||||
|
//try
|
||||||
|
//{
|
||||||
|
// lslPos = m_positionMap[new KeyValuePair<int, int>(CompErr.Line, CompErr.Column)];
|
||||||
|
//}
|
||||||
|
//catch (KeyNotFoundException) // we don't have this line/column mapped
|
||||||
|
//{
|
||||||
|
// lslPos = new KeyValuePair<int, int>(-1, -1);
|
||||||
|
//}
|
||||||
|
|
||||||
|
// The Second Life viewer's script editor begins
|
||||||
|
// countingn lines and columns at 0, so we subtract 1.
|
||||||
|
//errtext += String.Format("Line {0}, column {1}, Error Number: {2}, '{3}'\r\n", lslPos.Key - 1, lslPos.Value - 1, CompErr.ErrorNumber, CompErr.ErrorText);
|
||||||
errtext += "Line number " + (CompErr.Line - LinesToRemoveOnError) +
|
errtext += "Line number " + (CompErr.Line - LinesToRemoveOnError) +
|
||||||
", Error Number: " + CompErr.ErrorNumber +
|
", Error Number: " + CompErr.ErrorNumber +
|
||||||
", '" + CompErr.ErrorText + "'\r\n";
|
", '" + CompErr.ErrorText + "'\r\n";
|
||||||
|
|
|
@ -73,6 +73,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
|
||||||
private string ScriptEnginesPath = "ScriptEngines";
|
private string ScriptEnginesPath = "ScriptEngines";
|
||||||
|
|
||||||
private static ICodeConverter LSL_Converter;
|
private static ICodeConverter LSL_Converter;
|
||||||
|
private static Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> m_positionMap; // mapping between LSL and C# line/column numbers
|
||||||
private static CSharpCodeProvider CScodeProvider = new CSharpCodeProvider();
|
private static CSharpCodeProvider CScodeProvider = new CSharpCodeProvider();
|
||||||
private static VBCodeProvider VBcodeProvider = new VBCodeProvider();
|
private static VBCodeProvider VBcodeProvider = new VBCodeProvider();
|
||||||
private static JScriptCodeProvider JScodeProvider = new JScriptCodeProvider();
|
private static JScriptCodeProvider JScodeProvider = new JScriptCodeProvider();
|
||||||
|
@ -331,6 +332,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
|
||||||
else
|
else
|
||||||
LSL_Converter = (ICodeConverter)new LSL2CSConverter();
|
LSL_Converter = (ICodeConverter)new LSL2CSConverter();
|
||||||
compileScript = LSL_Converter.Convert(Script);
|
compileScript = LSL_Converter.Convert(Script);
|
||||||
|
|
||||||
|
if (m_UseCompiler)
|
||||||
|
m_positionMap = ((CSCodeGenerator) LSL_Converter).PositionMap;
|
||||||
|
|
||||||
l = enumCompileType.cs;
|
l = enumCompileType.cs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -540,9 +545,29 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
|
||||||
string errtext = String.Empty;
|
string errtext = String.Empty;
|
||||||
foreach (CompilerError CompErr in results.Errors)
|
foreach (CompilerError CompErr in results.Errors)
|
||||||
{
|
{
|
||||||
errtext += "Line number " + (CompErr.Line - LinesToRemoveOnError) +
|
if (m_UseCompiler)
|
||||||
", Error Number: " + CompErr.ErrorNumber +
|
{
|
||||||
", '" + CompErr.ErrorText + "'\r\n";
|
KeyValuePair<int, int> lslPos;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
lslPos = m_positionMap[new KeyValuePair<int, int>(CompErr.Line, CompErr.Column)];
|
||||||
|
}
|
||||||
|
catch (KeyNotFoundException) // we don't have this line/column mapped
|
||||||
|
{
|
||||||
|
lslPos = new KeyValuePair<int, int>(-1, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// The Second Life viewer's script editor begins
|
||||||
|
// countingn lines and columns at 0, so we subtract 1.
|
||||||
|
errtext += String.Format("Line {0}, column {1}, Error Number: {2}, '{3}'\r\n", lslPos.Key - 1, lslPos.Value - 1, CompErr.ErrorNumber, CompErr.ErrorText);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
errtext += "Line number " + (CompErr.Line - LinesToRemoveOnError) +
|
||||||
|
", Error Number: " + CompErr.ErrorNumber +
|
||||||
|
", '" + CompErr.ErrorText + "'\r\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Console.WriteLine("[COMPILER ERROR]:" + errtext);
|
Console.WriteLine("[COMPILER ERROR]:" + errtext);
|
||||||
if (!File.Exists(OutFile))
|
if (!File.Exists(OutFile))
|
||||||
|
|
Loading…
Reference in New Issue