renamed Type.fromDescriptor() to Type.instance()
authoradam <adam@megacz.com>
Fri, 3 Jun 2005 04:11:54 +0000 (04:11 +0000)
committeradam <adam@megacz.com>
Fri, 3 Jun 2005 04:11:54 +0000 (04:11 +0000)
darcs-hash:20050603041154-5007d-55bab0641ed0c19724691ec93d29814044876f78.gz

src/org/ibex/classgen/CPGen.java
src/org/ibex/classgen/ClassGen.java
src/org/ibex/classgen/FieldRef.java
src/org/ibex/classgen/MethodGen.java
src/org/ibex/classgen/MethodRef.java
src/org/ibex/classgen/Type.java

index 8ac9e7f..d249bfd 100644 (file)
@@ -87,11 +87,11 @@ class CPGen {
         private String fixme() { throw new Error("fixme"); }
         Object key() throws ClassGen.ClassReadExn {
             switch(tag) {
         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();
                 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);
                 }
                     if(t == null) throw new ClassGen.ClassReadExn("invalid type descriptor");
                     return new FieldRef((Type.Class)e1.key(), nt.name, t);
                 }
@@ -166,7 +166,7 @@ class CPGen {
 
     public final Type getType(int index) throws ClassGen.ClassReadExn {
         Ent e = getByIndex(index);
 
     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();
     }
 
         else return (Type)e.key();
     }
 
index e336723..39bd113 100644 (file)
@@ -62,7 +62,7 @@ public class ClassGen implements CGConst {
 
     /** @see #ClassGen(Type.Class, Type.Class, int) */
     public ClassGen(String name, String superName, int flags) {
 
     /** @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[]) */
     }
 
     /** @see #ClassGen(Type.Class, Type.Class, int, Type.Class[]) */
index 9a4b790..62460e1 100644 (file)
@@ -13,5 +13,5 @@ public class FieldRef extends ClassGen.FieldOrMethodRef {
     /** Equivalent to FieldRef(new Type.Class(s), ...)
         @see #FieldRef(Type.Class, String, Type, )
     */
     /** 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); }
 }
 }
index 632fc79..2fde5d3 100644 (file)
@@ -55,7 +55,7 @@ public class MethodGen implements CGConst {
         name = cp.getUtf8ByIndex(in.readShort());
         String descriptor = cp.getUtf8ByIndex(in.readShort());
         String ret = descriptor.substring(descriptor.indexOf(')')+1);
         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;
         //String args = descriptor.substring(1, descriptor.indexOf(')'));
         args = new Type[0]; // FIXME
         codeAttrs = null;
index 6460280..2f69e9a 100644 (file)
@@ -17,7 +17,7 @@ public class MethodRef extends ClassGen.FieldOrMethodRef {
         @see #MethodRef(Type.Class, String, Type, Type[])
     */
     public MethodRef(String s, String name, Type ret, Type[] args) {
         @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); }
     
     }
     MethodRef(MethodRef i) { super(i); }
     
index bc6160c..a8a68d8 100644 (file)
@@ -30,10 +30,10 @@ public class Type {
     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 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;
         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);
     }
 
         return new Type.Class(d);
     }
 
@@ -42,7 +42,7 @@ public class Type {
     public       int     hashCode() { return descriptor.hashCode(); }
     public       boolean equals(java.lang.Object o) { return this==o; }
 
     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"); }
 
     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"); }