コード例 #1
0
        void Log_ExplorationBoundaryHandler(ExplorationBoundaryEventArgs e)
        {
            var database = Host.GetService<ProblemTrackDatabase>();
            ProblemEventArgs successfulFlippedPathCondition = database.CurrentSuccessfulFlippedPathCondition;
            StringBuilder log = database.SimpleLog;

            SequencePoint sp;
            if (successfulFlippedPathCondition == null)
            {
                return;
            }
            CodeLocation location = successfulFlippedPathCondition.FlippedLocation;
            Host.Services.SymbolManager.TryGetSequencePoint(location.Method, location.Offset, out sp);
            StringBuilder sb = new StringBuilder("/////////////////////////////////// \n");
            log.AppendLine("exception: " + e.Kind + " e.TargetName: " + e.TargetName + " message: " + e);
            sb.AppendLine("flipped location: " + sp.Document + " line: " + sp.Line);
            var branchInfo = new BranchInfo("",0,0,0,"",0);
            try
            {
                branchInfo = new BranchInfo(sp.Document, sp.Line, sp.Column, sp.EndColumn, location.Method.FullName, location.Offset);
            }
            catch (Exception)
            {

            }

            var flippedCondition = successfulFlippedPathCondition.Suffix;
            var stringWriter = new StringWriter();
            var bodyWriter = this.Host.Services.LanguageManager.DefaultLanguage.CreateBodyWriter(stringWriter,
                                                                                                 VisibilityContext.
                                                                                                     Private);
            var emitter = new TermEmitter(successfulFlippedPathCondition.TermManager, new NameCreator());
            if (emitter.TryEvaluate(Indexable.One(flippedCondition), 1000, bodyWriter))
            {
                bodyWriter.Return(SystemTypes.Bool);
            }

            stringWriter.WriteLine();
            stringWriter.WriteLine("Feasible prefixes:");
            if (successfulFlippedPathCondition.FeasiblePrefix != null && successfulFlippedPathCondition.FeasiblePrefix.Length > 0)
            {
                var bodyWriter2 = this.Host.Services.LanguageManager.DefaultLanguage.CreateBodyWriter(stringWriter,
                                                                                                VisibilityContext.
                                                                                                    Private);
                foreach (Term prefix in successfulFlippedPathCondition.FeasiblePrefix)
                {
                    if (emitter.TryEvaluate(Indexable.One(prefix), 1000, bodyWriter2))
                    {
                        bodyWriter2.Return(SystemTypes.Bool);
                    }
                }
            }
            else
            {
                stringWriter.WriteLine("No feasible prefixes.");
            }

            this.Host.Log.Dump("My Category", "condition", stringWriter.ToString());
            sb.AppendLine(stringWriter.ToString());

            sb.AppendLine("///////////////////////////////////");
            var issue = new BoundaryProblem(e.Kind.ToString(), e.TargetName.ToString(), e.Message, branchInfo, stringWriter.ToString());
            Host.GetService<ProblemTrackDatabase>().BoundaryIssues.Add(issue);
            log.AppendLine(sb.ToString());
            //            e.
        }
コード例 #2
0
        void Log_ExplorationBoundaryHandler(ExplorationBoundaryEventArgs e)
        {
            var database = Host.GetService <ProblemTrackDatabase>();
            ProblemEventArgs successfulFlippedPathCondition = database.CurrentSuccessfulFlippedPathCondition;
            StringBuilder    log = database.SimpleLog;


            SequencePoint sp;

            if (successfulFlippedPathCondition == null)
            {
                return;
            }
            CodeLocation location = successfulFlippedPathCondition.FlippedLocation;

            Host.Services.SymbolManager.TryGetSequencePoint(location.Method, location.Offset, out sp);
            StringBuilder sb = new StringBuilder("/////////////////////////////////// \n");

            log.AppendLine("exception: " + e.Kind + " e.TargetName: " + e.TargetName + " message: " + e);
            sb.AppendLine("flipped location: " + sp.Document + " line: " + sp.Line);
            var branchInfo = new BranchInfo("", 0, 0, 0, "", 0);

            try
            {
                branchInfo = new BranchInfo(sp.Document, sp.Line, sp.Column, sp.EndColumn, location.Method.FullName, location.Offset);
            }
            catch (Exception)
            {
            }


            var flippedCondition = successfulFlippedPathCondition.Suffix;
            var stringWriter     = new StringWriter();
            var bodyWriter       = this.Host.Services.LanguageManager.DefaultLanguage.CreateBodyWriter(stringWriter,
                                                                                                       VisibilityContext.
                                                                                                       Private);
            var emitter = new TermEmitter(successfulFlippedPathCondition.TermManager, new NameCreator());

            if (emitter.TryEvaluate(Indexable.One(flippedCondition), 1000, bodyWriter))
            {
                bodyWriter.Return(SystemTypes.Bool);
            }

            stringWriter.WriteLine();
            stringWriter.WriteLine("Feasible prefixes:");
            if (successfulFlippedPathCondition.FeasiblePrefix != null && successfulFlippedPathCondition.FeasiblePrefix.Length > 0)
            {
                var bodyWriter2 = this.Host.Services.LanguageManager.DefaultLanguage.CreateBodyWriter(stringWriter,
                                                                                                      VisibilityContext.
                                                                                                      Private);
                foreach (Term prefix in successfulFlippedPathCondition.FeasiblePrefix)
                {
                    if (emitter.TryEvaluate(Indexable.One(prefix), 1000, bodyWriter2))
                    {
                        bodyWriter2.Return(SystemTypes.Bool);
                    }
                }
            }
            else
            {
                stringWriter.WriteLine("No feasible prefixes.");
            }

            this.Host.Log.Dump("My Category", "condition", stringWriter.ToString());
            sb.AppendLine(stringWriter.ToString());

            sb.AppendLine("///////////////////////////////////");
            var issue = new BoundaryProblem(e.Kind.ToString(), e.TargetName.ToString(), e.Message, branchInfo, stringWriter.ToString());

            Host.GetService <ProblemTrackDatabase>().BoundaryIssues.Add(issue);
            log.AppendLine(sb.ToString());
//            e.
        }