1 24 25 package org.aspectj.compiler.base.ast; 26 27 import org.aspectj.compiler.base.FlowCheckerPass; 28 import org.aspectj.compiler.base.JavaCompiler; 29 import org.aspectj.compiler.base.CodeWriter; 30 31 import org.aspectj.compiler.base.bcg.CodeBuilder; 32 import org.aspectj.compiler.base.bcg.Label; 33 34 38 public class TypeExpr extends Expr { 39 public Type discoverType() { return typeD.getType(); } 40 41 public void unparse(CodeWriter writer) { 42 typeD.unparse(writer, true); 44 } 45 46 public Expr makeReference() { 47 return (Expr)this.copy(); 48 } 49 50 53 public void checkSpec() { 55 super.checkSpec(); 56 if (fromSource() && getType() != null && 58 getType().getTypeDec() != null && 59 !getType().getTypeDec().isAccessible(this)) { 60 showError("can't access " + getType().getTypeDec().toShortString()); 61 return; 62 } 63 64 ASTObject self = this; 66 ASTObject parent = getParent(); 67 68 while (true) { 70 if (parent instanceof Expr) { 71 if (parent instanceof CallExpr) { 72 if ((((CallExpr)parent).getExpr() == self) 73 && ((CallExpr)parent).getMethod().isStatic()) return; 74 } else if (parent instanceof FieldAccessExpr) { 75 if ((((FieldAccessExpr)parent).getExpr() == self) 76 && ((FieldAccessExpr)parent).getField().isStatic()) return; 77 } else if (parent instanceof ParenExpr) { 78 self = parent; 79 parent = parent.getParent(); 80 continue; 81 } 82 } 83 break; 84 } 85 showError("bad identifier"); 86 } 87 88 91 protected void cgValue(CodeBuilder cb) {} 92 protected void cgEffect(CodeBuilder cb) {} 93 94 protected TypeD typeD; 96 public TypeD getTypeD() { return typeD; } 97 public void setTypeD(TypeD _typeD) { 98 if (_typeD != null) _typeD.setParent(this); 99 typeD = _typeD; 100 } 101 102 public TypeExpr(SourceLocation location, TypeD _typeD) { 103 super(location); 104 setTypeD(_typeD); 105 } 106 protected TypeExpr(SourceLocation source) { 107 super(source); 108 } 109 110 public ASTObject copyWalk(CopyWalker walker) { 111 TypeExpr ret = new TypeExpr(getSourceLocation()); 112 ret.preCopy(walker, this); 113 if (typeD != null) ret.setTypeD( (TypeD)walker.process(typeD) ); 114 return ret; 115 } 116 117 public ASTObject getChildAt(int childIndex) { 118 switch(childIndex) { 119 case 0: return typeD; 120 default: return super.getChildAt(childIndex); 121 } 122 } 123 public String getChildNameAt(int childIndex) { 124 switch(childIndex) { 125 case 0: return "typeD"; 126 default: return super.getChildNameAt(childIndex); 127 } 128 } 129 public void setChildAt(int childIndex, ASTObject child) { 130 switch(childIndex) { 131 case 0: setTypeD((TypeD)child); return; 132 default: super.setChildAt(childIndex, child); return; 133 } 134 } 135 public int getChildCount() { 136 return 1; 137 } 138 139 public String getDefaultDisplayName() { 140 return "TypeExpr()"; 141 } 142 143 } 145 | Popular Tags |