aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorMelanie2009-12-22 09:24:01 +0000
committerMelanie2009-12-22 09:24:01 +0000
commit1876ce90af98722a205d1c7181ef66b6a2b54fc5 (patch)
tree2929090816713fac73d3567314ba8727498d02c4
parentAdd missing file (diff)
downloadopensim-SC_OLD-1876ce90af98722a205d1c7181ef66b6a2b54fc5.zip
opensim-SC_OLD-1876ce90af98722a205d1c7181ef66b6a2b54fc5.tar.gz
opensim-SC_OLD-1876ce90af98722a205d1c7181ef66b6a2b54fc5.tar.bz2
opensim-SC_OLD-1876ce90af98722a205d1c7181ef66b6a2b54fc5.tar.xz
FINALLY! Script compile errors now appear in the script error pane,
not in a funky debug window.
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CSCodeGeneratorTest.cs4
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/XEngine.cs163
5 files changed, 98 insertions, 75 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs
index e427f50..b1fb6c2 100644
--- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs
@@ -111,7 +111,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
111 if (emessage.StartsWith(slinfo+": ")) 111 if (emessage.StartsWith(slinfo+": "))
112 emessage = emessage.Substring(slinfo.Length+2); 112 emessage = emessage.Substring(slinfo.Length+2);
113 113
114 message = String.Format("Line ({0},{1}) {2}", 114 message = String.Format("({0},{1}) {2}",
115 e.slInfo.lineNumber - 2, 115 e.slInfo.lineNumber - 2,
116 e.slInfo.charPosition - 1, emessage); 116 e.slInfo.charPosition - 1, emessage);
117 117
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs
index 3080c71..d8c0ba5 100644
--- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs
@@ -623,7 +623,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
623 623
624 // The Second Life viewer's script editor begins 624 // The Second Life viewer's script editor begins
625 // countingn lines and columns at 0, so we subtract 1. 625 // countingn lines and columns at 0, so we subtract 1.
626 errtext += String.Format("Line ({0},{1}): {4} {2}: {3}\n", 626 errtext += String.Format("({0},{1}): {4} {2}: {3}\n",
627 lslPos.Key - 1, lslPos.Value - 1, 627 lslPos.Key - 1, lslPos.Value - 1,
628 CompErr.ErrorNumber, text, severity); 628 CompErr.ErrorNumber, text, severity);
629 hadErrors = true; 629 hadErrors = true;
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CSCodeGeneratorTest.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CSCodeGeneratorTest.cs
index 3ca7f7c..63afb0b 100644
--- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CSCodeGeneratorTest.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CSCodeGeneratorTest.cs
@@ -1673,7 +1673,7 @@ default
1673 { 1673 {
1674 // The syntax error is on line 6, char 5 (expected ';', found 1674 // The syntax error is on line 6, char 5 (expected ';', found
1675 // '}'). 1675 // '}').
1676 Assert.AreEqual("Line (4,4) syntax error", e.Message); 1676 Assert.AreEqual("(4,4) syntax error", e.Message);
1677 throw; 1677 throw;
1678 } 1678 }
1679 } 1679 }
@@ -1698,7 +1698,7 @@ default
1698 catch (System.Exception e) 1698 catch (System.Exception e)
1699 { 1699 {
1700 // The syntax error is on line 5, char 14 (Syntax error) 1700 // The syntax error is on line 5, char 14 (Syntax error)
1701 Assert.AreEqual("Line (3,13) syntax error", e.Message); 1701 Assert.AreEqual("(3,13) syntax error", e.Message);
1702 1702
1703 throw; 1703 throw;
1704 } 1704 }
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
index 5c5d57e..d30d2dc 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
@@ -967,7 +967,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
967 if (col == 0) 967 if (col == 0)
968 col++; 968 col++;
969 message = string.Format("Runtime error:\n" + 969 message = string.Format("Runtime error:\n" +
970 "Line ({0}): {1}", scriptLine - 1, 970 "({0}): {1}", scriptLine - 1,
971 e.InnerException.Message); 971 e.InnerException.Message);
972 972
973 System.Console.WriteLine(e.ToString()+"\n"); 973 System.Console.WriteLine(e.ToString()+"\n");
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index 035686e..11b02e1 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -77,6 +77,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
77 private string m_ScriptErrorMessage; 77 private string m_ScriptErrorMessage;
78 private Dictionary<string, string> m_uniqueScripts = new Dictionary<string, string>(); 78 private Dictionary<string, string> m_uniqueScripts = new Dictionary<string, string>();
79 private bool m_AppDomainLoading; 79 private bool m_AppDomainLoading;
80 private Dictionary<UUID,ArrayList> m_ScriptErrors =
81 new Dictionary<UUID,ArrayList>();
80 82
81 // disable warning: need to keep a reference to XEngine.EventManager 83 // disable warning: need to keep a reference to XEngine.EventManager
82 // alive to avoid it being garbage collected 84 // alive to avoid it being garbage collected
@@ -589,87 +591,97 @@ namespace OpenSim.Region.ScriptEngine.XEngine
589 591
590 Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> linemap; 592 Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> linemap;
591 593
592 try 594 lock(m_ScriptErrors)
593 { 595 {
594 lock (m_AddingAssemblies) 596 try
595 { 597 {
596 m_Compiler.PerformScriptCompile(script, assetID.ToString(), item.OwnerID, out assembly, out linemap); 598 lock (m_AddingAssemblies)
597 if (!m_AddingAssemblies.ContainsKey(assembly)) { 599 {
598 m_AddingAssemblies[assembly] = 1; 600 m_Compiler.PerformScriptCompile(script, assetID.ToString(), item.OwnerID, out assembly, out linemap);
599 } else { 601 if (!m_AddingAssemblies.ContainsKey(assembly)) {
600 m_AddingAssemblies[assembly]++; 602 m_AddingAssemblies[assembly] = 1;
603 } else {
604 m_AddingAssemblies[assembly]++;
605 }
601 } 606 }
602 }
603 607
604 string[] warnings = m_Compiler.GetWarnings(); 608 string[] warnings = m_Compiler.GetWarnings();
605 609
606 if (warnings != null && warnings.Length != 0) 610 if (warnings != null && warnings.Length != 0)
607 {
608 foreach (string warning in warnings)
609 { 611 {
610 try 612 foreach (string warning in warnings)
611 { 613 {
612 // DISPLAY WARNING INWORLD 614 if (!m_ScriptErrors.ContainsKey(itemID))
613 string text = "Warning:\n" + warning; 615 m_ScriptErrors[itemID] = new ArrayList();
614 if (text.Length > 1000) 616
615 text = text.Substring(0, 1000); 617 m_ScriptErrors[itemID].Add(warning);
616 if (!ShowScriptSaveResponse(item.OwnerID, 618 // try
617 assetID, text, true)) 619 // {
618 { 620 // // DISPLAY WARNING INWORLD
619 if (presence != null && (!postOnRez)) 621 // string text = "Warning:\n" + warning;
620 presence.ControllingClient.SendAgentAlertMessage("Script saved with warnings, check debug window!", false); 622 // if (text.Length > 1000)
621 623 // text = text.Substring(0, 1000);
622 World.SimChat(Utils.StringToBytes(text), 624 // if (!ShowScriptSaveResponse(item.OwnerID,
623 ChatTypeEnum.DebugChannel, 2147483647, 625 // assetID, text, true))
624 part.AbsolutePosition, 626 // {
625 part.Name, part.UUID, false); 627 // if (presence != null && (!postOnRez))
626 } 628 // presence.ControllingClient.SendAgentAlertMessage("Script saved with warnings, check debug window!", false);
627 } 629 //
628 catch (Exception e2) // LEGIT: User Scripting 630 // World.SimChat(Utils.StringToBytes(text),
629 { 631 // ChatTypeEnum.DebugChannel, 2147483647,
630 m_log.Error("[XEngine]: " + 632 // part.AbsolutePosition,
631 "Error displaying warning in-world: " + 633 // part.Name, part.UUID, false);
632 e2.ToString()); 634 // }
633 m_log.Error("[XEngine]: " + 635 // }
634 "Warning:\r\n" + 636 // catch (Exception e2) // LEGIT: User Scripting
635 warning); 637 // {
638 // m_log.Error("[XEngine]: " +
639 // "Error displaying warning in-world: " +
640 // e2.ToString());
641 // m_log.Error("[XEngine]: " +
642 // "Warning:\r\n" +
643 // warning);
644 // }
636 } 645 }
637 } 646 }
638 } 647 }
639 } 648 catch (Exception e)
640 catch (Exception e)
641 {
642 try
643 { 649 {
644 // DISPLAY ERROR INWORLD 650 // try
645 m_ScriptErrorMessage += "Failed to compile script in object: '" + part.ParentGroup.RootPart.Name + "' Script name: '" + item.Name + "' Error message: " + e.Message.ToString(); 651 // {
646 652 if (!m_ScriptErrors.ContainsKey(itemID))
647 m_ScriptFailCount++; 653 m_ScriptErrors[itemID] = new ArrayList();
648 string text = "Error compiling script '" + item.Name + "':\n" + e.Message.ToString(); 654 // DISPLAY ERROR INWORLD
649 if (text.Length > 1000) 655 // m_ScriptErrorMessage += "Failed to compile script in object: '" + part.ParentGroup.RootPart.Name + "' Script name: '" + item.Name + "' Error message: " + e.Message.ToString();
650 text = text.Substring(0, 1000); 656 //
651 if (!ShowScriptSaveResponse(item.OwnerID, 657 m_ScriptFailCount++;
652 assetID, text, false)) 658 m_ScriptErrors[itemID].Add(e.Message.ToString());
653 { 659 // string text = "Error compiling script '" + item.Name + "':\n" + e.Message.ToString();
654 if (presence != null && (!postOnRez)) 660 // if (text.Length > 1000)
655 presence.ControllingClient.SendAgentAlertMessage("Script saved with errors, check debug window!", false); 661 // text = text.Substring(0, 1000);
656 World.SimChat(Utils.StringToBytes(text), 662 // if (!ShowScriptSaveResponse(item.OwnerID,
657 ChatTypeEnum.DebugChannel, 2147483647, 663 // assetID, text, false))
658 part.AbsolutePosition, 664 // {
659 part.Name, part.UUID, false); 665 // if (presence != null && (!postOnRez))
660 } 666 // presence.ControllingClient.SendAgentAlertMessage("Script saved with errors, check debug window!", false);
661 } 667 // World.SimChat(Utils.StringToBytes(text),
662 catch (Exception e2) // LEGIT: User Scripting 668 // ChatTypeEnum.DebugChannel, 2147483647,
663 { 669 // part.AbsolutePosition,
664 m_log.Error("[XEngine]: "+ 670 // part.Name, part.UUID, false);
665 "Error displaying error in-world: " + 671 // }
666 e2.ToString()); 672 // }
667 m_log.Error("[XEngine]: " + 673 // catch (Exception e2) // LEGIT: User Scripting
668 "Errormessage: Error compiling script:\r\n" + 674 // {
669 e.Message.ToString()); 675 // m_log.Error("[XEngine]: "+
670 } 676 // "Error displaying error in-world: " +
677 // e2.ToString());
678 // m_log.Error("[XEngine]: " +
679 // "Errormessage: Error compiling script:\r\n" +
680 // e.Message.ToString());
681 // }
671 682
672 return false; 683 return false;
684 }
673 } 685 }
674 686
675 lock (m_Scripts) 687 lock (m_Scripts)
@@ -1473,7 +1485,18 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1473 1485
1474 public ArrayList GetScriptErrors(UUID itemID) 1486 public ArrayList GetScriptErrors(UUID itemID)
1475 { 1487 {
1476 return new ArrayList(); 1488 System.Threading.Thread.Sleep(1000);
1489
1490 lock (m_ScriptErrors)
1491 {
1492 if (m_ScriptErrors.ContainsKey(itemID))
1493 {
1494 ArrayList ret = m_ScriptErrors[itemID];
1495 m_ScriptErrors.Remove(itemID);
1496 return ret;
1497 }
1498 return new ArrayList();
1499 }
1477 } 1500 }
1478 } 1501 }
1479} 1502}