Exemplo n.º 1
0
    /// <summary>
    /// Initializes a new instance of the <see cref="FrameManager"/> class.
    /// </summary>
    /// <param name="p">Path to Framestore File</param>
    public FrameManager(string p)
    {
        ProcessThreadCollection alloldones = Process.GetCurrentProcess().Threads;

        //foreach (Thread item in alloldones) {
        //	if (item.IsBackground == true) {
        //		item.Abort ();
        //	}
        //}

        Framecount = 0;

        Formatter = new FrameFormatter(p);
        Formatter.DelPath();
        Formatter.running         = true;
        formatthread              = new Thread(new ThreadStart(Formatter.RunAutoSerialization));
        formatthread.Name         = "Formatter";
        formatthread.IsBackground = true;
        formatthread.Start();
    }
Exemplo n.º 2
0
        public static void DumpStackTrace(AphidInterpreter interpreter, AphidFrame[] trace)
        {
            var cfg      = AphidConfig.Current;
            var frameNum = 0;

            if (!Console.IsOutputRedirected)
            {
                WriteSubheader(StackTraceHead, "~|Blue~~White~");
            }
            else
            {
                WriteErrorMessage(StackTraceHead);
            }

            foreach (var frame in trace)
            {
                var frameStr = FrameFormatter.FormatFrame(frameNum++, in frame);
                WriteLineOut(frameStr);

                if (cfg.StackTraceParams)
                {
                    var args = frame.Arguments
                               .Select((x, y) => string.Format(
                                           "{0} $args[{1}] = {2}",
                                           GetAphidObjectTypeName(x),
                                           y,
                                           SerializingFormatter.Format(
                                               interpreter,
                                               x,
                                               ignoreNull: false,
                                               ignoreClrObj: false)));

                    if (cfg.StackTraceParamsMax >= 0)
                    {
                        var h = cfg.StackTraceParamsMax / 2f;
                        int first = (int)Math.Ceiling(h), last = (int)Math.Floor(h);
                        var count = frame.Arguments.Count();
                        var skip  = Math.Max(0, count - first - last);

                        if (skip != 0)
                        {
                            args = args
                                   .Where((_, i) => i < first || i >= skip + first)
                                   .Append(string.Format("/* Skipped {0:n0} args /*", skip))
                                   .Skip(skip);
                        }
                    }

                    var argStr = args.JoinLines();

                    if (argStr.Length > 0)
                    {
                        WriteLineOut(Format(argStr.Indent("  ")));
                    }

                    //var locals = frame.Scope
                    //    .Select(x => string.Format(
                    //        "{0} {1} = {2}",
                    //        x.Key,
                    //        GetAphidObjectTypeName(x.Value),
                    //        DumpValue(interpreter, serializer, x.Value)))
                    //    .JoinLines();

                    //if (locals.Length > 0)
                    //{
                    //    WriteLineOut(Highlight(StyleEscape(locals.Indent("  "))));
                    //}
                }
            }

            WriteLineOut("");

            if (cfg.ShowErrorExpression || cfg.ShowErrorStatement)
            {
                ShowErrorNodes(interpreter, cfg, trace);
            }

            if (cfg.ShowErrorFrameExcerpts)
            {
                var dumpCount = 0;

                foreach (var t in trace)
                {
                    if (DumpFirstExcerpt(
                            t.Expression,
                            string.Format(
                                "Frame {0:x4} Excerpt",
                                Array.IndexOf(trace, t))) &&
                        ++dumpCount == cfg.FrameExcerptsMax)
                    {
                        break;
                    }
                }
            }

            //if(dumpCount == 0)
            //{
            //    foreach(var pair in ctxPairs)
            //    {
            //        DumpFirstExcerpt(
            //            pair.Item2,
            //            string.Format("Current {0} Excerpt", pair.Item1));
            //    }

            //}

            var headerPrinted = false;
            var statement     = interpreter.CurrentStatement;
            var exp           = interpreter.CurrentExpression;
            var file          = interpreter.GetScriptFilename();
            var stmtFile      = statement?.Filename;
            var expFile       = exp?.Filename;

            if (cfg.ShowErrorFileList)
            {
                foreach (var s in new (string, string, Func <List <AphidExpression> >)[]