1 cananian 1.1.2.2 // LineNumberTable.java, created Mon Jan 18 22:44:38 1999 by cananian
 2 cananian 1.1.2.1 // Copyright (C) 1998 C. Scott Ananian <cananian@alumni.princeton.edu>
 3 cananian 1.1.2.1 // Licensed under the terms of the GNU GPL; see COPYING for details.
 4 cananian 1.1.2.1 package harpoon.IR.RawClass;
 5 cananian 1.1.2.1 
 6 cananian 1.1.2.1 /** 
 7 cananian 1.1.2.1  * Each object indicates that the line number in the original Java
 8 cananian 1.1.2.1  * source file changes at a given point in the <code>code</code>
 9 cananian 1.1.2.1  * array. 
10 cananian 1.1.2.1  *
11 cananian 1.1.2.1  * @author  C. Scott Ananian <cananian@alumni.princeton.edu>
12 cananian 1.2      * @version $Id: LineNumberTable.java,v 1.2 2002/02/25 21:05:27 cananian Exp $
13 cananian 1.1.2.1  * @see "The Java Virtual Machine Specification, section 4.7.6"
14 cananian 1.1.2.1  * @see AttributeLineNumberTable
15 cananian 1.1.2.1  */ 
16 cananian 1.1.2.1 public class LineNumberTable {
17 cananian 1.1.2.1   /** The value of the <code>start_pc</code> item must indicate the
18 cananian 1.1.2.1       index into the <code>code</code> array at which the code for a
19 cananian 1.1.2.1       new line in the original Java source file begins.  The value
20 cananian 1.1.2.1       of <code>start_pc</code> must be less than the value of the
21 cananian 1.1.2.1       <code>code_length</code> item of the <code>Code</code>
22 cananian 1.1.2.1       attribute of which this <code>LineNumberTable</code> is an
23 cananian 1.1.2.1       attribute. */
24 cananian 1.1.2.1   public int start_pc;
25 cananian 1.1.2.1   /** The value of the <code>line_number</code> item must give the
26 cananian 1.1.2.1       corresponding line number in the original Java source file. */
27 cananian 1.1.2.1   public int line_number;
28 cananian 1.1.2.1 
29 cananian 1.1.2.1   /** Constructor. */
30 cananian 1.1.2.1   LineNumberTable(ClassDataInputStream in) throws java.io.IOException {
31 cananian 1.1.2.1     start_pc = in.read_u2();
32 cananian 1.1.2.1     line_number = in.read_u2();
33 cananian 1.1.2.1   }
34 cananian 1.1.2.1   /** Constructor. */
35 cananian 1.1.2.1   public LineNumberTable(int start_pc, int line_number) {
36 cananian 1.1.2.1     this.start_pc = start_pc;
37 cananian 1.1.2.1     this.line_number = line_number;
38 cananian 1.1.2.1   }
39 cananian 1.1.2.1   /** Writes to bytecode stream. */
40 cananian 1.1.2.1   public void write(ClassDataOutputStream out) throws java.io.IOException {
41 cananian 1.1.2.1     out.write_u2(start_pc);
42 cananian 1.1.2.1     out.write_u2(line_number);
43 cananian 1.1.2.1   }
44 cananian 1.1.2.1   /** Human-readable string: */
45 cananian 1.1.2.1   public String toString() {
46 cananian 1.1.2.1     return "line "+line_number+" starts at pc="+start_pc;
47 cananian 1.1.2.1   }
48 cananian 1.2     }