Make trace output resemble assembler listing
authorRaja R Harinath <harinath@hurrynot.org>
Tue, 29 Jun 2010 07:19:50 +0000 (07:19 -0000)
committerRaja R Harinath <harinath@hurrynot.org>
Tue, 29 Jun 2010 07:19:50 +0000 (07:19 -0000)
* compiler.cs (LinkRef.ToString) [TRACE_REGEX]: Add pretty-printer
in TRACE_REGEX mode.
(TraceRegexp): Indent the output.
(TraceRegexpLabel): New.  Prints out a line label.
(EmitCount): Don't trace.  All callers are traced.
(ResolveLink): Trace line labels.

svn path=/trunk/mcs/; revision=159646

mcs/class/System/System.Text.RegularExpressions/ChangeLog
mcs/class/System/System.Text.RegularExpressions/compiler.cs

index 97103cf16bce0ae133055e4b884f00cd56f21abc..164d058514b46a6bf9fa4b23ef395e4219fb33f2 100644 (file)
@@ -1,3 +1,13 @@
+2010-06-29  Raja R Harinath  <harinath@hurrynot.org>
+
+       Make trace output resemble assembler listing
+       * compiler.cs (LinkRef.ToString) [TRACE_REGEX]: Add pretty-printer
+       in TRACE_REGEX mode.
+       (TraceRegexp): Indent the output.
+       (TraceRegexpLabel): New.  Prints out a line label.
+       (EmitCount): Don't trace.  All callers are traced.
+       (ResolveLink): Trace line labels.
+
 2010-06-21  Rodrigo Kumpera  <rkumpera@novell.com>
 
        * compiler.cs: Use conditional compilation to enable
index 53d427129f5977069bfbd58bcfa4449dd763c9a0..cd2a8bc305cb0c397940b83f04e9b831612db760 100644 (file)
@@ -33,7 +33,15 @@ using System.Collections;
 
 namespace System.Text.RegularExpressions {
        abstract class LinkRef {
-               // empty
+#if TRACE_REGEX
+               static int next_label = 1;
+               int label = next_label++;
+
+               public override string ToString ()
+               {
+                       return "L" + label.ToString ();
+               }
+#endif
        }
                
        interface ICompiler {
@@ -127,9 +135,16 @@ namespace System.Text.RegularExpressions {
                [Conditional ("TRACE_REGEX")]
                static void TraceRegexp (string fmt, params object[] args)
                {
+                       Console.Write ("\t");
                        Console.WriteLine (fmt, args);
                }
 
+               [Conditional ("TRACE_REGEX")]
+               static void TraceRegexpLabel (LinkRef lref)
+               {
+                       Console.Write ("{0}:", lref);
+               }
+
                public static void DecodeOp (ushort word, out OpCode op, out OpFlags flags) {
                        op = (OpCode)(word & 0x00ff);
                        flags = (OpFlags)(word & 0xff00);
@@ -168,8 +183,6 @@ namespace System.Text.RegularExpressions {
                        uint ucount = (uint) count;
                        Emit ((ushort) (ucount & 0xFFFF)); // lo 16bits
                        Emit ((ushort) (ucount >> 16));    // hi
-
-                       TraceRegexp ("count {0}", count);
                }
 
                public void EmitCharacter (char c, bool negate, bool ignore, bool reverse) {
@@ -394,6 +407,8 @@ namespace System.Text.RegularExpressions {
                
                        while (stack.Pop ())
                                pgm[stack.OffsetAddress] = (ushort)stack.GetOffset (CurrentAddress);
+
+                       TraceRegexpLabel (lref);
                }
 
                public void EmitBranchEnd(){}