aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraclement <aclement>2005-04-19 12:18:30 +0000
committeraclement <aclement>2005-04-19 12:18:30 +0000
commitdf146370298318de22a449472d680c8259fecbc1 (patch)
treebed004b815739ca530fa16016caa4a16a627c132
parente5c3b3a9f777ea7a1f795ae583b3755248863511 (diff)
downloadaspectj-df146370298318de22a449472d680c8259fecbc1.tar.gz
aspectj-df146370298318de22a449472d680c8259fecbc1.zip
from branch: @AJ support
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/PerSingleton.java65
1 files changed, 53 insertions, 12 deletions
diff --git a/weaver/src/org/aspectj/weaver/patterns/PerSingleton.java b/weaver/src/org/aspectj/weaver/patterns/PerSingleton.java
index ead14bef2..169e83962 100644
--- a/weaver/src/org/aspectj/weaver/patterns/PerSingleton.java
+++ b/weaver/src/org/aspectj/weaver/patterns/PerSingleton.java
@@ -26,6 +26,7 @@ import org.aspectj.weaver.VersionedDataInputStream;
import org.aspectj.weaver.ast.Expr;
import org.aspectj.weaver.ast.Literal;
import org.aspectj.weaver.ast.Test;
+import org.aspectj.weaver.ataspectj.Ajc5MemberMaker;
public class PerSingleton extends PerClause {
public PerSingleton() {
@@ -47,23 +48,63 @@ public class PerSingleton extends PerClause {
// this method intentionally left blank
}
- protected Test findResidueInternal(Shadow shadow, ExposedState state) {
- Expr myInstance =
- Expr.makeCallExpr(AjcMemberMaker.perSingletonAspectOfMethod(inAspect),
- Expr.NONE, inAspect);
-
- state.setAspectInstance(myInstance);
-
- // we have no test
- // a NoAspectBoundException will be thrown if we need an instance of this
- // aspect before we are bound
- return Literal.TRUE;
+ public Test findResidueInternal(Shadow shadow, ExposedState state) {
+ // TODO: the commented code is for slow Aspects.aspectOf() style - keep or remove
+ //
+ // Expr myInstance =
+ // Expr.makeCallExpr(AjcMemberMaker.perSingletonAspectOfMethod(inAspect),
+ // Expr.NONE, inAspect);
+ //
+ // state.setAspectInstance(myInstance);
+ //
+ // // we have no test
+ // // a NoAspectBoundException will be thrown if we need an instance of this
+ // // aspect before we are bound
+ // return Literal.TRUE;
+// if (!Ajc5MemberMaker.isSlowAspect(inAspect)) {
+ Expr myInstance =
+ Expr.makeCallExpr(AjcMemberMaker.perSingletonAspectOfMethod(inAspect),
+ Expr.NONE, inAspect);
+
+ state.setAspectInstance(myInstance);
+
+ // we have no test
+ // a NoAspectBoundException will be thrown if we need an instance of this
+ // aspect before we are bound
+ return Literal.TRUE;
+// } else {
+// CallExpr callAspectOf =Expr.makeCallExpr(
+// Ajc5MemberMaker.perSingletonAspectOfMethod(inAspect),
+// new Expr[]{
+// Expr.makeStringConstantExpr(inAspect.getName(), inAspect),
+// //FieldGet is using ResolvedType and I don't need that here
+// new FieldGetOn(Member.ajClassField, shadow.getEnclosingType())
+// },
+// inAspect
+// );
+// Expr castedCallAspectOf = new CastExpr(callAspectOf, inAspect.getName());
+// state.setAspectInstance(castedCallAspectOf);
+// return Literal.TRUE;
+// }
}
public PerClause concretize(ResolvedTypeX inAspect) {
PerSingleton ret = new PerSingleton();
+
+ ret.copyLocationFrom(this);
+
ret.inAspect = inAspect;
- return ret;
+
+ //ATAJ: add a munger to add the aspectOf(..) to the @AJ aspects
+ if (!inAspect.isAbstract() && Ajc5MemberMaker.isAnnotationStyleAspect(inAspect)) {
+ //TODO will those change be ok if we add a serializable aspect ?
+ // dig: "can't be Serializable/Cloneable unless -XserializableAspects"
+ inAspect.crosscuttingMembers.addTypeMunger(
+ inAspect.getWorld().makePerClauseAspect(inAspect, getKind())
+ );
+ }
+
+ return ret;
}
public void write(DataOutputStream s) throws IOException {