1 24 25 package org.aspectj.compiler.base.cst; 26 27 import org.aspectj.compiler.base.ast.*; 28 import org.aspectj.compiler.base.*; 29 import java.util.*; 30 31 34 public class TypeScope extends Scope { 35 private Type type; 36 37 public TypeScope(JavaCompiler compiler, Scope parent, Type type) { 38 super(compiler, parent); 39 this.type = type; 40 } 41 public String shortToString() { return "TYPE(" + type.getString() + ")"; } 42 43 public Type findType(String name, ASTObject fromWhere) { 44 Type ret = type.getInnerType(name, fromWhere, false); 45 if (ret != getTypeManager().TYPE_NOT_FOUND && ret != null) return ret; 46 return super.findType(name, fromWhere); 49 } 50 51 public Expr bindUnqualifiedName(String name, ASTObject fromWhere) { 52 Field ret = type.getField(name, fromWhere, false); 53 if (ret != null) { 54 Expr thisExpr; 55 if (ret.isStatic()) thisExpr = getAST().makeTypeExpr(type); 56 else thisExpr = getAST().makeQualifiedThis(type); 57 return new FieldAccessExpr(fromWhere.getSourceLocation(), thisExpr, ret, false); 58 } 59 else return super.bindUnqualifiedName(name, fromWhere); 60 } 61 62 public Type findMethodLookupType(String name, ASTObject fromWhere) { 63 if (type.hasMethodNamed(name)) return type; 64 else return super.findMethodLookupType(name, fromWhere); 65 } 66 } 67 | Popular Tags |