]> source.dussan.org Git - aspectj.git/commitdiff
from branch: @AJ support
authoraclement <aclement>
Tue, 19 Apr 2005 12:18:30 +0000 (12:18 +0000)
committeraclement <aclement>
Tue, 19 Apr 2005 12:18:30 +0000 (12:18 +0000)
weaver/src/org/aspectj/weaver/patterns/PerSingleton.java

index ead14bef2ae995e8fa7e41718b4b00a6a0ab3a28..169e8396290c958b13ab39c1106368ac55f87a24 100644 (file)
@@ -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 {