1
2
3
4 package joeq.Class;
5
6 import java.util.HashMap;
7 import java.util.Map;
8 import java.io.DataInput;
9 import java.io.IOException;
10 import joeq.Main.jq;
11 import jwutil.util.Assert;
12
13
14
15
16
17
18
19 public final class jq_InstanceField extends jq_Field {
20
21 public static final int INVALID_OFFSET = 0x80000000;
22 private int offset;
23
24
25 private jq_InstanceField(jq_Class clazz, jq_NameAndDesc nd) {
26 super(clazz, nd);
27 offset = INVALID_OFFSET;
28 }
29
30 static jq_InstanceField newInstanceField(jq_Class clazz, jq_NameAndDesc nd) {
31 return new jq_InstanceField(clazz, nd);
32 }
33
34 public final int getWidth() {
35 return type.getReferenceSize();
36 }
37
38 public final void load(jq_InstanceField that) {
39 this.access_flags = that.access_flags;
40 this.attributes = (Map)((HashMap)that.attributes).clone();
41 state = STATE_LOADED;
42 }
43
44 public final void load(char access_flags, DataInput in)
45 throws IOException, ClassFormatError {
46 super.load(access_flags, in);
47 state = STATE_LOADED;
48 }
49
50 public final void load(char access_flags, Map attributes) {
51 super.load(access_flags, attributes);
52 state = STATE_LOADED;
53 }
54
55 public final jq_Member resolve() { return resolve1(); }
56 public final jq_InstanceField resolve1() {
57 this.clazz.load();
58 if (this.state >= STATE_LOADED) return this;
59
60 jq_InstanceField m = this.clazz.getInstanceField(nd);
61 if (m != null) return m;
62 throw new NoSuchFieldError(this.toString());
63 }
64
65 public final boolean isUnsignedType() { return type == jq_Primitive.CHAR; }
66 public final int getSize() { return type.getReferenceSize(); }
67 public final void prepare(int offset) { Assert._assert(state == STATE_LOADED); state = STATE_PREPARED; this.offset = offset; }
68 public final int getOffset() { chkState(STATE_PREPARED); Assert._assert(offset != INVALID_OFFSET); return offset; }
69 public final boolean needsDynamicLink(jq_Method method) {
70 if (!jq.RunningNative) return (state < STATE_PREPARED) || getDeclaringClass().needsDynamicLink(method);
71 return state < STATE_PREPARED;
72 }
73 public final boolean isStatic() { return false; }
74 public final void unprepare() { chkState(STATE_PREPARED); offset = INVALID_OFFSET; state = STATE_LOADED; }
75
76 public void accept(jq_FieldVisitor mv) {
77 mv.visitInstanceField(this);
78 super.accept(mv);
79 }
80
81 public static final jq_Class _class;
82 static {
83 _class = (jq_Class)PrimordialClassLoader.loader.getOrCreateBSType("Ljoeq/Class/jq_InstanceField;");
84 }
85 }