1 24 25 package org.aspectj.compiler.crosscuts.ast; 26 import org.aspectj.compiler.base.ast.*; 27 import org.aspectj.compiler.crosscuts.joinpoints.*; 28 29 import org.aspectj.compiler.base.JavaCompiler; 30 import org.aspectj.util.FuzzyBoolean; 31 32 import java.util.*; 33 34 38 public abstract class KindedPcd extends Pcd { 39 public void checkStatic() { } 40 public String toShortString() { 41 return getKind() + "(" + getPattern().toShortString() + ")"; 42 } 43 44 public abstract String getKind(); 45 public abstract int getJpKind(); 46 47 public JpPlanner makePlanner(PlanData planData) { 48 return new JpPlanner() { 49 public FuzzyBoolean fastMatch(JoinPoint jp) { 50 if (!(jp.getTypeCode() == getJpKind())) return FuzzyBoolean.NO; 51 52 53 return getPattern().matches(jp); 54 } 55 }; 56 } 57 58 protected DecPattern pattern; 60 public DecPattern getPattern() { return pattern; } 61 public void setPattern(DecPattern _pattern) { 62 if (_pattern != null) _pattern.setParent(this); 63 pattern = _pattern; 64 } 65 66 public KindedPcd(SourceLocation location, DecPattern _pattern) { 67 super(location); 68 setPattern(_pattern); 69 } 70 protected KindedPcd(SourceLocation source) { 71 super(source); 72 } 73 74 public ASTObject getChildAt(int childIndex) { 75 switch(childIndex) { 76 case 0: return pattern; 77 default: return super.getChildAt(childIndex); 78 } 79 } 80 public String getChildNameAt(int childIndex) { 81 switch(childIndex) { 82 case 0: return "pattern"; 83 default: return super.getChildNameAt(childIndex); 84 } 85 } 86 public void setChildAt(int childIndex, ASTObject child) { 87 switch(childIndex) { 88 case 0: setPattern((DecPattern)child); return; 89 default: super.setChildAt(childIndex, child); return; 90 } 91 } 92 public int getChildCount() { 93 return 1; 94 } 95 96 public String getDefaultDisplayName() { 97 return "KindedPcd()"; 98 } 99 100 } 102 103 | Popular Tags |