summaryrefslogtreecommitdiffstats
path: root/weaver
diff options
context:
space:
mode:
authoracolyer <acolyer>2005-08-11 15:29:35 +0000
committeracolyer <acolyer>2005-08-11 15:29:35 +0000
commitc53371b40761561cc0a70abe3f97926955d302fd (patch)
treebe9582e08c23d5bbe2f7bc461318656124ac85fc /weaver
parentdcd9cf5419b304c1cd3c0646ffa57096272acf86 (diff)
downloadaspectj-c53371b40761561cc0a70abe3f97926955d302fd.tar.gz
aspectj-c53371b40761561cc0a70abe3f97926955d302fd.zip
early "parameterizeWith" support for pointcuts
Diffstat (limited to 'weaver')
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/AndPointcut.java8
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/IfPointcut.java6
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/KindedPointcut.java7
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/NotPointcut.java7
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/OrPointcut.java8
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/Pointcut.java9
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/ReferencePointcut.java24
-rw-r--r--weaver/testsrc/org/aspectj/weaver/patterns/PointcutTestCase.java5
8 files changed, 72 insertions, 2 deletions
diff --git a/weaver/src/org/aspectj/weaver/patterns/AndPointcut.java b/weaver/src/org/aspectj/weaver/patterns/AndPointcut.java
index c046f6be8..ed74f33c8 100644
--- a/weaver/src/org/aspectj/weaver/patterns/AndPointcut.java
+++ b/weaver/src/org/aspectj/weaver/patterns/AndPointcut.java
@@ -17,6 +17,7 @@ import java.io.DataOutputStream;
import java.io.IOException;
import java.lang.reflect.Member;
import java.util.HashSet;
+import java.util.Map;
import java.util.Set;
import org.aspectj.lang.JoinPoint;
@@ -141,6 +142,13 @@ public class AndPointcut extends Pointcut {
ret.copyLocationFrom(this);
return ret;
}
+
+ public Pointcut parameterizeWith(Map typeVariableMap) {
+ AndPointcut ret = new AndPointcut(left.parameterizeWith(typeVariableMap),
+ right.parameterizeWith(typeVariableMap));
+ ret.copyLocationFrom(this);
+ return ret;
+ }
public Pointcut getLeft() {
return left;
diff --git a/weaver/src/org/aspectj/weaver/patterns/IfPointcut.java b/weaver/src/org/aspectj/weaver/patterns/IfPointcut.java
index c0e5abbdf..f641d8f8c 100644
--- a/weaver/src/org/aspectj/weaver/patterns/IfPointcut.java
+++ b/weaver/src/org/aspectj/weaver/patterns/IfPointcut.java
@@ -18,6 +18,7 @@ import java.lang.reflect.Member;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import org.aspectj.bridge.IMessage;
@@ -379,6 +380,11 @@ public class IfPointcut extends Pointcut {
return ret;
}
+ // we can't touch "if" methods
+ public Pointcut parameterizeWith(Map typeVariableMap) {
+ return this;
+ }
+
// public static Pointcut MatchesNothing = new MatchesNothingPointcut();
// ??? there could possibly be some good optimizations to be done at this point
public static IfPointcut makeIfFalsePointcut(State state) {
diff --git a/weaver/src/org/aspectj/weaver/patterns/KindedPointcut.java b/weaver/src/org/aspectj/weaver/patterns/KindedPointcut.java
index 655ed1bbd..c2d6658e4 100644
--- a/weaver/src/org/aspectj/weaver/patterns/KindedPointcut.java
+++ b/weaver/src/org/aspectj/weaver/patterns/KindedPointcut.java
@@ -16,6 +16,7 @@ package org.aspectj.weaver.patterns;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.HashSet;
+import java.util.Map;
import java.util.Set;
import org.aspectj.bridge.ISourceLocation;
@@ -395,6 +396,12 @@ public class KindedPointcut extends Pointcut {
ret.copyLocationFrom(this);
return ret;
}
+
+ public Pointcut parameterizeWith(Map typeVariableMap) {
+ Pointcut ret = new KindedPointcut(kind, signature.parameterizeWith(typeVariableMap), munger );
+ ret.copyLocationFrom(this);
+ return ret;
+ }
public Shadow.Kind getKind() {
return kind;
diff --git a/weaver/src/org/aspectj/weaver/patterns/NotPointcut.java b/weaver/src/org/aspectj/weaver/patterns/NotPointcut.java
index 7687750bf..4c727bd9c 100644
--- a/weaver/src/org/aspectj/weaver/patterns/NotPointcut.java
+++ b/weaver/src/org/aspectj/weaver/patterns/NotPointcut.java
@@ -16,6 +16,7 @@ package org.aspectj.weaver.patterns;
import java.io.DataOutputStream;
import java.io.IOException;
import java.lang.reflect.Member;
+import java.util.Map;
import java.util.Set;
import org.aspectj.lang.JoinPoint;
@@ -136,6 +137,12 @@ public class NotPointcut extends Pointcut {
ret.copyLocationFrom(this);
return ret;
}
+
+ public Pointcut parameterizeWith(Map typeVariableMap) {
+ Pointcut ret = new NotPointcut(body.parameterizeWith(typeVariableMap));
+ ret.copyLocationFrom(this);
+ return ret;
+ }
public Object accept(PatternNodeVisitor visitor, Object data) {
return visitor.visit(this, data);
diff --git a/weaver/src/org/aspectj/weaver/patterns/OrPointcut.java b/weaver/src/org/aspectj/weaver/patterns/OrPointcut.java
index 7801227c3..ad3eec289 100644
--- a/weaver/src/org/aspectj/weaver/patterns/OrPointcut.java
+++ b/weaver/src/org/aspectj/weaver/patterns/OrPointcut.java
@@ -17,6 +17,7 @@ import java.io.DataOutputStream;
import java.io.IOException;
import java.lang.reflect.Member;
import java.util.HashSet;
+import java.util.Map;
import java.util.Set;
import org.aspectj.lang.JoinPoint;
@@ -144,6 +145,13 @@ public class OrPointcut extends Pointcut {
return ret;
}
+ public Pointcut parameterizeWith(Map typeVariableMap) {
+ Pointcut ret = new OrPointcut(left.parameterizeWith(typeVariableMap),
+ right.parameterizeWith(typeVariableMap));
+ ret.copyLocationFrom(this);
+ return ret;
+ }
+
public Pointcut getLeft() {
return left;
}
diff --git a/weaver/src/org/aspectj/weaver/patterns/Pointcut.java b/weaver/src/org/aspectj/weaver/patterns/Pointcut.java
index 2cb14cca3..d752c98ae 100644
--- a/weaver/src/org/aspectj/weaver/patterns/Pointcut.java
+++ b/weaver/src/org/aspectj/weaver/patterns/Pointcut.java
@@ -17,6 +17,7 @@ import java.io.DataOutputStream;
import java.io.IOException;
import java.lang.reflect.Member;
import java.util.Collections;
+import java.util.Map;
import java.util.Set;
import org.aspectj.lang.JoinPoint;
@@ -438,6 +439,10 @@ public abstract class Pointcut extends PatternNode implements PointcutExpression
public Object accept(PatternNodeVisitor visitor, Object data) {
return visitor.visit(this, data);
}
+
+ public Pointcut parameterizeWith(Map typeVariableMap) {
+ return this;
+ }
}
//public static Pointcut MatchesNothing = new MatchesNothingPointcut();
@@ -454,6 +459,10 @@ public abstract class Pointcut extends PatternNode implements PointcutExpression
throw new BCException("expected state: " + state + " got: " + this.state);
}
}
+
+ public Pointcut parameterizeWith(Map typeVariableMap) {
+ throw new UnsupportedOperationException("this method needs to be defined in all subtypes and then made abstract when the work is complete");
+ }
}
diff --git a/weaver/src/org/aspectj/weaver/patterns/ReferencePointcut.java b/weaver/src/org/aspectj/weaver/patterns/ReferencePointcut.java
index f6baf83b8..4e8803626 100644
--- a/weaver/src/org/aspectj/weaver/patterns/ReferencePointcut.java
+++ b/weaver/src/org/aspectj/weaver/patterns/ReferencePointcut.java
@@ -16,6 +16,7 @@ package org.aspectj.weaver.patterns;
import java.io.DataOutputStream;
import java.io.IOException;
import java.lang.reflect.Modifier;
+import java.util.Map;
import java.util.Set;
import org.aspectj.bridge.IMessage;
@@ -43,6 +44,11 @@ public class ReferencePointcut extends Pointcut {
public String name;
public TypePatternList arguments;
+ /**
+ * if this is non-null then when the pointcut is concretized the result will be parameterized too.
+ */
+ private Map typeVariableMap;
+
//public ResolvedPointcut binding;
public ReferencePointcut(TypePattern onTypeSymbolic, String name, TypePatternList arguments) {
@@ -287,7 +293,9 @@ public class ReferencePointcut extends Pointcut {
newBindings.copyContext(bindings);
newBindings.pushEnclosingDefinition(pointcutDec);
try {
- return pointcutDec.getPointcut().concretize(searchStart, newBindings);
+ Pointcut ret = pointcutDec.getPointcut();
+ if (typeVariableMap != null) ret = ret.parameterizeWith(typeVariableMap);
+ return ret.concretize(searchStart, newBindings);
} finally {
newBindings.popEnclosingDefinitition();
}
@@ -296,7 +304,19 @@ public class ReferencePointcut extends Pointcut {
concretizing = false;
}
}
-
+
+ /**
+ * make a version of this pointcut with any refs to typeVariables replaced by their entry in the map.
+ * Tricky thing is, we can't do this at the point in time this method will be called, so we make a
+ * version that will parameterize the pointcut it ultimately resolves to.
+ */
+ public Pointcut parameterizeWith(Map typeVariableMap) {
+ ReferencePointcut ret = new ReferencePointcut(onType,name,arguments);
+ ret.onTypeSymbolic = onTypeSymbolic;
+ ret.typeVariableMap = typeVariableMap;
+ return ret;
+ }
+
// We want to keep the original source location, not the reference location
protected boolean shouldCopyLocationForConcretize() {
return false;
diff --git a/weaver/testsrc/org/aspectj/weaver/patterns/PointcutTestCase.java b/weaver/testsrc/org/aspectj/weaver/patterns/PointcutTestCase.java
index 6c9d19d6b..37c0266c1 100644
--- a/weaver/testsrc/org/aspectj/weaver/patterns/PointcutTestCase.java
+++ b/weaver/testsrc/org/aspectj/weaver/patterns/PointcutTestCase.java
@@ -12,6 +12,7 @@ package org.aspectj.weaver.patterns;
import java.io.DataOutputStream;
import java.io.IOException;
+import java.util.Map;
import java.util.Set;
import org.aspectj.lang.JoinPoint;
@@ -59,6 +60,10 @@ public class PointcutTestCase extends TestCase {
protected Pointcut concretize1(ResolvedType inAspect, IntMap bindings) {
return null;
}
+
+ public Pointcut parameterizeWith(Map typeVariableMap) {
+ return null;
+ }
protected Test findResidueInternal(Shadow shadow, ExposedState state) {
return null;