本文整理汇总了Java中org.apache.bcel.generic.BranchInstruction类的典型用法代码示例。如果您正苦于以下问题:Java BranchInstruction类的具体用法?Java BranchInstruction怎么用?Java BranchInstruction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BranchInstruction类属于org.apache.bcel.generic包,在下文中一共展示了BranchInstruction类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: registerInstructionHandle
import org.apache.bcel.generic.BranchInstruction; //导入依赖的package包/类
public void registerInstructionHandle(InstructionHandle ih) {
if (currentIds.size() == 0)
return;
for (Integer currentID : currentIds) {
mapID2InstructionHandle.put(currentID, ih);
List<BranchInstruction> l = mapID2BranchInstructions.get(currentID);
if (l != null) {
// We encountered some branch instructions earlier before we
// registered this instruction handle
for (BranchInstruction bi : l) {
bi.setTarget(ih);
}
mapID2BranchInstructions.remove(currentID);
}
}
currentIds.clear();
}
示例2: start
import org.apache.bcel.generic.BranchInstruction; //导入依赖的package包/类
public void start() {
if (!_mg.isAbstract() && !_mg.isNative()) {
for (InstructionHandle ih = _mg.getInstructionList().getStart(); ih != null; ih = ih
.getNext()) {
Instruction i = ih.getInstruction();
if (i instanceof BranchInstruction) {
branch_map.put(i, ih); // memorize container
}
if (ih.hasTargeters()) {
if (i instanceof BranchInstruction) {
_out.println(" InstructionHandle ih_" + ih.getPosition() + ";");
} else {
_out.print(" InstructionHandle ih_" + ih.getPosition() + " = ");
}
} else {
_out.print(" ");
}
if (!visitInstruction(i)) {
i.accept(this);
}
}
updateBranchTargets();
updateExceptionHandlers();
}
}
示例3: updateBranchTargets
import org.apache.bcel.generic.BranchInstruction; //导入依赖的package包/类
private void updateBranchTargets() {
for (Iterator i = branches.iterator(); i.hasNext();) {
BranchInstruction bi = (BranchInstruction) i.next();
BranchHandle bh = (BranchHandle) branch_map.get(bi);
int pos = bh.getPosition();
String name = bi.getName() + "_" + pos;
int t_pos = bh.getTarget().getPosition();
_out.println(" " + name + ".setTarget(ih_" + t_pos + ");");
if (bi instanceof Select) {
InstructionHandle[] ihs = ((Select) bi).getTargets();
for (int j = 0; j < ihs.length; j++) {
t_pos = ihs[j].getPosition();
_out.println(" " + name + ".setTarget(" + j + ", ih_" + t_pos + ");");
}
}
}
}
示例4: injectCommonExceptionCatchBlock
import org.apache.bcel.generic.BranchInstruction; //导入依赖的package包/类
/**
* Inject common exception catch blocks
*/
public void injectCommonExceptionCatchBlock(InstructionList il, MethodGen method, int variableIndex) {
il.append(new INSTANCEOF(constantsPool.addClass(new ObjectType("java.lang.RuntimeException"))));
BranchInstruction b1 = InstructionFactory.createBranchInstruction(Constants.IFEQ, null);
il.append(b1);
il.append(InstructionFactory.createLoad(Type.OBJECT, variableIndex));
il.append(factory.createCheckCast(new ObjectType("java.lang.RuntimeException")));
il.append(InstructionConstants.ATHROW);
InstructionHandle ih1 = il.append(InstructionFactory.createLoad(Type.OBJECT, variableIndex));
il.append(new INSTANCEOF(constantsPool.addClass(new ObjectType("java.lang.Error"))));
BranchInstruction b2 = InstructionFactory.createBranchInstruction(Constants.IFEQ, null);
il.append(b2);
il.append(InstructionFactory.createLoad(Type.OBJECT, variableIndex));
il.append(factory.createCheckCast(new ObjectType("java.lang.Error")));
il.append(InstructionConstants.ATHROW);
InstructionHandle ih2 = il.append(InstructionFactory.createLoad(Type.OBJECT, variableIndex));
il.append(factory.createInvoke("java.lang.Throwable", "printStackTrace", Type.VOID, Type.NO_ARGS, Constants.INVOKEVIRTUAL));
il.append(factory.createNew("org.codehaus.jremoting.client.InvocationException"));
il.append(InstructionConstants.DUP);
il.append(factory.createNew("java.lang.StringBuffer"));
il.append(InstructionConstants.DUP);
il.append(new PUSH(constantsPool, "Should never get here: "));
il.append(factory.createInvoke("java.lang.StringBuffer", "<init>", Type.VOID, new Type[]{Type.STRING}, Constants.INVOKESPECIAL));
il.append(InstructionFactory.createLoad(Type.OBJECT, variableIndex));
il.append(factory.createInvoke("java.lang.Throwable", "getMessage", Type.STRING, Type.NO_ARGS, Constants.INVOKEVIRTUAL));
il.append(factory.createInvoke("java.lang.StringBuffer", "append", Type.STRINGBUFFER, new Type[]{Type.STRING}, Constants.INVOKEVIRTUAL));
il.append(factory.createInvoke("java.lang.StringBuffer", "toString", Type.STRING, Type.NO_ARGS, Constants.INVOKEVIRTUAL));
il.append(factory.createInvoke("org.codehaus.jremoting.client.InvocationException", "<init>", Type.VOID, new Type[]{Type.STRING}, Constants.INVOKESPECIAL));
il.append(InstructionConstants.ATHROW);
b1.setTarget(ih1);
b2.setTarget(ih2);
}
示例5: registerBranchInstruction
import org.apache.bcel.generic.BranchInstruction; //导入依赖的package包/类
public void registerBranchInstruction(BranchInstruction g, int id) {
InstructionHandle ih = mapID2InstructionHandle.get(id);
if (ih != null) {
// Instruction handle was registered before
g.setTarget(ih);
return;
}
// We haven't seen the instruction handle yet. Remember this branch
// instruction
List<BranchInstruction> l = mapID2BranchInstructions.get(id);
if (l == null)
l = new ArrayList<BranchInstruction>();
l.add(g);
mapID2BranchInstructions.put(id, l);
}
示例6: createInstructionGoto
import org.apache.bcel.generic.BranchInstruction; //导入依赖的package包/类
@SuppressWarnings("unused")
// Called using reflection
private Instruction createInstructionGoto(Element inst) {
int id = Integer.parseInt(inst.getAttributeValue("label"));
BranchInstruction bi = new GOTO(null);
instructionHandlerManager.registerBranchInstruction(bi, id);
return bi;
}
示例7: createInstructionIf_acmpne
import org.apache.bcel.generic.BranchInstruction; //导入依赖的package包/类
@SuppressWarnings("unused")
// Called using reflection
private Instruction createInstructionIf_acmpne(Element inst) {
int id = Integer.parseInt(inst.getAttributeValue("label"));
BranchInstruction bi = new IF_ACMPNE(null);
instructionHandlerManager.registerBranchInstruction(bi, id);
return bi;
}
示例8: createInstructionIf_icmplt
import org.apache.bcel.generic.BranchInstruction; //导入依赖的package包/类
@SuppressWarnings("unused")
// Called using reflection
private Instruction createInstructionIf_icmplt(Element inst) {
int id = Integer.parseInt(inst.getAttributeValue("label"));
BranchInstruction bi = new IF_ICMPLT(null);
instructionHandlerManager.registerBranchInstruction(bi, id);
return bi;
}
示例9: createInstructionIf_icmpgt
import org.apache.bcel.generic.BranchInstruction; //导入依赖的package包/类
@SuppressWarnings("unused")
// Called using reflection
private Instruction createInstructionIf_icmpgt(Element inst) {
int id = Integer.parseInt(inst.getAttributeValue("label"));
BranchInstruction bi = new IF_ICMPGT(null);
instructionHandlerManager.registerBranchInstruction(bi, id);
return bi;
}
示例10: createInstructionIf_icmpge
import org.apache.bcel.generic.BranchInstruction; //导入依赖的package包/类
@SuppressWarnings("unused")
// Called using reflection
private Instruction createInstructionIf_icmpge(Element inst) {
int id = Integer.parseInt(inst.getAttributeValue("label"));
BranchInstruction bi = new IF_ICMPGE(null);
instructionHandlerManager.registerBranchInstruction(bi, id);
return bi;
}
示例11: createInstructionIf_icmple
import org.apache.bcel.generic.BranchInstruction; //导入依赖的package包/类
@SuppressWarnings("unused")
// Called using reflection
private Instruction createInstructionIf_icmple(Element inst) {
int id = Integer.parseInt(inst.getAttributeValue("label"));
BranchInstruction bi = new IF_ICMPLE(null);
instructionHandlerManager.registerBranchInstruction(bi, id);
return bi;
}
示例12: createInstructionIf_icmpne
import org.apache.bcel.generic.BranchInstruction; //导入依赖的package包/类
@SuppressWarnings("unused")
// Called using reflection
private Instruction createInstructionIf_icmpne(Element inst) {
int id = Integer.parseInt(inst.getAttributeValue("label"));
BranchInstruction bi = new IF_ICMPNE(null);
instructionHandlerManager.registerBranchInstruction(bi, id);
return bi;
}
示例13: createInstructionIfeq
import org.apache.bcel.generic.BranchInstruction; //导入依赖的package包/类
@SuppressWarnings("unused")
// Called using reflection
private Instruction createInstructionIfeq(Element inst) {
int id = Integer.parseInt(inst.getAttributeValue("label"));
BranchInstruction bi = new IFEQ(null);
instructionHandlerManager.registerBranchInstruction(bi, id);
return bi;
}
示例14: createInstructionIfne
import org.apache.bcel.generic.BranchInstruction; //导入依赖的package包/类
@SuppressWarnings("unused")
// Called using reflection
private Instruction createInstructionIfne(Element inst) {
int id = Integer.parseInt(inst.getAttributeValue("label"));
BranchInstruction bi = new IFNE(null);
instructionHandlerManager.registerBranchInstruction(bi, id);
return bi;
}
示例15: getCodeBytes
import org.apache.bcel.generic.BranchInstruction; //导入依赖的package包/类
private byte[] getCodeBytes(Method m, int start, int end) {
byte[] code = m.getCode().getCode();
byte[] bytes = new byte[end - start];
System.arraycopy(code, start, bytes, 0, end - start);
try {
ByteSequence sequence = new ByteSequence(code);
while ((sequence.available() > 0) && (sequence.getIndex() < start)) {
Instruction.readInstruction(sequence);
}
int pos;
while (sequence.available() > 0 && ((pos = sequence.getIndex()) < end)) {
Instruction ins = Instruction.readInstruction(sequence);
if ((ins instanceof BranchInstruction) && !(ins instanceof TABLESWITCH) && !(ins instanceof LOOKUPSWITCH)) {
BranchInstruction bi = (BranchInstruction) ins;
int offset = bi.getIndex();
int target = offset + pos;
if (target >= end) { // or target < start ??
byte hiByte = (byte) ((target >> 8) & 0x000000FF);
byte loByte = (byte) (target & 0x000000FF);
bytes[pos + bi.getLength() - 2 - start] = hiByte;
bytes[pos + bi.getLength() - 1 - start] = loByte;
}
}
}
} catch (IOException ioe) {
}
return bytes;
}