Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/generic/Select.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/generic/Select.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/generic/Select.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/generic/Select.java Wed Mar 15 03:31:56 2006
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
- */
+ */
package org.apache.bcel.generic;
import java.io.DataOutputStream;
@@ -31,200 +31,206 @@
* @see TABLESWITCH
* @see InstructionList
*/
-public abstract class Select extends BranchInstruction
- implements VariableLengthInstruction, StackProducer
-{
- protected int[] match; // matches, i.e., case 1: ...
- protected int[] indices; // target offsets
- protected InstructionHandle[] targets; // target objects in instruction list
- protected int fixed_length; // fixed length defined by subclasses
- protected int match_length; // number of cases
- protected int padding = 0; // number of pad bytes for alignment
-
- /**
- * Empty constructor needed for the Class.newInstance() statement in
- * Instruction.readInstruction(). Not to be used otherwise.
- */
- Select() {}
-
- /**
- * (Match, target) pairs for switch.
- * `Match' and `targets' must have the same length of course.
- *
- * @param match array of matching values
- * @param targets instruction targets
- * @param defaultTarget default instruction target
- */
- Select(short opcode, int[] match, InstructionHandle[] targets,
- InstructionHandle defaultTarget) {
- super(opcode, defaultTarget);
-
- this.targets = targets;
- for(int i=0; i < targets.length; i++)
- notifyTarget(null, targets[i], this);
-
- this.match = match;
-
- if((match_length = match.length) != targets.length)
- throw new ClassGenException("Match and target array have not the same length");
-
- indices = new int[match_length];
- }
-
- /**
- * Since this is a variable length instruction, it may shift the following
- * instructions which then need to update their position.
- *
- * Called by InstructionList.setPositions when setting the position for every
- * instruction. In the presence of variable length instructions `setPositions'
- * performs multiple passes over the instruction list to calculate the
- * correct (byte) positions and offsets by calling this function.
- *
- * @param offset additional offset caused by preceding (variable length) instructions
- * @param max_offset the maximum offset that may be caused by these instructions
- * @return additional offset caused by possible change of this instruction's length
- */
- protected int updatePosition(int offset, int max_offset) {
- position += offset; // Additional offset caused by preceding SWITCHs, GOTOs, etc.
-
- short old_length = length;
-
- /* Alignment on 4-byte-boundary, + 1, because of tag byte.
- */
- padding = (4 - ((position + 1) % 4)) % 4;
- length = (short)(fixed_length + padding); // Update length
-
- return length - old_length;
- }
-
- /**
- * Dump instruction as byte code to stream out.
- * @param out Output stream
- */
- public void dump(DataOutputStream out) throws IOException {
- out.writeByte(opcode);
-
- for(int i=0; i < padding; i++) // Padding bytes
- out.writeByte(0);
-
- index = getTargetOffset(); // Write default target offset
- out.writeInt(index);
- }
-
- /**
- * Read needed data (e.g. index) from file.
- */
- protected void initFromFile(ByteSequence bytes, boolean wide) throws IOException
- {
- padding = (4 - (bytes.getIndex() % 4)) % 4; // Compute number of pad bytes
-
- for(int i=0; i < padding; i++) {
- bytes.readByte();
- }
-
- // Default branch target common for both cases (TABLESWITCH, LOOKUPSWITCH)
- index = bytes.readInt();
- }
-
- /**
- * @return mnemonic for instruction
- */
- public String toString(boolean verbose) {
- StringBuffer buf = new StringBuffer(super.toString(verbose));
-
- if(verbose) {
- for(int i=0; i < match_length; i++) {
- String s = "null";
-
- if(targets[i] != null)
- s = targets[i].getInstruction().toString();
-
- buf.append("(").append(match[i]).append(", ").append(s).append(" = {").append(indices[i]).append("})");
- }
- }
- else
- buf.append(" ...");
-
- return buf.toString();
- }
-
- /**
- * Set branch target for `i'th case
- */
- public void setTarget(int i, InstructionHandle target) {
- notifyTarget(targets[i], target, this);
- targets[i] = target;
- }
-
- /**
- * @param old_ih old target
- * @param new_ih new target
- */
- public void updateTarget(InstructionHandle old_ih, InstructionHandle new_ih) {
- boolean targeted = false;
-
- if(target == old_ih) {
- targeted = true;
- setTarget(new_ih);
- }
-
- for(int i=0; i < targets.length; i++) {
- if(targets[i] == old_ih) {
- targeted = true;
- setTarget(i, new_ih);
- }
- }
-
- if(!targeted)
- throw new ClassGenException("Not targeting " + old_ih);
- }
-
- /**
- * @return true, if ih is target of this instruction
- */
- public boolean containsTarget(InstructionHandle ih) {
- if(target == ih)
- return true;
-
- for(int i=0; i < targets.length; i++)
- if(targets[i] == ih)
- return true;
-
- return false;
- }
-
- protected Object clone() throws CloneNotSupportedException {
- Select copy = (Select) super.clone();
-
- copy.match = (int[]) match.clone();
- copy.indices = (int[]) indices.clone();
- copy.targets = (InstructionHandle[]) targets.clone();
-
- return copy;
- }
-
- /**
- * Inform targets that they're not targeted anymore.
- */
- void dispose() {
- super.dispose();
-
- for(int i=0; i < targets.length; i++)
- targets[i].removeTargeter(this);
- }
-
- /**
- * @return array of match indices
- */
- public int[] getMatchs() { return match; }
-
- /**
- * @return array of match target offsets
- */
- public int[] getIndices() { return indices; }
-
- /**
- * @return array of match targets
- */
- public InstructionHandle[] getTargets() { return targets; }
+public abstract class Select extends BranchInstruction implements VariableLengthInstruction,
+ StackProducer {
+
+ protected int[] match; // matches, i.e., case 1: ...
+ protected int[] indices; // target offsets
+ protected InstructionHandle[] targets; // target objects in instruction list
+ protected int fixed_length; // fixed length defined by subclasses
+ protected int match_length; // number of cases
+ protected int padding = 0; // number of pad bytes for alignment
+
+
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ Select() {
+ }
+
+
+ /**
+ * (Match, target) pairs for switch.
+ * `Match' and `targets' must have the same length of course.
+ *
+ * @param match array of matching values
+ * @param targets instruction targets
+ * @param defaultTarget default instruction target
+ */
+ Select(short opcode, int[] match, InstructionHandle[] targets, InstructionHandle defaultTarget) {
+ super(opcode, defaultTarget);
+ this.targets = targets;
+ for (int i = 0; i < targets.length; i++) {
+ notifyTarget(null, targets[i], this);
+ }
+ this.match = match;
+ if ((match_length = match.length) != targets.length) {
+ throw new ClassGenException("Match and target array have not the same length");
+ }
+ indices = new int[match_length];
+ }
+
+
+ /**
+ * Since this is a variable length instruction, it may shift the following
+ * instructions which then need to update their position.
+ *
+ * Called by InstructionList.setPositions when setting the position for every
+ * instruction. In the presence of variable length instructions `setPositions'
+ * performs multiple passes over the instruction list to calculate the
+ * correct (byte) positions and offsets by calling this function.
+ *
+ * @param offset additional offset caused by preceding (variable length) instructions
+ * @param max_offset the maximum offset that may be caused by these instructions
+ * @return additional offset caused by possible change of this instruction's length
+ */
+ protected int updatePosition( int offset, int max_offset ) {
+ position += offset; // Additional offset caused by preceding SWITCHs, GOTOs, etc.
+ short old_length = length;
+ /* Alignment on 4-byte-boundary, + 1, because of tag byte.
+ */
+ padding = (4 - ((position + 1) % 4)) % 4;
+ length = (short) (fixed_length + padding); // Update length
+ return length - old_length;
+ }
+
+
+ /**
+ * Dump instruction as byte code to stream out.
+ * @param out Output stream
+ */
+ public void dump( DataOutputStream out ) throws IOException {
+ out.writeByte(opcode);
+ for (int i = 0; i < padding; i++) {
+ out.writeByte(0);
+ }
+ index = getTargetOffset(); // Write default target offset
+ out.writeInt(index);
+ }
+
+
+ /**
+ * Read needed data (e.g. index) from file.
+ */
+ protected void initFromFile( ByteSequence bytes, boolean wide ) throws IOException {
+ padding = (4 - (bytes.getIndex() % 4)) % 4; // Compute number of pad bytes
+ for (int i = 0; i < padding; i++) {
+ bytes.readByte();
+ }
+ // Default branch target common for both cases (TABLESWITCH, LOOKUPSWITCH)
+ index = bytes.readInt();
+ }
+
+
+ /**
+ * @return mnemonic for instruction
+ */
+ public String toString( boolean verbose ) {
+ StringBuffer buf = new StringBuffer(super.toString(verbose));
+ if (verbose) {
+ for (int i = 0; i < match_length; i++) {
+ String s = "null";
+ if (targets[i] != null) {
+ s = targets[i].getInstruction().toString();
+ }
+ buf.append("(").append(match[i]).append(", ").append(s).append(" = {").append(
+ indices[i]).append("})");
+ }
+ } else {
+ buf.append(" ...");
+ }
+ return buf.toString();
+ }
+
+
+ /**
+ * Set branch target for `i'th case
+ */
+ public void setTarget( int i, InstructionHandle target ) {
+ notifyTarget(targets[i], target, this);
+ targets[i] = target;
+ }
+
+
+ /**
+ * @param old_ih old target
+ * @param new_ih new target
+ */
+ public void updateTarget( InstructionHandle old_ih, InstructionHandle new_ih ) {
+ boolean targeted = false;
+ if (target == old_ih) {
+ targeted = true;
+ setTarget(new_ih);
+ }
+ for (int i = 0; i < targets.length; i++) {
+ if (targets[i] == old_ih) {
+ targeted = true;
+ setTarget(i, new_ih);
+ }
+ }
+ if (!targeted) {
+ throw new ClassGenException("Not targeting " + old_ih);
+ }
+ }
+
+
+ /**
+ * @return true, if ih is target of this instruction
+ */
+ public boolean containsTarget( InstructionHandle ih ) {
+ if (target == ih) {
+ return true;
+ }
+ for (int i = 0; i < targets.length; i++) {
+ if (targets[i] == ih) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ protected Object clone() throws CloneNotSupportedException {
+ Select copy = (Select) super.clone();
+ copy.match = (int[]) match.clone();
+ copy.indices = (int[]) indices.clone();
+ copy.targets = (InstructionHandle[]) targets.clone();
+ return copy;
+ }
+
+
+ /**
+ * Inform targets that they're not targeted anymore.
+ */
+ void dispose() {
+ super.dispose();
+ for (int i = 0; i < targets.length; i++) {
+ targets[i].removeTargeter(this);
+ }
+ }
+
+
+ /**
+ * @return array of match indices
+ */
+ public int[] getMatchs() {
+ return match;
+ }
+
+
+ /**
+ * @return array of match target offsets
+ */
+ public int[] getIndices() {
+ return indices;
+ }
+
+
+ /**
+ * @return array of match targets
+ */
+ public InstructionHandle[] getTargets() {
+ return targets;
+ }
}
Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/generic/StackConsumer.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/generic/StackConsumer.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/generic/StackConsumer.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/generic/StackConsumer.java Wed Mar 15 03:31:56 2006
@@ -13,10 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
- */
+ */
package org.apache.bcel.generic;
-
/**
* Denote an instruction that may consume a value from the stack.
*
@@ -24,8 +23,8 @@
* @author <A HREF="mailto:[email protected]">M. Dahm</A>
*/
public interface StackConsumer {
- /** @return how many words are consumed from stack
- */
- public int consumeStack(ConstantPoolGen cpg);
-}
+ /** @return how many words are consumed from stack
+ */
+ public int consumeStack( ConstantPoolGen cpg );
+}
Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/generic/StackInstruction.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/generic/StackInstruction.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/generic/StackInstruction.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/generic/StackInstruction.java Wed Mar 15 03:31:56 2006
@@ -13,10 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
- */
+ */
package org.apache.bcel.generic;
-
/**
* Super class for stack operations like DUP and POP.
*
@@ -24,23 +23,26 @@
* @author <A HREF="mailto:[email protected]">M. Dahm</A>
*/
public abstract class StackInstruction extends Instruction {
- /**
- * Empty constructor needed for the Class.newInstance() statement in
- * Instruction.readInstruction(). Not to be used otherwise.
- */
- StackInstruction() {}
-
- /**
- * @param opcode instruction opcode
- */
- protected StackInstruction(short opcode) {
- super(opcode, (short)1);
- }
-
- /** @return Type.UNKNOWN
- */
- public Type getType(ConstantPoolGen cp) {
- return Type.UNKNOWN;
- }
-}
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ StackInstruction() {
+ }
+
+
+ /**
+ * @param opcode instruction opcode
+ */
+ protected StackInstruction(short opcode) {
+ super(opcode, (short) 1);
+ }
+
+
+ /** @return Type.UNKNOWN
+ */
+ public Type getType( ConstantPoolGen cp ) {
+ return Type.UNKNOWN;
+ }
+}
Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/generic/StackProducer.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/generic/StackProducer.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/generic/StackProducer.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/generic/StackProducer.java Wed Mar 15 03:31:56 2006
@@ -13,10 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
- */
+ */
package org.apache.bcel.generic;
-
/**
* Denote an instruction that may produce a value on top of the stack
* (this excludes DUP_X1, e.g.)
@@ -25,8 +24,8 @@
* @author <A HREF="mailto:[email protected]">M. Dahm</A>
*/
public interface StackProducer {
- /** @return how many words are produced on stack
- */
- public int produceStack(ConstantPoolGen cpg);
-}
+ /** @return how many words are produced on stack
+ */
+ public int produceStack( ConstantPoolGen cpg );
+}
Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/generic/StoreInstruction.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/generic/StoreInstruction.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/generic/StoreInstruction.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/generic/StoreInstruction.java Wed Mar 15 03:31:56 2006
@@ -13,10 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
- */
+ */
package org.apache.bcel.generic;
-
/**
* Denotes an unparameterized instruction to store a value into a local variable,
* e.g. ISTORE.
@@ -24,41 +23,41 @@
* @version $Id$
* @author <A HREF="mailto:[email protected]">M. Dahm</A>
*/
-public abstract class StoreInstruction extends LocalVariableInstruction
- implements PopInstruction
-{
- /**
- * Empty constructor needed for the Class.newInstance() statement in
- * Instruction.readInstruction(). Not to be used otherwise.
- * tag and length are defined in readInstruction and initFromFile, respectively.
- */
- StoreInstruction(short canon_tag, short c_tag) {
- super(canon_tag, c_tag);
- }
-
- /**
- * @param opcode Instruction opcode
- * @param c_tag Instruction number for compact version, ASTORE_0, e.g.
- * @param n local variable index (unsigned short)
- */
- protected StoreInstruction(short opcode, short c_tag, int n) {
- super(opcode, c_tag, n);
- }
-
- /**
- * Call corresponding visitor method(s). The order is:
- * Call visitor methods of implemented interfaces first, then
- * call methods according to the class hierarchy in descending order,
- * i.e., the most specific visitXXX() call comes last.
- *
- * @param v Visitor object
- */
- public void accept(Visitor v) {
- v.visitStackConsumer(this);
- v.visitPopInstruction(this);
- v.visitTypedInstruction(this);
- v.visitLocalVariableInstruction(this);
- v.visitStoreInstruction(this);
- }
-}
+public abstract class StoreInstruction extends LocalVariableInstruction implements PopInstruction {
+
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ * tag and length are defined in readInstruction and initFromFile, respectively.
+ */
+ StoreInstruction(short canon_tag, short c_tag) {
+ super(canon_tag, c_tag);
+ }
+
+ /**
+ * @param opcode Instruction opcode
+ * @param c_tag Instruction number for compact version, ASTORE_0, e.g.
+ * @param n local variable index (unsigned short)
+ */
+ protected StoreInstruction(short opcode, short c_tag, int n) {
+ super(opcode, c_tag, n);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept( Visitor v ) {
+ v.visitStackConsumer(this);
+ v.visitPopInstruction(this);
+ v.visitTypedInstruction(this);
+ v.visitLocalVariableInstruction(this);
+ v.visitStoreInstruction(this);
+ }
+}
Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/generic/TABLESWITCH.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/generic/TABLESWITCH.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/generic/TABLESWITCH.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/generic/TABLESWITCH.java Wed Mar 15 03:31:56 2006
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
- */
+ */
package org.apache.bcel.generic;
import java.io.DataOutputStream;
@@ -28,84 +28,80 @@
* @see SWITCH
*/
public class TABLESWITCH extends Select {
- /**
- * Empty constructor needed for the Class.newInstance() statement in
- * Instruction.readInstruction(). Not to be used otherwise.
- */
- TABLESWITCH() {}
-
- /**
- * @param match sorted array of match values, match[0] must be low value,
- * match[match_length - 1] high value
- * @param targets where to branch for matched values
- * @param defaultTarget default branch
- */
- public TABLESWITCH(int[] match, InstructionHandle[] targets,
- InstructionHandle defaultTarget) {
- super(org.apache.bcel.Constants.TABLESWITCH, match, targets, defaultTarget);
-
- length = (short)(13 + match_length * 4); /* Alignment remainder assumed
- * 0 here, until dump time */
- fixed_length = length;
- }
-
- /**
- * Dump instruction as byte code to stream out.
- * @param out Output stream
- */
- public void dump(DataOutputStream out) throws IOException {
- super.dump(out);
-
- int low = (match_length > 0)? match[0] : 0;
- out.writeInt(low);
-
- int high = (match_length > 0)? match[match_length - 1] : 0;
- out.writeInt(high);
-
- for(int i=0; i < match_length; i++) // jump offsets
- out.writeInt(indices[i] = getTargetOffset(targets[i]));
- }
-
- /**
- * Read needed data (e.g. index) from file.
- */
- protected void initFromFile(ByteSequence bytes, boolean wide) throws IOException
- {
- super.initFromFile(bytes, wide);
-
- int low = bytes.readInt();
- int high = bytes.readInt();
-
- match_length = high - low + 1;
- fixed_length = (short)(13 + match_length * 4);
- length = (short)(fixed_length + padding);
-
- match = new int[match_length];
- indices = new int[match_length];
- targets = new InstructionHandle[match_length];
- for(int i=low; i <= high; i++)
- match[i - low] = i;
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ TABLESWITCH() {
+ }
+
+
+ /**
+ * @param match sorted array of match values, match[0] must be low value,
+ * match[match_length - 1] high value
+ * @param targets where to branch for matched values
+ * @param defaultTarget default branch
+ */
+ public TABLESWITCH(int[] match, InstructionHandle[] targets, InstructionHandle defaultTarget) {
+ super(org.apache.bcel.Constants.TABLESWITCH, match, targets, defaultTarget);
+ length = (short) (13 + match_length * 4); /* Alignment remainder assumed
+ * 0 here, until dump time */
+ fixed_length = length;
+ }
+
- for(int i=0; i < match_length; i++) {
- indices[i] = bytes.readInt();
+ /**
+ * Dump instruction as byte code to stream out.
+ * @param out Output stream
+ */
+ public void dump( DataOutputStream out ) throws IOException {
+ super.dump(out);
+ int low = (match_length > 0) ? match[0] : 0;
+ out.writeInt(low);
+ int high = (match_length > 0) ? match[match_length - 1] : 0;
+ out.writeInt(high);
+ for (int i = 0; i < match_length; i++) {
+ out.writeInt(indices[i] = getTargetOffset(targets[i]));
+ }
}
- }
- /**
- * Call corresponding visitor method(s). The order is:
- * Call visitor methods of implemented interfaces first, then
- * call methods according to the class hierarchy in descending order,
- * i.e., the most specific visitXXX() call comes last.
- *
- * @param v Visitor object
- */
- public void accept(Visitor v) {
- v.visitVariableLengthInstruction(this);
- v.visitStackProducer(this);
- v.visitBranchInstruction(this);
- v.visitSelect(this);
- v.visitTABLESWITCH(this);
- }
+ /**
+ * Read needed data (e.g. index) from file.
+ */
+ protected void initFromFile( ByteSequence bytes, boolean wide ) throws IOException {
+ super.initFromFile(bytes, wide);
+ int low = bytes.readInt();
+ int high = bytes.readInt();
+ match_length = high - low + 1;
+ fixed_length = (short) (13 + match_length * 4);
+ length = (short) (fixed_length + padding);
+ match = new int[match_length];
+ indices = new int[match_length];
+ targets = new InstructionHandle[match_length];
+ for (int i = low; i <= high; i++) {
+ match[i - low] = i;
+ }
+ for (int i = 0; i < match_length; i++) {
+ indices[i] = bytes.readInt();
+ }
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept( Visitor v ) {
+ v.visitVariableLengthInstruction(this);
+ v.visitStackProducer(this);
+ v.visitBranchInstruction(this);
+ v.visitSelect(this);
+ v.visitTABLESWITCH(this);
+ }
}
Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/generic/TargetLostException.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/generic/TargetLostException.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/generic/TargetLostException.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/generic/TargetLostException.java Wed Mar 15 03:31:56 2006
@@ -13,10 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
- */
+ */
package org.apache.bcel.generic;
-
/**
* Thrown by InstructionList.remove() when one or multiple disposed instruction
* are still being referenced by a InstructionTargeter object. I.e. the
@@ -49,15 +48,20 @@
* @author <A HREF="mailto:[email protected]">M. Dahm</A>
*/
public final class TargetLostException extends Exception {
- private InstructionHandle[] targets;
- TargetLostException(InstructionHandle[] t, String mesg) {
- super(mesg);
- targets = t;
- }
-
- /**
- * @return list of instructions still being targeted.
- */
- public InstructionHandle[] getTargets() { return targets; }
+ private InstructionHandle[] targets;
+
+
+ TargetLostException(InstructionHandle[] t, String mesg) {
+ super(mesg);
+ targets = t;
+ }
+
+
+ /**
+ * @return list of instructions still being targeted.
+ */
+ public InstructionHandle[] getTargets() {
+ return targets;
+ }
}
Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/generic/Type.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/generic/Type.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/generic/Type.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/generic/Type.java Wed Mar 15 03:31:56 2006
@@ -13,10 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
- */
+ */
package org.apache.bcel.generic;
-
import java.util.ArrayList;
import java.util.List;
import org.apache.bcel.Constants;
@@ -32,254 +31,260 @@
*/
public abstract class Type implements java.io.Serializable {
- protected byte type;
- protected String signature; // signature for the type
+ protected byte type;
+ protected String signature; // signature for the type
+ /** Predefined constants
+ */
+ public static final BasicType VOID = new BasicType(Constants.T_VOID);
+ public static final BasicType BOOLEAN = new BasicType(Constants.T_BOOLEAN);
+ public static final BasicType INT = new BasicType(Constants.T_INT);
+ public static final BasicType SHORT = new BasicType(Constants.T_SHORT);
+ public static final BasicType BYTE = new BasicType(Constants.T_BYTE);
+ public static final BasicType LONG = new BasicType(Constants.T_LONG);
+ public static final BasicType DOUBLE = new BasicType(Constants.T_DOUBLE);
+ public static final BasicType FLOAT = new BasicType(Constants.T_FLOAT);
+ public static final BasicType CHAR = new BasicType(Constants.T_CHAR);
+ public static final ObjectType OBJECT = new ObjectType("java.lang.Object");
+ public static final ObjectType CLASS = new ObjectType("java.lang.Class");
+ public static final ObjectType STRING = new ObjectType("java.lang.String");
+ public static final ObjectType STRINGBUFFER = new ObjectType("java.lang.StringBuffer");
+ public static final ObjectType THROWABLE = new ObjectType("java.lang.Throwable");
+ public static final Type[] NO_ARGS = new Type[0];
+ public static final ReferenceType NULL = new ReferenceType() {
+ };
+ public static final Type UNKNOWN = new Type(Constants.T_UNKNOWN, "<unknown object>") {
+ };
+
+
+ protected Type(byte t, String s) {
+ type = t;
+ signature = s;
+ }
+
+
+ /**
+ * @return signature for given type.
+ */
+ public String getSignature() {
+ return signature;
+ }
- /** Predefined constants
- */
- public static final BasicType VOID = new BasicType(Constants.T_VOID);
- public static final BasicType BOOLEAN = new BasicType(Constants.T_BOOLEAN);
- public static final BasicType INT = new BasicType(Constants.T_INT);
- public static final BasicType SHORT = new BasicType(Constants.T_SHORT);
- public static final BasicType BYTE = new BasicType(Constants.T_BYTE);
- public static final BasicType LONG = new BasicType(Constants.T_LONG);
- public static final BasicType DOUBLE = new BasicType(Constants.T_DOUBLE);
- public static final BasicType FLOAT = new BasicType(Constants.T_FLOAT);
- public static final BasicType CHAR = new BasicType(Constants.T_CHAR);
- public static final ObjectType OBJECT = new ObjectType("java.lang.Object");
- public static final ObjectType CLASS = new ObjectType("java.lang.Class");
- public static final ObjectType STRING = new ObjectType("java.lang.String");
- public static final ObjectType STRINGBUFFER = new ObjectType("java.lang.StringBuffer");
- public static final ObjectType THROWABLE = new ObjectType("java.lang.Throwable");
- public static final Type[] NO_ARGS = new Type[0];
- public static final ReferenceType NULL = new ReferenceType(){};
- public static final Type UNKNOWN = new Type(Constants.T_UNKNOWN,
- "<unknown object>"){};
-
- protected Type(byte t, String s) {
- type = t;
- signature = s;
- }
-
- /**
- * @return signature for given type.
- */
- public String getSignature() { return signature; }
-
- /**
- * @return type as defined in Constants
- */
- public byte getType() { return type; }
-
- /**
- * @return stack size of this type (2 for long and double, 0 for void, 1 otherwise)
- */
- public int getSize() {
- switch(type) {
- case Constants.T_DOUBLE:
- case Constants.T_LONG: return 2;
- case Constants.T_VOID: return 0;
- default: return 1;
- }
- }
-
- /**
- * @return Type string, e.g. `int[]'
- */
- public String toString() {
- return ((this.equals(Type.NULL) || (type >= Constants.T_UNKNOWN)))? signature :
- Utility.signatureToString(signature, false);
- }
-
- /**
- * Convert type to Java method signature, e.g. int[] f(java.lang.String x)
- * becomes (Ljava/lang/String;)[I
- *
- * @param return_type what the method returns
- * @param arg_types what are the argument types
- * @return method signature for given type(s).
- */
- public static String getMethodSignature(Type return_type, Type[] arg_types) {
- StringBuffer buf = new StringBuffer("(");
- int length = (arg_types == null)? 0 : arg_types.length;
- for(int i=0; i < length; i++)
- buf.append(arg_types[i].getSignature());
+ /**
+ * @return type as defined in Constants
+ */
+ public byte getType() {
+ return type;
+ }
- buf.append(')');
- buf.append(return_type.getSignature());
- return buf.toString();
- }
+ /**
+ * @return stack size of this type (2 for long and double, 0 for void, 1 otherwise)
+ */
+ public int getSize() {
+ switch (type) {
+ case Constants.T_DOUBLE:
+ case Constants.T_LONG:
+ return 2;
+ case Constants.T_VOID:
+ return 0;
+ default:
+ return 1;
+ }
+ }
+
+
+ /**
+ * @return Type string, e.g. `int[]'
+ */
+ public String toString() {
+ return ((this.equals(Type.NULL) || (type >= Constants.T_UNKNOWN))) ? signature : Utility
+ .signatureToString(signature, false);
+ }
+
+
+ /**
+ * Convert type to Java method signature, e.g. int[] f(java.lang.String x)
+ * becomes (Ljava/lang/String;)[I
+ *
+ * @param return_type what the method returns
+ * @param arg_types what are the argument types
+ * @return method signature for given type(s).
+ */
+ public static String getMethodSignature( Type return_type, Type[] arg_types ) {
+ StringBuffer buf = new StringBuffer("(");
+ int length = (arg_types == null) ? 0 : arg_types.length;
+ for (int i = 0; i < length; i++) {
+ buf.append(arg_types[i].getSignature());
+ }
+ buf.append(')');
+ buf.append(return_type.getSignature());
+ return buf.toString();
+ }
private static ThreadLocal consumed_chars = new ThreadLocal() {
- protected Object initialValue() {
- return new Integer(0);
- }
+
+ protected Object initialValue() {
+ return new Integer(0);
+ }
};//int consumed_chars=0; // Remember position in string, see getArgumentTypes
- private static int unwrap(ThreadLocal tl) {
- return ((Integer)tl.get()).intValue();
+
+ private static int unwrap( ThreadLocal tl ) {
+ return ((Integer) tl.get()).intValue();
}
- private static void wrap(ThreadLocal tl, int value) {
+
+ private static void wrap( ThreadLocal tl, int value ) {
tl.set(new Integer(value));
}
- /**
- * Convert signature to a Type object.
- * @param signature signature string such as Ljava/lang/String;
- * @return type object
- */
- public static final Type getType(String signature)
- throws StringIndexOutOfBoundsException
- {
- byte type = Utility.typeOfSignature(signature);
-
- if(type <= Constants.T_VOID) {
- //corrected concurrent private static field acess
- wrap(consumed_chars, 1);
- return BasicType.getType(type);
- } else if(type == Constants.T_ARRAY) {
- int dim=0;
- do { // Count dimensions
- dim++;
- } while(signature.charAt(dim) == '[');
-
- // Recurse, but just once, if the signature is ok
- Type t = getType(signature.substring(dim));
-
- //corrected concurrent private static field acess
- // consumed_chars += dim; // update counter - is replaced by
- int _temp = unwrap(consumed_chars) + dim;
- wrap(consumed_chars, _temp);
-
- return new ArrayType(t, dim);
- } else { // type == T_REFERENCE
- int index = signature.indexOf(';'); // Look for closing `;'
-
- if(index < 0)
- throw new ClassFormatException("Invalid signature: " + signature);
-
- //corrected concurrent private static field acess
- wrap(consumed_chars, index + 1); // "Lblabla;" `L' and `;' are removed
-
- return new ObjectType(signature.substring(1, index).replace('/', '.'));
- }
- }
-
- /**
- * Convert return value of a method (signature) to a Type object.
- *
- * @param signature signature string such as (Ljava/lang/String;)V
- * @return return type
- */
- public static Type getReturnType(String signature) {
- try {
- // Read return type after `)'
- int index = signature.lastIndexOf(')') + 1;
- return getType(signature.substring(index));
- } catch(StringIndexOutOfBoundsException e) { // Should never occur
- throw new ClassFormatException("Invalid method signature: " + signature);
- }
- }
-
- /**
- * Convert arguments of a method (signature) to an array of Type objects.
- * @param signature signature string such as (Ljava/lang/String;)V
- * @return array of argument types
- */
- public static Type[] getArgumentTypes(String signature) {
- List vec = new ArrayList();
- int index;
- Type[] types;
-
- try { // Read all declarations between for `(' and `)'
- if(signature.charAt(0) != '(')
- throw new ClassFormatException("Invalid method signature: " + signature);
-
- index = 1; // current string position
-
- while(signature.charAt(index) != ')') {
- vec.add(getType(signature.substring(index)));
- //corrected concurrent private static field acess
- index += unwrap(consumed_chars); // update position
- }
- } catch(StringIndexOutOfBoundsException e) { // Should never occur
- throw new ClassFormatException("Invalid method signature: " + signature);
- }
-
- types = new Type[vec.size()];
- vec.toArray(types);
- return types;
- }
-
- /** Convert runtime java.lang.Class to BCEL Type object.
- * @param cl Java class
- * @return corresponding Type object
- */
- public static Type getType(java.lang.Class cl) {
- if(cl == null) {
- throw new IllegalArgumentException("Class must not be null");
- }
-
- /* That's an amzingly easy case, because getName() returns
- * the signature. That's what we would have liked anyway.
- */
- if(cl.isArray()) {
- return getType(cl.getName());
- } else if(cl.isPrimitive()) {
- if(cl == Integer.TYPE) {
- return INT;
- } else if(cl == Void.TYPE) {
- return VOID;
- } else if(cl == Double.TYPE) {
- return DOUBLE;
- } else if(cl == Float.TYPE) {
- return FLOAT;
- } else if(cl == Boolean.TYPE) {
- return BOOLEAN;
- } else if(cl == Byte.TYPE) {
- return BYTE;
- } else if(cl == Short.TYPE) {
- return SHORT;
- } else if(cl == Byte.TYPE) {
- return BYTE;
- } else if(cl == Long.TYPE) {
- return LONG;
- } else if(cl == Character.TYPE) {
- return CHAR;
- } else {
- throw new IllegalStateException("Ooops, what primitive type is " + cl);
- }
- } else { // "Real" class
- return new ObjectType(cl.getName());
- }
- }
-
- /**
- * Convert runtime java.lang.Class[] to BCEL Type objects.
- * @param classes an array of runtime class objects
- * @return array of corresponding Type objects
- */
- public static Type[] getTypes(java.lang.Class[] classes){
- Type[] ret = new Type[classes.length];
- for (int i = 0; i < ret.length; i++) {
- ret[i] = getType(classes[i]);
- }
- return ret;
- }
-
- public static String getSignature(java.lang.reflect.Method meth) {
- StringBuffer sb = new StringBuffer("(");
- Class[] params = meth.getParameterTypes(); // avoid clone
-
- for(int j = 0; j < params.length; j++) {
- sb.append(getType(params[j]).getSignature());
- }
-
- sb.append(")");
- sb.append(getType(meth.getReturnType()).getSignature());
- return sb.toString();
- }
+
+ /**
+ * Convert signature to a Type object.
+ * @param signature signature string such as Ljava/lang/String;
+ * @return type object
+ */
+ public static final Type getType( String signature ) throws StringIndexOutOfBoundsException {
+ byte type = Utility.typeOfSignature(signature);
+ if (type <= Constants.T_VOID) {
+ //corrected concurrent private static field acess
+ wrap(consumed_chars, 1);
+ return BasicType.getType(type);
+ } else if (type == Constants.T_ARRAY) {
+ int dim = 0;
+ do { // Count dimensions
+ dim++;
+ } while (signature.charAt(dim) == '[');
+ // Recurse, but just once, if the signature is ok
+ Type t = getType(signature.substring(dim));
+ //corrected concurrent private static field acess
+ // consumed_chars += dim; // update counter - is replaced by
+ int _temp = unwrap(consumed_chars) + dim;
+ wrap(consumed_chars, _temp);
+ return new ArrayType(t, dim);
+ } else { // type == T_REFERENCE
+ int index = signature.indexOf(';'); // Look for closing `;'
+ if (index < 0) {
+ throw new ClassFormatException("Invalid signature: " + signature);
+ }
+ //corrected concurrent private static field acess
+ wrap(consumed_chars, index + 1); // "Lblabla;" `L' and `;' are removed
+ return new ObjectType(signature.substring(1, index).replace('/', '.'));
+ }
+ }
+
+
+ /**
+ * Convert return value of a method (signature) to a Type object.
+ *
+ * @param signature signature string such as (Ljava/lang/String;)V
+ * @return return type
+ */
+ public static Type getReturnType( String signature ) {
+ try {
+ // Read return type after `)'
+ int index = signature.lastIndexOf(')') + 1;
+ return getType(signature.substring(index));
+ } catch (StringIndexOutOfBoundsException e) { // Should never occur
+ throw new ClassFormatException("Invalid method signature: " + signature);
+ }
+ }
+
+
+ /**
+ * Convert arguments of a method (signature) to an array of Type objects.
+ * @param signature signature string such as (Ljava/lang/String;)V
+ * @return array of argument types
+ */
+ public static Type[] getArgumentTypes( String signature ) {
+ List vec = new ArrayList();
+ int index;
+ Type[] types;
+ try { // Read all declarations between for `(' and `)'
+ if (signature.charAt(0) != '(') {
+ throw new ClassFormatException("Invalid method signature: " + signature);
+ }
+ index = 1; // current string position
+ while (signature.charAt(index) != ')') {
+ vec.add(getType(signature.substring(index)));
+ //corrected concurrent private static field acess
+ index += unwrap(consumed_chars); // update position
+ }
+ } catch (StringIndexOutOfBoundsException e) { // Should never occur
+ throw new ClassFormatException("Invalid method signature: " + signature);
+ }
+ types = new Type[vec.size()];
+ vec.toArray(types);
+ return types;
+ }
+
+
+ /** Convert runtime java.lang.Class to BCEL Type object.
+ * @param cl Java class
+ * @return corresponding Type object
+ */
+ public static Type getType( java.lang.Class cl ) {
+ if (cl == null) {
+ throw new IllegalArgumentException("Class must not be null");
+ }
+ /* That's an amzingly easy case, because getName() returns
+ * the signature. That's what we would have liked anyway.
+ */
+ if (cl.isArray()) {
+ return getType(cl.getName());
+ } else if (cl.isPrimitive()) {
+ if (cl == Integer.TYPE) {
+ return INT;
+ } else if (cl == Void.TYPE) {
+ return VOID;
+ } else if (cl == Double.TYPE) {
+ return DOUBLE;
+ } else if (cl == Float.TYPE) {
+ return FLOAT;
+ } else if (cl == Boolean.TYPE) {
+ return BOOLEAN;
+ } else if (cl == Byte.TYPE) {
+ return BYTE;
+ } else if (cl == Short.TYPE) {
+ return SHORT;
+ } else if (cl == Byte.TYPE) {
+ return BYTE;
+ } else if (cl == Long.TYPE) {
+ return LONG;
+ } else if (cl == Character.TYPE) {
+ return CHAR;
+ } else {
+ throw new IllegalStateException("Ooops, what primitive type is " + cl);
+ }
+ } else { // "Real" class
+ return new ObjectType(cl.getName());
+ }
+ }
+
+
+ /**
+ * Convert runtime java.lang.Class[] to BCEL Type objects.
+ * @param classes an array of runtime class objects
+ * @return array of corresponding Type objects
+ */
+ public static Type[] getTypes( java.lang.Class[] classes ) {
+ Type[] ret = new Type[classes.length];
+ for (int i = 0; i < ret.length; i++) {
+ ret[i] = getType(classes[i]);
+ }
+ return ret;
+ }
+
+
+ public static String getSignature( java.lang.reflect.Method meth ) {
+ StringBuffer sb = new StringBuffer("(");
+ Class[] params = meth.getParameterTypes(); // avoid clone
+ for (int j = 0; j < params.length; j++) {
+ sb.append(getType(params[j]).getSignature());
+ }
+ sb.append(")");
+ sb.append(getType(meth.getReturnType()).getSignature());
+ return sb.toString();
+ }
}
Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/generic/TypedInstruction.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/generic/TypedInstruction.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/generic/TypedInstruction.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/generic/TypedInstruction.java Wed Mar 15 03:31:56 2006
@@ -13,10 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
- */
+ */
package org.apache.bcel.generic;
-
/**
* Get the type associated with an instruction, int for ILOAD, or the type
* of the field of a PUTFIELD instruction, e.g..
@@ -25,6 +24,6 @@
* @author <A HREF="mailto:[email protected]">M. Dahm</A>
*/
public interface TypedInstruction {
- public Type getType(ConstantPoolGen cpg);
-}
+ public Type getType( ConstantPoolGen cpg );
+}
Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/generic/UnconditionalBranch.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/generic/UnconditionalBranch.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/generic/UnconditionalBranch.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/generic/UnconditionalBranch.java Wed Mar 15 03:31:56 2006
@@ -13,10 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
- */
+ */
package org.apache.bcel.generic;
-
/**
* Denotes an instruction to perform an unconditional branch, i.e., GOTO, JSR.
*
@@ -26,5 +25,5 @@
* @see GOTO
* @see JSR
*/
-public interface UnconditionalBranch {}
-
+public interface UnconditionalBranch {
+}
Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/generic/VariableLengthInstruction.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/generic/VariableLengthInstruction.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/generic/VariableLengthInstruction.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/generic/VariableLengthInstruction.java Wed Mar 15 03:31:56 2006
@@ -13,10 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
- */
+ */
package org.apache.bcel.generic;
-
/**
* Denotes an instruction to be a variable length instruction, such as
* GOTO, JSR, LOOKUPSWITCH and TABLESWITCH.
@@ -29,5 +28,5 @@
* @see LOOKUPSWITCH
* @see TABLESWITCH
*/
-public interface VariableLengthInstruction {}
-
+public interface VariableLengthInstruction {
+}
Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/generic/Visitor.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/generic/Visitor.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/generic/Visitor.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/generic/Visitor.java Wed Mar 15 03:31:56 2006
@@ -13,10 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
- */
+ */
package org.apache.bcel.generic;
-
/**
* Interface implementing the Visitor pattern programming style.
* I.e., a class that implements this interface can handle all types of
@@ -27,184 +26,543 @@
* @author <A HREF="mailto:[email protected]">M. Dahm</A>
*/
public interface Visitor {
- public void visitStackInstruction(StackInstruction obj);
- public void visitLocalVariableInstruction(LocalVariableInstruction obj);
- public void visitBranchInstruction(BranchInstruction obj);
- public void visitLoadClass(LoadClass obj);
- public void visitFieldInstruction(FieldInstruction obj);
- public void visitIfInstruction(IfInstruction obj);
- public void visitConversionInstruction(ConversionInstruction obj);
- public void visitPopInstruction(PopInstruction obj);
- public void visitStoreInstruction(StoreInstruction obj);
- public void visitTypedInstruction(TypedInstruction obj);
- public void visitSelect(Select obj);
- public void visitJsrInstruction(JsrInstruction obj);
- public void visitGotoInstruction(GotoInstruction obj);
- public void visitUnconditionalBranch(UnconditionalBranch obj);
- public void visitPushInstruction(PushInstruction obj);
- public void visitArithmeticInstruction(ArithmeticInstruction obj);
- public void visitCPInstruction(CPInstruction obj);
- public void visitInvokeInstruction(InvokeInstruction obj);
- public void visitArrayInstruction(ArrayInstruction obj);
- public void visitAllocationInstruction(AllocationInstruction obj);
- public void visitReturnInstruction(ReturnInstruction obj);
- public void visitFieldOrMethod(FieldOrMethod obj);
- public void visitConstantPushInstruction(ConstantPushInstruction obj);
- public void visitExceptionThrower(ExceptionThrower obj);
- public void visitLoadInstruction(LoadInstruction obj);
- public void visitVariableLengthInstruction(VariableLengthInstruction obj);
- public void visitStackProducer(StackProducer obj);
- public void visitStackConsumer(StackConsumer obj);
- public void visitACONST_NULL(ACONST_NULL obj);
- public void visitGETSTATIC(GETSTATIC obj);
- public void visitIF_ICMPLT(IF_ICMPLT obj);
- public void visitMONITOREXIT(MONITOREXIT obj);
- public void visitIFLT(IFLT obj);
- public void visitLSTORE(LSTORE obj);
- public void visitPOP2(POP2 obj);
- public void visitBASTORE(BASTORE obj);
- public void visitISTORE(ISTORE obj);
- public void visitCHECKCAST(CHECKCAST obj);
- public void visitFCMPG(FCMPG obj);
- public void visitI2F(I2F obj);
- public void visitATHROW(ATHROW obj);
- public void visitDCMPL(DCMPL obj);
- public void visitARRAYLENGTH(ARRAYLENGTH obj);
- public void visitDUP(DUP obj);
- public void visitINVOKESTATIC(INVOKESTATIC obj);
- public void visitLCONST(LCONST obj);
- public void visitDREM(DREM obj);
- public void visitIFGE(IFGE obj);
- public void visitCALOAD(CALOAD obj);
- public void visitLASTORE(LASTORE obj);
- public void visitI2D(I2D obj);
- public void visitDADD(DADD obj);
- public void visitINVOKESPECIAL(INVOKESPECIAL obj);
- public void visitIAND(IAND obj);
- public void visitPUTFIELD(PUTFIELD obj);
- public void visitILOAD(ILOAD obj);
- public void visitDLOAD(DLOAD obj);
- public void visitDCONST(DCONST obj);
- public void visitNEW(NEW obj);
- public void visitIFNULL(IFNULL obj);
- public void visitLSUB(LSUB obj);
- public void visitL2I(L2I obj);
- public void visitISHR(ISHR obj);
- public void visitTABLESWITCH(TABLESWITCH obj);
- public void visitIINC(IINC obj);
- public void visitDRETURN(DRETURN obj);
- public void visitFSTORE(FSTORE obj);
- public void visitDASTORE(DASTORE obj);
- public void visitIALOAD(IALOAD obj);
- public void visitDDIV(DDIV obj);
- public void visitIF_ICMPGE(IF_ICMPGE obj);
- public void visitLAND(LAND obj);
- public void visitIDIV(IDIV obj);
- public void visitLOR(LOR obj);
- public void visitCASTORE(CASTORE obj);
- public void visitFREM(FREM obj);
- public void visitLDC(LDC obj);
- public void visitBIPUSH(BIPUSH obj);
- public void visitDSTORE(DSTORE obj);
- public void visitF2L(F2L obj);
- public void visitFMUL(FMUL obj);
- public void visitLLOAD(LLOAD obj);
- public void visitJSR(JSR obj);
- public void visitFSUB(FSUB obj);
- public void visitSASTORE(SASTORE obj);
- public void visitALOAD(ALOAD obj);
- public void visitDUP2_X2(DUP2_X2 obj);
- public void visitRETURN(RETURN obj);
- public void visitDALOAD(DALOAD obj);
- public void visitSIPUSH(SIPUSH obj);
- public void visitDSUB(DSUB obj);
- public void visitL2F(L2F obj);
- public void visitIF_ICMPGT(IF_ICMPGT obj);
- public void visitF2D(F2D obj);
- public void visitI2L(I2L obj);
- public void visitIF_ACMPNE(IF_ACMPNE obj);
- public void visitPOP(POP obj);
- public void visitI2S(I2S obj);
- public void visitIFEQ(IFEQ obj);
- public void visitSWAP(SWAP obj);
- public void visitIOR(IOR obj);
- public void visitIREM(IREM obj);
- public void visitIASTORE(IASTORE obj);
- public void visitNEWARRAY(NEWARRAY obj);
- public void visitINVOKEINTERFACE(INVOKEINTERFACE obj);
- public void visitINEG(INEG obj);
- public void visitLCMP(LCMP obj);
- public void visitJSR_W(JSR_W obj);
- public void visitMULTIANEWARRAY(MULTIANEWARRAY obj);
- public void visitDUP_X2(DUP_X2 obj);
- public void visitSALOAD(SALOAD obj);
- public void visitIFNONNULL(IFNONNULL obj);
- public void visitDMUL(DMUL obj);
- public void visitIFNE(IFNE obj);
- public void visitIF_ICMPLE(IF_ICMPLE obj);
- public void visitLDC2_W(LDC2_W obj);
- public void visitGETFIELD(GETFIELD obj);
- public void visitLADD(LADD obj);
- public void visitNOP(NOP obj);
- public void visitFALOAD(FALOAD obj);
- public void visitINSTANCEOF(INSTANCEOF obj);
- public void visitIFLE(IFLE obj);
- public void visitLXOR(LXOR obj);
- public void visitLRETURN(LRETURN obj);
- public void visitFCONST(FCONST obj);
- public void visitIUSHR(IUSHR obj);
- public void visitBALOAD(BALOAD obj);
- public void visitDUP2(DUP2 obj);
- public void visitIF_ACMPEQ(IF_ACMPEQ obj);
- public void visitIMPDEP1(IMPDEP1 obj);
- public void visitMONITORENTER(MONITORENTER obj);
- public void visitLSHL(LSHL obj);
- public void visitDCMPG(DCMPG obj);
- public void visitD2L(D2L obj);
- public void visitIMPDEP2(IMPDEP2 obj);
- public void visitL2D(L2D obj);
- public void visitRET(RET obj);
- public void visitIFGT(IFGT obj);
- public void visitIXOR(IXOR obj);
- public void visitINVOKEVIRTUAL(INVOKEVIRTUAL obj);
- public void visitFASTORE(FASTORE obj);
- public void visitIRETURN(IRETURN obj);
- public void visitIF_ICMPNE(IF_ICMPNE obj);
- public void visitFLOAD(FLOAD obj);
- public void visitLDIV(LDIV obj);
- public void visitPUTSTATIC(PUTSTATIC obj);
- public void visitAALOAD(AALOAD obj);
- public void visitD2I(D2I obj);
- public void visitIF_ICMPEQ(IF_ICMPEQ obj);
- public void visitAASTORE(AASTORE obj);
- public void visitARETURN(ARETURN obj);
- public void visitDUP2_X1(DUP2_X1 obj);
- public void visitFNEG(FNEG obj);
- public void visitGOTO_W(GOTO_W obj);
- public void visitD2F(D2F obj);
- public void visitGOTO(GOTO obj);
- public void visitISUB(ISUB obj);
- public void visitF2I(F2I obj);
- public void visitDNEG(DNEG obj);
- public void visitICONST(ICONST obj);
- public void visitFDIV(FDIV obj);
- public void visitI2B(I2B obj);
- public void visitLNEG(LNEG obj);
- public void visitLREM(LREM obj);
- public void visitIMUL(IMUL obj);
- public void visitIADD(IADD obj);
- public void visitLSHR(LSHR obj);
- public void visitLOOKUPSWITCH(LOOKUPSWITCH obj);
- public void visitDUP_X1(DUP_X1 obj);
- public void visitFCMPL(FCMPL obj);
- public void visitI2C(I2C obj);
- public void visitLMUL(LMUL obj);
- public void visitLUSHR(LUSHR obj);
- public void visitISHL(ISHL obj);
- public void visitLALOAD(LALOAD obj);
- public void visitASTORE(ASTORE obj);
- public void visitANEWARRAY(ANEWARRAY obj);
- public void visitFRETURN(FRETURN obj);
- public void visitFADD(FADD obj);
- public void visitBREAKPOINT(BREAKPOINT obj);
+
+ public void visitStackInstruction( StackInstruction obj );
+
+
+ public void visitLocalVariableInstruction( LocalVariableInstruction obj );
+
+
+ public void visitBranchInstruction( BranchInstruction obj );
+
+
+ public void visitLoadClass( LoadClass obj );
+
+
+ public void visitFieldInstruction( FieldInstruction obj );
+
+
+ public void visitIfInstruction( IfInstruction obj );
+
+
+ public void visitConversionInstruction( ConversionInstruction obj );
+
+
+ public void visitPopInstruction( PopInstruction obj );
+
+
+ public void visitStoreInstruction( StoreInstruction obj );
+
+
+ public void visitTypedInstruction( TypedInstruction obj );
+
+
+ public void visitSelect( Select obj );
+
+
+ public void visitJsrInstruction( JsrInstruction obj );
+
+
+ public void visitGotoInstruction( GotoInstruction obj );
+
+
+ public void visitUnconditionalBranch( UnconditionalBranch obj );
+
+
+ public void visitPushInstruction( PushInstruction obj );
+
+
+ public void visitArithmeticInstruction( ArithmeticInstruction obj );
+
+
+ public void visitCPInstruction( CPInstruction obj );
+
+
+ public void visitInvokeInstruction( InvokeInstruction obj );
+
+
+ public void visitArrayInstruction( ArrayInstruction obj );
+
+
+ public void visitAllocationInstruction( AllocationInstruction obj );
+
+
+ public void visitReturnInstruction( ReturnInstruction obj );
+
+
+ public void visitFieldOrMethod( FieldOrMethod obj );
+
+
+ public void visitConstantPushInstruction( ConstantPushInstruction obj );
+
+
+ public void visitExceptionThrower( ExceptionThrower obj );
+
+
+ public void visitLoadInstruction( LoadInstruction obj );
+
+
+ public void visitVariableLengthInstruction( VariableLengthInstruction obj );
+
+
+ public void visitStackProducer( StackProducer obj );
+
+
+ public void visitStackConsumer( StackConsumer obj );
+
+
+ public void visitACONST_NULL( ACONST_NULL obj );
+
+
+ public void visitGETSTATIC( GETSTATIC obj );
+
+
+ public void visitIF_ICMPLT( IF_ICMPLT obj );
+
+
+ public void visitMONITOREXIT( MONITOREXIT obj );
+
+
+ public void visitIFLT( IFLT obj );
+
+
+ public void visitLSTORE( LSTORE obj );
+
+
+ public void visitPOP2( POP2 obj );
+
+
+ public void visitBASTORE( BASTORE obj );
+
+
+ public void visitISTORE( ISTORE obj );
+
+
+ public void visitCHECKCAST( CHECKCAST obj );
+
+
+ public void visitFCMPG( FCMPG obj );
+
+
+ public void visitI2F( I2F obj );
+
+
+ public void visitATHROW( ATHROW obj );
+
+
+ public void visitDCMPL( DCMPL obj );
+
+
+ public void visitARRAYLENGTH( ARRAYLENGTH obj );
+
+
+ public void visitDUP( DUP obj );
+
+
+ public void visitINVOKESTATIC( INVOKESTATIC obj );
+
+
+ public void visitLCONST( LCONST obj );
+
+
+ public void visitDREM( DREM obj );
+
+
+ public void visitIFGE( IFGE obj );
+
+
+ public void visitCALOAD( CALOAD obj );
+
+
+ public void visitLASTORE( LASTORE obj );
+
+
+ public void visitI2D( I2D obj );
+
+
+ public void visitDADD( DADD obj );
+
+
+ public void visitINVOKESPECIAL( INVOKESPECIAL obj );
+
+
+ public void visitIAND( IAND obj );
+
+
+ public void visitPUTFIELD( PUTFIELD obj );
+
+
+ public void visitILOAD( ILOAD obj );
+
+
+ public void visitDLOAD( DLOAD obj );
+
+
+ public void visitDCONST( DCONST obj );
+
+
+ public void visitNEW( NEW obj );
+
+
+ public void visitIFNULL( IFNULL obj );
+
+
+ public void visitLSUB( LSUB obj );
+
+
+ public void visitL2I( L2I obj );
+
+
+ public void visitISHR( ISHR obj );
+
+
+ public void visitTABLESWITCH( TABLESWITCH obj );
+
+
+ public void visitIINC( IINC obj );
+
+
+ public void visitDRETURN( DRETURN obj );
+
+
+ public void visitFSTORE( FSTORE obj );
+
+
+ public void visitDASTORE( DASTORE obj );
+
+
+ public void visitIALOAD( IALOAD obj );
+
+
+ public void visitDDIV( DDIV obj );
+
+
+ public void visitIF_ICMPGE( IF_ICMPGE obj );
+
+
+ public void visitLAND( LAND obj );
+
+
+ public void visitIDIV( IDIV obj );
+
+
+ public void visitLOR( LOR obj );
+
+
+ public void visitCASTORE( CASTORE obj );
+
+
+ public void visitFREM( FREM obj );
+
+
+ public void visitLDC( LDC obj );
+
+
+ public void visitBIPUSH( BIPUSH obj );
+
+
+ public void visitDSTORE( DSTORE obj );
+
+
+ public void visitF2L( F2L obj );
+
+
+ public void visitFMUL( FMUL obj );
+
+
+ public void visitLLOAD( LLOAD obj );
+
+
+ public void visitJSR( JSR obj );
+
+
+ public void visitFSUB( FSUB obj );
+
+
+ public void visitSASTORE( SASTORE obj );
+
+
+ public void visitALOAD( ALOAD obj );
+
+
+ public void visitDUP2_X2( DUP2_X2 obj );
+
+
+ public void visitRETURN( RETURN obj );
+
+
+ public void visitDALOAD( DALOAD obj );
+
+
+ public void visitSIPUSH( SIPUSH obj );
+
+
+ public void visitDSUB( DSUB obj );
+
+
+ public void visitL2F( L2F obj );
+
+
+ public void visitIF_ICMPGT( IF_ICMPGT obj );
+
+
+ public void visitF2D( F2D obj );
+
+
+ public void visitI2L( I2L obj );
+
+
+ public void visitIF_ACMPNE( IF_ACMPNE obj );
+
+
+ public void visitPOP( POP obj );
+
+
+ public void visitI2S( I2S obj );
+
+
+ public void visitIFEQ( IFEQ obj );
+
+
+ public void visitSWAP( SWAP obj );
+
+
+ public void visitIOR( IOR obj );
+
+
+ public void visitIREM( IREM obj );
+
+
+ public void visitIASTORE( IASTORE obj );
+
+
+ public void visitNEWARRAY( NEWARRAY obj );
+
+
+ public void visitINVOKEINTERFACE( INVOKEINTERFACE obj );
+
+
+ public void visitINEG( INEG obj );
+
+
+ public void visitLCMP( LCMP obj );
+
+
+ public void visitJSR_W( JSR_W obj );
+
+
+ public void visitMULTIANEWARRAY( MULTIANEWARRAY obj );
+
+
+ public void visitDUP_X2( DUP_X2 obj );
+
+
+ public void visitSALOAD( SALOAD obj );
+
+
+ public void visitIFNONNULL( IFNONNULL obj );
+
+
+ public void visitDMUL( DMUL obj );
+
+
+ public void visitIFNE( IFNE obj );
+
+
+ public void visitIF_ICMPLE( IF_ICMPLE obj );
+
+
+ public void visitLDC2_W( LDC2_W obj );
+
+
+ public void visitGETFIELD( GETFIELD obj );
+
+
+ public void visitLADD( LADD obj );
+
+
+ public void visitNOP( NOP obj );
+
+
+ public void visitFALOAD( FALOAD obj );
+
+
+ public void visitINSTANCEOF( INSTANCEOF obj );
+
+
+ public void visitIFLE( IFLE obj );
+
+
+ public void visitLXOR( LXOR obj );
+
+
+ public void visitLRETURN( LRETURN obj );
+
+
+ public void visitFCONST( FCONST obj );
+
+
+ public void visitIUSHR( IUSHR obj );
+
+
+ public void visitBALOAD( BALOAD obj );
+
+
+ public void visitDUP2( DUP2 obj );
+
+
+ public void visitIF_ACMPEQ( IF_ACMPEQ obj );
+
+
+ public void visitIMPDEP1( IMPDEP1 obj );
+
+
+ public void visitMONITORENTER( MONITORENTER obj );
+
+
+ public void visitLSHL( LSHL obj );
+
+
+ public void visitDCMPG( DCMPG obj );
+
+
+ public void visitD2L( D2L obj );
+
+
+ public void visitIMPDEP2( IMPDEP2 obj );
+
+
+ public void visitL2D( L2D obj );
+
+
+ public void visitRET( RET obj );
+
+
+ public void visitIFGT( IFGT obj );
+
+
+ public void visitIXOR( IXOR obj );
+
+
+ public void visitINVOKEVIRTUAL( INVOKEVIRTUAL obj );
+
+
+ public void visitFASTORE( FASTORE obj );
+
+
+ public void visitIRETURN( IRETURN obj );
+
+
+ public void visitIF_ICMPNE( IF_ICMPNE obj );
+
+
+ public void visitFLOAD( FLOAD obj );
+
+
+ public void visitLDIV( LDIV obj );
+
+
+ public void visitPUTSTATIC( PUTSTATIC obj );
+
+
+ public void visitAALOAD( AALOAD obj );
+
+
+ public void visitD2I( D2I obj );
+
+
+ public void visitIF_ICMPEQ( IF_ICMPEQ obj );
+
+
+ public void visitAASTORE( AASTORE obj );
+
+
+ public void visitARETURN( ARETURN obj );
+
+
+ public void visitDUP2_X1( DUP2_X1 obj );
+
+
+ public void visitFNEG( FNEG obj );
+
+
+ public void visitGOTO_W( GOTO_W obj );
+
+
+ public void visitD2F( D2F obj );
+
+
+ public void visitGOTO( GOTO obj );
+
+
+ public void visitISUB( ISUB obj );
+
+
+ public void visitF2I( F2I obj );
+
+
+ public void visitDNEG( DNEG obj );
+
+
+ public void visitICONST( ICONST obj );
+
+
+ public void visitFDIV( FDIV obj );
+
+
+ public void visitI2B( I2B obj );
+
+
+ public void visitLNEG( LNEG obj );
+
+
+ public void visitLREM( LREM obj );
+
+
+ public void visitIMUL( IMUL obj );
+
+
+ public void visitIADD( IADD obj );
+
+
+ public void visitLSHR( LSHR obj );
+
+
+ public void visitLOOKUPSWITCH( LOOKUPSWITCH obj );
+
+
+ public void visitDUP_X1( DUP_X1 obj );
+
+
+ public void visitFCMPL( FCMPL obj );
+
+
+ public void visitI2C( I2C obj );
+
+
+ public void visitLMUL( LMUL obj );
+
+
+ public void visitLUSHR( LUSHR obj );
+
+
+ public void visitISHL( ISHL obj );
+
+
+ public void visitLALOAD( LALOAD obj );
+
+
+ public void visitASTORE( ASTORE obj );
+
+
+ public void visitANEWARRAY( ANEWARRAY obj );
+
+
+ public void visitFRETURN( FRETURN obj );
+
+
+ public void visitFADD( FADD obj );
+
+
+ public void visitBREAKPOINT( BREAKPOINT obj );
}
Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/util/AttributeHTML.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/util/AttributeHTML.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/util/AttributeHTML.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/util/AttributeHTML.java Wed Mar 15 03:31:56 2006
@@ -13,10 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
- */
+ */
package org.apache.bcel.util;
-
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
@@ -44,191 +43,169 @@
*
*/
final class AttributeHTML implements org.apache.bcel.Constants {
- private String class_name; // name of current class
- private PrintWriter file; // file to write to
- private int attr_count = 0;
- private ConstantHTML constant_html;
- private ConstantPool constant_pool;
-
- AttributeHTML(String dir, String class_name, ConstantPool constant_pool,
- ConstantHTML constant_html) throws IOException
- {
- this.class_name = class_name;
- this.constant_pool = constant_pool;
- this.constant_html = constant_html;
-
- file = new PrintWriter(new FileOutputStream(dir + class_name + "_attributes.html"));
- file.println("<HTML><BODY BGCOLOR=\"#C0C0C0\"><TABLE BORDER=0>");
- }
-
- private final String codeLink(int link, int method_number) {
- return "<A HREF=\"" + class_name + "_code.html#code" +
- method_number + "@" + link + "\" TARGET=Code>" +
- link + "</A>";
- }
-
- final void close() {
- file.println("</TABLE></BODY></HTML>");
- file.close();
- }
-
- final void writeAttribute(Attribute attribute, String anchor) throws IOException {
- writeAttribute(attribute, anchor, 0);
- }
-
- final void writeAttribute(Attribute attribute, String anchor, int method_number) throws IOException {
- byte tag = attribute.getTag();
- int index;
-
- if(tag == ATTR_UNKNOWN) // Don't know what to do about this one
- return;
-
- attr_count++; // Increment number of attributes found so far
-
- if(attr_count % 2 == 0)
- file.print("<TR BGCOLOR=\"#C0C0C0\"><TD>");
- else
- file.print("<TR BGCOLOR=\"#A0A0A0\"><TD>");
-
- file.println("<H4><A NAME=\"" + anchor + "\">" + attr_count + " " + ATTRIBUTE_NAMES[tag] + "</A></H4>");
-
- /* Handle different attributes
- */
- switch(tag) {
- case ATTR_CODE:
- Code c = (Code)attribute;
-
- // Some directly printable values
- file.print("<UL><LI>Maximum stack size = " + c.getMaxStack() +
- "</LI>\n<LI>Number of local variables = " +
- c.getMaxLocals() + "</LI>\n<LI><A HREF=\"" + class_name +
- "_code.html#method" + method_number + "\" TARGET=Code>Byte code</A></LI></UL>\n");
-
- // Get handled exceptions and list them
- CodeException[] ce = c.getExceptionTable();
- int len = ce.length;
-
- if(len > 0) {
- file.print("<P><B>Exceptions handled</B><UL>");
-
- for(int i=0; i < len; i++) {
- int catch_type = ce[i].getCatchType(); // Index in constant pool
-
- file.print("<LI>");
-
- if(catch_type != 0)
- file.print(constant_html.referenceConstant(catch_type)); // Create Link to _cp.html
- else
- file.print("Any Exception");
-
- file.print("<BR>(Ranging from lines " + codeLink(ce[i].getStartPC(), method_number) +
- " to " + codeLink(ce[i].getEndPC(), method_number) + ", handled at line " +
- codeLink(ce[i].getHandlerPC(), method_number) + ")</LI>");
- }
- file.print("</UL>");
- }
- break;
-
- case ATTR_CONSTANT_VALUE:
- index = ((ConstantValue)attribute).getConstantValueIndex();
-
- // Reference _cp.html
- file.print("<UL><LI><A HREF=\"" + class_name + "_cp.html#cp" + index +
- "\" TARGET=\"ConstantPool\">Constant value index(" + index +")</A></UL>\n");
- break;
-
- case ATTR_SOURCE_FILE:
- index = ((SourceFile)attribute).getSourceFileIndex();
-
- // Reference _cp.html
- file.print("<UL><LI><A HREF=\"" + class_name + "_cp.html#cp" + index +
- "\" TARGET=\"ConstantPool\">Source file index(" + index +")</A></UL>\n");
- break;
-
- case ATTR_EXCEPTIONS:
- // List thrown exceptions
- int[] indices = ((ExceptionTable)attribute).getExceptionIndexTable();
-
- file.print("<UL>");
-
- for(int i=0; i < indices.length; i++)
- file.print("<LI><A HREF=\"" + class_name + "_cp.html#cp" + indices[i] +
- "\" TARGET=\"ConstantPool\">Exception class index(" + indices[i] + ")</A>\n");
-
- file.print("</UL>\n");
- break;
-
- case ATTR_LINE_NUMBER_TABLE:
- LineNumber[] line_numbers =((LineNumberTable)attribute).getLineNumberTable();
-
- // List line number pairs
- file.print("<P>");
-
- for(int i=0; i < line_numbers.length; i++) {
- file.print("(" + line_numbers[i].getStartPC() + ", " + line_numbers[i].getLineNumber() + ")");
-
- if(i < line_numbers.length - 1)
- file.print(", "); // breakable
- }
- break;
-
- case ATTR_LOCAL_VARIABLE_TABLE:
- LocalVariable[] vars = ((LocalVariableTable)attribute).getLocalVariableTable();
-
- // List name, range and type
- file.print("<UL>");
-
- for(int i=0; i < vars.length; i++) {
- index = vars[i].getSignatureIndex();
- String signature = ((ConstantUtf8)constant_pool.getConstant(index, CONSTANT_Utf8)).getBytes();
- signature = Utility.signatureToString(signature, false);
- int start = vars[i].getStartPC();
- int end = (start + vars[i].getLength());
-
- file.println("<LI>" + Class2HTML.referenceType(signature) +
- " <B>" + vars[i].getName() + "</B> in slot %" + vars[i].getIndex() +
- "<BR>Valid from lines " +
- "<A HREF=\"" + class_name + "_code.html#code" + method_number + "@" + start + "\" TARGET=Code>" +
- start + "</A> to " +
- "<A HREF=\"" + class_name + "_code.html#code" + method_number + "@" + end + "\" TARGET=Code>" +
- end + "</A></LI>");
- }
- file.print("</UL>\n");
-
- break;
-
- case ATTR_INNER_CLASSES:
- InnerClass[] classes = ((InnerClasses)attribute).getInnerClasses();
-
- // List inner classes
- file.print("<UL>");
-
- for(int i=0; i < classes.length; i++) {
- String name, access;
-
- index = classes[i].getInnerNameIndex();
- if(index > 0)
- name =((ConstantUtf8)constant_pool.getConstant(index, CONSTANT_Utf8)).getBytes();
- else
- name = "<anonymous>";
-
- access = Utility.accessToString(classes[i].getInnerAccessFlags());
-
- file.print("<LI><FONT COLOR=\"#FF0000\">" + access + "</FONT> "+
- constant_html.referenceConstant(classes[i].getInnerClassIndex()) +
- " in class " +
- constant_html.referenceConstant(classes[i].getOuterClassIndex()) +
- " named " + name + "</LI>\n");
- }
- file.print("</UL>\n");
- break;
+ private String class_name; // name of current class
+ private PrintWriter file; // file to write to
+ private int attr_count = 0;
+ private ConstantHTML constant_html;
+ private ConstantPool constant_pool;
+
+
+ AttributeHTML(String dir, String class_name, ConstantPool constant_pool,
+ ConstantHTML constant_html) throws IOException {
+ this.class_name = class_name;
+ this.constant_pool = constant_pool;
+ this.constant_html = constant_html;
+ file = new PrintWriter(new FileOutputStream(dir + class_name + "_attributes.html"));
+ file.println("<HTML><BODY BGCOLOR=\"#C0C0C0\"><TABLE BORDER=0>");
+ }
+
+
+ private final String codeLink( int link, int method_number ) {
+ return "<A HREF=\"" + class_name + "_code.html#code" + method_number + "@" + link
+ + "\" TARGET=Code>" + link + "</A>";
+ }
+
- default: // Such as Unknown attribute or Deprecated
- file.print("<P>" + attribute.toString());
+ final void close() {
+ file.println("</TABLE></BODY></HTML>");
+ file.close();
}
- file.println("</TD></TR>");
- file.flush();
- }
+
+ final void writeAttribute( Attribute attribute, String anchor ) throws IOException {
+ writeAttribute(attribute, anchor, 0);
+ }
+
+
+ final void writeAttribute( Attribute attribute, String anchor, int method_number )
+ throws IOException {
+ byte tag = attribute.getTag();
+ int index;
+ if (tag == ATTR_UNKNOWN) {
+ return;
+ }
+ attr_count++; // Increment number of attributes found so far
+ if (attr_count % 2 == 0) {
+ file.print("<TR BGCOLOR=\"#C0C0C0\"><TD>");
+ } else {
+ file.print("<TR BGCOLOR=\"#A0A0A0\"><TD>");
+ }
+ file.println("<H4><A NAME=\"" + anchor + "\">" + attr_count + " " + ATTRIBUTE_NAMES[tag]
+ + "</A></H4>");
+ /* Handle different attributes
+ */
+ switch (tag) {
+ case ATTR_CODE:
+ Code c = (Code) attribute;
+ // Some directly printable values
+ file.print("<UL><LI>Maximum stack size = " + c.getMaxStack()
+ + "</LI>\n<LI>Number of local variables = " + c.getMaxLocals()
+ + "</LI>\n<LI><A HREF=\"" + class_name + "_code.html#method"
+ + method_number + "\" TARGET=Code>Byte code</A></LI></UL>\n");
+ // Get handled exceptions and list them
+ CodeException[] ce = c.getExceptionTable();
+ int len = ce.length;
+ if (len > 0) {
+ file.print("<P><B>Exceptions handled</B><UL>");
+ for (int i = 0; i < len; i++) {
+ int catch_type = ce[i].getCatchType(); // Index in constant pool
+ file.print("<LI>");
+ if (catch_type != 0) {
+ file.print(constant_html.referenceConstant(catch_type)); // Create Link to _cp.html
+ } else {
+ file.print("Any Exception");
+ }
+ file.print("<BR>(Ranging from lines "
+ + codeLink(ce[i].getStartPC(), method_number) + " to "
+ + codeLink(ce[i].getEndPC(), method_number) + ", handled at line "
+ + codeLink(ce[i].getHandlerPC(), method_number) + ")</LI>");
+ }
+ file.print("</UL>");
+ }
+ break;
+ case ATTR_CONSTANT_VALUE:
+ index = ((ConstantValue) attribute).getConstantValueIndex();
+ // Reference _cp.html
+ file.print("<UL><LI><A HREF=\"" + class_name + "_cp.html#cp" + index
+ + "\" TARGET=\"ConstantPool\">Constant value index(" + index
+ + ")</A></UL>\n");
+ break;
+ case ATTR_SOURCE_FILE:
+ index = ((SourceFile) attribute).getSourceFileIndex();
+ // Reference _cp.html
+ file.print("<UL><LI><A HREF=\"" + class_name + "_cp.html#cp" + index
+ + "\" TARGET=\"ConstantPool\">Source file index(" + index + ")</A></UL>\n");
+ break;
+ case ATTR_EXCEPTIONS:
+ // List thrown exceptions
+ int[] indices = ((ExceptionTable) attribute).getExceptionIndexTable();
+ file.print("<UL>");
+ for (int i = 0; i < indices.length; i++) {
+ file.print("<LI><A HREF=\"" + class_name + "_cp.html#cp" + indices[i]
+ + "\" TARGET=\"ConstantPool\">Exception class index(" + indices[i]
+ + ")</A>\n");
+ }
+ file.print("</UL>\n");
+ break;
+ case ATTR_LINE_NUMBER_TABLE:
+ LineNumber[] line_numbers = ((LineNumberTable) attribute).getLineNumberTable();
+ // List line number pairs
+ file.print("<P>");
+ for (int i = 0; i < line_numbers.length; i++) {
+ file.print("(" + line_numbers[i].getStartPC() + ", "
+ + line_numbers[i].getLineNumber() + ")");
+ if (i < line_numbers.length - 1) {
+ file.print(", "); // breakable
+ }
+ }
+ break;
+ case ATTR_LOCAL_VARIABLE_TABLE:
+ LocalVariable[] vars = ((LocalVariableTable) attribute).getLocalVariableTable();
+ // List name, range and type
+ file.print("<UL>");
+ for (int i = 0; i < vars.length; i++) {
+ index = vars[i].getSignatureIndex();
+ String signature = ((ConstantUtf8) constant_pool.getConstant(index,
+ CONSTANT_Utf8)).getBytes();
+ signature = Utility.signatureToString(signature, false);
+ int start = vars[i].getStartPC();
+ int end = (start + vars[i].getLength());
+ file.println("<LI>" + Class2HTML.referenceType(signature) + " <B>"
+ + vars[i].getName() + "</B> in slot %" + vars[i].getIndex()
+ + "<BR>Valid from lines " + "<A HREF=\"" + class_name
+ + "_code.html#code" + method_number + "@" + start + "\" TARGET=Code>"
+ + start + "</A> to " + "<A HREF=\"" + class_name + "_code.html#code"
+ + method_number + "@" + end + "\" TARGET=Code>" + end + "</A></LI>");
+ }
+ file.print("</UL>\n");
+ break;
+ case ATTR_INNER_CLASSES:
+ InnerClass[] classes = ((InnerClasses) attribute).getInnerClasses();
+ // List inner classes
+ file.print("<UL>");
+ for (int i = 0; i < classes.length; i++) {
+ String name, access;
+ index = classes[i].getInnerNameIndex();
+ if (index > 0) {
+ name = ((ConstantUtf8) constant_pool.getConstant(index, CONSTANT_Utf8))
+ .getBytes();
+ } else {
+ name = "<anonymous>";
+ }
+ access = Utility.accessToString(classes[i].getInnerAccessFlags());
+ file.print("<LI><FONT COLOR=\"#FF0000\">" + access + "</FONT> "
+ + constant_html.referenceConstant(classes[i].getInnerClassIndex())
+ + " in class "
+ + constant_html.referenceConstant(classes[i].getOuterClassIndex())
+ + " named " + name + "</LI>\n");
+ }
+ file.print("</UL>\n");
+ break;
+ default: // Such as Unknown attribute or Deprecated
+ file.print("<P>" + attribute.toString());
+ }
+ file.println("</TD></TR>");
+ file.flush();
+ }
}
Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/util/BCELComparator.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/util/BCELComparator.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/util/BCELComparator.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/util/BCELComparator.java Wed Mar 15 03:31:56 2006
@@ -7,20 +7,22 @@
* @version $Id$
*/
public interface BCELComparator {
- /**
- * Compare two objects and return what THIS.equals(THAT) should return
- *
- * @param THIS
- * @param THAT
- * @return true if and only if THIS equals THAT
- */
- public boolean equals(Object THIS, Object THAT);
-
- /**
- * Return hashcode for THIS.hashCode()
- *
- * @param THIS
- * @return hashcode for THIS.hashCode()
- */
- public int hashCode(Object THIS);
+
+ /**
+ * Compare two objects and return what THIS.equals(THAT) should return
+ *
+ * @param THIS
+ * @param THAT
+ * @return true if and only if THIS equals THAT
+ */
+ public boolean equals( Object THIS, Object THAT );
+
+
+ /**
+ * Return hashcode for THIS.hashCode()
+ *
+ * @param THIS
+ * @return hashcode for THIS.hashCode()
+ */
+ public int hashCode( Object THIS );
}
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.