1 package polyglot.types; 2 3 import polyglot.util.*; 4 import polyglot.main.Report; 5 import java.util.*; 6 7 12 public class ClassContextResolver extends ClassResolver { 13 TypeSystem ts; 14 ClassType type; 15 16 21 public ClassContextResolver(TypeSystem ts, ClassType type) { 22 this.ts = ts; 23 this.type = type; 24 } 25 26 public String toString() { 27 return "(class-context " + type + ")"; 28 } 29 30 34 public Named find(String name) throws SemanticException { 35 if (Report.should_report(TOPICS, 2)) 36 Report.report(2, "Looking for " + name + " in " + this); 37 38 if (! StringUtil.isNameShort(name)) { 39 throw new InternalCompilerError( 40 "Cannot lookup qualified name " + name); 41 } 42 43 ClassType inner = ts.findMemberClass(type, name); 45 46 if (inner != null) { 47 if (Report.should_report(TOPICS, 2)) 48 Report.report(2, "Found member class " + inner); 49 return inner; 50 } 51 52 throw new NoClassException(name, type); 53 } 54 55 58 public ClassType classType() { 59 return type; 60 } 61 62 private static final Collection TOPICS = 63 CollectionUtil.list(Report.types, Report.resolver); 64 65 } 66 | Popular Tags |