Lines 27-56
Link Here
|
27 |
|
27 |
|
28 |
public class AndPointcut extends Pointcut { |
28 |
public class AndPointcut extends Pointcut { |
29 |
Pointcut left, right; // exposed for testing |
29 |
Pointcut left, right; // exposed for testing |
|
|
30 |
|
31 |
private final boolean evaluateLeftFirst; |
30 |
|
32 |
|
31 |
public AndPointcut(Pointcut left, Pointcut right) { |
33 |
public AndPointcut(Pointcut left, Pointcut right) { |
32 |
super(); |
34 |
super(); |
33 |
this.left = left; |
35 |
this.left = left; |
34 |
this.right = right; |
36 |
this.right = right; |
35 |
setLocation(left.getSourceContext(), left.getStart(), right.getEnd()); |
37 |
setLocation(left.getSourceContext(), left.getStart(), right.getEnd()); |
|
|
38 |
//if left pc is easier to match, match this one first |
39 |
this.evaluateLeftFirst = this.left.matchingCosts() < this.right.matchingCosts(); |
36 |
} |
40 |
} |
37 |
|
41 |
|
38 |
public FuzzyBoolean fastMatch(FastMatchInfo type) { |
42 |
public FuzzyBoolean fastMatch(FastMatchInfo type) { |
39 |
return left.fastMatch(type).and(right.fastMatch(type)); |
43 |
if(this.evaluateLeftFirst) { |
|
|
44 |
FuzzyBoolean leftValue = left.fastMatch(type); |
45 |
if(leftValue.maybeTrue()) { |
46 |
return leftValue.and(right.fastMatch(type)); |
47 |
} else { |
48 |
return leftValue; |
49 |
} |
50 |
} else { |
51 |
FuzzyBoolean rightValue = right.fastMatch(type); |
52 |
if(rightValue.maybeTrue()) { |
53 |
return rightValue.and(left.fastMatch(type)); |
54 |
} else { |
55 |
return rightValue; |
56 |
} |
57 |
} |
40 |
} |
58 |
} |
41 |
|
59 |
|
42 |
public FuzzyBoolean match(Shadow shadow) { |
60 |
public FuzzyBoolean match(Shadow shadow) { |
43 |
return left.match(shadow).and(right.match(shadow)); |
61 |
if(this.evaluateLeftFirst) { |
|
|
62 |
FuzzyBoolean leftValue = left.match(shadow); |
63 |
if(leftValue.maybeTrue()) { |
64 |
return leftValue.and(right.match(shadow)); |
65 |
} else { |
66 |
return leftValue; |
67 |
} |
68 |
} else { |
69 |
FuzzyBoolean rightValue = right.match(shadow); |
70 |
if(rightValue.maybeTrue()) { |
71 |
return rightValue.and(left.match(shadow)); |
72 |
} else { |
73 |
return rightValue; |
74 |
} |
75 |
} |
44 |
} |
76 |
} |
45 |
|
77 |
|
46 |
public FuzzyBoolean match(JoinPoint jp, JoinPoint.StaticPart encJP) { |
78 |
public FuzzyBoolean match(JoinPoint jp, JoinPoint.StaticPart encJP) { |
47 |
return left.match(jp,encJP).and(right.match(jp,encJP)); |
79 |
if(this.evaluateLeftFirst) { |
|
|
80 |
FuzzyBoolean leftValue = left.match(jp,encJP); |
81 |
if(leftValue.maybeTrue()) { |
82 |
return leftValue.and(right.match(jp,encJP)); |
83 |
} else { |
84 |
return leftValue; |
85 |
} |
86 |
} else { |
87 |
FuzzyBoolean rightValue = right.match(jp,encJP); |
88 |
if(rightValue.maybeTrue()) { |
89 |
return rightValue.and(left.match(jp,encJP)); |
90 |
} else { |
91 |
return rightValue; |
92 |
} |
93 |
} |
48 |
} |
94 |
} |
49 |
|
95 |
|
50 |
public FuzzyBoolean match(JoinPoint.StaticPart jpsp) { |
96 |
public FuzzyBoolean match(JoinPoint.StaticPart jpsp) { |
51 |
return left.match(jpsp).and(right.match(jpsp)); |
97 |
if(this.evaluateLeftFirst) { |
|
|
98 |
FuzzyBoolean leftValue = left.match(jpsp); |
99 |
if(leftValue.maybeTrue()) { |
100 |
return leftValue.and(right.match(jpsp)); |
101 |
} else { |
102 |
return leftValue; |
103 |
} |
104 |
} else { |
105 |
FuzzyBoolean rightValue = right.match(jpsp); |
106 |
if(rightValue.maybeTrue()) { |
107 |
return rightValue.and(left.match(jpsp)); |
108 |
} else { |
109 |
return rightValue; |
110 |
} |
111 |
} |
52 |
} |
112 |
} |
53 |
|
113 |
|
54 |
public String toString() { |
114 |
public String toString() { |
55 |
return "(" + left.toString() + " && " + right.toString() + ")"; |
115 |
return "(" + left.toString() + " && " + right.toString() + ")"; |
56 |
} |
116 |
} |