1 24 25 package org.aspectj.compiler.crosscuts.ast; 26 import org.aspectj.compiler.base.ast.*; 27 28 import org.aspectj.compiler.base.JavaCompiler; 29 30 34 public class NameTypeDsPattern extends ASTObject { 35 public boolean matches(TypeDs otherNames) { 36 if (otherNames == null) return trueNames.size() == 0; 37 38 int i; 39 final int N1 = trueNames.size(); 40 for(i=0; i<N1; i++) { 41 if (!otherNames.contains(trueNames.get(i))) return false; 43 } 44 45 final int N2 = falseNames.size(); 46 for(i=0; i<N2; i++) { 47 if (otherNames.contains(falseNames.get(i))) return false; 49 } 50 51 53 return true; 54 } 55 56 protected TypeDs trueNames; 58 public TypeDs getTrueNames() { return trueNames; } 59 public void setTrueNames(TypeDs _trueNames) { 60 if (_trueNames != null) _trueNames.setParent(this); 61 trueNames = _trueNames; 62 } 63 64 protected TypeDs falseNames; 65 public TypeDs getFalseNames() { return falseNames; } 66 public void setFalseNames(TypeDs _falseNames) { 67 if (_falseNames != null) _falseNames.setParent(this); 68 falseNames = _falseNames; 69 } 70 71 public NameTypeDsPattern(SourceLocation location, TypeDs _trueNames, TypeDs _falseNames) { 72 super(location); 73 setTrueNames(_trueNames); 74 setFalseNames(_falseNames); 75 } 76 protected NameTypeDsPattern(SourceLocation source) { 77 super(source); 78 } 79 80 public ASTObject copyWalk(CopyWalker walker) { 81 NameTypeDsPattern ret = new NameTypeDsPattern(getSourceLocation()); 82 ret.preCopy(walker, this); 83 if (trueNames != null) ret.setTrueNames( (TypeDs)walker.process(trueNames) ); 84 if (falseNames != null) ret.setFalseNames( (TypeDs)walker.process(falseNames) ); 85 return ret; 86 } 87 88 public ASTObject getChildAt(int childIndex) { 89 switch(childIndex) { 90 case 0: return trueNames; 91 case 1: return falseNames; 92 default: return super.getChildAt(childIndex); 93 } 94 } 95 public String getChildNameAt(int childIndex) { 96 switch(childIndex) { 97 case 0: return "trueNames"; 98 case 1: return "falseNames"; 99 default: return super.getChildNameAt(childIndex); 100 } 101 } 102 public void setChildAt(int childIndex, ASTObject child) { 103 switch(childIndex) { 104 case 0: setTrueNames((TypeDs)child); return; 105 case 1: setFalseNames((TypeDs)child); return; 106 default: super.setChildAt(childIndex, child); return; 107 } 108 } 109 public int getChildCount() { 110 return 2; 111 } 112 113 public String getDefaultDisplayName() { 114 return "NameTypeDsPattern()"; 115 } 116 117 } 119 120 | Popular Tags |