Author: vgritsenko
Date: Sat Mar 10 19:12:10 2007
New Revision: 516847

URL: http://svn.apache.org/viewvc?view=rev&rev=516847
Log:
additional debug methods

Modified:
    jakarta/regexp/trunk/src/java/org/apache/regexp/REDebugCompiler.java

Modified: jakarta/regexp/trunk/src/java/org/apache/regexp/REDebugCompiler.java
URL: 
http://svn.apache.org/viewvc/jakarta/regexp/trunk/src/java/org/apache/regexp/REDebugCompiler.java?view=diff&rev=516847&r1=516846&r2=516847
==============================================================================
--- jakarta/regexp/trunk/src/java/org/apache/regexp/REDebugCompiler.java 
(original)
+++ jakarta/regexp/trunk/src/java/org/apache/regexp/REDebugCompiler.java Sat 
Mar 10 19:12:10 2007
@@ -54,19 +54,20 @@
         hashOpcode.put(new Integer(RE.OP_CLOSE),            "OP_CLOSE");
         hashOpcode.put(new Integer(RE.OP_BACKREF),          "OP_BACKREF");
         hashOpcode.put(new Integer(RE.OP_POSIXCLASS),       "OP_POSIXCLASS");
-        hashOpcode.put(new Integer(RE.OP_OPEN_CLUSTER),      
"OP_OPEN_CLUSTER");
-        hashOpcode.put(new Integer(RE.OP_CLOSE_CLUSTER),      
"OP_CLOSE_CLUSTER");
+        hashOpcode.put(new Integer(RE.OP_OPEN_CLUSTER),     "OP_OPEN_CLUSTER");
+        hashOpcode.put(new Integer(RE.OP_CLOSE_CLUSTER),    
"OP_CLOSE_CLUSTER");
     }
 
     /**
      * Returns a descriptive string for an opcode.
+     *
      * @param opcode Opcode to convert to a string
      * @return Description of opcode
      */
     String opcodeToString(char opcode)
     {
         // Get string for opcode
-        String ret =(String)hashOpcode.get(new Integer(opcode));
+        String ret = (String) hashOpcode.get(new Integer(opcode));
 
         // Just in case we have a corrupt program
         if (ret == null)
@@ -78,6 +79,7 @@
 
     /**
      * Return a string describing a (possibly unprintable) character.
+     *
      * @param c Character to convert to a printable representation
      * @return String representation of character
      */
@@ -86,7 +88,7 @@
         // If it's unprintable, convert to '\###'
         if (c < ' ' || c > 127)
         {
-            return "\\" + (int)c;
+            return "\\" + (int) c;
         }
 
         // Return the character as a string
@@ -101,47 +103,76 @@
     String nodeToString(int node)
     {
         // Get opcode and opdata for node
-        char opcode =      instruction[node + RE.offsetOpcode];
-        int opdata  = (int)instruction[node + RE.offsetOpdata];
+        char opcode =       instruction[node + RE.offsetOpcode];
+        int opdata  = (int) instruction[node + RE.offsetOpdata];
 
         // Return opcode as a string and opdata value
         return opcodeToString(opcode) + ", opdata = " + opdata;
     }
 
     /**
+     * Adds a new node
+     *
+     * @param opcode Opcode for node
+     * @param opdata Opdata for node (only the low 16 bits are currently used)
+     * @return Index of new node in program
+     * /
+    int node(char opcode, int opdata)
+    {
+        System.out.println("====> Add " + opcode + " " + opdata);
+        PrintWriter writer = new PrintWriter(System.out);
+        dumpProgram(writer);
+        writer.flush();
+        int r = super.node(opcode, opdata);
+        System.out.println("====< ");
+        dumpProgram(writer);
+        writer.flush();
+        return r;
+    }/**/
+
+    /**
      * Inserts a node with a given opcode and opdata at insertAt.  The node 
relative next
      * pointer is initialized to 0.
+     *
      * @param opcode Opcode for new node
      * @param opdata Opdata for new node (only the low 16 bits are currently 
used)
-     * @param insertAt Index at which to insert the new node in the program * /
-    void nodeInsert(char opcode, int opdata, int insertAt) {
-        System.out.println( "====> " + opcode + " " + opdata + " " + insertAt 
);
-        PrintWriter writer = new PrintWriter( System.out );
-        dumpProgram( writer );
-        super.nodeInsert( opcode, opdata, insertAt );
-        System.out.println( "====< " );
-        dumpProgram( writer );
+     * @param insertAt Index at which to insert the new node in the program
+     * /
+    void nodeInsert(char opcode, int opdata, int insertAt)
+    {
+        System.out.println("====> Ins " + opcode + " " + opdata + " " + 
insertAt);
+        PrintWriter writer = new PrintWriter(System.out);
+        dumpProgram(writer);
+        writer.flush();
+        super.nodeInsert(opcode, opdata, insertAt);
+        System.out.println("====< ");
+        dumpProgram(writer);
         writer.flush();
     }/**/
 
 
     /**
-    * Appends a node to the end of a node chain
-    * @param node Start of node chain to traverse
-    * @param pointTo Node to have the tail of the chain point to * /
-    void setNextOfEnd(int node, int pointTo) {
-        System.out.println( "====> " + node + " " + pointTo );
-        PrintWriter writer = new PrintWriter( System.out );
-        dumpProgram( writer );
-        super.setNextOfEnd( node, pointTo );
-        System.out.println( "====< " );
-        dumpProgram( writer );
+     * Appends a node to the end of a node chain
+     *
+     * @param node Start of node chain to traverse
+     * @param pointTo Node to have the tail of the chain point to
+     * /
+    void setNextOfEnd(int node, int pointTo)
+    {
+        System.out.println("====> Link " + node + " " + pointTo);
+        PrintWriter writer = new PrintWriter(System.out);
+        dumpProgram(writer);
+        writer.flush();
+        super.setNextOfEnd(node, pointTo);
+        System.out.println("====< ");
+        dumpProgram(writer);
         writer.flush();
     }/**/
 
 
     /**
-     * Dumps the current program to a PrintWriter
+     * Dumps the current program to a [EMAIL PROTECTED] PrintWriter}.
+     *
      * @param p PrintWriter for program dump output
      */
     public void dumpProgram(PrintWriter p)
@@ -218,5 +249,13 @@
             // Print a newline
             p.println("");
         }
+    }
+
+    /**
+     * Dumps the current program to a [EMAIL PROTECTED] System#out}.
+     */
+    public void dumpProgram()
+    {
+        dumpProgram(new PrintWriter(System.out));
     }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to