1 8 9 package jas; 10 11 import java.io.*; 12 import java.util.*; 13 14 public class LineTableAttr 15 { 16 static CP attr = new AsciiCP("LineNumberTable"); 17 18 Vector line, pc; 19 20 26 public LineTableAttr() 27 { line = new Vector(); pc = new Vector(); } 28 29 34 35 public void addEntry(Label l, int line) 36 { 37 pc.addElement(l); 38 this.line.addElement(new Integer (line)); 39 } 40 41 void resolve(ClassEnv e) 42 { e.addCPItem(attr); } 43 44 int size() 45 { return 46 (2 + 4 + 2 + 4*(pc.size())); } 51 52 void write(ClassEnv e, CodeAttr ce, DataOutputStream out) 53 throws IOException, jasError 54 { 55 out.writeShort(e.getCPIndex(attr)); 56 out.writeInt(2 + 4*(pc.size())); 57 out.writeShort(pc.size()); 58 for (Enumeration en = pc.elements(), ien = line.elements(); 59 en.hasMoreElements();) 60 { 61 Label l = (Label)(en.nextElement()); 62 Integer i = (Integer )(ien.nextElement()); 63 l.writeOffset(ce, null, out); 64 out.writeShort((int) i.intValue()); 65 } 66 } 67 } 68 | Popular Tags |