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 39 40 public class IntersectTypeName extends GenTypeName { 41 public String toShortString() { 42 return name1.toShortString() + " && " + name2.toShortString(); 43 } 44 45 public boolean matches(Type type) { 46 return name1.matches(type) && name2.matches(type); 47 } 48 49 public FuzzyBoolean matchesInstance(Type type) { 50 return name1.matchesInstance(type).and(name2.matchesInstance(type)); 51 } 52 53 public JpPlan makePlan(JoinPoint jp, Expr expr) { 54 JpPlan plan1 = name1.makePlan(jp, expr); 55 JpPlan plan2 = name2.makePlan(jp, expr); 56 return plan1.and(plan2); 57 } 58 59 protected GenTypeName name1; 61 public GenTypeName getName1() { return name1; } 62 public void setName1(GenTypeName _name1) { 63 if (_name1 != null) _name1.setParent(this); 64 name1 = _name1; 65 } 66 67 protected GenTypeName name2; 68 public GenTypeName getName2() { return name2; } 69 public void setName2(GenTypeName _name2) { 70 if (_name2 != null) _name2.setParent(this); 71 name2 = _name2; 72 } 73 74 public IntersectTypeName(SourceLocation location, GenTypeName _name1, GenTypeName _name2) { 75 super(location); 76 setName1(_name1); 77 setName2(_name2); 78 } 79 protected IntersectTypeName(SourceLocation source) { 80 super(source); 81 } 82 83 public ASTObject copyWalk(CopyWalker walker) { 84 IntersectTypeName ret = new IntersectTypeName(getSourceLocation()); 85 ret.preCopy(walker, this); 86 if (name1 != null) ret.setName1( (GenTypeName)walker.process(name1) ); 87 if (name2 != null) ret.setName2( (GenTypeName)walker.process(name2) ); 88 return ret; 89 } 90 91 public ASTObject getChildAt(int childIndex) { 92 switch(childIndex) { 93 case 0: return name1; 94 case 1: return name2; 95 default: return super.getChildAt(childIndex); 96 } 97 } 98 public String getChildNameAt(int childIndex) { 99 switch(childIndex) { 100 case 0: return "name1"; 101 case 1: return "name2"; 102 default: return super.getChildNameAt(childIndex); 103 } 104 } 105 public void setChildAt(int childIndex, ASTObject child) { 106 switch(childIndex) { 107 case 0: setName1((GenTypeName)child); return; 108 case 1: setName2((GenTypeName)child); return; 109 default: super.setChildAt(childIndex, child); return; 110 } 111 } 112 public int getChildCount() { 113 return 2; 114 } 115 116 public String getDefaultDisplayName() { 117 return "IntersectTypeName()"; 118 } 119 120 } 122 123 | Popular Tags |