当前位置: 首页>>代码示例>>Java>>正文


Java BranchInstruction类代码示例

本文整理汇总了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();

}
 
开发者ID:shannah,项目名称:cn1,代码行数:21,代码来源:JavaByteCodeOutputProcess.java

示例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();
    }
}
 
开发者ID:Hu6,项目名称:VestaClient,代码行数:26,代码来源:BCELFactory.java

示例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 + ");");
            }
        }
    }
}
 
开发者ID:Hu6,项目名称:VestaClient,代码行数:18,代码来源:BCELFactory.java

示例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);

}
 
开发者ID:paul-hammant,项目名称:JRemoting,代码行数:37,代码来源:BcelStubGenerator.java

示例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);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:16,代码来源:JavaByteCodeOutputProcess.java

示例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;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:9,代码来源:JavaByteCodeOutputProcess.java

示例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;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:9,代码来源:JavaByteCodeOutputProcess.java

示例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;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:9,代码来源:JavaByteCodeOutputProcess.java

示例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;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:9,代码来源:JavaByteCodeOutputProcess.java

示例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;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:9,代码来源:JavaByteCodeOutputProcess.java

示例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;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:9,代码来源:JavaByteCodeOutputProcess.java

示例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;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:9,代码来源:JavaByteCodeOutputProcess.java

示例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;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:9,代码来源:JavaByteCodeOutputProcess.java

示例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;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:9,代码来源:JavaByteCodeOutputProcess.java

示例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;
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:32,代码来源:DuplicateBranches.java


注:本文中的org.apache.bcel.generic.BranchInstruction类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。