]> source.dussan.org Git - aspectj.git/commitdiff
optimization: use bit twiddling rather than Sets for manipulating the list of Pointcu...
authoraclement <aclement>
Mon, 13 Feb 2006 15:37:17 +0000 (15:37 +0000)
committeraclement <aclement>
Mon, 13 Feb 2006 15:37:17 +0000 (15:37 +0000)
31 files changed:
weaver/src/org/aspectj/weaver/Shadow.java
weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java
weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java
weaver/src/org/aspectj/weaver/internal/tools/PointcutDesignatorHandlerBasedPointcut.java
weaver/src/org/aspectj/weaver/patterns/AndPointcut.java
weaver/src/org/aspectj/weaver/patterns/AnnotationPointcut.java
weaver/src/org/aspectj/weaver/patterns/ArgsAnnotationPointcut.java
weaver/src/org/aspectj/weaver/patterns/ArgsPointcut.java
weaver/src/org/aspectj/weaver/patterns/CflowPointcut.java
weaver/src/org/aspectj/weaver/patterns/ConcreteCflowPointcut.java
weaver/src/org/aspectj/weaver/patterns/HandlerPointcut.java
weaver/src/org/aspectj/weaver/patterns/IfPointcut.java
weaver/src/org/aspectj/weaver/patterns/KindedPointcut.java
weaver/src/org/aspectj/weaver/patterns/NotPointcut.java
weaver/src/org/aspectj/weaver/patterns/OrPointcut.java
weaver/src/org/aspectj/weaver/patterns/PerCflow.java
weaver/src/org/aspectj/weaver/patterns/PerFromSuper.java
weaver/src/org/aspectj/weaver/patterns/PerObject.java
weaver/src/org/aspectj/weaver/patterns/PerSingleton.java
weaver/src/org/aspectj/weaver/patterns/PerTypeWithin.java
weaver/src/org/aspectj/weaver/patterns/Pointcut.java
weaver/src/org/aspectj/weaver/patterns/PointcutEvaluationExpenseComparator.java
weaver/src/org/aspectj/weaver/patterns/PointcutRewriter.java
weaver/src/org/aspectj/weaver/patterns/ReferencePointcut.java
weaver/src/org/aspectj/weaver/patterns/ThisOrTargetAnnotationPointcut.java
weaver/src/org/aspectj/weaver/patterns/ThisOrTargetPointcut.java
weaver/src/org/aspectj/weaver/patterns/WithinAnnotationPointcut.java
weaver/src/org/aspectj/weaver/patterns/WithinCodeAnnotationPointcut.java
weaver/src/org/aspectj/weaver/patterns/WithinPointcut.java
weaver/src/org/aspectj/weaver/patterns/WithincodePointcut.java
weaver/testsrc/org/aspectj/weaver/patterns/PointcutRewriterTest.java

index ab652b24cfecd9695031e550864045027b8d6f22..2436a6c0e47dacf0bd1cbd644b60ee05af179770 100644 (file)
@@ -16,7 +16,6 @@ package org.aspectj.weaver;
 import java.io.DataInputStream;
 import java.io.IOException;
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
@@ -258,29 +257,55 @@ public abstract class Shadow {
     public static final Kind Initialization       = new Kind(JoinPoint.INITIALIZATION, 10,  false);
     public static final Kind ExceptionHandler     = new Kind(JoinPoint.EXCEPTION_HANDLER, 11,  true);
     
+    // Bits here are 1<<(Kind.getKey()) - and unfortunately keys didn't start at zero so bits here start at 2
+    public static final int MethodCallBit           = 0x002; 
+    public static final int ConstructorCallBit      = 0x004;
+    public static final int MethodExecutionBit      = 0x008;
+    public static final int ConstructorExecutionBit = 0x010;
+    public static final int FieldGetBit             = 0x020;
+    public static final int FieldSetBit             = 0x040;
+    public static final int StaticInitializationBit = 0x080;
+    public static final int PreInitializationBit    = 0x100;
+    public static final int AdviceExecutionBit      = 0x200;
+    public static final int InitializationBit       = 0x400;
+    public static final int ExceptionHandlerBit     = 0x800;
+    
     public static final int MAX_SHADOW_KIND = 11;
     public static final Kind[] SHADOW_KINDS = new Kind[] {
        MethodCall, ConstructorCall, MethodExecution, ConstructorExecution,
        FieldGet, FieldSet, StaticInitialization, PreInitialization,
        AdviceExecution, Initialization, ExceptionHandler,
     };
-
-    public static final Set ALL_SHADOW_KINDS;   
+    
+    public static final int ALL_SHADOW_KINDS_BITS;
+    public static final int NO_SHADOW_KINDS_BITS;
+    
     static {
-       HashSet aSet = new HashSet();
-       for (int i = 0; i < SHADOW_KINDS.length; i++) {
-                       aSet.add(SHADOW_KINDS[i]);
-               }
-       ALL_SHADOW_KINDS = Collections.unmodifiableSet(aSet);
+       ALL_SHADOW_KINDS_BITS = 0xffe;
+       NO_SHADOW_KINDS_BITS  = 0x000;  
     }
+    
+    /**
+     * Return count of how many bits set in the supplied parameter.
+     */
+       public static int howMany(int i) {
+               int count = 0;
+               for (int j = 0; j <SHADOW_KINDS.length; j++) {
+                       if ((i&SHADOW_KINDS[j].bit)!=0) count++;
+               }
+               return count;
+       }
 
     /** A type-safe enum representing the kind of shadows
      */
        public static final class Kind extends TypeSafeEnum {
 //             private boolean argsOnStack;  //XXX unused
 
+               public int bit;
+
                public Kind(String name, int key, boolean argsOnStack) {
                        super(name, key);
+                       bit = 1<<key;
 //                     this.argsOnStack = argsOnStack;
                }
 
@@ -297,55 +322,55 @@ public abstract class Shadow {
                        return true;
                }
                
+               public boolean isSet(int i) {
+                       return (i&bit)!=0;
+               }
+               
                // XXX revisit along with removal of priorities
                public boolean hasHighPriorityExceptions() {
                        return !isTargetSameAsThis();
                }
+
                
+               private final static int hasReturnValueFlag = 
+                       MethodCallBit | ConstructorCallBit | MethodExecutionBit | FieldGetBit | AdviceExecutionBit;
                /**
                 * These shadow kinds have return values that can be bound in
                 * after returning(Dooberry doo) advice.
                 * @return
                 */
                public boolean hasReturnValue() {
-                       return 
-                               this == MethodCall ||
-                               this == ConstructorCall ||
-                               this == MethodExecution ||
-                               this == FieldGet ||
-                               this == AdviceExecution;
+                       return (bit&hasReturnValueFlag)!=0;
                }
                
                
+               private final static int isEnclosingKindFlag = 
+                       MethodExecutionBit | ConstructorExecutionBit | AdviceExecutionBit | StaticInitializationBit | InitializationBit;
                /**
                 * These are all the shadows that contains other shadows within them and
                 * are often directly associated with methods.
                 */
                public boolean isEnclosingKind() {
-                       return this == MethodExecution || this == ConstructorExecution ||
-                                       this == AdviceExecution || this == StaticInitialization
-                                       || this == Initialization;
+                       return (bit&isEnclosingKindFlag)!=0;
                }
                
+               private final static int isTargetSameAsThisFlag =
+                       MethodExecutionBit | ConstructorExecutionBit | StaticInitializationBit | 
+                       PreInitializationBit | AdviceExecutionBit | InitializationBit;
                public boolean isTargetSameAsThis() {
-                       return this == MethodExecution 
-                               || this == ConstructorExecution 
-                               || this == StaticInitialization
-                               || this == PreInitialization
-                               || this == AdviceExecution
-                               || this == Initialization;
+                       return (bit&isTargetSameAsThisFlag)!=0;
                }
                
+               private final static int neverHasTargetFlag=
+                       ConstructorCallBit | ExceptionHandlerBit | PreInitializationBit | StaticInitializationBit;
                public boolean neverHasTarget() {
-                       return this == ConstructorCall
-                               || this == ExceptionHandler
-                               || this == PreInitialization
-                               || this == StaticInitialization;
+                       return (bit&neverHasTargetFlag)!=0;
                }
-               
+
+               private final static int neverHasThisFlag=
+                       PreInitializationBit | StaticInitializationBit;
                public boolean neverHasThis() {
-                       return this == PreInitialization
-                               || this == StaticInitialization;
+                       return (bit&neverHasThisFlag)!=0;
                }
                
                
@@ -645,4 +670,18 @@ public abstract class Shadow {
     public String toResolvedString(World world) {
        return getKind() + "(" + world.resolve(getSignature()).toGenericString() + ")";
     }
+
+    /**
+     * Convert a bit array for the shadow kinds into a set of them... should only 
+     * be used for testing - mainline code should do bit manipulation!
+     */
+       public static Set toSet(int i) {
+               Set results = new HashSet();
+               for (int j = 0; j < Shadow.SHADOW_KINDS.length; j++) {
+                       Kind k = Shadow.SHADOW_KINDS[j];
+                       if (k.isSet(i)) results.add(k);
+               }
+               return results;
+       }
+
 }
index 3e7f7a70df2084a34cdc72eb6ea6e04263e4ae6a..d080ec18fded371fdbf7c20ef2dca79919a84e0c 100644 (file)
@@ -181,12 +181,19 @@ class BcelClassWeaver implements IClassWeaver {
        }
        for (Iterator iter = shadowMungers.iterator(); iter.hasNext();) {
                        ShadowMunger munger = (ShadowMunger) iter.next();
-                       Set couldMatchKinds = munger.getPointcut().couldMatchKinds();
-                       for (Iterator kindIterator = couldMatchKinds.iterator(); 
-                            kindIterator.hasNext();) {
-                               Shadow.Kind aKind = (Shadow.Kind) kindIterator.next();
-                               perKindShadowMungers[aKind.getKey()].add(munger);
+                       
+                       int couldMatchKinds = munger.getPointcut().couldMatchKinds();
+                       for (int i = 0; i < Shadow.SHADOW_KINDS.length; i++) {
+                               Shadow.Kind kind = Shadow.SHADOW_KINDS[i];
+                               if (kind.isSet(couldMatchKinds)) perKindShadowMungers[kind.getKey()].add(munger);
                        }
+                       
+//                     Set couldMatchKinds = munger.getPointcut().couldMatchKinds();
+//                     for (Iterator kindIterator = couldMatchKinds.iterator(); 
+//                          kindIterator.hasNext();) {
+//                             Shadow.Kind aKind = (Shadow.Kind) kindIterator.next();
+//                             perKindShadowMungers[aKind.getKey()].add(munger);
+//                     }
                }
        
        if (!perKindShadowMungers[Shadow.Initialization.getKey()].isEmpty())
index 64692bf40301fd86e2f57410011b4ea8bfc07060..db4caee5a153f7c238d78ea6dabec616b6c7e231 100644 (file)
@@ -71,6 +71,7 @@ import org.aspectj.weaver.ReferenceType;
 import org.aspectj.weaver.ReferenceTypeDelegate;
 import org.aspectj.weaver.ResolvedTypeMunger;
 import org.aspectj.weaver.ResolvedType;
+import org.aspectj.weaver.Shadow;
 import org.aspectj.weaver.ShadowMunger;
 import org.aspectj.weaver.UnresolvedType;
 import org.aspectj.weaver.WeaverMessages;
@@ -571,7 +572,7 @@ public class BcelWeaver implements IWeaver {
     // common.
     private void validateBindings(Pointcut dnfPointcut, Pointcut userPointcut, int numFormals, String[] names) {
        if (numFormals == 0) return; // nothing to check
-       if (dnfPointcut.couldMatchKinds().isEmpty()) return; // cant have problems if you dont match!
+       if (dnfPointcut.couldMatchKinds()==Shadow.NO_SHADOW_KINDS_BITS) return; // cant have problems if you dont match!
        if (dnfPointcut instanceof OrPointcut) {
                OrPointcut orBasedDNFPointcut = (OrPointcut) dnfPointcut;
                Pointcut[] leftBindings = new Pointcut[numFormals];
@@ -591,19 +592,18 @@ public class BcelWeaver implements IWeaver {
                Pointcut[] newRightBindings = new Pointcut[numFormals];
                validateOrBranch((OrPointcut)left,userPointcut,numFormals,names,leftBindings,newRightBindings);                 
        } else {
-               if (left.couldMatchKinds().size() > 0)
+               if (left.couldMatchKinds()!=Shadow.NO_SHADOW_KINDS_BITS)
                        validateSingleBranch(left, userPointcut, numFormals, names, leftBindings);
        }
        if (right instanceof OrPointcut) {
                Pointcut[] newLeftBindings = new Pointcut[numFormals];
                validateOrBranch((OrPointcut)right,userPointcut,numFormals,names,newLeftBindings,rightBindings);
        } else {
-               if (right.couldMatchKinds().size() > 0)
+               if (right.couldMatchKinds()!=Shadow.NO_SHADOW_KINDS_BITS)
                        validateSingleBranch(right, userPointcut, numFormals, names, rightBindings);                    
        }
-               Set kindsInCommon = left.couldMatchKinds();
-               kindsInCommon.retainAll(right.couldMatchKinds());
-               if (!kindsInCommon.isEmpty() && couldEverMatchSameJoinPoints(left,right)) {
+               int kindsInCommon = left.couldMatchKinds() & right.couldMatchKinds();
+               if (kindsInCommon!=Shadow.NO_SHADOW_KINDS_BITS && couldEverMatchSameJoinPoints(left,right)) {
                        // we know that every branch binds every formal, so there is no ambiguity
                        // if each branch binds it in exactly the same way...
                        List ambiguousNames = new ArrayList();
index 3934f56c9137facee6ec6c3d772a0841b8d308ba..824e5219248334495cf68900153f25bd12b10b56 100644 (file)
@@ -14,7 +14,6 @@ package org.aspectj.weaver.internal.tools;
 import java.io.DataOutputStream;
 import java.io.IOException;
 import java.util.Map;
-import java.util.Set;
 
 import org.aspectj.util.FuzzyBoolean;
 import org.aspectj.weaver.IntMap;
@@ -74,8 +73,8 @@ public class PointcutDesignatorHandlerBasedPointcut extends Pointcut{
        /* (non-Javadoc)
         * @see org.aspectj.weaver.patterns.Pointcut#couldMatchKinds()
         */
-       public Set couldMatchKinds() {
-               return Shadow.ALL_SHADOW_KINDS;
+       public int couldMatchKinds() {
+               return Shadow.ALL_SHADOW_KINDS_BITS;
        }
 
        /* (non-Javadoc)
index 0aa55e115355a3f1926abdcd0fcc69873ace610e..88810c2883c3840f1b6a0a8bda24154ebd36c031 100644 (file)
@@ -15,9 +15,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.util.FuzzyBoolean;
 import org.aspectj.weaver.ISourceContext;
@@ -30,7 +28,7 @@ import org.aspectj.weaver.ast.Test;
 public class AndPointcut extends Pointcut {
        Pointcut left, right;  // exposed for testing
 
-       private Set couldMatchKinds;
+       private int couldMatchKinds;
        
        public AndPointcut(Pointcut left, Pointcut right) {
                super();
@@ -38,12 +36,10 @@ public class AndPointcut extends Pointcut {
                this.right = right;
                this.pointcutKind = AND;
                setLocation(left.getSourceContext(), left.getStart(), right.getEnd());
-               couldMatchKinds = new HashSet();
-               couldMatchKinds.addAll(left.couldMatchKinds());
-               couldMatchKinds.retainAll(right.couldMatchKinds());
+               couldMatchKinds = left.couldMatchKinds() & right.couldMatchKinds();
        }
        
-       public Set couldMatchKinds() {
+       public int couldMatchKinds() {
                return couldMatchKinds;
        }
 
index f01b9240eb5d13498780147bb12b923c9cbec74a..883f93fb69fa2347981eef08a4fbe20276493ffe 100644 (file)
@@ -17,7 +17,6 @@ import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
 
 import org.aspectj.bridge.MessageUtil;
 import org.aspectj.util.FuzzyBoolean;
@@ -84,8 +83,8 @@ public class AnnotationPointcut extends NameBindingPointcut {
         return annotationTypePattern;
     }
 
-       public Set couldMatchKinds() {
-               return Shadow.ALL_SHADOW_KINDS;
+       public int couldMatchKinds() {
+               return Shadow.ALL_SHADOW_KINDS_BITS;
        }
        
        public Pointcut parameterizeWith(Map typeVariableMap) {
index aec5585df539e443378694b67e96e168f09ef626..41d7416e6c600ef0bfa5e059efb4266186da9af2 100644 (file)
@@ -15,7 +15,6 @@ 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;
 import org.aspectj.bridge.ISourceLocation;
@@ -57,8 +56,8 @@ public class ArgsAnnotationPointcut extends NameBindingPointcut {
         return arguments;
     }
 
-       public Set couldMatchKinds() {
-               return Shadow.ALL_SHADOW_KINDS;  // empty args() matches jps with no args
+       public int couldMatchKinds() {
+               return Shadow.ALL_SHADOW_KINDS_BITS;  // empty args() matches jps with no args
        }
        
        public Pointcut parameterizeWith(Map typeVariableMap) {
index 04581891bc5a05a9249ad1d26a7ddd2b56314287..18b624c11d086d93ba1898443d3f500dc608600c 100644 (file)
@@ -19,7 +19,6 @@ 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;
 import org.aspectj.bridge.ISourceLocation;
@@ -65,8 +64,8 @@ public class ArgsPointcut extends NameBindingPointcut {
        return ret;
     }
     
-       public Set couldMatchKinds() {
-               return Shadow.ALL_SHADOW_KINDS;  // empty args() matches jps with no args
+       public int couldMatchKinds() {
+               return Shadow.ALL_SHADOW_KINDS_BITS;  // empty args() matches jps with no args
        }
 
     public FuzzyBoolean fastMatch(FastMatchInfo type) {
index 4eea612fd7d99094cf131a15d987c665032de757..b1f3a8ef0760ce3b9e4c31ee1539800b935bd830 100644 (file)
@@ -23,7 +23,6 @@ import java.util.Hashtable;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
 
 import org.aspectj.bridge.IMessage;
 import org.aspectj.util.FileUtil;
@@ -34,8 +33,8 @@ import org.aspectj.weaver.ISourceContext;
 import org.aspectj.weaver.IntMap;
 import org.aspectj.weaver.Member;
 import org.aspectj.weaver.NameMangler;
-import org.aspectj.weaver.ResolvedMemberImpl;
 import org.aspectj.weaver.ResolvedMember;
+import org.aspectj.weaver.ResolvedMemberImpl;
 import org.aspectj.weaver.ResolvedPointcutDefinition;
 import org.aspectj.weaver.ResolvedType;
 import org.aspectj.weaver.Shadow;
@@ -79,8 +78,8 @@ public class CflowPointcut extends Pointcut {
                return isBelow;
        }
 
-       public Set couldMatchKinds() {
-               return Shadow.ALL_SHADOW_KINDS;
+       public int couldMatchKinds() {
+               return Shadow.ALL_SHADOW_KINDS_BITS;
        }
        
        // enh 76055
index d86578be8fbf73b6ecce50d351013b9d04410b02..3a91e54864df3df36e3c144e83327834e2ea0ade 100644 (file)
@@ -18,7 +18,6 @@ import java.io.IOException;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
 
 import org.aspectj.util.FuzzyBoolean;
 import org.aspectj.weaver.IntMap;
@@ -46,8 +45,8 @@ public class ConcreteCflowPointcut extends Pointcut {
                this.pointcutKind = CFLOW;
        }
     
-       public Set couldMatchKinds() {
-               return Shadow.ALL_SHADOW_KINDS;
+       public int couldMatchKinds() {
+               return Shadow.ALL_SHADOW_KINDS_BITS;
        }
        
     public FuzzyBoolean fastMatch(FastMatchInfo type) {
index a92eaa00794568395044af3d469abd8cfb092ffc..0d9e5637721b79e302d7787224eadf4025fa4685 100644 (file)
@@ -15,9 +15,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.MessageUtil;
 import org.aspectj.util.FuzzyBoolean;
@@ -40,17 +38,14 @@ import org.aspectj.weaver.ast.Test;
 public class HandlerPointcut extends Pointcut {
        TypePattern exceptionType;
 
-       private static final Set MATCH_KINDS = new HashSet();
-       static {
-               MATCH_KINDS.add(Shadow.ExceptionHandler);
-       }
+       private static final int MATCH_KINDS = Shadow.ExceptionHandler.bit;
        
        public HandlerPointcut(TypePattern exceptionType) {
                this.exceptionType = exceptionType;
                this.pointcutKind = HANDLER;
        }
 
-       public Set couldMatchKinds() {
+       public int couldMatchKinds() {
                return MATCH_KINDS;
        }
        
index 9b8d5b6af42e0ff2a7a390015ff867a8a5014ba8..bcb5bf3a9fa6e779e2fbad6f664861f41f166324 100644 (file)
@@ -15,11 +15,9 @@ package org.aspectj.weaver.patterns;
 import java.io.DataOutputStream;
 import java.io.IOException;
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
 
 import org.aspectj.bridge.IMessage;
 import org.aspectj.lang.JoinPoint;
@@ -73,8 +71,8 @@ public class IfPointcut extends Pointcut {
         this.extraParameterFlags = -1;//allows to keep track of the @Aj style
     }
 
-       public Set couldMatchKinds() {
-               return Shadow.ALL_SHADOW_KINDS;
+       public int couldMatchKinds() {
+               return Shadow.ALL_SHADOW_KINDS_BITS;
        }
 
        public FuzzyBoolean fastMatch(FastMatchInfo type) {
@@ -393,8 +391,8 @@ public class IfPointcut extends Pointcut {
             this.pointcutKind = Pointcut.IF_FALSE;
                }
                
-               public Set couldMatchKinds() {
-                       return Collections.EMPTY_SET;
+               public int couldMatchKinds() {
+                       return Shadow.NO_SHADOW_KINDS_BITS;
                }
                
                public boolean alwaysFalse() {
index 25c25740c8aad5b268d24c049e74bbdaf0c19928..0c3dffe0d39bd955ae93d6ca51a44672412e0ddc 100644 (file)
@@ -15,9 +15,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;
 import org.aspectj.bridge.MessageUtil;
@@ -40,7 +38,7 @@ import org.aspectj.weaver.ast.Test;
 public class KindedPointcut extends Pointcut {
        Shadow.Kind kind;
        private SignaturePattern signature;
-       private Set matchKinds;
+       private int matchKinds;
     
     private ShadowMunger munger = null; // only set after concretization
 
@@ -50,8 +48,7 @@ public class KindedPointcut extends Pointcut {
         this.kind = kind;
         this.signature = signature;
         this.pointcutKind = KINDED;
-        this.matchKinds = new HashSet();
-        matchKinds.add(kind);
+        this.matchKinds = kind.bit;
     }
     public KindedPointcut(
         Shadow.Kind kind,
@@ -68,7 +65,7 @@ public class KindedPointcut extends Pointcut {
     /* (non-Javadoc)
         * @see org.aspectj.weaver.patterns.Pointcut#couldMatchKinds()
         */
-       public Set couldMatchKinds() {
+       public int couldMatchKinds() {
                return matchKinds;
        }
        
index 9f70b73f918ba2f343f13c541f42899015d127b3..972657f936469db264770d977e35b2539a324da1 100644 (file)
@@ -16,7 +16,6 @@ package org.aspectj.weaver.patterns;
 import java.io.DataOutputStream;
 import java.io.IOException;
 import java.util.Map;
-import java.util.Set;
 
 import org.aspectj.util.FuzzyBoolean;
 import org.aspectj.weaver.ISourceContext;
@@ -39,8 +38,8 @@ public class NotPointcut extends Pointcut {
                setLocation(pointcut.getSourceContext(), startPos, pointcut.getEnd());          
        }
 
-       public Set couldMatchKinds() {
-               return Shadow.ALL_SHADOW_KINDS;
+       public int couldMatchKinds() {
+               return Shadow.ALL_SHADOW_KINDS_BITS;
        }
        
        public Pointcut getNegatedPointcut() { return body; }
index 76774e61316e440bb873c8c48171aa01a0c2b328..5a564ec9cc1ea07c88984b2796da2db0127e8846 100644 (file)
@@ -15,9 +15,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.util.FuzzyBoolean;
 import org.aspectj.weaver.ISourceContext;
@@ -29,7 +27,7 @@ import org.aspectj.weaver.ast.Test;
 
 public class OrPointcut extends Pointcut {
        Pointcut left, right;
-       private Set couldMatchKinds;
+       private int couldMatchKinds;
 
        public OrPointcut(Pointcut left, Pointcut right) {
                super();
@@ -37,11 +35,10 @@ public class OrPointcut extends Pointcut {
                this.right = right;
                setLocation(left.getSourceContext(), left.getStart(), right.getEnd());
                this.pointcutKind = OR;
-               this.couldMatchKinds = new HashSet(left.couldMatchKinds());
-               this.couldMatchKinds.addAll(right.couldMatchKinds());
+               this.couldMatchKinds = left.couldMatchKinds() | right.couldMatchKinds();
        }
 
-       public Set couldMatchKinds() {
+       public int couldMatchKinds() {
                return couldMatchKinds;
        }
 
index dd63f3d5175620cc894493591265f9a4c492240c..ee55170486240f37dd8bce8a7fefcdd90b90b028 100644 (file)
@@ -20,7 +20,6 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
 
 import org.aspectj.util.FuzzyBoolean;
 import org.aspectj.weaver.Advice;
@@ -35,9 +34,9 @@ import org.aspectj.weaver.Shadow;
 import org.aspectj.weaver.UnresolvedType;
 import org.aspectj.weaver.VersionedDataInputStream;
 import org.aspectj.weaver.World;
-import org.aspectj.weaver.bcel.BcelAccessForInlineMunger;
 import org.aspectj.weaver.ast.Expr;
 import org.aspectj.weaver.ast.Test;
+import org.aspectj.weaver.bcel.BcelAccessForInlineMunger;
 
 public class PerCflow extends PerClause {
        private boolean isBelow;
@@ -54,8 +53,8 @@ public class PerCflow extends PerClause {
                return visitor.visit(this,data);
        }
        
-       public Set couldMatchKinds() {
-               return Shadow.ALL_SHADOW_KINDS;
+       public int couldMatchKinds() {
+               return Shadow.ALL_SHADOW_KINDS_BITS;
        }
        
        public FuzzyBoolean fastMatch(FastMatchInfo type) {
index 02335285e78ac9d77eeb97b2ee10aea9e840c98c..822345216134a7b13698ee4b725adc1c3192d47f 100644 (file)
@@ -16,7 +16,6 @@ package org.aspectj.weaver.patterns;
 import java.io.DataOutputStream;
 import java.io.IOException;
 import java.util.Map;
-import java.util.Set;
 
 import org.aspectj.bridge.MessageUtil;
 import org.aspectj.util.FuzzyBoolean;
@@ -38,8 +37,8 @@ public class PerFromSuper extends PerClause {
                return visitor.visit(this,data);
        }
        
-       public Set couldMatchKinds() {
-               return Shadow.ALL_SHADOW_KINDS;
+       public int couldMatchKinds() {
+               return Shadow.ALL_SHADOW_KINDS_BITS;
        }
 
        public FuzzyBoolean fastMatch(FastMatchInfo type) {
index b29fee3fc37a2e9491feda749e5c16e8db218de1..64f2ea2f7ef4f8477a16835f1595b046872698d1 100644 (file)
@@ -15,37 +15,40 @@ package org.aspectj.weaver.patterns;
 
 import java.io.DataOutputStream;
 import java.io.IOException;
-import java.util.HashSet;
-import java.util.Iterator;
 import java.util.Map;
-import java.util.Set;
 
 import org.aspectj.util.FuzzyBoolean;
 import org.aspectj.weaver.Advice;
 import org.aspectj.weaver.AjcMemberMaker;
 import org.aspectj.weaver.ISourceContext;
 import org.aspectj.weaver.PerObjectInterfaceTypeMunger;
-import org.aspectj.weaver.ResolvedTypeMunger;
 import org.aspectj.weaver.ResolvedType;
+import org.aspectj.weaver.ResolvedTypeMunger;
 import org.aspectj.weaver.Shadow;
 import org.aspectj.weaver.VersionedDataInputStream;
 import org.aspectj.weaver.World;
-import org.aspectj.weaver.bcel.BcelAccessForInlineMunger;
 import org.aspectj.weaver.ast.Expr;
 import org.aspectj.weaver.ast.Test;
 import org.aspectj.weaver.ast.Var;
+import org.aspectj.weaver.bcel.BcelAccessForInlineMunger;
 
 public class PerObject extends PerClause {
        private boolean isThis;
        private Pointcut entry;
-       private static final Set thisKindSet = new HashSet(Shadow.ALL_SHADOW_KINDS);
-       private static final Set targetKindSet = new HashSet(Shadow.ALL_SHADOW_KINDS);
+       
+       private static final int thisKindSet;
+       private static final int targetKindSet;
+       
        static {
-               for (Iterator iter = Shadow.ALL_SHADOW_KINDS.iterator(); iter.hasNext();) {
-                       Shadow.Kind kind = (Shadow.Kind) iter.next();
-                       if (kind.neverHasThis()) thisKindSet.remove(kind);
-                       if (kind.neverHasTarget()) targetKindSet.remove(kind);
+               int thisFlags = Shadow.ALL_SHADOW_KINDS_BITS;
+               int targFlags = Shadow.ALL_SHADOW_KINDS_BITS;
+               for (int i = 0; i < Shadow.SHADOW_KINDS.length; i++) {
+                       Shadow.Kind kind = Shadow.SHADOW_KINDS[i];
+                       if (kind.neverHasThis()) thisFlags-=kind.bit;
+                       if (kind.neverHasTarget()) targFlags-=kind.bit;
                }
+               thisKindSet = thisFlags;
+               targetKindSet=targFlags;
        }
        
        public PerObject(Pointcut entry, boolean isThis) {
@@ -57,7 +60,7 @@ public class PerObject extends PerClause {
                return visitor.visit(this,data);
        }
        
-       public Set couldMatchKinds() {
+       public int couldMatchKinds() {
                return isThis ? thisKindSet : targetKindSet;
        }
        
index f8155ed707998b9cf97afbe126cca3c43de125ff..addf03925ffae652b553d8e9508846d2ecbbad34 100644 (file)
@@ -16,7 +16,6 @@ package org.aspectj.weaver.patterns;
 import java.io.DataOutputStream;
 import java.io.IOException;
 import java.util.Map;
-import java.util.Set;
 
 import org.aspectj.util.FuzzyBoolean;
 import org.aspectj.weaver.AjcMemberMaker;
@@ -24,10 +23,10 @@ import org.aspectj.weaver.ISourceContext;
 import org.aspectj.weaver.ResolvedType;
 import org.aspectj.weaver.Shadow;
 import org.aspectj.weaver.VersionedDataInputStream;
-import org.aspectj.weaver.bcel.BcelAccessForInlineMunger;
 import org.aspectj.weaver.ast.Expr;
 import org.aspectj.weaver.ast.Literal;
 import org.aspectj.weaver.ast.Test;
+import org.aspectj.weaver.bcel.BcelAccessForInlineMunger;
 
 public class PerSingleton extends PerClause {
        public PerSingleton() {
@@ -37,8 +36,8 @@ public class PerSingleton extends PerClause {
                return visitor.visit(this,data);
        }
        
-       public Set couldMatchKinds() {
-               return Shadow.ALL_SHADOW_KINDS;
+       public int couldMatchKinds() {
+               return Shadow.ALL_SHADOW_KINDS_BITS;
        }
 
        public FuzzyBoolean fastMatch(FastMatchInfo type) {
index 0f8d2a32753e0cf273f974a84ebabbd6c257accf..0c8a5096e076a6149e17549c049b8289139f3be4 100644 (file)
@@ -14,9 +14,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.IMessage;
 import org.aspectj.bridge.ISourceLocation;
@@ -26,17 +24,16 @@ import org.aspectj.weaver.Advice;
 import org.aspectj.weaver.AjcMemberMaker;
 import org.aspectj.weaver.ISourceContext;
 import org.aspectj.weaver.Member;
-//import org.aspectj.weaver.PerTypeWithinTargetTypeMunger;
 import org.aspectj.weaver.PerTypeWithinTargetTypeMunger;
-import org.aspectj.weaver.ResolvedTypeMunger;
 import org.aspectj.weaver.ResolvedType;
+import org.aspectj.weaver.ResolvedTypeMunger;
 import org.aspectj.weaver.Shadow;
 import org.aspectj.weaver.VersionedDataInputStream;
 import org.aspectj.weaver.World;
-import org.aspectj.weaver.bcel.BcelAccessForInlineMunger;
 import org.aspectj.weaver.ast.Expr;
 import org.aspectj.weaver.ast.Literal;
 import org.aspectj.weaver.ast.Test;
+import org.aspectj.weaver.bcel.BcelAccessForInlineMunger;
 
 
 // PTWIMPL Represents a parsed pertypewithin()
@@ -45,7 +42,7 @@ public class PerTypeWithin extends PerClause {
        private TypePattern typePattern;
        
        // Any shadow could be considered within a pertypewithin() type pattern
-       private static final Set kindSet = new HashSet(Shadow.ALL_SHADOW_KINDS);
+       private static final int kindSet = Shadow.ALL_SHADOW_KINDS_BITS;
        
        public TypePattern getTypePattern() {
                return typePattern;
@@ -59,7 +56,7 @@ public class PerTypeWithin extends PerClause {
                return visitor.visit(this,data);
        }
        
-       public Set couldMatchKinds() {
+       public int couldMatchKinds() {
                return kindSet;
        }
        
index 4fdf124baa1e8cd4499d80d037aab5f72028ef77..f0fd775c245776c6e18737c0327d7f2de4bb2fb2 100644 (file)
@@ -15,9 +15,7 @@ package org.aspectj.weaver.patterns;
 
 import java.io.DataOutputStream;
 import java.io.IOException;
-import java.util.Collections;
 import java.util.Map;
-import java.util.Set;
 
 import org.aspectj.util.FuzzyBoolean;
 import org.aspectj.util.TypeSafeEnum;
@@ -121,9 +119,10 @@ public abstract class Pointcut extends PatternNode {
        public abstract FuzzyBoolean fastMatch(FastMatchInfo info);
        
        /**
-        * The set of ShadowKinds that this Pointcut could possibly match  
+        * The set of ShadowKinds that this Pointcut could possibly match -
+        * an int whose bits are set according to the Kinds specified in Shadow.java
         */
-       public abstract /*Enum*/Set/*<Shadow.Kind>*/ couldMatchKinds();
+       public abstract int couldMatchKinds();
        
        public String[] getTypeVariablesInScope() {
                return typeVariablesInScope;
@@ -141,7 +140,7 @@ public abstract class Pointcut extends PatternNode {
                if (shadow.shadowId == lastMatchedShadowId) return lastMatchedShadowResult;
                FuzzyBoolean ret;
                // this next test will prevent a lot of un-needed matching going on....
-               if (couldMatchKinds().contains(shadow.getKind())) {
+               if (shadow.getKind().isSet(couldMatchKinds())) {
                        ret = matchInternal(shadow);
                } else {
                        ret = FuzzyBoolean.NO;
@@ -326,8 +325,8 @@ public abstract class Pointcut extends PatternNode {
                        return Literal.FALSE; // can only get here if an earlier error occurred
                }
 
-               public Set couldMatchKinds() {
-                       return Collections.EMPTY_SET;
+               public int couldMatchKinds() {
+                       return Shadow.NO_SHADOW_KINDS_BITS;
                }
                
                public FuzzyBoolean fastMatch(FastMatchInfo type) {
index 578670031645560633afd2cf766ccf209f255448..2c2d7c0e6e3e1903578ebd239e884842bae9e01e 100644 (file)
@@ -75,7 +75,7 @@ public class PointcutEvaluationExpenseComparator implements Comparator {
 
        // a higher score means a more expensive evaluation
        private int getScore(Pointcut p) {
-               if (p.couldMatchKinds().isEmpty()) return MATCHES_NOTHING;
+               if (p.couldMatchKinds()==Shadow.NO_SHADOW_KINDS_BITS) return MATCHES_NOTHING;
                if (p instanceof WithinPointcut) return WITHIN;
                if (p instanceof WithinAnnotationPointcut) return ATWITHIN;
                if (p instanceof KindedPointcut) {
index 2d70942bf86a3d2f68668d44334813b3c13e3032..8b08b041ab6cd5f39d773db77b93eacec57d2336 100644 (file)
@@ -307,9 +307,9 @@ public class PointcutRewriter {
                                if (((IfPointcut)element).alwaysFalse()) return Pointcut.makeMatchesNothing(element.state);
                        }
                        // If it can't match anything, the whole AND can't match anything
-                       if (element.couldMatchKinds().isEmpty()) return element;
+                       if (element.couldMatchKinds()==Shadow.NO_SHADOW_KINDS_BITS) return element;
                }
-               if (apc.couldMatchKinds().isEmpty()) return Pointcut.makeMatchesNothing(apc.state);
+               if (apc.couldMatchKinds()==Shadow.NO_SHADOW_KINDS_BITS) return Pointcut.makeMatchesNothing(apc.state);
                // write out with cheapest on left
                Iterator iter = nodes.iterator();
                Pointcut result = (Pointcut) iter.next();
index bb2c6ba619a608912d4ba02d2241055c112ae327..4110eec925d73bc429a354fd308a2e1464736170 100644 (file)
@@ -18,7 +18,6 @@ import java.io.IOException;
 import java.lang.reflect.Modifier;
 import java.util.HashMap;
 import java.util.Map;
-import java.util.Set;
 
 import org.aspectj.bridge.IMessage;
 import org.aspectj.bridge.MessageUtil;
@@ -67,8 +66,8 @@ public class ReferencePointcut extends Pointcut {
                this.pointcutKind = REFERENCE;
        }
        
-       public Set couldMatchKinds() {
-               return Shadow.ALL_SHADOW_KINDS;
+       public int couldMatchKinds() {
+               return Shadow.ALL_SHADOW_KINDS_BITS;
        }
 
 
index fc9493c5bd50bd697a57160a67fa661d48c0ebda..8f1cb3c31ccad9a9418b0ae9cf27db7d5187d6bd 100644 (file)
@@ -13,11 +13,8 @@ import java.io.DataOutputStream;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
 
 import org.aspectj.bridge.IMessage;
 import org.aspectj.bridge.MessageUtil;
@@ -47,14 +44,20 @@ public class ThisOrTargetAnnotationPointcut extends NameBindingPointcut {
        private ExactAnnotationTypePattern annotationTypePattern;
        private ShadowMunger munger;
        private String declarationText;
-       private static final Set thisKindSet = new HashSet(Shadow.ALL_SHADOW_KINDS);
-       private static final Set targetKindSet = new HashSet(Shadow.ALL_SHADOW_KINDS);
+       
+       private static final int thisKindSet;
+       private static final int targetKindSet;
+       
        static {
-               for (Iterator iter = Shadow.ALL_SHADOW_KINDS.iterator(); iter.hasNext();) {
-                       Shadow.Kind kind = (Shadow.Kind) iter.next();
-                       if (kind.neverHasThis()) thisKindSet.remove(kind);
-                       if (kind.neverHasTarget()) targetKindSet.remove(kind);
+               int thisFlags = Shadow.ALL_SHADOW_KINDS_BITS;
+               int targFlags = Shadow.ALL_SHADOW_KINDS_BITS;
+               for (int i = 0; i < Shadow.SHADOW_KINDS.length; i++) {
+                       Shadow.Kind kind = Shadow.SHADOW_KINDS[i];
+                       if (kind.neverHasThis()) thisFlags-=kind.bit;
+                       if (kind.neverHasTarget()) targFlags-=kind.bit;
                }
+               thisKindSet = thisFlags;
+               targetKindSet=targFlags;
        }
        
        /**
@@ -77,7 +80,7 @@ public class ThisOrTargetAnnotationPointcut extends NameBindingPointcut {
         return annotationTypePattern;
     }
 
-       public Set couldMatchKinds() {
+       public int couldMatchKinds() {
                return isThis ? thisKindSet : targetKindSet;
        }
        
index 862000825901cfe7b55807a65412a67f3ab42522..c50577323ef4d4fa21023fdbdf6ae17aa3892270 100644 (file)
@@ -17,11 +17,8 @@ import java.io.DataOutputStream;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
 
 import org.aspectj.bridge.IMessage;
 import org.aspectj.bridge.MessageUtil;
@@ -56,16 +53,22 @@ public class ThisOrTargetPointcut extends NameBindingPointcut {
        private TypePattern type;
        private String declarationText;
 
-       private static final Set thisKindSet = new HashSet(Shadow.ALL_SHADOW_KINDS);
-       private static final Set targetKindSet = new HashSet(Shadow.ALL_SHADOW_KINDS);
+       private static final int thisKindSet;
+       private static final int targetKindSet;
+       
        static {
-               for (Iterator iter = Shadow.ALL_SHADOW_KINDS.iterator(); iter.hasNext();) {
-                       Shadow.Kind kind = (Shadow.Kind) iter.next();
-                       if (kind.neverHasThis()) thisKindSet.remove(kind);
-                       if (kind.neverHasTarget()) targetKindSet.remove(kind);
+               int thisFlags = Shadow.ALL_SHADOW_KINDS_BITS;
+               int targFlags = Shadow.ALL_SHADOW_KINDS_BITS;
+               for (int i = 0; i < Shadow.SHADOW_KINDS.length; i++) {
+                       Shadow.Kind kind = Shadow.SHADOW_KINDS[i];
+                       if (kind.neverHasThis()) thisFlags-=kind.bit;
+                       if (kind.neverHasTarget()) targFlags-=kind.bit;
                }
+               thisKindSet = thisFlags;
+               targetKindSet=targFlags;
        }
        
+       
        public boolean isBinding() {
                return (type instanceof BindingTypePattern);
        }
@@ -89,7 +92,7 @@ public class ThisOrTargetPointcut extends NameBindingPointcut {
                return ret;
        }
        
-       public Set couldMatchKinds() {
+       public int couldMatchKinds() {
                return isThis ? thisKindSet : targetKindSet;
        }
 
index 5996464d756a2fe1628484fdfcdbc067d39fb9dd..f2c5d8a88bc05f95a55b20b94daf05a9a64eb83e 100644 (file)
@@ -15,7 +15,6 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
 
 import org.aspectj.bridge.ISourceLocation;
 import org.aspectj.bridge.MessageUtil;
@@ -65,8 +64,8 @@ public class WithinAnnotationPointcut extends NameBindingPointcut {
         return annotationTypePattern;
     }
 
-       public Set couldMatchKinds() {
-               return Shadow.ALL_SHADOW_KINDS;
+       public int couldMatchKinds() {
+               return Shadow.ALL_SHADOW_KINDS_BITS;
        }
        
        public Pointcut parameterizeWith(Map typeVariableMap) {
index 7022d2ceeddb156c5344fd6f95a2e47b6554d9b4..cb0295c066a003b92fba632c03aa8544b876a0ea 100644 (file)
@@ -13,10 +13,8 @@ import java.io.DataOutputStream;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
 
 import org.aspectj.bridge.MessageUtil;
 import org.aspectj.util.FuzzyBoolean;
@@ -48,13 +46,15 @@ public class WithinCodeAnnotationPointcut extends NameBindingPointcut {
        private ExactAnnotationTypePattern annotationTypePattern;
     private ShadowMunger munger = null; // only set after concretization
     private String declarationText;
-    private static final Set matchedShadowKinds = new HashSet();
+    
+    private static final int matchedShadowKinds;
     static {
-       matchedShadowKinds.addAll(Shadow.ALL_SHADOW_KINDS);
+       int flags = Shadow.ALL_SHADOW_KINDS_BITS;
        for (int i = 0; i < Shadow.SHADOW_KINDS.length; i++) {
                        if (Shadow.SHADOW_KINDS[i].isEnclosingKind()) 
-                               matchedShadowKinds.remove(Shadow.SHADOW_KINDS[i]);
+                               flags -= Shadow.SHADOW_KINDS[i].bit;
                }
+       matchedShadowKinds=flags;
     }
        
        public WithinCodeAnnotationPointcut(ExactAnnotationTypePattern type) {
@@ -74,7 +74,7 @@ public class WithinCodeAnnotationPointcut extends NameBindingPointcut {
         return annotationTypePattern;
     }
 
-       public Set couldMatchKinds() {
+       public int couldMatchKinds() {
                return matchedShadowKinds;
        }
        
index 5e893256a64d1e85b09aee469e25b4757197d4e3..3b213be0ac83327e0973b785f051c02ae1b0e87b 100644 (file)
@@ -16,7 +16,6 @@ package org.aspectj.weaver.patterns;
 import java.io.DataOutputStream;
 import java.io.IOException;
 import java.util.Map;
-import java.util.Set;
 
 import org.aspectj.bridge.ISourceLocation;
 import org.aspectj.bridge.MessageUtil;
@@ -52,8 +51,8 @@ public class WithinPointcut extends Pointcut {
                return FuzzyBoolean.NO;
        }
 
-       public Set couldMatchKinds() {
-               return Shadow.ALL_SHADOW_KINDS;
+       public int couldMatchKinds() {
+               return Shadow.ALL_SHADOW_KINDS_BITS;
        }
        
        public Pointcut parameterizeWith(Map typeVariableMap) {
index 88315200a38cb598afd9653d06dc65d6124dcab9..b3fcf03cb52dd1d7f898d47c82463685b4abc755 100644 (file)
@@ -15,9 +15,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.MessageUtil;
 import org.aspectj.util.FuzzyBoolean;
@@ -32,16 +30,17 @@ import org.aspectj.weaver.ast.Test;
 
 public class WithincodePointcut extends Pointcut {
        private SignaturePattern signature;
-    private static final Set matchedShadowKinds = new HashSet();
+    private static final int matchedShadowKinds;
     static {
-       matchedShadowKinds.addAll(Shadow.ALL_SHADOW_KINDS);
+       int flags = Shadow.ALL_SHADOW_KINDS_BITS;
        for (int i = 0; i < Shadow.SHADOW_KINDS.length; i++) {
                        if (Shadow.SHADOW_KINDS[i].isEnclosingKind()) 
-                               matchedShadowKinds.remove(Shadow.SHADOW_KINDS[i]);
+                               flags -= Shadow.SHADOW_KINDS[i].bit;
                }
        // these next two are needed for inlining of field initializers
-       matchedShadowKinds.add(Shadow.ConstructorExecution);
-       matchedShadowKinds.add(Shadow.Initialization);
+       flags|=Shadow.ConstructorExecution.bit;
+       flags|=Shadow.Initialization.bit;
+       matchedShadowKinds = flags;
     }
        
        public WithincodePointcut(SignaturePattern signature) {
@@ -53,7 +52,7 @@ public class WithincodePointcut extends Pointcut {
         return signature;
     }
 
-       public Set couldMatchKinds() {
+       public int couldMatchKinds() {
                return matchedShadowKinds;
        }
        
index 84a32ddb11905ff04f87129e70ef3963888725d0..3684e9d86abcde0aedcba70b060c77bcaeb72b8e 100644 (file)
@@ -212,73 +212,73 @@ public class PointcutRewriterTest extends TestCase {
        public void testDetermineKindSetOfAnd() {
                Pointcut oneKind = getPointcut("execution(* foo(..)) && this(Boo)");
                AndPointcut rewritten = (AndPointcut) prw.rewrite(oneKind);
-               assertEquals("Only one kind",1,rewritten.couldMatchKinds().size());
-               assertTrue("It's Shadow.MethodExecution",rewritten.couldMatchKinds().contains(Shadow.MethodExecution));
+               assertEquals("Only one kind",1,Shadow.howMany(rewritten.couldMatchKinds()));
+               assertTrue("It's Shadow.MethodExecution",Shadow.MethodExecution.isSet(rewritten.couldMatchKinds()));
        }
        
        public void testKindSetOfExecution() {
                Pointcut p = getPointcut("execution(* foo(..))");
-               assertEquals("Only one kind",1,p.couldMatchKinds().size());
-               assertTrue("It's Shadow.MethodExecution",p.couldMatchKinds().contains(Shadow.MethodExecution));
+               assertEquals("Only one kind",1,Shadow.howMany(p.couldMatchKinds()));
+               assertTrue("It's Shadow.MethodExecution",Shadow.MethodExecution.isSet(p.couldMatchKinds()));
                p = getPointcut("execution(new(..))");
-               assertEquals("Only one kind",1,p.couldMatchKinds().size());
-               assertTrue("It's Shadow.ConstructorExecution",p.couldMatchKinds().contains(Shadow.ConstructorExecution));               
+               assertEquals("Only one kind",1,Shadow.howMany(p.couldMatchKinds()));
+               assertTrue("It's Shadow.ConstructorExecution",Shadow.ConstructorExecution.isSet(p.couldMatchKinds()));          
        }
        
        public void testKindSetOfCall() {
                Pointcut p = getPointcut("call(* foo(..))");
-               assertEquals("Only one kind",1,p.couldMatchKinds().size());
-               assertTrue("It's Shadow.MethodCall",p.couldMatchKinds().contains(Shadow.MethodCall));
+               assertEquals("Only one kind",1,Shadow.howMany(p.couldMatchKinds()));
+               assertTrue("It's Shadow.MethodCall",Shadow.MethodCall.isSet(p.couldMatchKinds()));
                p = getPointcut("call(new(..))");
-               assertEquals("Only one kind",1,p.couldMatchKinds().size());
-               assertTrue("It's Shadow.ConstructorCall",p.couldMatchKinds().contains(Shadow.ConstructorCall));         
+               assertEquals("Only one kind",1,Shadow.howMany(p.couldMatchKinds()));
+               assertTrue("It's Shadow.ConstructorCall",Shadow.ConstructorCall.isSet(p.couldMatchKinds()));            
        }
        
        public void testKindSetOfAdviceExecution() {
                Pointcut p = getPointcut("adviceexecution()");
-               assertEquals("Only one kind",1,p.couldMatchKinds().size());
-               assertTrue("It's Shadow.AdviceExecution",p.couldMatchKinds().contains(Shadow.AdviceExecution));         
+               assertEquals("Only one kind",1,Shadow.howMany(p.couldMatchKinds()));
+               assertTrue("It's Shadow.AdviceExecution",Shadow.AdviceExecution.isSet(p.couldMatchKinds()));            
        }
        
        public void testKindSetOfGet() {
                Pointcut p = getPointcut("get(* *)");
-               assertEquals("Only one kind",1,p.couldMatchKinds().size());
-               assertTrue("It's Shadow.FieldGet",p.couldMatchKinds().contains(Shadow.FieldGet));
+               assertEquals("Only one kind",1,Shadow.howMany(p.couldMatchKinds()));
+               assertTrue("It's Shadow.FieldGet",Shadow.FieldGet.isSet(p.couldMatchKinds()));
        }
        
        public void testKindSetOfSet() {
                Pointcut p = getPointcut("set(* *)");
-               assertEquals("Only one kind",1,p.couldMatchKinds().size());
-               assertTrue("It's Shadow.FieldSet",p.couldMatchKinds().contains(Shadow.FieldSet));                                               
+               assertEquals("Only one kind",1,Shadow.howMany(p.couldMatchKinds()));
+               assertTrue("It's Shadow.FieldSet",Shadow.FieldSet.isSet(p.couldMatchKinds()));                                          
        }
        
        public void testKindSetOfHandler() {
                Pointcut p = getPointcut("handler(*)");
-               assertEquals("Only one kind",1,p.couldMatchKinds().size());
-               assertTrue("It's Shadow.ExceptionHandler",p.couldMatchKinds().contains(Shadow.ExceptionHandler));                                                               
+               assertEquals("Only one kind",1,Shadow.howMany(p.couldMatchKinds()));
+               assertTrue("It's Shadow.ExceptionHandler",Shadow.ExceptionHandler.isSet(p.couldMatchKinds()));                                                          
        }
        
        public void testKindSetOfInitialization() {
                Pointcut p = getPointcut("initialization(new (..))");
-               assertEquals("Only one kind",1,p.couldMatchKinds().size());
-               assertTrue("It's Shadow.Initialization",p.couldMatchKinds().contains(Shadow.Initialization));                                                   
+               assertEquals("Only one kind",1,Shadow.howMany(p.couldMatchKinds()));
+               assertTrue("It's Shadow.Initialization",Shadow.Initialization.isSet(p.couldMatchKinds()));                                                      
        }
        
        public void testKindSetOfPreInitialization() {
                Pointcut p = getPointcut("preinitialization(new (..))");
-               assertEquals("Only one kind",1,p.couldMatchKinds().size());
-               assertTrue("It's Shadow.PreInitialization",p.couldMatchKinds().contains(Shadow.PreInitialization));                                                                     
+               assertEquals("Only one kind",1,Shadow.howMany(p.couldMatchKinds()));
+               assertTrue("It's Shadow.PreInitialization",Shadow.PreInitialization.isSet(p.couldMatchKinds()));                                                                        
        }
        
        public void testKindSetOfStaticInitialization() {
                Pointcut p = getPointcut("staticinitialization(*)");
-               assertEquals("Only one kind",1,p.couldMatchKinds().size());
-               assertTrue("It's Shadow.StaticInitialization",p.couldMatchKinds().contains(Shadow.StaticInitialization));                                                       
+               assertEquals("Only one kind",1,Shadow.howMany(p.couldMatchKinds()));
+               assertTrue("It's Shadow.StaticInitialization",Shadow.StaticInitialization.isSet(p.couldMatchKinds()));                                                  
        }
        
        public void testKindSetOfThis() {
                Pointcut p = getPointcut("this(Foo)");
-               Set matches = p.couldMatchKinds();
+               Set matches = Shadow.toSet(p.couldMatchKinds());
                for (Iterator iter = matches.iterator(); iter.hasNext();) {
                        Shadow.Kind kind = (Shadow.Kind) iter.next();
                        assertFalse("No kinds that don't have a this",kind.neverHasThis());
@@ -290,7 +290,7 @@ public class PointcutRewriterTest extends TestCase {
                }
                // + @
                p = getPointcut("@this(Foo)");
-               matches = p.couldMatchKinds();
+               matches = Shadow.toSet(p.couldMatchKinds());
                for (Iterator iter = matches.iterator(); iter.hasNext();) {
                        Shadow.Kind kind = (Shadow.Kind) iter.next();
                        assertFalse("No kinds that don't have a this",kind.neverHasThis());
@@ -304,7 +304,7 @@ public class PointcutRewriterTest extends TestCase {
        
        public void testKindSetOfTarget() {
                Pointcut p = getPointcut("target(Foo)");
-               Set matches = p.couldMatchKinds();
+               Set matches = Shadow.toSet(p.couldMatchKinds());
                for (Iterator iter = matches.iterator(); iter.hasNext();) {
                        Shadow.Kind kind = (Shadow.Kind) iter.next();
                        assertFalse("No kinds that don't have a target",kind.neverHasTarget());
@@ -316,7 +316,7 @@ public class PointcutRewriterTest extends TestCase {
                }
                // + @
                p = getPointcut("@target(Foo)");
-               matches = p.couldMatchKinds();
+               matches = Shadow.toSet(p.couldMatchKinds());
                for (Iterator iter = matches.iterator(); iter.hasNext();) {
                        Shadow.Kind kind = (Shadow.Kind) iter.next();
                        assertFalse("No kinds that don't have a target",kind.neverHasTarget());
@@ -330,28 +330,28 @@ public class PointcutRewriterTest extends TestCase {
        
        public void testKindSetOfArgs() {
                Pointcut p = getPointcut("args(..)");
-               assertTrue("All kinds",p.couldMatchKinds().containsAll(Shadow.ALL_SHADOW_KINDS));
+               assertTrue("All kinds",p.couldMatchKinds()==Shadow.ALL_SHADOW_KINDS_BITS);
                // + @
                p = getPointcut("@args(..)");
-               assertTrue("All kinds",p.couldMatchKinds().containsAll(Shadow.ALL_SHADOW_KINDS));
+               assertTrue("All kinds",p.couldMatchKinds()==Shadow.ALL_SHADOW_KINDS_BITS);
        }
        
        public void testKindSetOfAnnotation() {
                Pointcut p = getPointcut("@annotation(Foo)");
-               assertTrue("All kinds",p.couldMatchKinds().containsAll(Shadow.ALL_SHADOW_KINDS));               
+               assertTrue("All kinds",p.couldMatchKinds()==Shadow.ALL_SHADOW_KINDS_BITS);              
        }
        
        public void testKindSetOfWithin() {
                Pointcut p = getPointcut("within(*)");
-               assertTrue("All kinds",p.couldMatchKinds().containsAll(Shadow.ALL_SHADOW_KINDS));
+               assertTrue("All kinds",p.couldMatchKinds()==Shadow.ALL_SHADOW_KINDS_BITS);
                // + @
                p = getPointcut("@within(Foo)");
-               assertTrue("All kinds",p.couldMatchKinds().containsAll(Shadow.ALL_SHADOW_KINDS));
+               assertTrue("All kinds",p.couldMatchKinds()==Shadow.ALL_SHADOW_KINDS_BITS);
        }
        
        public void testKindSetOfWithinCode() {
                Pointcut p = getPointcut("withincode(* foo(..))");
-               Set matches = p.couldMatchKinds();
+               Set matches = Shadow.toSet(p.couldMatchKinds());
                for (Iterator iter = matches.iterator(); iter.hasNext();) {
                        Shadow.Kind kind = (Shadow.Kind) iter.next();
                        assertFalse("No kinds that are themselves enclosing",
@@ -366,7 +366,7 @@ public class PointcutRewriterTest extends TestCase {
                assertTrue("Need init for inlined field inits",matches.contains(Shadow.Initialization));
                // + @
                p = getPointcut("@withincode(Foo)");
-               matches = p.couldMatchKinds();
+               matches = Shadow.toSet(p.couldMatchKinds());
                for (Iterator iter = matches.iterator(); iter.hasNext();) {
                        Shadow.Kind kind = (Shadow.Kind) iter.next();
                        assertFalse("No kinds that are themselves enclosing",kind.isEnclosingKind());
@@ -380,29 +380,29 @@ public class PointcutRewriterTest extends TestCase {
        
        public void testKindSetOfIf() {
                Pointcut p = new IfPointcut(null,0);
-               assertTrue("All kinds",p.couldMatchKinds().containsAll(Shadow.ALL_SHADOW_KINDS));
+               assertTrue("All kinds",p.couldMatchKinds()==Shadow.ALL_SHADOW_KINDS_BITS);
                p = IfPointcut.makeIfTruePointcut(Pointcut.CONCRETE);
-               assertTrue("All kinds",p.couldMatchKinds().containsAll(Shadow.ALL_SHADOW_KINDS));
+               assertTrue("All kinds",p.couldMatchKinds()==Shadow.ALL_SHADOW_KINDS_BITS);
                p = IfPointcut.makeIfFalsePointcut(Pointcut.CONCRETE);
-               assertTrue("Nothing",p.couldMatchKinds().isEmpty());
+               assertTrue("Nothing",p.couldMatchKinds()==Shadow.NO_SHADOW_KINDS_BITS);
        }
        
        public void testKindSetOfCflow() {
                Pointcut p = getPointcut("cflow(this(Foo))");
-               assertTrue("All kinds",p.couldMatchKinds().containsAll(Shadow.ALL_SHADOW_KINDS));
+               assertTrue("All kinds",p.couldMatchKinds()==Shadow.ALL_SHADOW_KINDS_BITS);
                // [below]
                p = getPointcut("cflowbelow(this(Foo))");
-               assertTrue("All kinds",p.couldMatchKinds().containsAll(Shadow.ALL_SHADOW_KINDS));
+               assertTrue("All kinds",p.couldMatchKinds()==Shadow.ALL_SHADOW_KINDS_BITS);
        }
        
        public void testKindSetInNegation() {
                Pointcut p = getPointcut("!execution(new(..))");
-               assertTrue("All kinds",p.couldMatchKinds().containsAll(Shadow.ALL_SHADOW_KINDS));               
+               assertTrue("All kinds",p.couldMatchKinds()==Shadow.ALL_SHADOW_KINDS_BITS);              
        }
        
        public void testKindSetOfOr() {
                Pointcut p = getPointcut("execution(new(..)) || get(* *)");
-               Set matches = p.couldMatchKinds();
+               Set matches = Shadow.toSet(p.couldMatchKinds());
                assertEquals("2 kinds",2,matches.size());
                assertTrue("ConstructorExecution",matches.contains(Shadow.ConstructorExecution));
                assertTrue("FieldGet",matches.contains(Shadow.FieldGet));