1 package com.sun.org.apache.bcel.internal.generic; 2 3 56 57 import com.sun.org.apache.bcel.internal.Constants; 58 import com.sun.org.apache.bcel.internal.classfile.*; 59 60 69 public class LineNumberGen implements InstructionTargeter, Cloneable { 70 private InstructionHandle ih; 71 private int src_line; 72 73 79 public LineNumberGen(InstructionHandle ih, int src_line) { 80 setInstruction(ih); 81 setSourceLine(src_line); 82 } 83 84 87 public boolean containsTarget(InstructionHandle ih) { 88 return this.ih == ih; 89 } 90 91 95 public void updateTarget(InstructionHandle old_ih, InstructionHandle new_ih) { 96 if(old_ih != ih) 97 throw new ClassGenException("Not targeting " + old_ih + ", but " + ih + "}"); 98 else 99 setInstruction(new_ih); 100 } 101 102 108 public LineNumber getLineNumber() { 109 return new LineNumber(ih.getPosition(), src_line); 110 } 111 112 public void setInstruction(InstructionHandle ih) { 113 BranchInstruction.notifyTarget(this.ih, ih, this); 114 115 this.ih = ih; 116 } 117 118 public Object clone() { 119 try { 120 return super.clone(); 121 } catch(CloneNotSupportedException e) { 122 System.err.println(e); 123 return null; 124 } 125 } 126 127 public InstructionHandle getInstruction() { return ih; } 128 public void setSourceLine(int src_line) { this.src_line = src_line; } 129 public int getSourceLine() { return src_line; } 130 } 131 | Popular Tags |