예제 #1
0
        /// <summary>
        /// Formats a trace to user string.
        /// </summary>
        /// <returns>The formatted trace.</returns>
        public string FormatUserTrace()
        {
            int           i      = GetFrameCount() - 1;
            StringBuilder result = new StringBuilder(String.Format("#{0} {{main}}", i));

            if (i >= 1)
            {
                PhpStackFrame info_frame = GetFrame(i--);

                while (i >= 0)
                {
                    PhpStackFrame frame = GetFrame(i);

                    result.Insert(0, String.Format("#{0} {1}{2}: {3}{4}\n",
                                                   i,
                                                   info_frame.File,
                                                   (info_frame.Line > 0) ? String.Format("({0},{1})", info_frame.Line, info_frame.Column) : null,
                                                   (frame.IsMethod) ? frame.DeclaringTypeName + frame.Operator : null,
                                                   frame.Name));

                    if (frame.HasDebugInfo)
                    {
                        info_frame = frame;
                    }

                    i--;
                }
            }
            return(result.ToString());
        }
예제 #2
0
        /// <summary>
        /// Returns array containing current stack state. Each item is an array representing one stack frame.
        /// </summary>
        /// <returns>The stack trace.</returns>
        /// <remarks>
        /// The resulting array contains the following items (their keys are stated):
        /// <list type="bullet">
        /// <item><c>"file"</c> - a source file where the function/method has been called</item>
        /// <item><c>"line"</c> - a line in a source code where the function/method has been called</item>
        /// <item><c>"column"</c> - a column in a source code where the function/method has been called</item>
        /// <item><c>"function"</c> - a name of the function/method</item>
        /// <item><c>"class"</c> - a name of a class where the method is declared (if any)</item>
        /// <item><c>"type"</c> - either "::" for static methods or "->" for instance methods</item>
        /// </list>
        /// Unsupported items:
        /// <list type="bullet">
        /// <item><c>"args"</c> - routine arguments</item>
        /// <item><c>"object"</c> - target instance of the method invocation</item>
        /// </list>
        /// </remarks>
        public PhpArray GetUserTrace()
        {
            int      i      = GetFrameCount() - 1;
            PhpArray result = new PhpArray();

            if (i >= 1)
            {
                PhpStackFrame info_frame = GetFrame(i--);

                while (i >= 0)
                {
                    PhpStackFrame frame = GetFrame(i);
                    PhpArray      item  = new PhpArray();

                    // debug info may be unknown in the case of transient code:
                    if (info_frame.Line > 0)
                    {
                        item["line"]   = info_frame.Line;
                        item["column"] = info_frame.Column;
                    }
                    item["file"] = info_frame.File;

                    item["function"] = frame.Name;
                    if (frame.IsMethod)
                    {
                        item["class"] = frame.DeclaringTypeName;
                        item["type"]  = frame.Operator;
                    }

                    result.Prepend(i, item);

                    if (frame.HasDebugInfo)
                    {
                        info_frame = frame;
                    }

                    i--;
                }
            }

            return(result);
        }
예제 #3
0
 internal void SetDebugInfo(PhpStackFrame /*!*/ frame)
 {
     this.line   = frame.line;
     this.column = frame.column;
     this.file   = frame.file;
 }
예제 #4
0
		internal void SetDebugInfo(PhpStackFrame/*!*/ frame)
		{
			this.line = frame.line;
			this.column = frame.column;
			this.file = frame.file;
		}