X-Git-Url: http://git.megacz.com/?p=org.ibex.classgen.git;a=blobdiff_plain;f=src%2Forg%2Fibex%2Fclassgen%2FClassGen.java;h=16e10e7e47b506fff5bc5a364392636fcd3a86d3;hp=cd120454ef54690e3b7e0aefeccbd12a42a8d6d3;hb=bc9112573cba51be5e7d285ccd3e496be4278c63;hpb=cb0bae954e7dd0067e77c436c78ee19ace52d9e3 diff --git a/src/org/ibex/classgen/ClassGen.java b/src/org/ibex/classgen/ClassGen.java index cd12045..16e10e7 100644 --- a/src/org/ibex/classgen/ClassGen.java +++ b/src/org/ibex/classgen/ClassGen.java @@ -36,6 +36,12 @@ public class ClassGen implements CGConst { return mg; } + public final FieldGen addField(String name, Type type, int flags) { + FieldGen fg = new FieldGen(this,name,type,flags); + fields.addElement(fg); + return fg; + } + public void dump(String s) throws IOException { dump(new File(s)); } public void dump(File f) throws IOException { if(f.isDirectory()) { @@ -63,19 +69,26 @@ public class ClassGen implements CGConst { cp.seal(); o.writeInt(0xcafebabe); // magic + // FIXME: What should this be for JDK 1.1 ? o.writeShort(0); // minor_version o.writeShort(46); // major_version + o.writeShort(cp.size()); // constant_pool_count cp.dump(o); // constant_pool + o.writeShort(flags); - o.writeShort(cp.get(thisType).index); // this_class - o.writeShort(cp.get(superType).index); // super_class + o.writeShort(cp.getIndex(thisType)); // this_class + o.writeShort(cp.getIndex(superType)); // super_class + o.writeShort(interfaces.size()); // interfaces_count - for(int i=0;i