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 java.util.*; 32 import org.aspectj.util.FuzzyBoolean; 33 34 38 public class ThisPcd extends Pcd { 39 public String toShortString() { 40 return "this(" + getTypeName().toShortString() + ")"; 41 } 42 43 public boolean allowsNameBinding() { return true; } 44 public void checkStatic() { showNonStaticError(); } 45 46 public JpPlanner makePlanner(PlanData planData) { 47 return new JpPlanner() { 48 public FuzzyBoolean fastMatch(JoinPoint jp) { 49 if (jp.getThisExprType() == null) return FuzzyBoolean.NO; 52 return getTypeName().matchesInstance(jp.getThisExprType()); 53 } 54 public JpPlan makePlan(JoinPoint jp) { 55 if (jp.getSourceLocation() == null) return JpPlan.NEVER_PLAN; 56 if (jp.makeThisExpr() == null) return JpPlan.NO_PLAN; 57 return getTypeName().makePlan(jp, jp.makeThisExpr()); 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 ThisPcd(SourceLocation location, GenTypeName _typeName) { 71 super(location); 72 setTypeName(_typeName); 73 } 74 protected ThisPcd(SourceLocation source) { 75 super(source); 76 } 77 78 public ASTObject copyWalk(CopyWalker walker) { 79 ThisPcd ret = new ThisPcd(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 "ThisPcd()"; 109 } 110 111 } 113 114 | Popular Tags |