From 461988e3c3434e1060e23faa9b8ac212c4db2e25 Mon Sep 17 00:00:00 2001 From: Sian January Date: Tue, 21 Sep 2010 10:47:46 +0000 Subject: [PATCH] Pack200 - simplify method calls git-svn-id: https://svn.apache.org/repos/asf/harmony/enhanced/java/trunk@999306 13f79535-47bb-0310-9956-ffa450edef68 --- .../harmony/unpack200/NewAttributeBands.java | 24 ++++++------- .../unpack200/bytecode/NewAttribute.java | 34 ++----------------- 2 files changed, 14 insertions(+), 44 deletions(-) diff --git a/src/main/java/org/apache/harmony/unpack200/NewAttributeBands.java b/src/main/java/org/apache/harmony/unpack200/NewAttributeBands.java index a72e6e7..0677e49 100644 --- a/src/main/java/org/apache/harmony/unpack200/NewAttributeBands.java +++ b/src/main/java/org/apache/harmony/unpack200/NewAttributeBands.java @@ -729,30 +729,30 @@ public class NewAttributeBands extends BandSet { public void addToAttribute(int n, NewAttribute attribute) { if (tag.startsWith("KI")) { // Integer - attribute.addCPConstant(length, ((CPInteger[]) band)[n]); + attribute.addToBody(length, ((CPInteger[]) band)[n]); } else if (tag.startsWith("KJ")) { // Long - attribute.addCPConstant(length, ((CPLong[]) band)[n]); + attribute.addToBody(length, ((CPLong[]) band)[n]); } else if (tag.startsWith("KF")) { // Float - attribute.addCPConstant(length, ((CPFloat[]) band)[n]); + attribute.addToBody(length, ((CPFloat[]) band)[n]); } else if (tag.startsWith("KD")) { // Double - attribute.addCPConstant(length, ((CPDouble[]) band)[n]); + attribute.addToBody(length, ((CPDouble[]) band)[n]); } else if (tag.startsWith("KS")) { // String - attribute.addCPConstant(length, ((CPString[]) band)[n]); + attribute.addToBody(length, ((CPString[]) band)[n]); } else if (tag.startsWith("RC")) { // Class - attribute.addCPClass(length, ((CPClass[]) band)[n]); + attribute.addToBody(length, ((CPClass[]) band)[n]); } else if (tag.startsWith("RS")) { // Signature - attribute.addCPUTF8(length, ((CPUTF8[]) band)[n]); + attribute.addToBody(length, ((CPUTF8[]) band)[n]); } 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 - attribute.addCPFieldRef(length, ((CPFieldRef[]) band)[n]); + attribute.addToBody(length, ((CPFieldRef[]) band)[n]); } 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 - attribute.addCPIMethodRef(length, + attribute.addToBody(length, ((CPInterfaceMethodRef[]) band)[n]); } else if (tag.startsWith("RU")) { // UTF8 String - attribute.addCPUTF8(length, ((CPUTF8[]) band)[n]); + attribute.addToBody(length, ((CPUTF8[]) band)[n]); } } diff --git a/src/main/java/org/apache/harmony/unpack200/bytecode/NewAttribute.java b/src/main/java/org/apache/harmony/unpack200/bytecode/NewAttribute.java index 2642d61..56842bd 100644 --- a/src/main/java/org/apache/harmony/unpack200/bytecode/NewAttribute.java +++ b/src/main/java/org/apache/harmony/unpack200/bytecode/NewAttribute.java @@ -113,39 +113,9 @@ public class NewAttribute extends BCIRenumberedAttribute { body.add(new BCLength(value)); } - public void addCPConstant(int length, CPConstant constant) { + public void addToBody(int length, Object value) { lengths.add(new Integer(length)); - body.add(constant); - } - - 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); + body.add(value); } protected void resolve(ClassConstantPool pool) {