diff options
author | aclement <aclement> | 2005-04-19 12:26:04 +0000 |
---|---|---|
committer | aclement <aclement> | 2005-04-19 12:26:04 +0000 |
commit | d8fe1508a6c0a2a13edf32f26b72f11d229facd2 (patch) | |
tree | e023be2fca6ab118778a3606d7e654c09dc3711d /weaver | |
parent | 32c3ac7de17abb9dff859adea6139c096b29ac31 (diff) | |
download | aspectj-d8fe1508a6c0a2a13edf32f26b72f11d229facd2.tar.gz aspectj-d8fe1508a6c0a2a13edf32f26b72f11d229facd2.zip |
from branch: modified parameter code for @AJ
Diffstat (limited to 'weaver')
-rw-r--r-- | weaver/src/org/aspectj/weaver/bcel/BcelAdvice.java | 134 |
1 files changed, 99 insertions, 35 deletions
diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelAdvice.java b/weaver/src/org/aspectj/weaver/bcel/BcelAdvice.java index 948fc536a..813cf8232 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelAdvice.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelAdvice.java @@ -1,13 +1,14 @@ /* ******************************************************************* * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC). - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Common Public License v1.0 - * which accompanies this distribution and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * PARC initial implementation + * All rights reserved. + * This program and the accompanying materials are made available + * under the terms of the Common Public License v1.0 + * which accompanies this distribution and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * PARC initial implementation + * Alexandre Vasseur support for @AJ aspects * ******************************************************************/ @@ -34,6 +35,7 @@ import org.aspectj.weaver.Shadow; import org.aspectj.weaver.TypeX; import org.aspectj.weaver.WeaverMessages; import org.aspectj.weaver.World; +import org.aspectj.weaver.ataspectj.Ajc5MemberMaker; import org.aspectj.weaver.ast.Literal; import org.aspectj.weaver.ast.Test; import org.aspectj.weaver.patterns.ExactTypePattern; @@ -150,6 +152,9 @@ public class BcelAdvice extends Advice { } else if (getKind() == AdviceKind.Around) { if (!canInline(s)) { shadow.weaveAroundClosure(this, hasDynamicTests()); + //FIXME : check Inlining and LTW + //ALEX : uncomment to force inlining for LTW - else inlining does not seems to happen. + //shadow.weaveAroundInline(this, hasDynamicTests()); } else { shadow.weaveAroundInline(this, hasDynamicTests()); } @@ -218,6 +223,22 @@ public class BcelAdvice extends Advice { return thrownExceptions; } + /** + * The munger must not check for the advice exceptions to be declared by the shadow in the case + * of @AJ aspects so that around can throws Throwable + * + * @return + */ + public boolean mustCheckExceptions() { + if (getConcreteAspect() == null) { + //FIXME Alex: not sure this is good to default to that. + // dig when do we reach that ie not yet concretized + return true; + } + return !getConcreteAspect().isAnnotationStyleAspect(); + } + + // only call me after prepare has been called public boolean hasDynamicTests() { @@ -308,38 +329,75 @@ public class BcelAdvice extends Advice { for (int i = 0, len = exposedState.size(); i < len; i++) { if (exposedState.isErroneousVar(i)) continue; // Erroneous vars have already had error msgs reported! BcelVar v = (BcelVar) exposedState.get(i); - if (v == null) continue; - TypeX desiredTy = getSignature().getParameterTypes()[i]; - v.appendLoadAndConvert(il, fact, desiredTy.resolve(world)); - } - - if (getKind() == AdviceKind.Around) { - il.append(closureInstantiation); - } else if (hasExtraParameter()) { - extraVar.appendLoadAndConvert( - il, - fact, - getExtraParameterType().resolve(world)); - } - - // handle thisJoinPoint parameters - // these need to be in that same order as parameters in - // org.aspectj.ajdt.internal.compiler.ast.AdviceDeclaration - if ((getExtraParameterFlags() & ThisJoinPointStaticPart) != 0) { - shadow.getThisJoinPointStaticPartBcelVar().appendLoad(il, fact); - } - - if ((getExtraParameterFlags() & ThisJoinPoint) != 0) { - il.append(shadow.loadThisJoinPoint()); + if (v == null) { + // if not @AJ aspect, go on with the regular binding handling + if (!Ajc5MemberMaker.isAnnotationStyleAspect(getConcreteAspect())) { + continue; + } else { + // ATAJ: for @AJ aspects, handle implicit binding of xxJoinPoint + if (getKind() == AdviceKind.Around) { + il.append(closureInstantiation); + continue; + } else if ("Lorg/aspectj/lang/JoinPoint$StaticPart;".equals(getSignature().getParameterTypes()[i].getSignature())) { + if ((getExtraParameterFlags() & ThisJoinPointStaticPart) != 0) { + shadow.getThisJoinPointStaticPartBcelVar().appendLoad(il, fact); + } + } else if ("Lorg/aspectj/lang/JoinPoint;".equals(getSignature().getParameterTypes()[i].getSignature())) { + if ((getExtraParameterFlags() & ThisJoinPoint) != 0) { + il.append(shadow.loadThisJoinPoint()); + } + } else if ("Lorg/aspectj/lang/JoinPoint$EnclosingStaticPart;".equals(getSignature().getParameterTypes()[i].getSignature())) { + if ((getExtraParameterFlags() & ThisEnclosingJoinPointStaticPart) != 0) { + shadow.getThisEnclosingJoinPointStaticPartBcelVar().appendLoad(il, fact); + } + } else if (hasExtraParameter()) { + extraVar.appendLoadAndConvert( + il, + fact, + getExtraParameterType().resolve(world)); + } else { + //FIXME this code will throw an error if ProceedingJP is used in a before advice f.e. ok ?? + throw new Error("Should not happen - unbound advice argument at index " + i + " in [" + + toString() + "]"); + } + } + } else { + TypeX desiredTy = getSignature().getParameterTypes()[i]; + v.appendLoadAndConvert(il, fact, desiredTy.resolve(world)); + } } + + // ATAJ: for code style aspect, handles the extraFlag as usual ie not + // in the middle of the formal bindings but at the end, in a rock solid ordering + if (!Ajc5MemberMaker.isAnnotationStyleAspect(getConcreteAspect())) { + if (getKind() == AdviceKind.Around) { + il.append(closureInstantiation); + } else if (hasExtraParameter()) { + extraVar.appendLoadAndConvert( + il, + fact, + getExtraParameterType().resolve(world)); + } - if ((getExtraParameterFlags() & ThisEnclosingJoinPointStaticPart) != 0) { - shadow.getThisEnclosingJoinPointStaticPartBcelVar().appendLoad(il, fact); + // handle thisJoinPoint parameters + // these need to be in that same order as parameters in + // org.aspectj.ajdt.internal.compiler.ast.AdviceDeclaration + if ((getExtraParameterFlags() & ThisJoinPointStaticPart) != 0) { + shadow.getThisJoinPointStaticPartBcelVar().appendLoad(il, fact); + } + + if ((getExtraParameterFlags() & ThisJoinPoint) != 0) { + il.append(shadow.loadThisJoinPoint()); + } + + if ((getExtraParameterFlags() & ThisEnclosingJoinPointStaticPart) != 0) { + shadow.getThisEnclosingJoinPointStaticPartBcelVar().appendLoad(il, fact); + } } - - + + return il; } @@ -419,6 +477,12 @@ public class BcelAdvice extends Advice { } public BcelVar[] getExposedStateAsBcelVars() { + // ATAJ aspect + // the closure instantiation has the same mapping as the extracted method from wich it is called + if (getConcreteAspect()!= null && getConcreteAspect().isAnnotationStyleAspect()) { + return BcelVar.NONE; + } + //System.out.println("vars: " + Arrays.asList(exposedState.vars)); if (exposedState == null) return BcelVar.NONE; int len = exposedState.vars.length; |