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 31 import org.aspectj.util.*; 32 33 import java.util.*; 34 35 39 public class TargetPcd extends Pcd { 40 public String toShortString() { 41 return "target(" + getTypeName().toShortString() + ")"; 42 } 43 44 public boolean allowsNameBinding() { return true; } 45 public void checkStatic() { showNonStaticError(); } 46 47 public JpPlanner makePlanner(PlanData planData) { 48 return new JpPlanner() { 49 public FuzzyBoolean fastMatch(JoinPoint jp) { 50 if (jp.getTargetExprType() == null) return FuzzyBoolean.NO; 53 return getTypeName().matchesInstance(jp.getTargetExprType()); 54 } 55 public JpPlan makePlan(JoinPoint jp) { 56 if (jp.makeTargetExpr() == null) return JpPlan.NO_PLAN; 57 return getTypeName().makePlan(jp, jp.makeTargetExpr()); 58 } 59 }; 60 } 61 62 protected GenTypeName typeName; 64 public GenTypeName getTypeName() { return typeName; } 65 public void setTypeName(GenTypeName _typeName) { 66 if (_typeName != null) _typeName.setParent(this); 67 typeName = _typeName; 68 } 69 70 public TargetPcd(SourceLocation location, GenTypeName _typeName) { 71 super(location); 72 setTypeName(_typeName); 73 } 74 protected TargetPcd(SourceLocation source) { 75 super(source); 76 } 77 78 public ASTObject copyWalk(CopyWalker walker) { 79 TargetPcd ret = new TargetPcd(getSourceLocation()); 80 ret.preCopy(walker, this); 81 if (typeName != null) ret.setTypeName( (GenTypeName)walker.process(typeName) ); 82 return ret; 83 } 84 85 public ASTObject getChildAt(int childIndex) { 86 switch(childIndex) { 87 case 0: return typeName; 88 default: return super.getChildAt(childIndex); 89 } 90 } 91 public String getChildNameAt(int childIndex) { 92 switch(childIndex) { 93 case 0: return "typeName"; 94 default: return super.getChildNameAt(childIndex); 95 } 96 } 97 public void setChildAt(int childIndex, ASTObject child) { 98 switch(childIndex) { 99 case 0: setTypeName((GenTypeName)child); return; 100 default: super.setChildAt(childIndex, child); return; 101 } 102 } 103 public int getChildCount() { 104 return 1; 105 } 106 107 public String getDefaultDisplayName() { 108 return "TargetPcd()"; 109 } 110 111 } 113 114 | Popular Tags |