1 package com.sun.org.apache.bcel.internal.generic; 2 3 56 57 69 public final class BranchHandle extends InstructionHandle { 70 private BranchInstruction bi; 72 private BranchHandle(BranchInstruction i) { 73 super(i); 74 bi = i; 75 } 76 77 79 private static BranchHandle bh_list = null; 81 static final BranchHandle getBranchHandle(BranchInstruction i) { 82 if(bh_list == null) 83 return new BranchHandle(i); 84 else { 85 BranchHandle bh = bh_list; 86 bh_list = (BranchHandle)bh.next; 87 88 bh.setInstruction(i); 89 90 return bh; 91 } 92 } 93 94 96 protected void addHandle() { 97 next = bh_list; 98 bh_list = this; 99 } 100 101 105 public int getPosition() { return bi.position; } 106 107 void setPosition(int pos) { 108 i_position = bi.position = pos; 109 } 110 111 protected int updatePosition(int offset, int max_offset) { 112 int x = bi.updatePosition(offset, max_offset); 113 i_position = bi.position; 114 return x; 115 } 116 117 120 public void setTarget(InstructionHandle ih) { 121 bi.setTarget(ih); 122 } 123 124 127 public void updateTarget(InstructionHandle old_ih, InstructionHandle new_ih) { 128 bi.updateTarget(old_ih, new_ih); 129 } 130 131 134 public InstructionHandle getTarget() { 135 return bi.getTarget(); 136 } 137 138 141 public void setInstruction(Instruction i) { 142 super.setInstruction(i); 143 144 if(!(i instanceof BranchInstruction)) 145 throw new ClassGenException("Assigning " + i + 146 " to branch handle which is not a branch instruction"); 147 148 bi = (BranchInstruction)i; 149 } 150 } 151 152 | Popular Tags |