]> source.dussan.org Git - aspectj.git/commitdiff
around inlining works more often
authorjhugunin <jhugunin>
Tue, 31 Dec 2002 01:56:32 +0000 (01:56 +0000)
committerjhugunin <jhugunin>
Tue, 31 Dec 2002 01:56:32 +0000 (01:56 +0000)
weaver/src/org/aspectj/weaver/bcel/BcelAdvice.java
weaver/src/org/aspectj/weaver/bcel/BcelShadow.java

index 6c9e4055ad181bb00db10c82cd68bf7408542c60..e6ff472eef85b35a0b3c1aa4837d6712c0d54ed1 100644 (file)
@@ -90,6 +90,7 @@ public class BcelAdvice extends Advice {
             shadow.weaveAfter(this);
         } else if (getKind() == AdviceKind.Around) {
             shadow.weaveAroundClosure(this, hasDynamicTests());
+            //shadow.weaveAroundInline(this, hasDynamicTests());
         } else if (getKind() == AdviceKind.InterInitializer) {
                 shadow.weaveAfterReturning(this);
         } else if (getKind().isCflow()) {
index 4f80060e1b74019dd5ef2c3f5f69bc6da598b902..9f4d8d28a9d0a8f9f7e9ea6529861bd96efa047c 100644 (file)
@@ -829,7 +829,8 @@ public class BcelShadow extends Shadow {
        InstructionFactory fact = getFactory();
         int len = getArgCount();
         argVars = new BcelVar[len];
-        int positionOffset = (hasTarget() ? 0 : 1) + (hasThis() ? 0 : 1);
+        int positionOffset = (hasTarget() ? 1 : 0) + 
+                       ((hasThis() && !getKind().isTargetSameAsThis()) ? 1 : 0);
                      
         if (getKind().argsOnStack()) {
             // we move backwards because we're popping off the stack
@@ -838,7 +839,7 @@ public class BcelShadow extends Shadow {
                 BcelVar tmp = genTempVar(type, "ajc$arg" + i);
                 range.insert(tmp.createStore(getFactory()), Range.OutsideBefore);
                 int position = i;
-                if (hasTarget()) position += positionOffset;
+                position += positionOffset;
                 tmp.setPositionInAroundState(position);
                 argVars[i] = tmp;
             }
@@ -852,7 +853,9 @@ public class BcelShadow extends Shadow {
                 range.insert(tmp.createCopyFrom(fact, index), Range.OutsideBefore);
                 argVars[i] = tmp;
                 int position = i;
-                if (hasTarget()) position += positionOffset;
+                position += positionOffset;
+//                System.out.println("set position: " + tmp + ", " + position + " in " + this);
+//                System.out.println("   hasThis: " + hasThis() + ", hasTarget: " + hasTarget());
                 tmp.setPositionInAroundState(position);
                 index += type.getSize();
             }       
@@ -862,6 +865,7 @@ public class BcelShadow extends Shadow {
         initializeArgVars();
         if (hasTarget()) initializeTargetVar();
         if (hasThis()) initializeThisVar();
+//        System.out.println("initialized: " + this + " thisVar = " + thisVar);
     }
 
             
@@ -1225,10 +1229,19 @@ public class BcelShadow extends Shadow {
                List argVarList = new ArrayList();
                
                // start w/ stuff
-               if (targetVar != null) argVarList.add(targetVar);
+               if (thisVar != null) {
+                       argVarList.add(thisVar);
+               }
+               
+        if (targetVar != null && targetVar != thisVar) {
+            argVarList.add(targetVar);
+        }
                for (int i = 0, len = getArgCount(); i < len; i++) {
                        argVarList.add(argVars[i]);
                }
+               if (thisJoinPointVar != null) {
+                       argVarList.add(thisJoinPointVar);
+               }
                
                BcelVar[] adviceVars = munger.getExposedStateAsBcelVars();              
                //??? this is too easy
@@ -1240,16 +1253,25 @@ public class BcelShadow extends Shadow {
 
                IntMap proceedMap =  makeProceedArgumentMap(adviceVars);
 
-//             System.out.println(proceedMap);
-//             System.out.println(Arrays.asList(adviceVars));
+//             System.out.println(proceedMap + " for " + this);
+//             System.out.println(argVarList);
                
                ResolvedTypeX[] proceedParamTypes = world.resolve(munger.getSignature().getParameterTypes());
+               // remove this*JoinPoint* as arguments to proceed
+               if (munger.getBaseParameterCount()+1 < proceedParamTypes.length) {
+                       int len = munger.getBaseParameterCount()+1;
+                       ResolvedTypeX[] newTypes = new ResolvedTypeX[len];
+                       System.arraycopy(proceedParamTypes, 0, newTypes, 0, len);
+                       proceedParamTypes = newTypes;
+               }
                
+               //System.out.println("stateTypes: " + Arrays.asList(stateTypes));
                BcelVar[] proceedVars = 
                        Utility.pushAndReturnArrayOfVars(proceedParamTypes, ret, fact, enclosingMethod);
                
 
                Type[] stateTypes = callbackMethod.getArgumentTypes();
+//             System.out.println("stateTypes: " + Arrays.asList(stateTypes));
                
                for (int i=0, len=stateTypes.length; i < len; i++) {
             Type stateType = stateTypes[i];