X-Git-Url: http://git.megacz.com/?p=org.ibex.classgen.git;a=blobdiff_plain;f=src%2Forg%2Fibex%2Fclassgen%2FFieldGen.java;h=39e91c0b04cc9152180f86894ec2283087fba5fb;hp=805a7278ce25596f133755ccf444345a15633333;hb=bc9112573cba51be5e7d285ccd3e496be4278c63;hpb=cb0bae954e7dd0067e77c436c78ee19ace52d9e3 diff --git a/src/org/ibex/classgen/FieldGen.java b/src/org/ibex/classgen/FieldGen.java index 805a727..39e91c0 100644 --- a/src/org/ibex/classgen/FieldGen.java +++ b/src/org/ibex/classgen/FieldGen.java @@ -2,8 +2,31 @@ package org.ibex.classgen; import java.io.*; -public class FieldGen { - public void dump(DataOutput o) { - throw new Error("FIXME"); +public class FieldGen implements CGConst { + private final CPGen cp; + private final String name; + private final Type type; + private final int flags; + private final AttrGen attrs; + + 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; + this.name = name; + this.type = type; + this.flags = flags; + this.attrs = new AttrGen(cp); + + cp.addUtf8(name); + cp.addUtf8(type.getDescriptor()); + } + + public void dump(DataOutput o) throws IOException { + o.writeShort(flags); + o.writeShort(cp.getUtf8Index(name)); + o.writeShort(cp.getUtf8Index(type.getDescriptor())); + o.writeShort(attrs.size()); + attrs.dump(o); } }