• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java BranchInstruction类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.bcel.generic.BranchInstruction的典型用法代码示例。如果您正苦于以下问题:Java BranchInstruction类的具体用法?Java BranchInstruction怎么用?Java BranchInstruction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



BranchInstruction类属于org.apache.bcel.generic包,在下文中一共展示了BranchInstruction类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: isMerge

import org.apache.bcel.generic.BranchInstruction; //导入依赖的package包/类
/**
 * Determine whether or not the given instruction is a control flow merge.
 *
 * @param handle
 *            the instruction
 * @return true if the instruction is a control merge, false otherwise
 */
private static boolean isMerge(InstructionHandle handle) {
    if (handle.hasTargeters()) {
        // Check all targeters of this handle to see if any
        // of them are branches. If so, the instruction is a merge.
        InstructionTargeter[] targeterList = handle.getTargeters();
        for (InstructionTargeter targeter : targeterList) {
            if (targeter instanceof BranchInstruction)
                return true;
        }
    }
    return false;
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:20,代码来源:BetterCFGBuilder2.java


示例17: createInterfaceMethodArgs

import org.apache.bcel.generic.BranchInstruction; //导入依赖的package包/类
/**
 * Create interface method's args.
 *
 * @param numberOfArguments  the number of arguments.
 * @param il                 an instruction list
 * @param variableIndex      a varible index.
 * @param paramTypes         parameter types
 * @param generatedClassName the generated class name.
 */
private void createInterfaceMethodArgs(int numberOfArguments, InstructionList il, int variableIndex, Class[] paramTypes, String generatedClassName) {
    Type previousType = null;
    int loadIndex = 0;
    for (int i = 0; i < numberOfArguments; i++) {
        // assigning the obj ref's
        il.append(InstructionFactory.createLoad(Type.OBJECT, variableIndex - 1));
        il.append(new PUSH(constantsPool, i));
        String className = paramTypes[i].getName();
        //adjust for any previous wider datatype (double/long)
        if (previousType != null && (previousType == Type.DOUBLE || previousType == Type.LONG)) {
            ++loadIndex;
        }
        if (paramTypes[i].isPrimitive()) {
            il.append(factory.createNew(getJavaWrapperClass(className)));
            il.append(InstructionConstants.DUP);
            il.append(InstructionFactory.createLoad(getBCELPrimitiveType(className), ++loadIndex));
            il.append(factory.createInvoke(getJavaWrapperClass(className), "<init>", Type.VOID, new Type[]{getBCELPrimitiveType(className)}, Constants.INVOKESPECIAL));
            il.append(InstructionConstants.AASTORE);
        } else {

            //create the static fields for enabling .class calls
            String encodedFieldName;
            if (paramTypes[i].isArray()) {
                int index = className.lastIndexOf('[');
                if (className.charAt(index + 1) == 'L') {
                    encodedFieldName = "array$" + className.substring(1 + index, className.length() - 1).replace('.', '$');
                } else {
                    encodedFieldName = "array$" + className.substring(1 + index, className.length());
                }
            } else {
                encodedFieldName = "class$" + className.replace('.', '$');
            }

            addField(encodedFieldName);
            // ******** TODO assign the obj reference
            il.append(InstructionFactory.createLoad(Type.OBJECT, variableIndex - 1));
            il.append(new PUSH(constantsPool, i));
            il.append(InstructionFactory.createLoad(Type.OBJECT, ++loadIndex));
            il.append(InstructionConstants.AASTORE);

            // *********TODO assign the class ref's
            il.append(InstructionFactory.createLoad(Type.OBJECT, variableIndex));
            il.append(new PUSH(constantsPool, i));
            il.append(factory.createFieldAccess(generatedClassName, encodedFieldName, new ObjectType("java.lang.Class"), Constants.GETSTATIC));
            BranchInstruction ifnull = InstructionFactory.createBranchInstruction(Constants.IFNULL, null);
            il.append(ifnull);
            il.append(factory.createFieldAccess(generatedClassName, encodedFieldName, new ObjectType("java.lang.Class"), Constants.GETSTATIC));
            BranchInstruction goHeadToStoreRef = InstructionFactory.createBranchInstruction(Constants.GOTO, null);
            il.append(goHeadToStoreRef);
            InstructionHandle ifnullStartHere = il.append(new PUSH(constantsPool, className));

            ifnull.setTarget(ifnullStartHere);

            il.append(factory.createInvoke(generatedClassName, "class$", new ObjectType("java.lang.Class"), new Type[]{Type.STRING}, Constants.INVOKESTATIC));
            il.append(InstructionConstants.DUP);
            il.append(factory.createFieldAccess(generatedClassName, encodedFieldName, new ObjectType("java.lang.Class"), Constants.PUTSTATIC));
            InstructionHandle storeClassRef = il.append(InstructionConstants.AASTORE);
            goHeadToStoreRef.setTarget(storeClassRef);

        }
        previousType = getBCELPrimitiveType(className);
    }
}
 
开发者ID:paul-hammant,项目名称:JRemoting,代码行数:73,代码来源:BcelStubGenerator.java


示例18: InstructionHandlerManager

import org.apache.bcel.generic.BranchInstruction; //导入依赖的package包/类
public InstructionHandlerManager() {
    mapID2InstructionHandle = new HashMap<Integer, InstructionHandle>();
    mapID2BranchInstructions = new HashMap<Integer, List<BranchInstruction>>();
    currentIds = new ArrayList<Integer>();
}
 
开发者ID:shannah,项目名称:cn1,代码行数:6,代码来源:JavaByteCodeOutputProcess.java


示例19: JavaBuilder

import org.apache.bcel.generic.BranchInstruction; //导入依赖的package包/类
public JavaBuilder(ProtoInfo pi, String classname, String filename) {
	this.pi = pi;
	this.p = pi.prototype;
	this.classname = classname;
	
	// what class to inherit from
	superclassType = p.numparams;
	if ( p.is_vararg != 0 || superclassType >= SUPERTYPE_VARARGS )
		superclassType = SUPERTYPE_VARARGS;
	for ( int i=0, n=p.code.length; i<n; i++ ) {
		int inst = p.code[i];
		int o = Lua.GET_OPCODE(inst);
		if ( (o == Lua.OP_TAILCALL) ||
		     ((o == Lua.OP_RETURN) && (Lua.GETARG_B(inst) < 1 || Lua.GETARG_B(inst) > 2)) ) {
			superclassType = SUPERTYPE_VARARGS;
			break;
		}
	}
	
	// create class generator
	cg = new ClassGen(classname, SUPER_NAME_N[superclassType], filename,
			Constants.ACC_PUBLIC | Constants.ACC_SUPER, null);
	cp = cg.getConstantPool(); // cg creates constant pool

	// main instruction lists
	factory = new InstructionFactory(cg);
	init = new InstructionList();
	main = new InstructionList();

	// create the fields
	for ( int i=0; i<p.upvalues.length; i++ ) {
		boolean isrw = pi.isReadWriteUpvalue( pi.upvals[i] ); 
		Type uptype = isrw? (Type) TYPE_LOCALUPVALUE: (Type) TYPE_LUAVALUE;
		FieldGen fg = new FieldGen(0, uptype, upvalueName(i), cp);
		cg.addField(fg.getField());
	}
	
	// create the method
	mg = new MethodGen( Constants.ACC_PUBLIC | Constants.ACC_FINAL, // access flags
			RETURN_TYPE_N[superclassType], // return type
			ARG_TYPES_N[superclassType], // argument types
			ARG_NAMES_N[superclassType], // arg names
			METH_NAME_N[superclassType], 
			STR_LUAVALUE, // method, defining class
			main, cp);
	
	// initialize the values in the slots
	initializeSlots();	

	// initialize branching
	int nc = p.code.length;
	targets = new int[nc];
	branches = new BranchInstruction[nc];
	branchDestHandles = new InstructionHandle[nc];
	lastInstrHandles = new InstructionHandle[nc];
}
 
开发者ID:gnosygnu,项目名称:luaj_xowa,代码行数:57,代码来源:JavaBuilder.java


示例20: append

import org.apache.bcel.generic.BranchInstruction; //导入依赖的package包/类
private void append( BranchInstruction i ) {
	conditionalSetBeginningOfLua( main.append(i) );
}
 
开发者ID:gnosygnu,项目名称:luaj_xowa,代码行数:4,代码来源:JavaBuilder.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DisconnectedBufferOptions类代码示例发布时间:2022-05-22
下一篇:
Java ShiroAuthRealmType类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap