1 /* Copyright (C) 2003 Vladimir Roubtsov. All rights reserved. 2 * 3 * This program and the accompanying materials are made available under 4 * the terms of the Common Public License v1.0 which accompanies this distribution, 5 * and is available at http://www.eclipse.org/legal/cpl-v10.html 6 * 7 * $Id: LineNumber_info.java,v 1.1.1.1 2004/05/09 16:57:48 vlad_r Exp $ 8 */ 9 package com.vladium.jcd.cls.attribute; 10 11 import java.io.IOException; 12 13 import com.vladium.jcd.compiler.IClassFormatOutput; 14 import com.vladium.jcd.lib.UDataInputStream; 15 import com.vladium.jcd.lib.UDataOutputStream; 16 17 // ---------------------------------------------------------------------------- 18 /** 19 * This class represents a line_number_table entry contained by 20 * {@link LineNumberTableAttribute_info} attribute. Each entry contains the 21 * following items: 22 * <PRE> 23 * start_pc 24 * </PRE> 25 * The value of the start_pc item must indicate the index into the code array 26 * at which the code for a new line in the original source file begins. The 27 * value of start_pc must be less than the value of the code_length item of 28 * the {@link CodeAttribute_info} attribute of which this LineNumberTable 29 * is an attribute.<P> 30 * <PRE> 31 * line_number 32 * </PRE> 33 * The value of the line_number item must give the corresponding line number 34 * in the original source file. 35 * 36 * @author Vlad Roubtsov, (C) 2003 37 */ 38 public 39 final class LineNumber_info implements Cloneable, IClassFormatOutput 40 { 41 // public: ................................................................ 42 43 public int m_start_pc, m_line_number; 44 45 LineNumber_info(final int start_pc, final int line_number)46 public LineNumber_info (final int start_pc, final int line_number) 47 { 48 m_start_pc = start_pc; 49 m_line_number = line_number; 50 } 51 toString()52 public String toString () 53 { 54 return "line_number_info: [start_pc = " + m_start_pc + ", line_number = " + m_line_number + "]"; 55 } 56 57 // Cloneable: 58 59 /** 60 * Performs a deep copy. 61 */ clone()62 public Object clone () 63 { 64 try 65 { 66 return super.clone (); 67 } 68 catch (CloneNotSupportedException e) 69 { 70 throw new InternalError (e.toString ()); 71 } 72 } 73 74 // IClassFormatOutput: 75 writeInClassFormat(final UDataOutputStream out)76 public void writeInClassFormat (final UDataOutputStream out) throws IOException 77 { 78 out.writeU2 (m_start_pc); 79 out.writeU2 (m_line_number); 80 } 81 82 // protected: ............................................................. 83 84 // package: ............................................................... 85 86 LineNumber_info(final UDataInputStream bytes)87 LineNumber_info (final UDataInputStream bytes) throws IOException 88 { 89 m_start_pc = bytes.readU2 (); 90 m_line_number = bytes.readU2 (); 91 } 92 93 // private: ............................................................... 94 95 } // end of class 96 // ----------------------------------------------------------------------------