Pack200 - simplify method calls

git-svn-id: https://svn.apache.org/repos/asf/harmony/enhanced/java/trunk@999306 13f79535-47bb-0310-9956-ffa450edef68
master
Sian January 14 years ago
parent 6ecf018b3c
commit 461988e3c3
  1. 24
      src/main/java/org/apache/harmony/unpack200/NewAttributeBands.java
  2. 34
      src/main/java/org/apache/harmony/unpack200/bytecode/NewAttribute.java

@ -729,30 +729,30 @@ public class NewAttributeBands extends BandSet {
public void addToAttribute(int n, NewAttribute attribute) { public void addToAttribute(int n, NewAttribute attribute) {
if (tag.startsWith("KI")) { // Integer if (tag.startsWith("KI")) { // Integer
attribute.addCPConstant(length, ((CPInteger[]) band)[n]); attribute.addToBody(length, ((CPInteger[]) band)[n]);
} else if (tag.startsWith("KJ")) { // Long } else if (tag.startsWith("KJ")) { // Long
attribute.addCPConstant(length, ((CPLong[]) band)[n]); attribute.addToBody(length, ((CPLong[]) band)[n]);
} else if (tag.startsWith("KF")) { // Float } else if (tag.startsWith("KF")) { // Float
attribute.addCPConstant(length, ((CPFloat[]) band)[n]); attribute.addToBody(length, ((CPFloat[]) band)[n]);
} else if (tag.startsWith("KD")) { // Double } else if (tag.startsWith("KD")) { // Double
attribute.addCPConstant(length, ((CPDouble[]) band)[n]); attribute.addToBody(length, ((CPDouble[]) band)[n]);
} else if (tag.startsWith("KS")) { // String } else if (tag.startsWith("KS")) { // String
attribute.addCPConstant(length, ((CPString[]) band)[n]); attribute.addToBody(length, ((CPString[]) band)[n]);
} else if (tag.startsWith("RC")) { // Class } else if (tag.startsWith("RC")) { // Class
attribute.addCPClass(length, ((CPClass[]) band)[n]); attribute.addToBody(length, ((CPClass[]) band)[n]);
} else if (tag.startsWith("RS")) { // Signature } else if (tag.startsWith("RS")) { // Signature
attribute.addCPUTF8(length, ((CPUTF8[]) band)[n]); attribute.addToBody(length, ((CPUTF8[]) band)[n]);
} else if (tag.startsWith("RD")) { // Descriptor } else if (tag.startsWith("RD")) { // Descriptor
attribute.addCPNameAndType(length, ((CPNameAndType[]) band)[n]); attribute.addToBody(length, ((CPNameAndType[]) band)[n]);
} else if (tag.startsWith("RF")) { // Field Reference } else if (tag.startsWith("RF")) { // Field Reference
attribute.addCPFieldRef(length, ((CPFieldRef[]) band)[n]); attribute.addToBody(length, ((CPFieldRef[]) band)[n]);
} else if (tag.startsWith("RM")) { // Method Reference } else if (tag.startsWith("RM")) { // Method Reference
attribute.addCPMethodRef(length, ((CPMethodRef[]) band)[n]); attribute.addToBody(length, ((CPMethodRef[]) band)[n]);
} else if (tag.startsWith("RI")) { // Interface Method Reference } else if (tag.startsWith("RI")) { // Interface Method Reference
attribute.addCPIMethodRef(length, attribute.addToBody(length,
((CPInterfaceMethodRef[]) band)[n]); ((CPInterfaceMethodRef[]) band)[n]);
} else if (tag.startsWith("RU")) { // UTF8 String } else if (tag.startsWith("RU")) { // UTF8 String
attribute.addCPUTF8(length, ((CPUTF8[]) band)[n]); attribute.addToBody(length, ((CPUTF8[]) band)[n]);
} }
} }

@ -113,39 +113,9 @@ public class NewAttribute extends BCIRenumberedAttribute {
body.add(new BCLength(value)); body.add(new BCLength(value));
} }
public void addCPConstant(int length, CPConstant constant) { public void addToBody(int length, Object value) {
lengths.add(new Integer(length)); lengths.add(new Integer(length));
body.add(constant); body.add(value);
}
public void addCPClass(int length, CPClass class1) {
lengths.add(new Integer(length));
body.add(class1);
}
public void addCPUTF8(int length, CPUTF8 cputf8) {
lengths.add(new Integer(length));
body.add(cputf8);
}
public void addCPNameAndType(int length, CPNameAndType type) {
lengths.add(new Integer(length));
body.add(type);
}
public void addCPFieldRef(int length, CPFieldRef ref) {
lengths.add(new Integer(length));
body.add(ref);
}
public void addCPMethodRef(int length, CPMethodRef ref) {
lengths.add(new Integer(length));
body.add(ref);
}
public void addCPIMethodRef(int length, CPInterfaceMethodRef ref) {
lengths.add(new Integer(length));
body.add(ref);
} }
protected void resolve(ClassConstantPool pool) { protected void resolve(ClassConstantPool pool) {

Loading…
Cancel
Save