From 377c02631b475eb33c82f4f3ad7f97efd7a1bdb7 Mon Sep 17 00:00:00 2001 From: jhugunin Date: Tue, 21 Jan 2003 18:55:23 +0000 Subject: changed class name to match change from declare dominates to declare precedence --- .../org/aspectj/weaver/CrosscuttingMembers.java | 2 +- weaver/src/org/aspectj/weaver/World.java | 2 +- .../src/org/aspectj/weaver/patterns/Declare.java | 2 +- .../aspectj/weaver/patterns/DeclareDominates.java | 131 --------------------- .../aspectj/weaver/patterns/DeclarePrecedence.java | 131 +++++++++++++++++++++ .../org/aspectj/weaver/patterns/PatternParser.java | 4 +- .../aspectj/weaver/bcel/WeaveOrderTestCase.java | 2 +- 7 files changed, 137 insertions(+), 137 deletions(-) delete mode 100644 weaver/src/org/aspectj/weaver/patterns/DeclareDominates.java create mode 100644 weaver/src/org/aspectj/weaver/patterns/DeclarePrecedence.java (limited to 'weaver') diff --git a/weaver/src/org/aspectj/weaver/CrosscuttingMembers.java b/weaver/src/org/aspectj/weaver/CrosscuttingMembers.java index 21be96474..1ffb5dfdf 100644 --- a/weaver/src/org/aspectj/weaver/CrosscuttingMembers.java +++ b/weaver/src/org/aspectj/weaver/CrosscuttingMembers.java @@ -93,7 +93,7 @@ public class CrosscuttingMembers { if (declare instanceof DeclareErrorOrWarning) { ShadowMunger m = new Checker((DeclareErrorOrWarning)declare); addShadowMunger(m); - } else if (declare instanceof DeclareDominates) { + } else if (declare instanceof DeclarePrecedence) { declareDominates.add(declare); } else if (declare instanceof DeclareParents) { DeclareParents dp = (DeclareParents)declare; diff --git a/weaver/src/org/aspectj/weaver/World.java b/weaver/src/org/aspectj/weaver/World.java index 156c449ac..a97664fd6 100644 --- a/weaver/src/org/aspectj/weaver/World.java +++ b/weaver/src/org/aspectj/weaver/World.java @@ -278,7 +278,7 @@ public abstract class World { //??? This method can be called a large number of times. int order = 0; for (Iterator i = crosscuttingMembersSet.getDeclareDominates().iterator(); i.hasNext(); ) { - DeclareDominates d = (DeclareDominates)i.next(); + DeclarePrecedence d = (DeclarePrecedence)i.next(); int thisOrder = d.compare(aspect1, aspect2); //System.out.println("comparing: " + thisOrder + ": " + d); if (thisOrder != 0) { diff --git a/weaver/src/org/aspectj/weaver/patterns/Declare.java b/weaver/src/org/aspectj/weaver/patterns/Declare.java index 415043dee..14e04eae1 100644 --- a/weaver/src/org/aspectj/weaver/patterns/Declare.java +++ b/weaver/src/org/aspectj/weaver/patterns/Declare.java @@ -29,7 +29,7 @@ public abstract class Declare extends PatternNode { case ERROR_OR_WARNING: return DeclareErrorOrWarning.read(s, context); case DOMINATES: - return DeclareDominates.read(s, context); + return DeclarePrecedence.read(s, context); case PARENTS: return DeclareParents.read(s, context); case SOFT: diff --git a/weaver/src/org/aspectj/weaver/patterns/DeclareDominates.java b/weaver/src/org/aspectj/weaver/patterns/DeclareDominates.java deleted file mode 100644 index b5c9f563f..000000000 --- a/weaver/src/org/aspectj/weaver/patterns/DeclareDominates.java +++ /dev/null @@ -1,131 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC). - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Common Public License v1.0 - * which accompanies this distribution and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * PARC initial implementation - * ******************************************************************/ - - -package org.aspectj.weaver.patterns; - -import java.io.*; -import java.util.List; - -import org.aspectj.bridge.IMessage; -import org.aspectj.weaver.*; -import org.aspectj.weaver.ResolvedTypeX; - -public class DeclareDominates extends Declare { - private TypePatternList patterns; - - - public DeclareDominates(List patterns) { - this(new TypePatternList(patterns)); - } - - private DeclareDominates(TypePatternList patterns) { - this.patterns = patterns; - } - - public String toString() { - StringBuffer buf = new StringBuffer(); - buf.append("declare precedence: "); - buf.append(patterns); - buf.append(";"); - return buf.toString(); - } - - public boolean equals(Object other) { - if (!(other instanceof DeclareDominates)) return false; - DeclareDominates o = (DeclareDominates)other; - return o.patterns.equals(patterns); - } - - public int hashCode() { - return patterns.hashCode(); - } - - - public void write(DataOutputStream s) throws IOException { - s.writeByte(Declare.DOMINATES); - patterns.write(s); - writeLocation(s); - } - - public static Declare read(DataInputStream s, ISourceContext context) throws IOException { - Declare ret = new DeclareDominates(TypePatternList.read(s, context)); - ret.readLocation(context, s); - return ret; - } - - public void resolve(IScope scope) { - patterns = patterns.resolveBindings(scope, Bindings.NONE, false, false); - - for (int i=0; i < patterns.size(); i++) { - TypePattern pi = patterns.get(i); - if (pi.isStar()) continue; - ResolvedTypeX exactType = pi.getExactType().resolve(scope.getWorld()); - if (exactType == ResolvedTypeX.MISSING) continue; - for (int j=0; j < patterns.size(); j++) { - if (j == i) continue; - TypePattern pj = patterns.get(j); - if (pj.isStar()) continue; - if (pj.matchesStatically(exactType)) { - scope.getWorld().showMessage(IMessage.ERROR, - "circularity in declare dominates, '" + exactType.getName() + - "' matches two patterns", pi.getSourceLocation(), pj.getSourceLocation()); - } - } - } - } - - public TypePatternList getPatterns() { - return patterns; - } - - private int matchingIndex(ResolvedTypeX a) { - int knownMatch = -1; - int starMatch = -1; - for (int i=0, len=patterns.size(); i < len; i++) { - TypePattern p = patterns.get(i); - if (p.isStar()) { - starMatch = i; - } else if (p.matchesStatically(a)) { - if (knownMatch != -1) { - a.getWorld().showMessage(IMessage.ERROR, "multiple matches for " + a + - ", matches both " + patterns.get(knownMatch) + " and " + p, - patterns.get(knownMatch).getSourceLocation(), p.getSourceLocation()); - return -1; - } else { - knownMatch = i; - } - } - } - if (knownMatch == -1) return starMatch; - else return knownMatch; - } - - - public int compare(ResolvedTypeX aspect1, ResolvedTypeX aspect2) { - int index1 = matchingIndex(aspect1); - int index2 = matchingIndex(aspect2); - - //System.out.println("a1: " + aspect1 + ", " + aspect2 + " = " + index1 + ", " + index2); - - if (index1 == -1 || index2 == -1) return 0; - - if (index1 == index2) return 0; - else if (index1 > index2) return -1; - else return +1; - } - - public boolean isAdviceLike() { - return false; - } - -} diff --git a/weaver/src/org/aspectj/weaver/patterns/DeclarePrecedence.java b/weaver/src/org/aspectj/weaver/patterns/DeclarePrecedence.java new file mode 100644 index 000000000..837bbc7ce --- /dev/null +++ b/weaver/src/org/aspectj/weaver/patterns/DeclarePrecedence.java @@ -0,0 +1,131 @@ +/* ******************************************************************* + * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC). + * All rights reserved. + * This program and the accompanying materials are made available + * under the terms of the Common Public License v1.0 + * which accompanies this distribution and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * PARC initial implementation + * ******************************************************************/ + + +package org.aspectj.weaver.patterns; + +import java.io.*; +import java.util.List; + +import org.aspectj.bridge.IMessage; +import org.aspectj.weaver.*; +import org.aspectj.weaver.ResolvedTypeX; + +public class DeclarePrecedence extends Declare { + private TypePatternList patterns; + + + public DeclarePrecedence(List patterns) { + this(new TypePatternList(patterns)); + } + + private DeclarePrecedence(TypePatternList patterns) { + this.patterns = patterns; + } + + public String toString() { + StringBuffer buf = new StringBuffer(); + buf.append("declare precedence: "); + buf.append(patterns); + buf.append(";"); + return buf.toString(); + } + + public boolean equals(Object other) { + if (!(other instanceof DeclarePrecedence)) return false; + DeclarePrecedence o = (DeclarePrecedence)other; + return o.patterns.equals(patterns); + } + + public int hashCode() { + return patterns.hashCode(); + } + + + public void write(DataOutputStream s) throws IOException { + s.writeByte(Declare.DOMINATES); + patterns.write(s); + writeLocation(s); + } + + public static Declare read(DataInputStream s, ISourceContext context) throws IOException { + Declare ret = new DeclarePrecedence(TypePatternList.read(s, context)); + ret.readLocation(context, s); + return ret; + } + + public void resolve(IScope scope) { + patterns = patterns.resolveBindings(scope, Bindings.NONE, false, false); + + for (int i=0; i < patterns.size(); i++) { + TypePattern pi = patterns.get(i); + if (pi.isStar()) continue; + ResolvedTypeX exactType = pi.getExactType().resolve(scope.getWorld()); + if (exactType == ResolvedTypeX.MISSING) continue; + for (int j=0; j < patterns.size(); j++) { + if (j == i) continue; + TypePattern pj = patterns.get(j); + if (pj.isStar()) continue; + if (pj.matchesStatically(exactType)) { + scope.getWorld().showMessage(IMessage.ERROR, + "circularity in declare dominates, '" + exactType.getName() + + "' matches two patterns", pi.getSourceLocation(), pj.getSourceLocation()); + } + } + } + } + + public TypePatternList getPatterns() { + return patterns; + } + + private int matchingIndex(ResolvedTypeX a) { + int knownMatch = -1; + int starMatch = -1; + for (int i=0, len=patterns.size(); i < len; i++) { + TypePattern p = patterns.get(i); + if (p.isStar()) { + starMatch = i; + } else if (p.matchesStatically(a)) { + if (knownMatch != -1) { + a.getWorld().showMessage(IMessage.ERROR, "multiple matches for " + a + + ", matches both " + patterns.get(knownMatch) + " and " + p, + patterns.get(knownMatch).getSourceLocation(), p.getSourceLocation()); + return -1; + } else { + knownMatch = i; + } + } + } + if (knownMatch == -1) return starMatch; + else return knownMatch; + } + + + public int compare(ResolvedTypeX aspect1, ResolvedTypeX aspect2) { + int index1 = matchingIndex(aspect1); + int index2 = matchingIndex(aspect2); + + //System.out.println("a1: " + aspect1 + ", " + aspect2 + " = " + index1 + ", " + index2); + + if (index1 == -1 || index2 == -1) return 0; + + if (index1 == index2) return 0; + else if (index1 > index2) return -1; + else return +1; + } + + public boolean isAdviceLike() { + return false; + } + +} diff --git a/weaver/src/org/aspectj/weaver/patterns/PatternParser.java b/weaver/src/org/aspectj/weaver/patterns/PatternParser.java index 315272981..9b1ce7455 100644 --- a/weaver/src/org/aspectj/weaver/patterns/PatternParser.java +++ b/weaver/src/org/aspectj/weaver/patterns/PatternParser.java @@ -109,13 +109,13 @@ public class PatternParser { return ret; } - public DeclareDominates parseDominates() { + public DeclarePrecedence parseDominates() { List l = new ArrayList(); do { l.add(parseTypePattern()); } while (maybeEat(",")); - return new DeclareDominates(l); + return new DeclarePrecedence(l); } private Declare parseParents() { diff --git a/weaver/testsrc/org/aspectj/weaver/bcel/WeaveOrderTestCase.java b/weaver/testsrc/org/aspectj/weaver/bcel/WeaveOrderTestCase.java index 270faf6fc..da9818622 100644 --- a/weaver/testsrc/org/aspectj/weaver/bcel/WeaveOrderTestCase.java +++ b/weaver/testsrc/org/aspectj/weaver/bcel/WeaveOrderTestCase.java @@ -19,7 +19,7 @@ import java.io.*; import org.apache.bcel.Constants; import org.apache.bcel.generic.*; import org.aspectj.weaver.patterns.*; -import org.aspectj.weaver.patterns.DeclareDominates; +import org.aspectj.weaver.patterns.DeclarePrecedence; import org.aspectj.weaver.*; /**. -- cgit v1.2.3