1 17 package org.apache.bcel.generic; 18 19 import org.apache.bcel.classfile.LineNumber; 20 21 30 public class LineNumberGen implements InstructionTargeter, Cloneable , java.io.Serializable { 31 32 private InstructionHandle ih; 33 private int src_line; 34 35 36 41 public LineNumberGen(InstructionHandle ih, int src_line) { 42 setInstruction(ih); 43 setSourceLine(src_line); 44 } 45 46 47 50 public boolean containsTarget( InstructionHandle ih ) { 51 return this.ih == ih; 52 } 53 54 55 59 public void updateTarget( InstructionHandle old_ih, InstructionHandle new_ih ) { 60 if (old_ih != ih) { 61 throw new ClassGenException("Not targeting " + old_ih + ", but " + ih + "}"); 62 } else { 63 setInstruction(new_ih); 64 } 65 } 66 67 68 74 public LineNumber getLineNumber() { 75 return new LineNumber(ih.getPosition(), src_line); 76 } 77 78 79 public void setInstruction( InstructionHandle ih ) { 80 BranchInstruction.notifyTarget(this.ih, ih, this); 81 this.ih = ih; 82 } 83 84 85 public Object clone() { 86 try { 87 return super.clone(); 88 } catch (CloneNotSupportedException e) { 89 System.err.println(e); 90 return null; 91 } 92 } 93 94 95 public InstructionHandle getInstruction() { 96 return ih; 97 } 98 99 100 public void setSourceLine( int src_line ) { 101 this.src_line = src_line; 102 } 103 104 105 public int getSourceLine() { 106 return src_line; 107 } 108 } 109 | Popular Tags |