massive rewrite of Code.java
[org.ibex.classgen.git] / src / org / ibex / classgen / Type.java
index af3da6b..5eba76d 100644 (file)
@@ -44,6 +44,7 @@ public class Type {
     public       boolean equals(java.lang.Object o) { return this==o; }
 
     public Type.Array  makeArray() { return (Type.Array)instance("["+descriptor); }
+    public Type.Array  makeArray(int i) { return i==0 ? this : makeArray().makeArray(i-1); }
 
     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"); }
@@ -152,6 +153,21 @@ public class Type {
             public final Type   returnType;
             public Type getArgType(int i) { return argTypes[i]; }
             public int  getNumArgs()      { return argTypes.length; }
+            public String debugToString() {
+                StringBuffer sb = new StringBuffer();
+                if (name.equals("<clinit>")) sb.append("static ");
+                else {
+                    if (name.equals("<init>"))
+                        sb.append(Class.this.getShortName());
+                    else
+                        sb.append(returnType).append(" ").append(name);
+                    sb.append("(");
+                    for(int i=0; i<argTypes.length; i++)
+                        sb.append((i==0?"":", ")+argTypes[i].debugToString());
+                    sb.append(") ");
+                }
+                return sb.toString();
+            }
             private Method(String name, Type returnType, Type[] argTypes) {
                 super(name);
                 this.argTypes = argTypes;