]> source.dussan.org Git - aspectj.git/commitdiff
303758: fixes
authoraclement <aclement>
Wed, 24 Feb 2010 18:33:20 +0000 (18:33 +0000)
committeraclement <aclement>
Wed, 24 Feb 2010 18:33:20 +0000 (18:33 +0000)
org.aspectj.matcher/src/org/aspectj/weaver/patterns/ExposedState.java
org.aspectj.matcher/src/org/aspectj/weaver/patterns/Pointcut.java

index fb34da91c56869050662e3646ca5b60b62d3b3cc..127db0406eb8e7b6797d0f637eb4fd3c458e15e2 100644 (file)
@@ -10,7 +10,6 @@
  *     PARC     initial implementation 
  * ******************************************************************/
 
-
 package org.aspectj.weaver.patterns;
 
 import java.util.Arrays;
@@ -22,6 +21,7 @@ import org.aspectj.weaver.ast.Expr;
 import org.aspectj.weaver.ast.Var;
 
 public class ExposedState {
+       public static final boolean[] NO_ERRONEOUS_VARS = new boolean[0];
        public Var[] vars;
        private boolean[] erroneousVars;
        private Expr aspectInstance;
@@ -29,37 +29,45 @@ public class ExposedState {
 
        public ExposedState(int size) {
                super();
-               vars = new Var[size];
-               erroneousVars = new boolean[size];
+               if (size == 0) {
+                       vars = Var.NONE;
+                       erroneousVars = NO_ERRONEOUS_VARS;
+               } else {
+                       vars = new Var[size];
+                       erroneousVars = new boolean[size];
+
+               }
        }
 
        public ExposedState(Member signature) {
                // XXX there maybe something about target for non-static sigs
                this(signature.getParameterTypes().length);
                expectedVarTypes = new UnresolvedType[signature.getParameterTypes().length];
-               if (expectedVarTypes.length>0) {
+               if (expectedVarTypes.length > 0) {
                        for (int i = 0; i < signature.getParameterTypes().length; i++) {
                                expectedVarTypes[i] = signature.getParameterTypes()[i];
                        }
                }
-               
+
        }
-       
+
        public boolean isFullySetUp() {
                for (int i = 0; i < vars.length; i++) {
-                       if (vars[i]==null) return false;
+                       if (vars[i] == null)
+                               return false;
                }
                return true;
        }
 
        public void set(int i, Var var) {
                // check the type is OK if we can... these are the same rules as in matchesInstanceOf() processing
-               if (expectedVarTypes!=null) {
+               if (expectedVarTypes != null) {
                        ResolvedType expected = expectedVarTypes[i].resolve(var.getType().getWorld());
                        if (!expected.equals(ResolvedType.OBJECT)) {
                                if (!expected.isAssignableFrom(var.getType())) {
                                        if (!var.getType().isCoerceableFrom(expected)) {
-//                                             throw new BCException("Expected type "+expectedVarTypes[i]+" in slot "+i+" but attempt to put "+var.getType()+" into it");
+                                               // throw new
+                                               // BCException("Expected type "+expectedVarTypes[i]+" in slot "+i+" but attempt to put "+var.getType()+" into it");
                                                return;
                                        }
                                }
@@ -67,31 +75,33 @@ public class ExposedState {
                }
                vars[i] = var;
        }
-    public Var get(int i) {
-        return vars[i];
-    }
-    public int size() {
-        return vars.length;
-    }
 
-    public Expr getAspectInstance() {
-        return aspectInstance;
-    }
+       public Var get(int i) {
+               return vars[i];
+       }
+
+       public int size() {
+               return vars.length;
+       }
+
+       public Expr getAspectInstance() {
+               return aspectInstance;
+       }
 
-    public void setAspectInstance(Expr aspectInstance) {
-        this.aspectInstance = aspectInstance;
-    }
+       public void setAspectInstance(Expr aspectInstance) {
+               this.aspectInstance = aspectInstance;
+       }
 
        public String toString() {
-               return "ExposedState(#Vars="+vars.length+",Vars=" + Arrays.asList(vars) + ",AspectInstance=" + aspectInstance + ")";
+               return "ExposedState(#Vars=" + vars.length + ",Vars=" + Arrays.asList(vars) + ",AspectInstance=" + aspectInstance + ")";
        }
 
        // Set to true if we have reported an error message against it,
        // prevents us blowing up in later code gen.
        public void setErroneousVar(int formalIndex) {
-               erroneousVars[formalIndex]=true;
+               erroneousVars[formalIndex] = true;
        }
-       
+
        public boolean isErroneousVar(int formalIndex) {
                return erroneousVars[formalIndex];
        }
index 6eb4d0b542708955157ba13738c15df198306cf0..da8d98eee3cbee8821e8df68cac32ecbac51c2b9 100644 (file)
@@ -78,7 +78,9 @@ public abstract class Pointcut extends PatternNode {
         * ATAJ the name of the formal for which we don't want any warning when unbound since we consider them as implicitly bound. f.e.
         * JoinPoint for @AJ advices
         */
-       public String[] m_ignoreUnboundBindingForNames = new String[0];
+       public String[] m_ignoreUnboundBindingForNames = EMPTY_STRING_ARRAY;
+
+       public static final String[] EMPTY_STRING_ARRAY = new String[0];
 
        public static final State SYMBOLIC = new State("symbolic", 0);
        public static final State RESOLVED = new State("resolved", 1);
@@ -90,7 +92,7 @@ public abstract class Pointcut extends PatternNode {
 
        protected int lastMatchedShadowId;
        private FuzzyBoolean lastMatchedShadowResult;
-       private String[] typeVariablesInScope = new String[0];
+       private String[] typeVariablesInScope = EMPTY_STRING_ARRAY;
 
        protected boolean hasBeenParameterized = false;