diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/CodeTools')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs | 115 |
1 files changed, 74 insertions, 41 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs index cb5664b..fe26429 100644 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs | |||
@@ -542,23 +542,50 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
542 | break; | 542 | break; |
543 | case enumCompileType.cs: | 543 | case enumCompileType.cs: |
544 | case enumCompileType.lsl: | 544 | case enumCompileType.lsl: |
545 | lock (CScodeProvider) | 545 | bool complete = false; |
546 | bool retried = false; | ||
547 | do | ||
546 | { | 548 | { |
547 | results = CScodeProvider.CompileAssemblyFromSource( | 549 | lock (CScodeProvider) |
550 | { | ||
551 | results = CScodeProvider.CompileAssemblyFromSource( | ||
548 | parameters, Script); | 552 | parameters, Script); |
549 | } | 553 | } |
554 | // Deal with an occasional segv in the compiler. | ||
555 | // Rarely, if ever, occurs twice in succession. | ||
556 | // Line # == 0 and no file name are indications that | ||
557 | // this is a native stack trace rather than a normal | ||
558 | // error log. | ||
559 | if (results.Errors.Count > 0) | ||
560 | { | ||
561 | if (!retried && (results.Errors[0].FileName == null || results.Errors[0].FileName == String.Empty) && | ||
562 | results.Errors[0].Line == 0) | ||
563 | { | ||
564 | // System.Console.WriteLine("retrying failed compilation"); | ||
565 | retried = true; | ||
566 | } | ||
567 | else | ||
568 | { | ||
569 | complete = true; | ||
570 | } | ||
571 | } | ||
572 | else | ||
573 | { | ||
574 | complete = true; | ||
575 | } | ||
576 | } while (!complete); | ||
550 | break; | 577 | break; |
551 | case enumCompileType.js: | 578 | case enumCompileType.js: |
552 | results = JScodeProvider.CompileAssemblyFromSource( | 579 | results = JScodeProvider.CompileAssemblyFromSource( |
553 | parameters, Script); | 580 | parameters, Script); |
554 | break; | 581 | break; |
555 | case enumCompileType.yp: | 582 | case enumCompileType.yp: |
556 | results = YPcodeProvider.CompileAssemblyFromSource( | 583 | results = YPcodeProvider.CompileAssemblyFromSource( |
557 | parameters, Script); | 584 | parameters, Script); |
558 | break; | 585 | break; |
559 | default: | 586 | default: |
560 | throw new Exception("Compiler is not able to recongnize "+ | 587 | throw new Exception("Compiler is not able to recongnize "+ |
561 | "language type \"" + lang.ToString() + "\""); | 588 | "language type \"" + lang.ToString() + "\""); |
562 | } | 589 | } |
563 | 590 | ||
564 | // Check result | 591 | // Check result |
@@ -567,56 +594,62 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
567 | // | 594 | // |
568 | // WARNINGS AND ERRORS | 595 | // WARNINGS AND ERRORS |
569 | // | 596 | // |
570 | int display = 5; | 597 | bool hadErrors = false; |
598 | string errtext = String.Empty; | ||
599 | |||
571 | if (results.Errors.Count > 0) | 600 | if (results.Errors.Count > 0) |
572 | { | 601 | { |
573 | string errtext = String.Empty; | ||
574 | foreach (CompilerError CompErr in results.Errors) | 602 | foreach (CompilerError CompErr in results.Errors) |
575 | { | 603 | { |
576 | // Show 5 errors max | 604 | string severity = CompErr.IsWarning ? "Warning" : "Error"; |
577 | // | ||
578 | if (display <= 0) | ||
579 | break; | ||
580 | display--; | ||
581 | |||
582 | string severity = "Error"; | ||
583 | if (CompErr.IsWarning) | ||
584 | { | ||
585 | severity = "Warning"; | ||
586 | } | ||
587 | 605 | ||
588 | KeyValuePair<int, int> lslPos; | 606 | KeyValuePair<int, int> lslPos; |
589 | 607 | ||
590 | lslPos = FindErrorPosition(CompErr.Line, CompErr.Column); | 608 | // Show 5 errors max, but check entire list for errors |
591 | 609 | ||
592 | string text = CompErr.ErrorText; | 610 | if (severity == "Error") |
611 | { | ||
612 | lslPos = FindErrorPosition(CompErr.Line, CompErr.Column); | ||
613 | string text = CompErr.ErrorText; | ||
614 | |||
615 | // Use LSL type names | ||
616 | if (lang == enumCompileType.lsl) | ||
617 | text = ReplaceTypes(CompErr.ErrorText); | ||
618 | |||
619 | // The Second Life viewer's script editor begins | ||
620 | // countingn lines and columns at 0, so we subtract 1. | ||
621 | errtext += String.Format("Line ({0},{1}): {4} {2}: {3}\n", | ||
622 | lslPos.Key - 1, lslPos.Value - 1, | ||
623 | CompErr.ErrorNumber, text, severity); | ||
624 | hadErrors = true; | ||
625 | } | ||
626 | } | ||
627 | } | ||
628 | |||
629 | if (hadErrors) | ||
630 | { | ||
631 | throw new Exception(errtext); | ||
632 | } | ||
593 | 633 | ||
594 | // Use LSL type names | 634 | // On today's highly asynchronous systems, the result of |
595 | if (lang == enumCompileType.lsl) | 635 | // the compile may not be immediately apparent. Wait a |
596 | text = ReplaceTypes(CompErr.ErrorText); | 636 | // reasonable amount of time before giving up on it. |
597 | 637 | ||
598 | // The Second Life viewer's script editor begins | 638 | if (!File.Exists(OutFile)) |
599 | // countingn lines and columns at 0, so we subtract 1. | 639 | { |
600 | errtext += String.Format("Line ({0},{1}): {4} {2}: {3}\n", | 640 | for (int i=0; i<20 && !File.Exists(OutFile); i++) |
601 | lslPos.Key - 1, lslPos.Value - 1, | 641 | { |
602 | CompErr.ErrorNumber, text, severity); | 642 | System.Threading.Thread.Sleep(250); |
603 | } | 643 | } |
604 | 644 | // One final chance... | |
605 | if (!File.Exists(OutFile)) | 645 | if (!File.Exists(OutFile)) |
606 | { | 646 | { |
647 | errtext = String.Empty; | ||
648 | errtext += "No compile error. But not able to locate compiled file."; | ||
607 | throw new Exception(errtext); | 649 | throw new Exception(errtext); |
608 | } | 650 | } |
609 | } | 651 | } |
610 | 652 | ||
611 | // | ||
612 | // NO ERRORS, BUT NO COMPILED FILE | ||
613 | // | ||
614 | if (!File.Exists(OutFile)) | ||
615 | { | ||
616 | string errtext = String.Empty; | ||
617 | errtext += "No compile error. But not able to locate compiled file."; | ||
618 | throw new Exception(errtext); | ||
619 | } | ||
620 | // m_log.DebugFormat("[Compiler] Compiled new assembly "+ | 653 | // m_log.DebugFormat("[Compiler] Compiled new assembly "+ |
621 | // "for {0}", asset); | 654 | // "for {0}", asset); |
622 | 655 | ||
@@ -629,7 +662,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
629 | 662 | ||
630 | if (fi == null) | 663 | if (fi == null) |
631 | { | 664 | { |
632 | string errtext = String.Empty; | 665 | errtext = String.Empty; |
633 | errtext += "No compile error. But not able to stat file."; | 666 | errtext += "No compile error. But not able to stat file."; |
634 | throw new Exception(errtext); | 667 | throw new Exception(errtext); |
635 | } | 668 | } |
@@ -644,7 +677,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
644 | } | 677 | } |
645 | catch (Exception) | 678 | catch (Exception) |
646 | { | 679 | { |
647 | string errtext = String.Empty; | 680 | errtext = String.Empty; |
648 | errtext += "No compile error. But not able to open file."; | 681 | errtext += "No compile error. But not able to open file."; |
649 | throw new Exception(errtext); | 682 | throw new Exception(errtext); |
650 | } | 683 | } |