private String fixme() { throw new Error("fixme"); }
Object key() throws ClassGen.ClassReadExn {
switch(tag) {
- case 7: return Type.fromDescriptor(((Utf8Ent)e1).s);
+ case 7: return Type.instance(((Utf8Ent)e1).s);
case 8: return (((Utf8Ent)e1).s);
case 9: {
NameAndTypeKey nt = (NameAndTypeKey) e2.key();
- Type t = Type.fromDescriptor(nt.type);
+ Type t = Type.instance(nt.type);
if(t == null) throw new ClassGen.ClassReadExn("invalid type descriptor");
return new FieldRef((Type.Class)e1.key(), nt.name, t);
}
public final Type getType(int index) throws ClassGen.ClassReadExn {
Ent e = getByIndex(index);
- if (e instanceof Utf8Ent) return Type.fromDescriptor(((Utf8Ent)e).s);
+ if (e instanceof Utf8Ent) return Type.instance(((Utf8Ent)e).s);
else return (Type)e.key();
}
/** @see #ClassGen(Type.Class, Type.Class, int) */
public ClassGen(String name, String superName, int flags) {
- this(Type.fromDescriptor(name).asClass(), Type.fromDescriptor(superName).asClass(), flags);
+ this(Type.instance(name).asClass(), Type.instance(superName).asClass(), flags);
}
/** @see #ClassGen(Type.Class, Type.Class, int, Type.Class[]) */
/** Equivalent to FieldRef(new Type.Class(s), ...)
@see #FieldRef(Type.Class, String, Type, )
*/
- public FieldRef(String s, String name, Type t) { this(Type.fromDescriptor(s).asClass(), name, t); }
+ public FieldRef(String s, String name, Type t) { this(Type.instance(s).asClass(), name, t); }
}
name = cp.getUtf8ByIndex(in.readShort());
String descriptor = cp.getUtf8ByIndex(in.readShort());
String ret = descriptor.substring(descriptor.indexOf(')')+1);
- this.ret = Type.fromDescriptor(ret);
+ this.ret = Type.instance(ret);
//String args = descriptor.substring(1, descriptor.indexOf(')'));
args = new Type[0]; // FIXME
codeAttrs = null;
@see #MethodRef(Type.Class, String, Type, Type[])
*/
public MethodRef(String s, String name, Type ret, Type[] args) {
- this(Type.fromDescriptor(s).asClass(), name, ret, args);
+ this(Type.instance(s).asClass(), name, ret, args);
}
MethodRef(MethodRef i) { super(i); }
public static final Type[] NO_ARGS = new Type[0];
/** guarantee: there will only be one instance of Type for a given descriptor ==> equals() and == are interchangeable */
- public static Type fromDescriptor(String d) {
+ public static Type instance(String d) {
Type ret = (Type)instances.get(d);
if (ret != null) return ret;
- if (d.endsWith("[")) return new Type.Array(fromDescriptor(d.substring(d.length()-1)));
+ if (d.endsWith("[")) return new Type.Array(instance(d.substring(d.length()-1)));
return new Type.Class(d);
}
public int hashCode() { return descriptor.hashCode(); }
public boolean equals(java.lang.Object o) { return this==o; }
- public Type.Array makeArray() { return (Type.Array)fromDescriptor(descriptor+"["); }
+ public Type.Array makeArray() { return (Type.Array)instance(descriptor+"["); }
public Type.Ref asRef() { throw new RuntimeException("attempted to use "+this+" as a Type.Ref, which it is not"); }
public Type.Class asClass() { throw new RuntimeException("attempted to use "+this+" as a Type.Class, which it is not"); }