[jboss-cvs] javassist/src/main/javassist/bytecode ...
Shigeru Chiba
chiba at is.titech.ac.jp
Tue Apr 10 12:32:32 EDT 2007
User: chiba
Date: 07/04/10 12:32:32
Modified: src/main/javassist/bytecode StackMapTable.java
CodeAttribute.java
Log:
stackmap support (cont.)
Revision Changes Path
1.6 +32 -2 javassist/src/main/javassist/bytecode/StackMapTable.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: StackMapTable.java
===================================================================
RCS file: /cvsroot/jboss/javassist/src/main/javassist/bytecode/StackMapTable.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- StackMapTable.java 9 Feb 2007 18:05:21 -0000 1.5
+++ StackMapTable.java 10 Apr 2007 16:32:32 -0000 1.6
@@ -41,7 +41,7 @@
/**
* Constructs a <code>stack_map</code> attribute.
*/
- private StackMapTable(ConstPool cp, byte[] newInfo) {
+ StackMapTable(ConstPool cp, byte[] newInfo) {
super(cp, tag, newInfo);
}
@@ -143,6 +143,9 @@
/**
* Constructs a walker.
+ *
+ * @param smt the StackMapTable that this walker
+ * walks around.
*/
public Walker(StackMapTable smt) {
this(smt.get());
@@ -156,7 +159,7 @@
* It can be obtained by <code>get()</code>
* in the <code>AttributeInfo</code> class.
*/
- Walker(byte[] data) {
+ public Walker(byte[] data) {
info = data;
numOfEntries = ByteArray.readU16bit(data, 0);
}
@@ -448,6 +451,17 @@
}
/**
+ * Constructs and a return a stack map table containing
+ * the written stack map entries.
+ *
+ * @param cp the constant pool used to write
+ * the stack map entries.
+ */
+ public StackMapTable toStackMapTable(ConstPool cp) {
+ return new StackMapTable(cp, toByteArray());
+ }
+
+ /**
* Writes a <code>same_frame</code> or a <code>same_frame_extended</code>.
*/
public void sameFrame(int offsetDelta) {
@@ -559,6 +573,22 @@
}
}
+ /**
+ * Prints the stack table map.
+ */
+ public void println(PrintWriter w) {
+ Printer.print(this, w);
+ }
+
+ /**
+ * Prints the stack table map.
+ *
+ * @param ps a print stream such as <code>System.out</code>.
+ */
+ public void println(java.io.PrintStream ps) {
+ Printer.print(this, new java.io.PrintWriter(ps, true));
+ }
+
static class Printer extends Walker {
private PrintWriter writer;
1.12 +14 -0 javassist/src/main/javassist/bytecode/CodeAttribute.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: CodeAttribute.java
===================================================================
RCS file: /cvsroot/jboss/javassist/src/main/javassist/bytecode/CodeAttribute.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- CodeAttribute.java 11 Jan 2006 06:45:56 -0000 1.11
+++ CodeAttribute.java 10 Apr 2007 16:32:32 -0000 1.12
@@ -293,6 +293,20 @@
}
/**
+ * Adds a stack map table. If another copy of stack map table
+ * is already contained, the old one is removed.
+ *
+ * @param smt the stack map table added to this code attribute.
+ * If it is null, a new stack map is not added.
+ * Only the old stack map is removed.
+ */
+ public void setAttribute(StackMapTable smt) {
+ AttributeInfo.remove(attributes, StackMapTable.tag);
+ if (smt != null)
+ attributes.add(smt);
+ }
+
+ /**
* Copies code.
*/
private byte[] copyCode(ConstPool destCp, Map classnames,
More information about the jboss-cvs-commits
mailing list