From 50a344886756b00af0e30d548a7a86822ef7e962 Mon Sep 17 00:00:00 2001 From: adam Date: Fri, 3 Jun 2005 00:49:54 +0000 Subject: [PATCH] formatting only: added spaces after commas darcs-hash:20050603004954-5007d-11f9a4975ad76ffafd67736e765da2c4728d3b3a.gz --- src/org/ibex/classgen/CGConst.java | 8 ++-- src/org/ibex/classgen/CPGen.java | 42 ++++++++--------- src/org/ibex/classgen/ClassGen.java | 44 +++++++++--------- src/org/ibex/classgen/FieldGen.java | 4 +- src/org/ibex/classgen/FieldRef.java | 6 +-- src/org/ibex/classgen/MethodGen.java | 82 +++++++++++++++++----------------- src/org/ibex/classgen/MethodRef.java | 10 ++--- src/org/ibex/classgen/Type.java | 10 ++--- 8 files changed, 103 insertions(+), 103 deletions(-) diff --git a/src/org/ibex/classgen/CGConst.java b/src/org/ibex/classgen/CGConst.java index ca59d67..e67218c 100644 --- a/src/org/ibex/classgen/CGConst.java +++ b/src/org/ibex/classgen/CGConst.java @@ -235,15 +235,15 @@ public interface CGConst { /* #!/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 ($name,$num) = ($1,hex($2)); + my ($name, $num) = ($1, hex($2)); $_ = $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(/./); @@ -251,7 +251,7 @@ while(<>) { } 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__ */ diff --git a/src/org/ibex/classgen/CPGen.java b/src/org/ibex/classgen/CPGen.java index 01ef840..3a453d1 100644 --- a/src/org/ibex/classgen/CPGen.java +++ b/src/org/ibex/classgen/CPGen.java @@ -36,7 +36,7 @@ class CPGen { // 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) { @@ -50,7 +50,7 @@ class CPGen { // 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) { @@ -75,7 +75,7 @@ class CPGen { 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()) + "]"; } @@ -107,7 +107,7 @@ class CPGen { 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"); } @@ -166,7 +166,7 @@ class CPGen { 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) { @@ -179,27 +179,27 @@ class CPGen { } 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) { - CPRefEnt ce = new CPRefEnt(this,8); + CPRefEnt ce = new CPRefEnt(this, 8); 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) { - 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) { - LongEnt le = new LongEnt(this,5); + LongEnt le = new LongEnt(this, 5); 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) { @@ -207,7 +207,7 @@ class CPGen { 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); @@ -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"); - CPRefEnt ce = new CPRefEnt(this,tag); + CPRefEnt ce = new CPRefEnt(this, tag); 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"); @@ -231,7 +231,7 @@ class CPGen { usedSlots += spaces; - entries.put(o,ent); + entries.put(o, 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(); - Sort.sort(ents,reverseCompareFunc); + Sort.sort(ents, reverseCompareFunc); state = STABLE; assignIndex(ents); } @@ -299,7 +299,7 @@ class CPGen { 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;iname of class c with the type t */ - 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); } } diff --git a/src/org/ibex/classgen/MethodGen.java b/src/org/ibex/classgen/MethodGen.java index 547330d..88c35bb 100644 --- a/src/org/ibex/classgen/MethodGen.java +++ b/src/org/ibex/classgen/MethodGen.java @@ -47,11 +47,11 @@ public class MethodGen implements CGConst { 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 */ - public String getDescriptor() { return MethodRef.getDescriptor(ret,args); } + public String getDescriptor() { return MethodRef.getDescriptor(ret, args); } private class ExnTableEnt { public int start; @@ -72,14 +72,14 @@ public class MethodGen implements CGConst { } } - /** Adds an exception handler for the range [start,end) pointing to handler + /** Adds an exception handler for the range [start, end) pointing to handler @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 @@ -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) { - thrownExceptions.put(type,cp.add(type)); + thrownExceptions.put(type, cp.add(type)); } 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; - newCap = Math.max(newCap,capacity == 0 ? 256 : capacity*2); + newCap = Math.max(newCap, capacity == 0 ? 256 : capacity*2); 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]; - if(capacity != 0) System.arraycopy(arg,0,arg2,0,size); + if(capacity != 0) System.arraycopy(arg, 0, arg2, 0, size); arg = arg2; capacity = newCap; @@ -128,17 +128,17 @@ public class MethodGen implements CGConst { /** Adds a bytecode, op, with argument arg 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 - @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 - @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 pos @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]; } - /** Sets the argument for pos to arg. This is equivalent to set(pos,op,new Integer(arg)), but optimized to prevent the allocation when possible. + /** Sets the argument for pos to arg. 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() - @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 pos to arg. @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 pos to op and arg 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() */ - 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 pos to op and n 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) { @@ -213,7 +213,7 @@ public class MethodGen implements CGConst { } break; default: - set(pos,op,N(n)); + set(pos, op, N(n)); 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: - // 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: - // 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(); @@ -286,8 +286,8 @@ public class MethodGen implements CGConst { 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 } @@ -315,7 +315,7 @@ public class MethodGen implements CGConst { 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; } } @@ -361,10 +361,10 @@ public class MethodGen implements CGConst { 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 - for(i=0,p=0;i 255) { this.op[i] = WIDE; - this.arg[i] = new Wide(op,arg); + this.arg[i] = new Wide(op, arg); } 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; - this.arg[i] = new Wide(IINC,pair.i1,pair.i2); + this.arg[i] = new Wide(IINC, pair.i1, pair.i2); } break; } @@ -450,7 +450,7 @@ public class MethodGen implements CGConst { } // Pass3 - Calculate actual pc - for(i=0,p=0;iname of class c with the return type ret and the arguments args */ 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); @@ -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 { - 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); } } } diff --git a/src/org/ibex/classgen/Type.java b/src/org/ibex/classgen/Type.java index e301414..01276db 100644 --- a/src/org/ibex/classgen/Type.java +++ b/src/org/ibex/classgen/Type.java @@ -52,7 +52,7 @@ public class 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 dim dimensional array type for the base type base @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) { - 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() { - 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 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(";"); @@ -95,7 +95,7 @@ public class Type { } 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) { -- 1.7.10.4