return result;
}
-
/**
* Return the type of the 'extra argument'. For either after returning or after throwing advice, the extra argument will be the
* returned value or the thrown exception respectively. With annotation style the user may declare the parameters in any order,
// ---- fields
- public static final int ExtraArgument = 1;
- public static final int ThisJoinPoint = 2;
- public static final int ThisJoinPointStaticPart = 4;
- public static final int ThisEnclosingJoinPointStaticPart = 8;
- public static final int ParameterMask = 0xf;
-
+ public static final int ExtraArgument = 0x01;
+ public static final int ThisJoinPoint = 0x02;
+ public static final int ThisJoinPointStaticPart = 0x04;
+ public static final int ThisEnclosingJoinPointStaticPart = 0x08;
+ public static final int ParameterMask = 0x0f;
+ // For an if pointcut, this indicates it is hard wired to access a constant of either true or false
+ public static final int ConstantReference = 0x10;
+ // When the above flag is set, this indicates whether it is true or false
+ public static final int ConstantValue = 0x20;
public static final int CanInline = 0x40;
// for testing only
}
protected FuzzyBoolean matchInternal(Shadow shadow) {
+ if ((extraParameterFlags & Advice.ConstantReference) != 0) {
+ if ((extraParameterFlags & Advice.ConstantValue) != 0) {
+ return FuzzyBoolean.YES;
+ } else {
+ return FuzzyBoolean.NO;
+ }
+ }
// ??? this is not maximally efficient
return FuzzyBoolean.MAYBE;
}
* At each shadow that matched, the residue can be different.
*/
protected Test findResidueInternal(Shadow shadow, ExposedState state) {
- if (findingResidue)
+ if (findingResidue) {
return Literal.TRUE;
+ }
findingResidue = true;
try {
// code style
if (extraParameterFlags >= 0) {
+ if ((extraParameterFlags & Advice.ConstantReference) != 0) {
+ // it is either always true or always false, no need for test
+ if ((extraParameterFlags & Advice.ConstantValue) != 0) {
+ ret = Literal.TRUE;
+ ifLastMatchedShadowId = shadow.shadowId;
+ ifLastMatchedShadowResidue = ret;
+ return ret;
+ } else {
+ // Dont think we should be in here as the match cannot have succeeded...
+ ret = Literal.FALSE;
+ ifLastMatchedShadowId = shadow.shadowId;
+ ifLastMatchedShadowResidue = ret;
+ return ret;
+ }
+ }
+
// If there are no args to sort out, don't bother with the recursive call
if (baseArgsCount > 0) {
ExposedState myState = new ExposedState(baseArgsCount);
}
}
+ /**
+ * Called when it is determined that the pointcut refers to a constant value of TRUE or FALSE - enabling exact matching and no
+ * unnecessary calls to the method representing the if body.
+ */
+ public void setAlways(boolean matches) {
+ extraParameterFlags |= Advice.ConstantReference;
+ if (matches) {
+ extraParameterFlags |= Advice.ConstantValue;
+ }
+ }
+
}