formatting only: added spaces after commas
authoradam <adam@megacz.com>
Fri, 3 Jun 2005 00:49:54 +0000 (00:49 +0000)
committeradam <adam@megacz.com>
Fri, 3 Jun 2005 00:49:54 +0000 (00:49 +0000)
darcs-hash:20050603004954-5007d-11f9a4975ad76ffafd67736e765da2c4728d3b3a.gz

src/org/ibex/classgen/CGConst.java
src/org/ibex/classgen/CPGen.java
src/org/ibex/classgen/ClassGen.java
src/org/ibex/classgen/FieldGen.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 ca59d67..e67218c 100644 (file)
@@ -235,15 +235,15 @@ public interface CGConst {
 
 /*
 #!/usr/bin/perl -w
 
 /*
 #!/usr/bin/perl -w
-@ARGV || push @ARGV,$0;
+@ARGV || push @ARGV, $0;
 my @a = ();
 while(<>) {
         chomp;
         next unless(m|byte ([A-Z0-9_]+) = .*?([0-9xA-F]+);\s+//\s*(.*)$|i);
 my @a = ();
 while(<>) {
         chomp;
         next unless(m|byte ([A-Z0-9_]+) = .*?([0-9xA-F]+);\s+//\s*(.*)$|i);
-        my ($name,$num) = ($1,hex($2));
+        my ($name, $num) = ($1, hex($2));
         $_ = $3;
         my $n = 1<<5;
         $_ = $3;
         my $n = 1<<5;
-        $n |= s/^(\d+)// ? $1 : (s/^V//||die,7);
+        $n |= s/^(\d+)// ? $1 : (s/^V//||die, 7);
         $n |= (1<<4) if(s/^C//);
         $n |= (1<<3) if(s/^B//);
         die if(/./);
         $n |= (1<<4) if(s/^C//);
         $n |= (1<<3) if(s/^B//);
         die if(/./);
@@ -251,7 +251,7 @@ while(<>) {
 }
 print "private static final byte[] OP_DATA = {\n\t";
 for(my $i=0;$i<256;$i++) {
 }
 print "private static final byte[] OP_DATA = {\n\t";
 for(my $i=0;$i<256;$i++) {
-        printf "0x%02x%s", $a[$i]||1, $i==255?"\n};\n":($i%16)==15?",\n\t":", ";
+        printf "0x%02x%s", $a[$i]||1, $i==255?"\n};\n":($i%16)==15?", \n\t":", ";
 }
 __END__
 */
 }
 __END__
 */
index 01ef840..3a453d1 100644 (file)
@@ -36,7 +36,7 @@ class CPGen {
     // INVARIANTS: tag == 3 || tag == 4
     static class IntEnt extends Ent {
         int i;
     // INVARIANTS: tag == 3 || tag == 4
     static class IntEnt extends Ent {
         int i;
-        IntEnt(CPGen owner, int tag) { super(owner,tag); }
+        IntEnt(CPGen owner, int tag) { super(owner, tag); }
         void dump(DataOutput o) throws IOException { super.dump(o); o.writeInt(i);  }
         Object key() {
             switch(tag) {
         void dump(DataOutput o) throws IOException { super.dump(o); o.writeInt(i);  }
         Object key() {
             switch(tag) {
@@ -50,7 +50,7 @@ class CPGen {
     // INVARIANTS: tag == 5 || tag == 6
     static class LongEnt extends Ent {
         long l;
     // INVARIANTS: tag == 5 || tag == 6
     static class LongEnt extends Ent {
         long l;
-        LongEnt(CPGen owner, int tag) { super(owner,tag); }
+        LongEnt(CPGen owner, int tag) { super(owner, tag); }
         void dump(DataOutput o) throws IOException { super.dump(o); o.writeLong(l); }
         Object key() {
             switch(tag) {
         void dump(DataOutput o) throws IOException { super.dump(o); o.writeLong(l); }
         Object key() {
             switch(tag) {
@@ -75,7 +75,7 @@ class CPGen {
     static class CPRefEnt extends Ent {
         Ent e1;
         Ent e2;
     static class CPRefEnt extends Ent {
         Ent e1;
         Ent e2;
-        CPRefEnt(CPGen owner, int tag) { super(owner,tag); }
+        CPRefEnt(CPGen owner, int tag) { super(owner, tag); }
         
         String debugToString() { return "[" + e1.n + ":" + e1.debugToString() + (e2 == null ? "" : " + " + e2.n + ":" + e2.debugToString()) + "]"; }
         
         
         String debugToString() { return "[" + e1.n + ":" + e1.debugToString() + (e2 == null ? "" : " + " + e2.n + ":" + e2.debugToString()) + "]"; }
         
@@ -107,7 +107,7 @@ class CPGen {
         
     static class Utf8Ent extends Ent {
         String s;
         
     static class Utf8Ent extends Ent {
         String s;
-        Utf8Ent(CPGen owner) { super(owner,1); }
+        Utf8Ent(CPGen owner) { super(owner, 1); }
         String debugToString() { return s; }
         void dump(DataOutput o) throws IOException { super.dump(o); o.writeUTF(s); }
         Object key() { throw new Error("Brian is lame"); }
         String debugToString() { return s; }
         void dump(DataOutput o) throws IOException { super.dump(o); o.writeUTF(s); }
         Object key() { throw new Error("Brian is lame"); }
@@ -166,7 +166,7 @@ class CPGen {
         return e;
     }
     
         return e;
     }
     
-    public final Ent addNameAndType(String name, String descriptor) { return add(new NameAndTypeKey(name,descriptor)); }
+    public final Ent addNameAndType(String name, String descriptor) { return add(new NameAndTypeKey(name, descriptor)); }
     public final Ent addUtf8(String s) { return add(new Utf8Key(s)); }
     
     public final Ent add(Object o) {
     public final Ent addUtf8(String s) { return add(new Utf8Key(s)); }
     
     public final Ent add(Object o) {
@@ -179,27 +179,27 @@ class CPGen {
         }
         
         if(o instanceof Type.Object) {
         }
         
         if(o instanceof Type.Object) {
-            CPRefEnt ce = new CPRefEnt(this,7);
+            CPRefEnt ce = new CPRefEnt(this, 7);
             ce.e1 = addUtf8(((Type.Object)o).internalForm());
             ent = ce;
         } else if(o instanceof String) {
             ce.e1 = addUtf8(((Type.Object)o).internalForm());
             ent = ce;
         } else if(o instanceof String) {
-            CPRefEnt ce = new CPRefEnt(this,8);
+            CPRefEnt ce = new CPRefEnt(this, 8);
             ce.e1 = addUtf8((String)o);
             ent = ce;
         } else if(o instanceof Integer) {
             ce.e1 = addUtf8((String)o);
             ent = ce;
         } else if(o instanceof Integer) {
-            IntEnt ue = new IntEnt(this,3);
+            IntEnt ue = new IntEnt(this, 3);
             ue.i = ((Integer)o).intValue();
             ent = ue;
         } else if(o instanceof Float) {
             ue.i = ((Integer)o).intValue();
             ent = ue;
         } else if(o instanceof Float) {
-            IntEnt ue = new IntEnt(this,4);
+            IntEnt ue = new IntEnt(this, 4);
             ue.i = Float.floatToIntBits(((Float)o).floatValue());
             ent = ue;
         } else if(o instanceof Long) {
             ue.i = Float.floatToIntBits(((Float)o).floatValue());
             ent = ue;
         } else if(o instanceof Long) {
-            LongEnt le = new LongEnt(this,5);
+            LongEnt le = new LongEnt(this, 5);
             le.l = ((Long)o).longValue();
             ent = le;
         } else if(o instanceof Double) {
             le.l = ((Long)o).longValue();
             ent = le;
         } else if(o instanceof Double) {
-            LongEnt le = new LongEnt(this,6);
+            LongEnt le = new LongEnt(this, 6);
             le.l = Double.doubleToLongBits(((Double)o).doubleValue());
             ent = le;
         } else if(o instanceof Utf8Key) {
             le.l = Double.doubleToLongBits(((Double)o).doubleValue());
             ent = le;
         } else if(o instanceof Utf8Key) {
@@ -207,7 +207,7 @@ class CPGen {
             ue.s = ((Utf8Key)o).s;
             ent = ue;
         } else if(o instanceof NameAndTypeKey) {
             ue.s = ((Utf8Key)o).s;
             ent = ue;
         } else if(o instanceof NameAndTypeKey) {
-            CPRefEnt ce = new CPRefEnt(this,12);
+            CPRefEnt ce = new CPRefEnt(this, 12);
             NameAndTypeKey key = (NameAndTypeKey) o;
             ce.e1 = addUtf8(key.name);
             ce.e2 = addUtf8(key.type);
             NameAndTypeKey key = (NameAndTypeKey) o;
             ce.e1 = addUtf8(key.name);
             ce.e2 = addUtf8(key.type);
@@ -216,9 +216,9 @@ class CPGen {
             ClassGen.FieldOrMethodRef key = (ClassGen.FieldOrMethodRef) o;
             int tag = o instanceof FieldRef ? 9 : o instanceof MethodRef ? 10 : o instanceof MethodRef.I ? 11 : 0;
             if(tag == 0) throw new Error("should never happen");
             ClassGen.FieldOrMethodRef key = (ClassGen.FieldOrMethodRef) o;
             int tag = o instanceof FieldRef ? 9 : o instanceof MethodRef ? 10 : o instanceof MethodRef.I ? 11 : 0;
             if(tag == 0) throw new Error("should never happen");
-            CPRefEnt ce = new CPRefEnt(this,tag);
+            CPRefEnt ce = new CPRefEnt(this, tag);
             ce.e1 = add(key.klass);
             ce.e1 = add(key.klass);
-            ce.e2 = addNameAndType(key.name,key.descriptor);
+            ce.e2 = addNameAndType(key.name, key.descriptor);
             ent = ce;
         } else {
             throw new IllegalArgumentException("Unknown type passed to add");
             ent = ce;
         } else {
             throw new IllegalArgumentException("Unknown type passed to add");
@@ -231,7 +231,7 @@ class CPGen {
 
         usedSlots += spaces;        
 
 
         usedSlots += spaces;        
 
-        entries.put(o,ent);
+        entries.put(o, ent);
         return ent;
     }
     
         return ent;
     }
     
@@ -281,7 +281,7 @@ class CPGen {
     public void optimize() {
         if(state != OPEN) throw new IllegalStateException("can't optimize a stable constant pool");
         Ent[] ents = asArray();
     public void optimize() {
         if(state != OPEN) throw new IllegalStateException("can't optimize a stable constant pool");
         Ent[] ents = asArray();
-        Sort.sort(ents,reverseCompareFunc);
+        Sort.sort(ents, reverseCompareFunc);
         state = STABLE;
         assignIndex(ents);
     }
         state = STABLE;
         assignIndex(ents);
     }
@@ -299,7 +299,7 @@ class CPGen {
     
     public void dump(DataOutput o) throws IOException {
         Ent[] ents = asArray();
     
     public void dump(DataOutput o) throws IOException {
         Ent[] ents = asArray();
-        Sort.sort(ents,compareFunc);
+        Sort.sort(ents, compareFunc);
         o.writeShort(usedSlots);
         for(int i=0;i<ents.length;i++) {
             //System.err.println("" + ents[i].n + ": " + ents[i].debugToString());
         o.writeShort(usedSlots);
         for(int i=0;i<ents.length;i++) {
             //System.err.println("" + ents[i].n + ": " + ents[i].debugToString());
@@ -329,7 +329,7 @@ class CPGen {
                 case 11: // Instance Method Ref
                 case 12: // NameAndType
                 {
                 case 11: // Instance Method Ref
                 case 12: // NameAndType
                 {
-                    e = new CPRefEnt(this,tag);
+                    e = new CPRefEnt(this, tag);
                     e1s[index] = in.readUnsignedShort();;
                     if(tag != 7 && tag != 8) e2s[index] = in.readUnsignedShort();
                     break;
                     e1s[index] = in.readUnsignedShort();;
                     if(tag != 7 && tag != 8) e2s[index] = in.readUnsignedShort();
                     break;
@@ -338,7 +338,7 @@ class CPGen {
                 case 4: // Float
                 {
                     IntEnt ie;
                 case 4: // Float
                 {
                     IntEnt ie;
-                    e = ie = new IntEnt(this,tag);
+                    e = ie = new IntEnt(this, tag);
                     ie.i = in.readInt();
                     break;
                 }
                     ie.i = in.readInt();
                     break;
                 }
@@ -346,7 +346,7 @@ class CPGen {
                 case 6: // Double
                 {
                     LongEnt le;
                 case 6: // Double
                 {
                     LongEnt le;
-                    e = le = new LongEnt(this,tag);
+                    e = le = new LongEnt(this, tag);
                     le.l = in.readLong();
                     index++;
                     break;
                     le.l = in.readLong();
                     index++;
                     break;
@@ -398,7 +398,7 @@ class CPGen {
             } else if(e instanceof LongEnt) {
                 index++;
             }
             } else if(e instanceof LongEnt) {
                 index++;
             }
-            entries.put(e.key(),e);
+            entries.put(e.key(), e);
         }
         state = STABLE;
     }
         }
         state = STABLE;
     }
index 1300c3a..99436e2 100644 (file)
@@ -17,14 +17,14 @@ public class ClassGen implements CGConst {
     final CPGen cp;
     private final AttrGen attributes;
     
     final CPGen cp;
     private final AttrGen attributes;
     
-    /** @see #ClassGen(Type.Object,Type.Object,int) */
+    /** @see #ClassGen(Type.Object, Type.Object, int) */
     public ClassGen(String name, String superName, int flags) {
         this(Type.fromDescriptor(name).asObject(), Type.fromDescriptor(superName).asObject(), flags);
     }
 
     public ClassGen(String name, String superName, int flags) {
         this(Type.fromDescriptor(name).asObject(), Type.fromDescriptor(superName).asObject(), flags);
     }
 
-    /** @see #ClassGen(Type.Object,Type.Object,int,Type.Object[]) */
-    public ClassGen(Type.Object thisType,Type.Object superType, int flags) {
-        this(thisType,superType,flags,null);
+    /** @see #ClassGen(Type.Object, Type.Object, int, Type.Object[]) */
+    public ClassGen(Type.Object thisType, Type.Object superType, int flags) {
+        this(thisType, superType, flags, null);
     }
     
     /** Creates a new ClassGen object 
     }
     
     /** Creates a new ClassGen object 
@@ -32,7 +32,7 @@ public class ClassGen implements CGConst {
         @param superType The superclass of the generated class (commonly Type.OBJECT) 
         @param flags The access flags for this class (ACC_PUBLIC, ACC_FINAL, ACC_SUPER, ACC_INTERFACE, and ACC_ABSTRACT)
     */
         @param superType The superclass of the generated class (commonly Type.OBJECT) 
         @param flags The access flags for this class (ACC_PUBLIC, ACC_FINAL, ACC_SUPER, ACC_INTERFACE, and ACC_ABSTRACT)
     */
-    public ClassGen(Type.Object thisType,Type.Object superType, int flags, Type.Object[] interfaces) {
+    public ClassGen(Type.Object thisType, Type.Object superType, int flags, Type.Object[] interfaces) {
         if((flags & ~(ACC_PUBLIC|ACC_FINAL|ACC_SUPER|ACC_INTERFACE|ACC_ABSTRACT)) != 0)
             throw new IllegalArgumentException("invalid flags");
         this.thisType = thisType;
         if((flags & ~(ACC_PUBLIC|ACC_FINAL|ACC_SUPER|ACC_INTERFACE|ACC_ABSTRACT)) != 0)
             throw new IllegalArgumentException("invalid flags");
         this.thisType = thisType;
@@ -56,7 +56,7 @@ public class ClassGen implements CGConst {
         @see CGConst
     */
     public final MethodGen addMethod(String name, Type ret, Type[] args, int flags) {
         @see CGConst
     */
     public final MethodGen addMethod(String name, Type ret, Type[] args, int flags) {
-        MethodGen mg = new MethodGen(this,name,ret,args,flags);
+        MethodGen mg = new MethodGen(this, name, ret, args, flags);
         methods.addElement(mg);
         return mg;
     }
         methods.addElement(mg);
         return mg;
     }
@@ -72,7 +72,7 @@ public class ClassGen implements CGConst {
         @see CGConst
         */  
     public final FieldGen addField(String name, Type type, int flags) {
         @see CGConst
         */  
     public final FieldGen addField(String name, Type type, int flags) {
-        FieldGen fg = new FieldGen(this,name,type,flags);
+        FieldGen fg = new FieldGen(this, name, type, flags);
         fields.addElement(fg);
         return fg;
     }
         fields.addElement(fg);
         return fg;
     }
@@ -96,10 +96,10 @@ public class ClassGen implements CGConst {
             String[] a = thisType.components();
             int i;
             for(i=0;i<a.length-1;i++) {
             String[] a = thisType.components();
             int i;
             for(i=0;i<a.length-1;i++) {
-                f = new File(f,a[i]);
+                f = new File(f, a[i]);
                 f.mkdir();
             }
                 f.mkdir();
             }
-            f = new File(f,a[i] + ".class");
+            f = new File(f, a[i] + ".class");
         }
         OutputStream os = new FileOutputStream(f);
         dump(os);
         }
         OutputStream os = new FileOutputStream(f);
         dump(os);
@@ -125,7 +125,7 @@ public class ClassGen implements CGConst {
         cp.add(thisType);
         cp.add(superType);
         if(interfaces != null) for(int i=0;i<interfaces.length;i++) cp.add(interfaces[i]);
         cp.add(thisType);
         cp.add(superType);
         if(interfaces != null) for(int i=0;i<interfaces.length;i++) cp.add(interfaces[i]);
-        if(sourceFile != null && !attributes.contains("SourceFile")) attributes.add("SourceFile",cp.addUtf8(sourceFile));
+        if(sourceFile != null && !attributes.contains("SourceFile")) attributes.add("SourceFile", cp.addUtf8(sourceFile));
                 
         for(int i=0;i<methods.size();i++) ((MethodGen)methods.elementAt(i)).finish();
         for(int i=0;i<fields.size();i++) ((FieldGen)fields.elementAt(i)).finish();
                 
         for(int i=0;i<methods.size();i++) ((MethodGen)methods.elementAt(i)).finish();
         for(int i=0;i<fields.size();i++) ((FieldGen)fields.elementAt(i)).finish();
@@ -228,7 +228,7 @@ public class ClassGen implements CGConst {
         
         public void add(String s, Object data) {
             cp.addUtf8(s);
         
         public void add(String s, Object data) {
             cp.addUtf8(s);
-            ht.put(s,data);
+            ht.put(s, data);
         }
         
         public boolean contains(String s) { return ht.get(s) != null; }
         }
         
         public boolean contains(String s) { return ht.get(s) != null; }
@@ -256,28 +256,28 @@ public class ClassGen implements CGConst {
     
     /*public static void main(String[] args) throws Exception {
         Type.Object me = new Type.Object("Test");
     
     /*public static void main(String[] args) throws Exception {
         Type.Object me = new Type.Object("Test");
-        ClassGen cg = new ClassGen("Test","java.lang.Object",ACC_PUBLIC|ACC_SUPER|ACC_FINAL);
-        FieldGen fg = cg.addField("foo",Type.INT,ACC_PUBLIC|ACC_STATIC);
+        ClassGen cg = new ClassGen("Test", "java.lang.Object", ACC_PUBLIC|ACC_SUPER|ACC_FINAL);
+        FieldGen fg = cg.addField("foo", Type.INT, ACC_PUBLIC|ACC_STATIC);
         
         
-        MethodGen mg = cg.addMethod("main",Type.VOID,new Type[]{Type.arrayType(Type.STRING)},ACC_STATIC|ACC_PUBLIC);
+        MethodGen mg = cg.addMethod("main", Type.VOID, new Type[]{Type.arrayType(Type.STRING)}, ACC_STATIC|ACC_PUBLIC);
         mg.setMaxLocals(1);
         mg.addPushConst(0);
         //mg.add(ISTORE_0);
         mg.setMaxLocals(1);
         mg.addPushConst(0);
         //mg.add(ISTORE_0);
-        mg.add(PUTSTATIC, fieldRef(me,"foo",Type.INT));
+        mg.add(PUTSTATIC, fieldRef(me, "foo", Type.INT));
         int top = mg.size();
         int top = mg.size();
-        mg.add(GETSTATIC,cg.fieldRef(new Type.Object("java.lang.System"),"out",new Type.Object("java.io.PrintStream")));
+        mg.add(GETSTATIC, cg.fieldRef(new Type.Object("java.lang.System"), "out", new Type.Object("java.io.PrintStream")));
         //mg.add(ILOAD_0);
         //mg.add(ILOAD_0);
-        mg.add(GETSTATIC,cg.fieldRef(me,"foo",Type.INT));
-        mg.add(INVOKEVIRTUAL,cg.methodRef(new Type.Object("java.io.PrintStream"),"println",Type.VOID, new Type[]{Type.INT}));
-        //mg.add(IINC,new int[]{0,1});
+        mg.add(GETSTATIC, cg.fieldRef(me, "foo", Type.INT));
+        mg.add(INVOKEVIRTUAL, cg.methodRef(new Type.Object("java.io.PrintStream"), "println", Type.VOID, new Type[]{Type.INT}));
+        //mg.add(IINC, new int[]{0, 1});
         //mg.add(ILOAD_0);
         //mg.add(ILOAD_0);
-        mg.add(GETSTATIC,cg.fieldRef(me,"foo",Type.INT));
+        mg.add(GETSTATIC, cg.fieldRef(me, "foo", Type.INT));
         mg.addPushConst(1);
         mg.add(IADD);
         mg.add(DUP);
         mg.addPushConst(1);
         mg.add(IADD);
         mg.add(DUP);
-        mg.add(PUTSTATIC,cg.fieldRef(me,"foo",Type.INT));       
+        mg.add(PUTSTATIC, cg.fieldRef(me, "foo", Type.INT));       
         mg.addPushConst(10);
         mg.addPushConst(10);
-        mg.add(IF_ICMPLT,top);
+        mg.add(IF_ICMPLT, top);
         mg.add(RETURN);
         cg.dump("Test.class");
     }*/
         mg.add(RETURN);
         cg.dump("Test.class");
     }*/
index e4f6763..330849b 100644 (file)
@@ -14,7 +14,7 @@ public class FieldGen implements CGConst {
     private Object constantValue;
     
     FieldGen(DataInput in) { throw new Error("Brian is lame"); }
     private Object constantValue;
     
     FieldGen(DataInput in) { throw new Error("Brian is lame"); }
-    FieldGen(ClassGen owner, String name,Type type, int flags) {
+    FieldGen(ClassGen owner, String name, Type type, int flags) {
         if((flags & ~(ACC_PUBLIC|ACC_PRIVATE|ACC_PROTECTED|ACC_VOLATILE|ACC_TRANSIENT|ACC_STATIC|ACC_FINAL)) != 0)
             throw new IllegalArgumentException("invalid flags");
         this.cp = owner.cp;
         if((flags & ~(ACC_PUBLIC|ACC_PRIVATE|ACC_PROTECTED|ACC_VOLATILE|ACC_TRANSIENT|ACC_STATIC|ACC_FINAL)) != 0)
             throw new IllegalArgumentException("invalid flags");
         this.cp = owner.cp;
@@ -36,7 +36,7 @@ public class FieldGen implements CGConst {
     
     void finish() {
         if(constantValue != null && !attrs.contains("ConstantValue"))
     
     void finish() {
         if(constantValue != null && !attrs.contains("ConstantValue"))
-            attrs.add("ConstantValue",cp.add(constantValue));
+            attrs.add("ConstantValue", cp.add(constantValue));
     }
     
     void dump(DataOutput o) throws IOException {
     }
     
     void dump(DataOutput o) throws IOException {
index 2d6bc0e..9548a24 100644 (file)
@@ -9,9 +9,9 @@ GETFIELD, PUTFIELD, GETSTATIC, and PUTSTATCI bytecodes
 */
 public class FieldRef extends ClassGen.FieldOrMethodRef {
     /** Create a reference to field <i>name</i> of class <i>c</i> with the type <i>t</i>  */    
 */
 public class FieldRef extends ClassGen.FieldOrMethodRef {
     /** Create a reference to field <i>name</i> of class <i>c</i> with the type <i>t</i>  */    
-    public FieldRef(Type.Object c, String name, Type t) { super(c,name,t.getDescriptor()); }
-    /** Equivalent to FieldRef(new Type.Object(s),...)
-        @see #FieldRef(Type.Object,String,Type,)
+    public FieldRef(Type.Object c, String name, Type t) { super(c, name, t.getDescriptor()); }
+    /** Equivalent to FieldRef(new Type.Object(s), ...)
+        @see #FieldRef(Type.Object, String, Type, )
     */
     public FieldRef(String s, String name, Type t) { this(Type.fromDescriptor(s).asObject(), name, t); }
 }
     */
     public FieldRef(String s, String name, Type t) { this(Type.fromDescriptor(s).asObject(), name, t); }
 }
index 547330d..88c35bb 100644 (file)
@@ -47,11 +47,11 @@ public class MethodGen implements CGConst {
         
         if((owner.flags & ACC_INTERFACE) != 0 || (flags & (ACC_ABSTRACT|ACC_NATIVE)) != 0) size = capacity = -1;
         
         
         if((owner.flags & ACC_INTERFACE) != 0 || (flags & (ACC_ABSTRACT|ACC_NATIVE)) != 0) size = capacity = -1;
         
-        maxLocals = Math.max(args.length + (flags&ACC_STATIC)==0 ? 1 : 0,4);
+        maxLocals = Math.max(args.length + (flags&ACC_STATIC)==0 ? 1 : 0, 4);
     }
     
     /** Returns the descriptor string for this method */
     }
     
     /** Returns the descriptor string for this method */
-    public String getDescriptor() { return MethodRef.getDescriptor(ret,args); }
+    public String getDescriptor() { return MethodRef.getDescriptor(ret, args); }
     
     private class ExnTableEnt {
         public int start;
     
     private class ExnTableEnt {
         public int start;
@@ -72,14 +72,14 @@ public class MethodGen implements CGConst {
         }
     }
     
         }
     }
     
-    /** Adds an exception handler for the range [<i>start</i>,<i>end</i>) pointing to <i>handler</i>
+    /** Adds an exception handler for the range [<i>start</i>, <i>end</i>) pointing to <i>handler</i>
         @param start The instruction to start at (inclusive)
         @param end The instruction to end at (exclusive)
         @param handler The instruction of the excepton handler
         @param type The type of exception that is to be handled (MUST inherit from Throwable)
     */
     public final void addExceptionHandler(int start, int end, int handler, Type.Object type) {
         @param start The instruction to start at (inclusive)
         @param end The instruction to end at (exclusive)
         @param handler The instruction of the excepton handler
         @param type The type of exception that is to be handled (MUST inherit from Throwable)
     */
     public final void addExceptionHandler(int start, int end, int handler, Type.Object type) {
-        exnTable.put(type, new ExnTableEnt(start,end,handler,cp.add(type)));
+        exnTable.put(type, new ExnTableEnt(start, end, handler, cp.add(type)));
     }
     
     /** Adds a exception type that can be thrown from this method
     }
     
     /** Adds a exception type that can be thrown from this method
@@ -87,7 +87,7 @@ public class MethodGen implements CGConst {
         @param type The type of exception that can be thrown 
     */
     public final void addThrow(Type.Object type) {
         @param type The type of exception that can be thrown 
     */
     public final void addThrow(Type.Object type) {
-        thrownExceptions.put(type,cp.add(type));
+        thrownExceptions.put(type, cp.add(type));
     }
     
     private final void grow() { if(size == capacity) grow(size+1); }
     }
     
     private final void grow() { if(size == capacity) grow(size+1); }
@@ -95,14 +95,14 @@ public class MethodGen implements CGConst {
         if(capacity == NO_CODE) throw new IllegalStateException("method can't have code");
         if(capacity == FINISHED) throw new IllegalStateException("method has been finished");
         if(newCap <= capacity) return;
         if(capacity == NO_CODE) throw new IllegalStateException("method can't have code");
         if(capacity == FINISHED) throw new IllegalStateException("method has been finished");
         if(newCap <= capacity) return;
-        newCap = Math.max(newCap,capacity == 0 ? 256 : capacity*2);
+        newCap = Math.max(newCap, capacity == 0 ? 256 : capacity*2);
         
         byte[] op2 = new byte[newCap];
         
         byte[] op2 = new byte[newCap];
-        if(capacity != 0) System.arraycopy(op,0,op2,0,size);
+        if(capacity != 0) System.arraycopy(op, 0, op2, 0, size);
         op = op2;
         
         Object[] arg2 = new Object[newCap];
         op = op2;
         
         Object[] arg2 = new Object[newCap];
-        if(capacity != 0) System.arraycopy(arg,0,arg2,0,size);
+        if(capacity != 0) System.arraycopy(arg, 0, arg2, 0, size);
         arg = arg2;
         
         capacity = newCap;
         arg = arg2;
         
         capacity = newCap;
@@ -128,17 +128,17 @@ public class MethodGen implements CGConst {
     /** Adds a bytecode, <i>op</i>, with argument <i>arg</i> to the method 
         @return The position of the new bytecode
         */
     /** Adds a bytecode, <i>op</i>, with argument <i>arg</i> to the method 
         @return The position of the new bytecode
         */
-    public final int add(byte op, Object arg) { if(capacity == size) grow(); set(size,op,arg); return size++; }
-    /** Adds a bytecode with a boolean argument - equivalent to add(op,arg?1:0);
+    public final int add(byte op, Object arg) { if(capacity == size) grow(); set(size, op, arg); return size++; }
+    /** Adds a bytecode with a boolean argument - equivalent to add(op, arg?1:0);
         @return The position of the new bytecode
         @return The position of the new bytecode
-        @see #add(byte,int)
+        @see #add(byte, int)
     */
     */
-    public final int add(byte op, boolean arg) { if(capacity == size) grow(); set(size,op,arg); return size++; }
-    /** Adds a bytecode with an integer argument. This is equivalent to add(op,new Integer(arg)), but optimized to prevent the allocation when possible
+    public final int add(byte op, boolean arg) { if(capacity == size) grow(); set(size, op, arg); return size++; }
+    /** Adds a bytecode with an integer argument. This is equivalent to add(op, new Integer(arg)), but optimized to prevent the allocation when possible
         @return The position of the new bytecode
         @return The position of the new bytecode
-        @see #add(byte,Object)
+        @see #add(byte, Object)
     */
     */
-    public final int add(byte op, int arg) { if(capacity == size) grow(); set(size,op,arg); return size++; }
+    public final int add(byte op, int arg) { if(capacity == size) grow(); set(size, op, arg); return size++; }
     
     /** Gets the bytecode at position <i>pos</i>
         @exception ArrayIndexOutOfBoundException if pos < 0 || pos >= size()
     
     /** Gets the bytecode at position <i>pos</i>
         @exception ArrayIndexOutOfBoundException if pos < 0 || pos >= size()
@@ -153,24 +153,24 @@ public class MethodGen implements CGConst {
     */    
     public final Object getArg(int pos) { return arg[pos]; }
     
     */    
     public final Object getArg(int pos) { return arg[pos]; }
     
-    /** Sets the argument for <i>pos</i> to <i>arg</i>. This is equivalent to set(pos,op,new Integer(arg)), but optimized to prevent the allocation when possible.
+    /** Sets the argument for <i>pos</i> to <i>arg</i>. This is equivalent to set(pos, op, new Integer(arg)), but optimized to prevent the allocation when possible.
         @exception ArrayIndexOutOfBoundException if pos < 0 || pos >= size()
         @exception ArrayIndexOutOfBoundException if pos < 0 || pos >= size()
-        @see #setArg(int,Object) */
-    public final void setArg(int pos, int arg) { set(pos,op[pos],N(arg)); }
+        @see #setArg(int, Object) */
+    public final void setArg(int pos, int arg) { set(pos, op[pos], N(arg)); }
     /** Sets the argument for <i>pos</i> to <i>arg</i>.
         @exception ArrayIndexOutOfBoundException if pos < 0 || pos >= size()
     */
     /** Sets the argument for <i>pos</i> to <i>arg</i>.
         @exception ArrayIndexOutOfBoundException if pos < 0 || pos >= size()
     */
-    public final void setArg(int pos, Object arg) { set(pos,op[pos],arg); }
+    public final void setArg(int pos, Object arg) { set(pos, op[pos], arg); }
     
     /** Sets the bytecode and argument  at <i>pos</i> to <i>op</i> and <i>arg</i> respectivly. 
     
     /** Sets the bytecode and argument  at <i>pos</i> to <i>op</i> and <i>arg</i> respectivly. 
-        This is equivalent to set(pos,op,arg?1:0) 
+        This is equivalent to set(pos, op, arg?1:0) 
         @exception ArrayIndexOutOfBoundException if pos < 0 || pos >= size()
     */
         @exception ArrayIndexOutOfBoundException if pos < 0 || pos >= size()
     */
-    public final void set(int pos, byte op, boolean arg) { set(pos,op,arg?1:0); }
+    public final void set(int pos, byte op, boolean arg) { set(pos, op, arg?1:0); }
     
     
-    // This MUST handle x{LOAD,STORE} and LDC with an int arg WITHOUT falling back to set(int,byte,Object)
+    // This MUST handle x{LOAD, STORE} and LDC with an int arg WITHOUT falling back to set(int, byte, Object)
     /** Sets the bytecode and argument  at <i>pos</i> to <i>op</i> and <i>n</i> respectivly.
     /** Sets the bytecode and argument  at <i>pos</i> to <i>op</i> and <i>n</i> respectivly.
-        This is equivalent to set(pos,op, new Integer(n)), but optimized to prevent the allocation when possible.
+        This is equivalent to set(pos, op, new Integer(n)), but optimized to prevent the allocation when possible.
         @exception ArrayIndexOutOfBoundException if pos < 0 || pos >= size()
     */
     public final void set(int pos, byte op, int n) {
         @exception ArrayIndexOutOfBoundException if pos < 0 || pos >= size()
     */
     public final void set(int pos, byte op, int n) {
@@ -213,7 +213,7 @@ public class MethodGen implements CGConst {
                 }
                 break;
             default:
                 }
                 break;
             default:
-                set(pos,op,N(n));
+                set(pos, op, N(n));
                 return;
         }            
         this.op[pos] = op;
                 return;
         }            
         this.op[pos] = op;
@@ -227,13 +227,13 @@ public class MethodGen implements CGConst {
         switch(op) {
             case ILOAD: case ISTORE: case LLOAD: case LSTORE: case FLOAD:
             case FSTORE: case DLOAD: case DSTORE: case ALOAD: case ASTORE:
         switch(op) {
             case ILOAD: case ISTORE: case LLOAD: case LSTORE: case FLOAD:
             case FSTORE: case DLOAD: case DSTORE: case ALOAD: case ASTORE:
-                // set(int,byte,int) always handles these ops itself
-                set(pos,op,((Integer)arg).intValue());
+                // set(int, byte, int) always handles these ops itself
+                set(pos, op, ((Integer)arg).intValue());
                 return;
             case LDC:
                 return;
             case LDC:
-                // set(int,byte,int) always handles these opts itself
-                if(arg instanceof Integer) { set(pos,op,((Integer)arg).intValue()); return; }
-                if(arg instanceof Boolean) { set(pos,op,((Boolean)arg).booleanValue()); return; }
+                // set(int, byte, int) always handles these opts itself
+                if(arg instanceof Integer) { set(pos, op, ((Integer)arg).intValue()); return; }
+                if(arg instanceof Boolean) { set(pos, op, ((Boolean)arg).booleanValue()); return; }
                 
                 if(arg instanceof Long) {
                     long l = ((Long)arg).longValue();
                 
                 if(arg instanceof Long) {
                     long l = ((Long)arg).longValue();
@@ -286,8 +286,8 @@ public class MethodGen implements CGConst {
             this.lo = lo;
             this.hi = hi;
         }
             this.lo = lo;
             this.hi = hi;
         }
-        public void setTargetForVal(int val, Object o) { setTarget(val-lo,o); }
-        public void setTargetForVal(int val, int n) { setTarget(val-lo,n); }
+        public void setTargetForVal(int val, Object o) { setTarget(val-lo, o); }
+        public void setTargetForVal(int val, int n) { setTarget(val-lo, n); }
         
         int length() { return 12 + targets.length * 4; } // 4bytes/target, hi, lo, default
     }
         
         int length() { return 12 + targets.length * 4; } // 4bytes/target, hi, lo, default
     }
@@ -315,7 +315,7 @@ public class MethodGen implements CGConst {
         public final byte op;
         public final int varNum;
         public final int n;
         public final byte op;
         public final int varNum;
         public final int n;
-        Wide(byte op, int varNum) { this(op,varNum,0); }
+        Wide(byte op, int varNum) { this(op, varNum, 0); }
         Wide(byte op, int varNum, int n) { this.op = op; this.varNum = varNum; this.n = n; }
     }
         
         Wide(byte op, int varNum, int n) { this.op = op; this.varNum = varNum; this.n = n; }
     }
         
@@ -361,10 +361,10 @@ public class MethodGen implements CGConst {
     
         int[] pc = new int[size];
         int[] maxpc = pc;
     
         int[] pc = new int[size];
         int[] maxpc = pc;
-        int p,i;
+        int p, i;
         
         // Pass1 - Calculate maximum pc of each bytecode, widen some insns, resolve any unresolved jumps, etc
         
         // Pass1 - Calculate maximum pc of each bytecode, widen some insns, resolve any unresolved jumps, etc
-        for(i=0,p=0;i<size;i++) {
+        for(i=0, p=0;i<size;i++) {
             byte op = this.op[i];
             int opdata = OP_DATA[op&0xff];
             int j;
             byte op = this.op[i];
             int opdata = OP_DATA[op&0xff];
             int j;
@@ -413,7 +413,7 @@ public class MethodGen implements CGConst {
                     int arg = ((Integer)this.arg[i]).intValue();
                     if(arg > 255) {
                         this.op[i] = WIDE;
                     int arg = ((Integer)this.arg[i]).intValue();
                     if(arg > 255) {
                         this.op[i] = WIDE;
-                        this.arg[i] = new Wide(op,arg);
+                        this.arg[i] = new Wide(op, arg);
                     }
                     break;
                 }
                     }
                     break;
                 }
@@ -421,7 +421,7 @@ public class MethodGen implements CGConst {
                     Pair pair = (Pair) this.arg[i];
                     if(pair.i1 > 255 || pair.i2 < -128 || pair.i2 > 127) {
                         this.op[i] = WIDE;
                     Pair pair = (Pair) this.arg[i];
                     if(pair.i1 > 255 || pair.i2 < -128 || pair.i2 > 127) {
                         this.op[i] = WIDE;
-                        this.arg[i] = new Wide(IINC,pair.i1,pair.i2);
+                        this.arg[i] = new Wide(IINC, pair.i1, pair.i2);
                     }
                     break;
                 }
                     }
                     break;
                 }
@@ -450,7 +450,7 @@ public class MethodGen implements CGConst {
         }
         
         // Pass3 - Calculate actual pc
         }
         
         // Pass3 - Calculate actual pc
-        for(i=0,p=0;i<size;i++) {
+        for(i=0, p=0;i<size;i++) {
             byte op = this.op[i];
             pc[i] = p;
             switch(op) {
             byte op = this.op[i];
             pc[i] = p;
             switch(op) {
@@ -464,7 +464,7 @@ public class MethodGen implements CGConst {
                     p = (p + 3) & ~3; // padding
                     p += 4; // default
                     if(op == TABLESWITCH) p += 4 + 4 + si.size() * 4; // lo, hi, targets
                     p = (p + 3) & ~3; // padding
                     p += 4; // default
                     if(op == TABLESWITCH) p += 4 + 4 + si.size() * 4; // lo, hi, targets
-                    else p += 4 + si.size() * 4 * 2; // count, key,val * targets
+                    else p += 4 + si.size() * 4 * 2; // count, key, val * targets
                     break;
                 }
                 case WIDE:
                     break;
                 }
                 case WIDE:
@@ -573,7 +573,7 @@ public class MethodGen implements CGConst {
         
         o.writeShort(exnTable.size());
         for(Enumeration e = exnTable.keys();e.hasMoreElements();)
         
         o.writeShort(exnTable.size());
         for(Enumeration e = exnTable.keys();e.hasMoreElements();)
-            ((ExnTableEnt)exnTable.get(e.nextElement())).dump(o,pc,codeSize);
+            ((ExnTableEnt)exnTable.get(e.nextElement())).dump(o, pc, codeSize);
         
         o.writeShort(codeAttrs.size());
         codeAttrs.dump(o);
         
         o.writeShort(codeAttrs.size());
         codeAttrs.dump(o);
@@ -581,13 +581,13 @@ public class MethodGen implements CGConst {
         baos.close();
         
         byte[] codeAttribute = baos.toByteArray();
         baos.close();
         
         byte[] codeAttribute = baos.toByteArray();
-        attrs.add("Code",codeAttribute);
+        attrs.add("Code", codeAttribute);
         
         baos.reset();
         o.writeShort(thrownExceptions.size());
         for(Enumeration e = thrownExceptions.keys();e.hasMoreElements();)
             o.writeShort(cp.getIndex((CPGen.Ent)thrownExceptions.get(e.nextElement())));
         
         baos.reset();
         o.writeShort(thrownExceptions.size());
         for(Enumeration e = thrownExceptions.keys();e.hasMoreElements();)
             o.writeShort(cp.getIndex((CPGen.Ent)thrownExceptions.get(e.nextElement())));
-        attrs.add("Exceptions",baos.toByteArray());
+        attrs.add("Exceptions", baos.toByteArray());
         
         size = capacity = FINISHED;        
     }
         
         size = capacity = FINISHED;        
     }
index 52ccf2f..deec819 100644 (file)
@@ -11,10 +11,10 @@ public class MethodRef extends ClassGen.FieldOrMethodRef {
     /** Create a reference to method <i>name</i> of class <i>c</i> with the return type <i>ret</i> and the
         arguments <i>args</i> */
     public MethodRef(Type.Object c, String name, Type ret, Type[] args) {
     /** Create a reference to method <i>name</i> of class <i>c</i> with the return type <i>ret</i> and the
         arguments <i>args</i> */
     public MethodRef(Type.Object c, String name, Type ret, Type[] args) {
-        super(c,name,getDescriptor(ret,args));
+        super(c, name, getDescriptor(ret, args));
     }
     }
-    /** Equivalent to MethodRef(new Type.Object(s),...)
-        @see #MethodRef(Type.Object,String,Type,Type[])
+    /** Equivalent to MethodRef(new Type.Object(s), ...)
+        @see #MethodRef(Type.Object, String, Type, Type[])
     */
     public MethodRef(String s, String name, Type ret, Type[] args) {
         this(Type.fromDescriptor(s).asObject(), name, ret, args);
     */
     public MethodRef(String s, String name, Type ret, Type[] args) {
         this(Type.fromDescriptor(s).asObject(), name, ret, args);
@@ -35,8 +35,8 @@ public class MethodRef extends ClassGen.FieldOrMethodRef {
         users don't need to be concerned with this though because MethodRef's are automatically converted
         to MethodRef.I's when they are applied to an INVOKEINTERFACE bytecode */
     public static class I extends MethodRef {
         users don't need to be concerned with this though because MethodRef's are automatically converted
         to MethodRef.I's when they are applied to an INVOKEINTERFACE bytecode */
     public static class I extends MethodRef {
-        public I(Type.Object c, String name, Type ret, Type[] args) { super(c,name,ret,args); }
-        public I(String s, String name, Type ret, Type[] args) { super(s,name,ret,args); }
+        public I(Type.Object c, String name, Type ret, Type[] args) { super(c, name, ret, args); }
+        public I(String s, String name, Type ret, Type[] args) { super(s, name, ret, args); }
         I(MethodRef m) { super(m); }
     }
 }
         I(MethodRef m) { super(m); }
     }
 }
index e301414..01276db 100644 (file)
@@ -52,7 +52,7 @@ public class Type {
         @param base The base type
         @return A one dimensional array of the base type
     */
         @param base The base type
         @return A one dimensional array of the base type
     */
-    public static Type arrayType(Type base) { return arrayType(base,1); }
+    public static Type arrayType(Type base) { return arrayType(base, 1); }
     /** Returns a <i>dim</i> dimensional array type for the base type <i>base</i>
         @param base The base type
         @param dim Number if dimensions
     /** Returns a <i>dim</i> dimensional array type for the base type <i>base</i>
         @param base The base type
         @param dim Number if dimensions
@@ -75,19 +75,19 @@ public class Type {
         public boolean isObject() { return true; }
 
         private static String _initHelper(String s) {
         public boolean isObject() { return true; }
 
         private static String _initHelper(String s) {
-            if(!s.startsWith("L") || !s.endsWith(";")) s = "L" + s.replace('.','/') + ";";
+            if(!s.startsWith("L") || !s.endsWith(";")) s = "L" + s.replace('.', '/') + ";";
             if(!validDescriptorString(s)) throw new IllegalArgumentException("invalid descriptor string");
             return s;
         }
 
         String[] components() {
             if(!validDescriptorString(s)) throw new IllegalArgumentException("invalid descriptor string");
             return s;
         }
 
         String[] components() {
-            StringTokenizer st = new StringTokenizer(descriptor.substring(1,descriptor.length()-1),"/");
+            StringTokenizer st = new StringTokenizer(descriptor.substring(1, descriptor.length()-1), "/");
             String[] a = new String[st.countTokens()];
             for(int i=0;st.hasMoreTokens();i++) a[i] = st.nextToken();
             return a;
         }
         
             String[] a = new String[st.countTokens()];
             for(int i=0;st.hasMoreTokens();i++) a[i] = st.nextToken();
             return a;
         }
         
-        String internalForm() { return descriptor.substring(1,descriptor.length()-1); }
+        String internalForm() { return descriptor.substring(1, descriptor.length()-1); }
         
         static boolean validDescriptorString(String s) {
             return s.startsWith("L") && s.endsWith(";");
         
         static boolean validDescriptorString(String s) {
             return s.startsWith("L") && s.endsWith(";");
@@ -95,7 +95,7 @@ public class Type {
     }    
 
     public static class Array extends Object {
     }    
 
     public static class Array extends Object {
-        protected Array(Type t, int dim) {  super(arrayify(t,dim)); }
+        protected Array(Type t, int dim) {  super(arrayify(t, dim)); }
         public Type.Array asArray() { return this; }
         public boolean isArray() { return true; }
         private static String arrayify(Type t, int dim) {
         public Type.Array asArray() { return this; }
         public boolean isArray() { return true; }
         private static String arrayify(Type t, int dim) {