diff options
author | jhugunin <jhugunin> | 2003-03-05 21:46:49 +0000 |
---|---|---|
committer | jhugunin <jhugunin> | 2003-03-05 21:46:49 +0000 |
commit | cb775240056309c20aac308be5ab2abd9696be84 (patch) | |
tree | 8fd9d7849d91e868d52048f1cb862d57ba8f5e20 /weaver | |
parent | 769afc68966b6ea101dfebca14c6d67bd426bfa0 (diff) | |
download | aspectj-cb775240056309c20aac308be5ab2abd9696be84.tar.gz aspectj-cb775240056309c20aac308be5ab2abd9696be84.zip |
Bugzilla Bug 33635
Negation of if pointcut does not work
Diffstat (limited to 'weaver')
-rw-r--r-- | weaver/src/org/aspectj/weaver/patterns/IfPointcut.java | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/weaver/src/org/aspectj/weaver/patterns/IfPointcut.java b/weaver/src/org/aspectj/weaver/patterns/IfPointcut.java index 4c4beb1ab..267e5e00c 100644 --- a/weaver/src/org/aspectj/weaver/patterns/IfPointcut.java +++ b/weaver/src/org/aspectj/weaver/patterns/IfPointcut.java @@ -29,6 +29,7 @@ import org.aspectj.weaver.ResolvedPointcutDefinition; import org.aspectj.weaver.ResolvedTypeX; import org.aspectj.weaver.Shadow; import org.aspectj.weaver.ShadowMunger; +import org.aspectj.weaver.ast.*; import org.aspectj.weaver.ast.Expr; import org.aspectj.weaver.ast.Literal; import org.aspectj.weaver.ast.Test; @@ -84,6 +85,9 @@ public class IfPointcut extends Pointcut { return "if(" + testMethod + ")"; } + + //??? The implementation of name binding and type checking in if PCDs is very convoluted + // There has to be a better way... private boolean findingResidue = false; public Test findResidue(Shadow shadow, ExposedState state) { if (findingResidue) return Literal.TRUE; @@ -91,15 +95,21 @@ public class IfPointcut extends Pointcut { try { ExposedState myState = new ExposedState(baseArgsCount); //System.out.println(residueSource); - //??? some of these tests are preconditions for the if to run correctly - // this implementation will duplicate those tests, we should be more careful - Test preTest = residueSource.findResidue(shadow, myState); // might need this + //??? we throw out the test that comes from this walk. All we want here + // is bindings for the arguments + residueSource.findResidue(shadow, myState); //System.out.println(myState); + Test ret = Literal.TRUE; + List args = new ArrayList(); for (int i=0; i < baseArgsCount; i++) { - args.add(myState.get(i)); + Var v = myState.get(i); + args.add(v); + ret = Test.makeAnd(ret, + Test.makeInstanceof(v, + testMethod.getParameterTypes()[i].resolve(shadow.getIWorld()))); } // handle thisJoinPoint parameters @@ -114,8 +124,10 @@ public class IfPointcut extends Pointcut { if ((extraParameterFlags & Advice.ThisEnclosingJoinPointStaticPart) != 0) { args.add(shadow.getThisEnclosingJoinPointStaticPartVar()); } - Test myTest = Test.makeCall(testMethod, (Expr[])args.toArray(new Expr[args.size()])); - return Test.makeAnd(preTest, myTest); + + ret = Test.makeAnd(ret, Test.makeCall(testMethod, (Expr[])args.toArray(new Expr[args.size()]))); + + return ret; } finally { findingResidue = false; |