Source code: com/chaoswg/xtc4y/classdesc/LineNumberTableEntry.java
1 //$Header: /cvsroot/xtc4y/xtc4y/src/com/chaoswg/xtc4y/classdesc/LineNumberTableEntry.java,v 1.1 2003/09/08 21:00:54 toggm Exp $
2 /******************************************************************************
3 * XTC4y - eXtreme Testing Collection 4 you *
4 * -------------------------------------------------------------------------- *
5 * URL: http://www.chaoswg.com/xtc4y *
6 * Author: Mike Toggweiler (2.dog@gmx.ch) *
7 * *
8 * Last Updated: $Date: 2003/09/08 21:00:54 $, by $Author: toggm $ *
9 * Version: $Revision: 1.1 $ *
10 * -------------------------------------------------------------------------- *
11 * COPYRIGHT: (c) 2003 by Mike Toggweiler *
12 * *
13 * This program is free software; you can redistribute it and/or modify *
14 * it under the terms of the GNU General Public License as published by *
15 * the Free Software Foundation; either version 2 of the License, or *
16 * (at your option) any later version. *
17 *****************************************************************************/
18 package com.chaoswg.xtc4y.classdesc;
19
20 import java.io.DataInputStream;
21 import java.io.DataOutputStream;
22 import java.io.IOException;
23
24 import com.chaoswg.xtc4y.classdesc.code.Code;
25 import com.chaoswg.xtc4y.classdesc.code.instructions.Instruction;
26
27 /**
28 * this class represents an antry in the linevariabletable attribute,
29 * described in §4.7.8
30 * @author Mike Toggweiler
31 **/
32 public class LineNumberTableEntry implements CodeCompatible {
33 private short startPc;
34 private short lineNumber;
35
36 private Instruction startInstr;
37
38 /**
39 * Creates a LineNumberTableEntry and initializes it from a
40 * DataInputStream
41 * @param dis the DataInputStream to read from
42 * @param cp the constant pool to resolve indices
43 **/
44 protected LineNumberTableEntry(DataInputStream dis, ConstantPool cp)
45 throws IOException {
46 startPc = (short)dis.readUnsignedShort();
47 lineNumber = (short)dis.readUnsignedShort();
48 }
49
50 /**
51 * Write the attribute information onto the DataOutputStream, using the
52 * constant pool to register variables. .
53 * @param dos the DataOutputStream to write on
54 * @param cp The constant pool to register variables
55 **/
56 protected void writeEntry(DataOutputStream dos, ConstantPool cp)
57 throws IOException {
58 dos.writeShort(startPc);
59 dos.writeShort(lineNumber);
60 }
61
62 /**
63 * Called to resolve the temporary stored indices into the code
64 * table
65 * @param code the Code table after initialization
66 **/
67 public void resolveIndices(Code code) {
68 startInstr = code.getInstructionAt(startPc);
69 }
70
71 /**
72 * Called to resolve indices on instructions from the code table
73 * @param code the code table after initialization
74 **/
75 public void readIndices(Code code) {
76 startPc = code.getIndexOf(startInstr);
77 }
78 }