1 package polyglot.ext.coffer.types; 2 3 import polyglot.ext.param.types.*; 4 import polyglot.frontend.Source; 5 import polyglot.types.*; 6 import polyglot.util.*; 7 import java.util.*; 8 9 public class CofferTypeSystem_c extends ParamTypeSystem_c 10 implements CofferTypeSystem 11 { 12 protected void initTypes() { 13 } 16 17 public ParsedClassType createClassType(LazyClassInitializer init, 18 Source fromSource) 19 { 20 if (! init.fromClassFile()) { 21 return new CofferParsedClassType_c(this, init, fromSource); 22 } 23 else { 24 return super.createClassType(init, fromSource); 25 } 26 } 27 28 public MethodInstance methodInstance(Position pos, 29 ReferenceType container, 30 Flags flags, Type returnType, 31 String name, List argTypes, 32 List excTypes) { 33 34 List l = new LinkedList(); 35 36 for (Iterator i = excTypes.iterator(); i.hasNext(); ) { 37 Type t = (Type) i.next(); 38 l.add(throwConstraint(t.position(), t, emptyKeySet(pos))); 39 } 40 41 return cofferMethodInstance(pos, container, flags, returnType, name, 42 argTypes, emptyKeySet(pos), 43 emptyKeySet(pos), l); 44 } 45 46 public CofferMethodInstance cofferMethodInstance(Position pos, 47 ReferenceType container, 48 Flags flags, Type returnType, 49 String name, List argTypes, 50 KeySet entryKeys, 51 KeySet returnKeys, 52 List throwConstraints) { 53 54 CofferMethodInstance mi = new CofferMethodInstance_c(this, pos, 55 container, flags, 56 returnType, name, 57 argTypes, 58 entryKeys, 59 returnKeys, 60 throwConstraints); 61 return mi; 62 } 63 64 public ConstructorInstance constructorInstance(Position pos, 65 ClassType container, 66 Flags flags, 67 List argTypes, 68 List excTypes) { 69 70 List l = new LinkedList(); 71 72 for (Iterator i = excTypes.iterator(); i.hasNext(); ) { 73 Type t = (Type) i.next(); 74 l.add(throwConstraint(t.position(), t, emptyKeySet(pos))); 75 } 76 77 return cofferConstructorInstance(pos, container, flags, 78 argTypes, emptyKeySet(pos), 79 emptyKeySet(pos), l); 80 } 81 82 public CofferConstructorInstance cofferConstructorInstance(Position pos, 83 ClassType container, 84 Flags flags, 85 List argTypes, 86 KeySet entryKeys, 87 KeySet returnKeys, 88 List throwConstraints) { 89 90 CofferConstructorInstance ci = new CofferConstructorInstance_c(this, pos, 91 container, flags, 92 argTypes, 93 entryKeys, 94 returnKeys, 95 throwConstraints); 96 return ci; 97 } 98 99 public boolean canOverride(MethodInstance mi, MethodInstance mj) { 100 return super.canOverride(mi, mj); 101 } 102 103 public KeySet emptyKeySet(Position pos) { 104 return new KeySet_c(this, pos); 105 } 106 107 public InstKey instKey(Position pos, String name) { 108 return new InstKey_c(this, pos, name); 109 } 110 111 public UnknownKey unknownKey(Position pos, String name) { 112 return new UnknownKey_c(this, pos, name); 113 } 114 115 public ParamKey paramKey(Position pos, String name) { 116 return new ParamKey_c(this, pos, name); 117 } 118 119 public Subst subst(Map substMap, Map cache) { 120 return new CofferSubst_c(this, substMap, cache); 121 } 122 123 public ThrowConstraint throwConstraint(Position pos, Type type, KeySet keys) { 124 return new ThrowConstraint_c(this, pos, type, keys); 125 } 126 127 public Context createContext() { 128 return new CofferContext_c(this); 129 } 130 131 public Collection uncheckedExceptions() { 132 return CollectionUtil.list(Error(), NullPointerException()); 133 } 134 } 135 | Popular Tags |