1 17 package org.apache.bcel.generic; 18 19 31 public final class BranchHandle extends InstructionHandle { 32 33 private BranchInstruction bi; 35 36 private BranchHandle(BranchInstruction i) { 37 super(i); 38 bi = i; 39 } 40 41 43 private static BranchHandle bh_list = null; 45 46 static final BranchHandle getBranchHandle( BranchInstruction i ) { 47 if (bh_list == null) { 48 return new BranchHandle(i); 49 } 50 BranchHandle bh = bh_list; 51 bh_list = (BranchHandle) bh.next; 52 bh.setInstruction(i); 53 return bh; 54 } 55 56 57 59 protected void addHandle() { 60 next = bh_list; 61 bh_list = this; 62 } 63 64 65 69 public int getPosition() { 70 return bi.position; 71 } 72 73 74 void setPosition( int pos ) { 75 i_position = bi.position = pos; 76 } 77 78 79 protected int updatePosition( int offset, int max_offset ) { 80 int x = bi.updatePosition(offset, max_offset); 81 i_position = bi.position; 82 return x; 83 } 84 85 86 89 public void setTarget( InstructionHandle ih ) { 90 bi.setTarget(ih); 91 } 92 93 94 97 public void updateTarget( InstructionHandle old_ih, InstructionHandle new_ih ) { 98 bi.updateTarget(old_ih, new_ih); 99 } 100 101 102 105 public InstructionHandle getTarget() { 106 return bi.getTarget(); 107 } 108 109 110 113 public void setInstruction( Instruction i ) { 114 super.setInstruction(i); 115 if (!(i instanceof BranchInstruction)) { 116 throw new ClassGenException("Assigning " + i 117 + " to branch handle which is not a branch instruction"); 118 } 119 bi = (BranchInstruction) i; 120 } 121 } 122 | Popular Tags |