1 10 11 package jas; 12 13 import java.io.*; 14 import java.util.*; 15 16 17 public class Var 18 { 19 short var_acc; 20 CP name, sig; 21 ConstAttr const_attr; 22 SyntheticAttr synth_attr = null; 23 DeprecatedAttr dep_attr = null; 24 SignatureAttr sig_attr = null; 25 VisibilityAnnotationAttr vis_annot_attr = null; 26 27 Vector genericAttrs = new Vector(); 28 29 30 38 39 public Var(short vacc, CP name, CP sig, ConstAttr cattr) 40 { 41 var_acc = vacc; this.name = name; 42 this.sig = sig; const_attr = cattr; 43 } 44 45 public Var(short vacc, CP name, CP sig, ConstAttr cattr, SyntheticAttr sattr){ 46 var_acc = vacc; 47 this.name = name; 48 this.sig = sig; 49 const_attr = cattr; 50 synth_attr = sattr; 51 } 52 53 public void addGenericAttr(GenericAttr g) 54 { 55 genericAttrs.addElement(g); 56 } 57 58 public void addDeprecatedAttr(DeprecatedAttr d){ 59 dep_attr = d; 60 } 61 62 public void addSignatureAttr(SignatureAttr s){ 63 sig_attr = s; 64 } 65 66 public void addVisibilityAnnotationAttr(VisibilityAnnotationAttr v){ 67 vis_annot_attr = v; 68 } 70 71 void resolve(ClassEnv e) 72 { 73 e.addCPItem(name); 74 e.addCPItem(sig); 75 if (const_attr != null) 76 { const_attr.resolve(e); } 77 if (synth_attr != null){ 78 synth_attr.resolve(e); 79 } 80 if (dep_attr != null){ 81 dep_attr.resolve(e); 82 } 83 if (sig_attr != null){ 84 sig_attr.resolve(e); 85 } 86 if (vis_annot_attr != null){ 87 vis_annot_attr.resolve(e); 88 } 89 } 90 91 void write(ClassEnv e, DataOutputStream out) 92 throws IOException, jasError 93 { 94 out.writeShort(var_acc); 95 out.writeShort(e.getCPIndex(name)); 96 out.writeShort(e.getCPIndex(sig)); 97 int attrCnt = genericAttrs.size(); 98 99 if (const_attr != null) attrCnt++; 100 if (synth_attr != null) attrCnt++; 101 if (dep_attr != null) attrCnt++; 102 if (sig_attr != null) attrCnt++; 103 if (vis_annot_attr != null) attrCnt ++; 104 105 out.writeShort(attrCnt); 106 107 if (const_attr != null){ 108 const_attr.write(e, out); 109 } 110 if (synth_attr != null){ 111 synth_attr.write(e, out); 112 } 113 if (dep_attr != null){ 114 dep_attr.write(e, out); 115 } 116 if (sig_attr != null){ 117 sig_attr.write(e, out); 118 } 119 if (vis_annot_attr != null){ 120 vis_annot_attr.write(e,out); 121 } 122 126 127 for(Enumeration enu = genericAttrs.elements(); enu.hasMoreElements();) { 128 ((GenericAttr)enu.nextElement()).write(e, out); 129 } 130 } 131 } 132 | Popular Tags |