diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs | 43 |
1 files changed, 13 insertions, 30 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs index c88cd05..b14e7ac 100644 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs | |||
@@ -82,7 +82,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
82 | 82 | ||
83 | // private static int instanceID = new Random().Next(0, int.MaxValue); // Unique number to use on our compiled files | 83 | // private static int instanceID = new Random().Next(0, int.MaxValue); // Unique number to use on our compiled files |
84 | private static UInt64 scriptCompileCounter = 0; // And a counter | 84 | private static UInt64 scriptCompileCounter = 0; // And a counter |
85 | private bool m_UseCompiler = true; | ||
86 | 85 | ||
87 | public IScriptEngine m_scriptEngine; | 86 | public IScriptEngine m_scriptEngine; |
88 | public Compiler(IScriptEngine scriptEngine) | 87 | public Compiler(IScriptEngine scriptEngine) |
@@ -93,8 +92,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
93 | public bool in_startup = true; | 92 | public bool in_startup = true; |
94 | public void ReadConfig() | 93 | public void ReadConfig() |
95 | { | 94 | { |
96 | m_UseCompiler = m_scriptEngine.Config.GetBoolean("UseNewCompiler", true); | ||
97 | |||
98 | // Get some config | 95 | // Get some config |
99 | WriteScriptSourceToDebugFile = m_scriptEngine.Config.GetBoolean("WriteScriptSourceToDebugFile", true); | 96 | WriteScriptSourceToDebugFile = m_scriptEngine.Config.GetBoolean("WriteScriptSourceToDebugFile", true); |
100 | CompileWithDebugInformation = m_scriptEngine.Config.GetBoolean("CompileWithDebugInformation", true); | 97 | CompileWithDebugInformation = m_scriptEngine.Config.GetBoolean("CompileWithDebugInformation", true); |
@@ -327,14 +324,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
327 | { | 324 | { |
328 | // Its LSL, convert it to C# | 325 | // Its LSL, convert it to C# |
329 | //compileScript = LSL_Converter.Convert(Script); | 326 | //compileScript = LSL_Converter.Convert(Script); |
330 | if (m_UseCompiler) | 327 | LSL_Converter = (ICodeConverter)new CSCodeGenerator(); |
331 | LSL_Converter = (ICodeConverter)new CSCodeGenerator(); | ||
332 | else | ||
333 | LSL_Converter = (ICodeConverter)new LSL2CSConverter(); | ||
334 | compileScript = LSL_Converter.Convert(Script); | 328 | compileScript = LSL_Converter.Convert(Script); |
335 | 329 | ||
336 | if (m_UseCompiler) | 330 | m_positionMap = ((CSCodeGenerator) LSL_Converter).PositionMap; |
337 | m_positionMap = ((CSCodeGenerator) LSL_Converter).PositionMap; | ||
338 | 331 | ||
339 | l = enumCompileType.cs; | 332 | l = enumCompileType.cs; |
340 | } | 333 | } |
@@ -549,31 +542,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
549 | severity = "Warning"; | 542 | severity = "Warning"; |
550 | } | 543 | } |
551 | 544 | ||
552 | if (m_UseCompiler) | 545 | KeyValuePair<int, int> lslPos; |
553 | { | ||
554 | KeyValuePair<int, int> lslPos; | ||
555 | |||
556 | try | ||
557 | { | ||
558 | lslPos = m_positionMap[new KeyValuePair<int, int>(CompErr.Line, CompErr.Column)]; | ||
559 | } | ||
560 | catch (KeyNotFoundException) // we don't have this line/column mapped | ||
561 | { | ||
562 | m_scriptEngine.Log.Debug(String.Format("[Compiler]: Lookup of C# line {0}, column {1} failed.", CompErr.Line, CompErr.Column)); | ||
563 | lslPos = new KeyValuePair<int, int>(-CompErr.Line, -CompErr.Column); | ||
564 | } | ||
565 | |||
566 | // The Second Life viewer's script editor begins | ||
567 | // countingn lines and columns at 0, so we subtract 1. | ||
568 | errtext += String.Format("Line {0}, column {1}, {4} Number: {2}, '{3}'\r\n", lslPos.Key - 1, lslPos.Value - 1, CompErr.ErrorNumber, CompErr.ErrorText, severity); | ||
569 | 546 | ||
547 | try | ||
548 | { | ||
549 | lslPos = m_positionMap[new KeyValuePair<int, int>(CompErr.Line, CompErr.Column)]; | ||
570 | } | 550 | } |
571 | else | 551 | catch (KeyNotFoundException) // we don't have this line/column mapped |
572 | { | 552 | { |
573 | errtext += "Line number " + (CompErr.Line - LinesToRemoveOnError) + | 553 | m_scriptEngine.Log.Debug(String.Format("[Compiler]: Lookup of C# line {0}, column {1} failed.", CompErr.Line, CompErr.Column)); |
574 | ", " + severity + " Number: " + CompErr.ErrorNumber + | 554 | lslPos = new KeyValuePair<int, int>(-CompErr.Line, -CompErr.Column); |
575 | ", '" + CompErr.ErrorText + "'\r\n"; | ||
576 | } | 555 | } |
556 | |||
557 | // The Second Life viewer's script editor begins | ||
558 | // countingn lines and columns at 0, so we subtract 1. | ||
559 | errtext += String.Format("Line {0}, column {1}, {4} Number: {2}, '{3}'\r\n", lslPos.Key - 1, lslPos.Value - 1, CompErr.ErrorNumber, CompErr.ErrorText, severity); | ||
577 | } | 560 | } |
578 | 561 | ||
579 | Console.WriteLine("[COMPILER MESSAGES]: " + errtext); | 562 | Console.WriteLine("[COMPILER MESSAGES]: " + errtext); |