harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sjanu...@apache.org
Subject svn commit: r775099 - in /harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200: BcBands.java CpBands.java
Date Fri, 15 May 2009 12:19:00 GMT
Author: sjanuary
Date: Fri May 15 12:19:00 2009
New Revision: 775099

URL: http://svn.apache.org/viewvc?rev=775099&view=rev
Log:
Pack200 - complete implementation of BcBands (take 2)

Modified:
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/BcBands.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CpBands.java

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/BcBands.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/BcBands.java?rev=775099&r1=775098&r2=775099&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/BcBands.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/BcBands.java
Fri May 15 12:19:00 2009
@@ -369,21 +369,21 @@
                 opcode += 24; // change to invokevirtual_this,
                 // invokespecial_this etc.
 
-//                if(name.equals("<init>") && opcode == 207) {
-//                    opcode = 230; // invokespecial_this_init
-//                    bcInitRef.add(cpBands.getCPMethod(owner, name, desc));
-//                } else {
+                if(name.equals("<init>") && opcode == 207) {
+                    opcode = 230; // invokespecial_this_init
+                    bcInitRef.add(cpBands.getCPMethod(owner, name, desc));
+                } else {
                     bcThisMethod.add(cpBands.getCPMethod(owner, name, desc));
-//                }
+                }
             } else if (owner.equals(superClass)) { // TODO
                 opcode += 38; // change to invokevirtual_super,
                 // invokespecial_super etc.
-//                if(name.equals("<init>") && opcode == 221) {
-//                    opcode = 231; // invokespecial_super_init
-//                    bcInitRef.add(cpBands.getCPMethod(owner, name, desc));
-//                } else {
+                if(name.equals("<init>") && opcode == 221) {
+                    opcode = 231; // invokespecial_super_init
+                    bcInitRef.add(cpBands.getCPMethod(owner, name, desc));
+                } else {
                     bcSuperMethod.add(cpBands.getCPMethod(owner, name, desc));
-//                }
+                }
             } else {
                 if (aload_0) {
                     opcode -= 7;
@@ -392,12 +392,12 @@
                     // special rewrite in this
                     // case.
                 }
-//                if(name.equals("<init>") && opcode == 183 && owner.equals(currentNewClass))
{
-//                    opcode = 232; // invokespecial_new_init
-//                    bcInitRef.add(cpBands.getCPMethod(owner, name, desc));
-//                } else {
+                if(name.equals("<init>") && opcode == 183 && owner.equals(currentNewClass))
{
+                    opcode = 232; // invokespecial_new_init
+                    bcInitRef.add(cpBands.getCPMethod(owner, name, desc));
+                } else {
                     bcMethodRef.add(cpBands.getCPMethod(owner, name, desc));
-//                }
+                }
             }
             bcCodes.add(opcode);
             break;

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CpBands.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CpBands.java?rev=775099&r1=775098&r2=775099&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CpBands.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CpBands.java
Fri May 15 12:19:00 2009
@@ -125,7 +125,7 @@
             cpUtf8Prefix[i - 2] = prefix;
             currentStr = currentStr.substring(prefix);
             char[] suffix = currentStr.toCharArray();
-            if (suffix.length > 100) { // big suffix (100 is arbitrary - can we
+            if (suffix.length > 1000) { // big suffix (1000 is arbitrary - can we
                 // do better?)
                 cpUtf8Suffix[i - 1] = 0;
                 bigSuffix.add(new Integer(suffix.length));
@@ -356,6 +356,7 @@
             }
         }
         classNameToIndex.clear();
+        Map classNameToConstructorIndex = new HashMap();
         for (Iterator iterator = cp_Method.iterator(); iterator.hasNext();) {
             CPMethodOrField mOrF = (CPMethodOrField) iterator.next();
             CPClass className = mOrF.getClassName();
@@ -368,6 +369,17 @@
                 mOrF.setIndexInClass(theIndex);
                 classNameToIndex.put(className, new Integer(theIndex + 1));
             }
+            if(mOrF.getDesc().getName().equals("<init>")) {
+                Integer constructorIndex = (Integer) classNameToConstructorIndex.get(className);
+                if (constructorIndex == null) {
+                    classNameToConstructorIndex.put(className, new Integer(1));
+                    mOrF.setIndexInClassForConstructor(0);
+                } else {
+                    int theIndex = constructorIndex.intValue();
+                    mOrF.setIndexInClassForConstructor(theIndex);
+                    classNameToConstructorIndex.put(className, new Integer(theIndex + 1));
+                }
+            }
         }
     }
 
@@ -585,30 +597,4 @@
         return getCPIMethod(getCPClass(owner), name, desc);
     }
 
-    public CPMethodOrField addCPMethod(CPClass cpClass, String name, String desc) {
-        String key = cpClass.toString() + ":" + name + ":" + desc;
-        CPMethodOrField cpM = (CPMethodOrField) stringsToCpMethod
-                .get(key);
-        if (cpM == null) {
-            CPNameAndType nAndT = getCPNameAndType(name, desc);
-            cpM = new CPMethodOrField(cpClass, nAndT);
-            stringsToCpMethod.put(key, cpM);
-            cp_Method.add(cpM);
-        }
-        return cpM;
-    }
-
-    public CPMethodOrField addCPField(CPClass cpClass, String name, String desc) {
-        String key = cpClass.toString() + ":" + name + ":" + desc;
-        CPMethodOrField cpF = (CPMethodOrField) stringsToCpField
-                .get(key);
-        if (cpF == null) {
-            CPNameAndType nAndT = getCPNameAndType(name, desc);
-            cpF = new CPMethodOrField(cpClass, nAndT);
-            stringsToCpField.put(key, cpF);
-            cp_Field.add(cpF);
-        }
-        return cpF;
-    }
-
 }



Mime
View raw message