1 24 25 package org.aspectj.compiler.base.ast; 26 27 import org.aspectj.compiler.base.*; 28 import org.aspectj.compiler.base.cst.*; 29 30 import java.util.*; 31 32 33 37 public class ArrayTypeD extends TypeD { 38 public String getString() { 39 return componentTypeD.getString()+"[]"; 40 } 41 42 public String toShortString() { 43 return componentTypeD.toShortString()+"[]"; 44 } 45 46 public void unparse(CodeWriter writer) { 47 writer.write(componentTypeD); 48 writer.write("[]"); 49 } 50 51 public void checkSpec() { 52 if (componentTypeD.getType().isVoid()) { 53 showError("can't have an array of void"); 54 } else { 55 super.checkSpec(); 56 } 57 } 58 59 public Type getType() { 62 return componentTypeD.getType().getArrayType(); 63 } 64 65 public boolean equals(Object other) { 67 if (!(other instanceof ArrayTypeD)) return false; 68 return componentTypeD.equals(((ArrayTypeD)other).getComponentTypeD()); 69 } 70 71 protected TypeD componentTypeD; 73 public TypeD getComponentTypeD() { return componentTypeD; } 74 public void setComponentTypeD(TypeD _componentTypeD) { 75 if (_componentTypeD != null) _componentTypeD.setParent(this); 76 componentTypeD = _componentTypeD; 77 } 78 79 public ArrayTypeD(SourceLocation location, TypeD _componentTypeD) { 80 super(location); 81 setComponentTypeD(_componentTypeD); 82 } 83 protected ArrayTypeD(SourceLocation source) { 84 super(source); 85 } 86 87 public ASTObject copyWalk(CopyWalker walker) { 88 ArrayTypeD ret = new ArrayTypeD(getSourceLocation()); 89 ret.preCopy(walker, this); 90 if (componentTypeD != null) ret.setComponentTypeD( (TypeD)walker.process(componentTypeD) ); 91 return ret; 92 } 93 94 public ASTObject getChildAt(int childIndex) { 95 switch(childIndex) { 96 case 0: return componentTypeD; 97 default: return super.getChildAt(childIndex); 98 } 99 } 100 public String getChildNameAt(int childIndex) { 101 switch(childIndex) { 102 case 0: return "componentTypeD"; 103 default: return super.getChildNameAt(childIndex); 104 } 105 } 106 public void setChildAt(int childIndex, ASTObject child) { 107 switch(childIndex) { 108 case 0: setComponentTypeD((TypeD)child); return; 109 default: super.setChildAt(childIndex, child); return; 110 } 111 } 112 public int getChildCount() { 113 return 1; 114 } 115 116 public String getDefaultDisplayName() { 117 return "ArrayTypeD()"; 118 } 119 120 } 122 | Popular Tags |