1 27 package ch.ethz.prose.filter; 28 29 import java.util.*; 31 import java.io.*; 32 import ch.ethz.jvmai.JoinPointKinds; 33 import ch.ethz.jvmai.JoinPoint; 34 import ch.ethz.jvmai.CodeJoinPoint; 35 import ch.ethz.prose.engine.JoinPointRequest; 36 import ch.ethz.prose.crosscut.MethodCut; 37 38 44 public 45 class Cflow { 46 47 static class BelowPointCutter extends PointCutter implements JoinPointKinds 48 { 49 PointCutter pcut; 50 protected BelowPointCutter(PointCutter pcut) 51 { 52 if (pcut == null) 53 throw new IllegalArgumentException ("the argument to Cflow.below cannot be null"); 54 55 acceptMask = MASK_ALL_JP; 56 canFilterStaticallyMask = 0; 57 mayFilterStaticallyMask = 0; 58 this.pcut = pcut; 59 } 60 61 protected boolean doIsSpecialRequest(JoinPointRequest jpr) 62 { 63 throw new Error ("if we cannot filter statically, we should not be here"); 64 } 65 66 protected boolean doIsSpecialEvent(CodeJoinPoint jpe) 67 { 68 try 69 { 70 CodeJoinPoint upper = jpe.getEnclosingJoinPoint(); 71 while (upper != null) 72 { 73 if (pcut.isSpecialEvent(upper)) 74 return true; 75 76 upper=upper.getEnclosingJoinPoint(); 77 } 78 return false; 79 } 80 catch (ch.ethz.jvmai.JVMAIRuntimeException e) 81 { 82 return false; 84 } 85 } 86 }; 87 88 static class BelowMethodCut extends PointCutter implements JoinPointKinds 89 { 90 MethodCut mcut; 91 protected BelowMethodCut(MethodCut methCut) 92 { 93 if (methCut == null) 94 throw new IllegalArgumentException ("the argument to Cflow.below cannot be null"); 95 acceptMask = MASK_ALL_JP; 96 canFilterStaticallyMask = 0; 97 mayFilterStaticallyMask = 0; 98 mcut = methCut; 99 } 100 101 protected boolean doIsSpecialRequest(JoinPointRequest jpr) 102 { 103 throw new Error ("if we cannot filter statically, we should not be here"); 104 } 105 106 protected boolean doIsSpecialEvent(CodeJoinPoint jpe) 107 { 108 try 109 { 110 CodeJoinPoint upper = jpe.getEnclosingJoinPoint(); 111 while (upper != null) 112 { 113 if (mcut.equivalentSpecializer().isSpecialEvent(upper)) 114 return true; 115 116 upper=upper.getEnclosingJoinPoint(); 117 } 118 return false; 119 } 120 catch (ch.ethz.jvmai.JVMAIRuntimeException e) 121 { 122 return false; 124 } 125 } 126 }; 127 128 public static PointCutter below(MethodCut mcut) 129 { 130 return new BelowMethodCut(mcut); 131 } 132 133 public static PointCutter below(PointCutter pcut) 134 { 135 return new BelowPointCutter(pcut); 136 } 137 138 } 139 140 141 | Popular Tags |