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

Java InstructionList类代码示例

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

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



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

示例1: visitCode

import org.apache.bcel.generic.InstructionList; //导入依赖的package包/类
/**
 * @see org.apache.bcel.classfile.Visitor#visitCode
 */
public void visitCode(Code aCode)
{   
    for (Iterator iter = mVisitors.iterator(); iter.hasNext();) {
        IDeepVisitor visitor = (IDeepVisitor) iter.next();
        Visitor v = visitor.getClassFileVisitor();
        aCode.accept(v);
    }
    
    // perform a deep visit
    final byte[] code = aCode.getCode();
    final InstructionList list = new InstructionList(code);
    final Iterator it = list.iterator();
    for (Iterator iter = list.iterator(); iter.hasNext();) {
        InstructionHandle instruction = (InstructionHandle) iter.next();
        visitInstructionHandle(instruction);
    }
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:21,代码来源:VisitorSet.java


示例2: fillSpawnTable

import org.apache.bcel.generic.InstructionList; //导入依赖的package包/类
private void fillSpawnTable(MethodTableEntry me) {
InstructionList il = me.mg.getInstructionList();
InstructionHandle[] ins = il.getInstructionHandles();

il.setPositions();

int spawnId = 0;

for (int k = 0; k < ins.length; k++) {
    if (ins[k].getInstruction() instanceof INVOKEVIRTUAL) {
	Method target = self.findMethod((INVOKEVIRTUAL) (ins[k]
		.getInstruction()));
	JavaClass cl = self.findMethodClass((INVOKEVIRTUAL) (ins[k]
		.getInstruction()));
	if (isSpawnable(target, cl)) {
	    // we have a spawn!
	    analyzeSpawn(me, ins[k], spawnId);
	    spawnId++;
	}
    }
}
   }
 
开发者ID:pieterhijma,项目名称:cashmere,代码行数:23,代码来源:MethodTable.java


示例3: calcNrSpawns

import org.apache.bcel.generic.InstructionList; //导入依赖的package包/类
private int calcNrSpawns(MethodGen mg) {
InstructionList il = mg.getInstructionList();
if (il == null) {
    return 0;
}

InstructionHandle[] ins = il.getInstructionHandles();
int count = 0;

for (int i = 0; i < ins.length; i++) {
    if (ins[i].getInstruction() instanceof INVOKEVIRTUAL) {
	Method target = self.findMethod((INVOKEVIRTUAL) (ins[i]
		.getInstruction()));
	JavaClass cl = self.findMethodClass((INVOKEVIRTUAL) (ins[i]
		.getInstruction()));
	if (isSpawnable(target, cl)) {
	    count++;
	}
    }
}

return count;
   }
 
开发者ID:pieterhijma,项目名称:cashmere,代码行数:24,代码来源:MethodTable.java


示例4: containsSpawnedCall

import org.apache.bcel.generic.InstructionList; //导入依赖的package包/类
boolean containsSpawnedCall(MethodGen m) {
InstructionList code = m.getInstructionList();

if (code == null) {
    return false;
}

InstructionHandle ih[] = code.getInstructionHandles();

for (int i = 0; i < ih.length; i++) {
    Instruction ins = ih[i].getInstruction();
    if (ins instanceof INVOKEVIRTUAL) {
	Method target = self.findMethod((INVOKEVIRTUAL) (ins));
	JavaClass cl = self.findMethodClass((INVOKEVIRTUAL) (ins));
	if (isSpawnable(target, cl)) {
	    return true;
	}
    }
}

return false;
   }
 
开发者ID:pieterhijma,项目名称:cashmere,代码行数:23,代码来源:MethodTable.java


示例5: insertDeleteSpawncounter

import org.apache.bcel.generic.InstructionList; //导入依赖的package包/类
InstructionHandle insertDeleteSpawncounter(InstructionList il,
    InstructionHandle i, int maxLocals) {
    // In this case, jumps to the return must in fact jump to
    // the new instruction sequence! So, we change the instruction
    // at the handle.

    // First, save the return instruction.
    Instruction r = i.getInstruction();

    i.setInstruction(new ALOAD(maxLocals));
    i = il
        .append(i, ins_f.createInvoke(
            "ibis.cashmere.impl.spawnSync.SpawnCounter", "deleteSpawnCounter",
            Type.VOID, new Type[] { spawnCounterType },
            Constants.INVOKESTATIC));
    i = il.append(i, r);

    return i;
}
 
开发者ID:pieterhijma,项目名称:cashmere,代码行数:20,代码来源:Cashmerec.java


示例6: deleteIns

import org.apache.bcel.generic.InstructionList; //导入依赖的package包/类
static private void deleteIns(InstructionList il, InstructionHandle ih,
    InstructionHandle new_target) {
    // System.out.println("deleteIns: instructionList = " + il);
    // System.out.println("   handle = " + ih);
    try {
        il.delete(ih);
    } catch (TargetLostException e) {
        InstructionHandle[] targets = e.getTargets();
        for (int i = 0; i < targets.length; i++) {
            InstructionTargeter[] targeters = targets[i].getTargeters();

            for (int j = 0; j < targeters.length; j++) {
                targeters[j].updateTarget(targets[i], new_target);
            }
        }
    }
}
 
开发者ID:pieterhijma,项目名称:cashmere,代码行数:18,代码来源:Cashmerec.java


示例7: pushParams

import org.apache.bcel.generic.InstructionList; //导入依赖的package包/类
InstructionHandle pushParams(InstructionList il, Method m) {
    Type[] params = mtab.typesOfParams(m);
    InstructionHandle pos = il.getStart();

    for (int i = 0, param = 0; i < params.length; i++, param++) {
        if (params[i].equals(Type.BOOLEAN) || params[i].equals(Type.BYTE)
            || params[i].equals(Type.SHORT) || params[i].equals(Type.CHAR)
            || params[i].equals(Type.INT)) {
            il.insert(pos, new ILOAD(param));
        } else if (params[i].equals(Type.FLOAT)) {
            il.insert(pos, new FLOAD(param));
        } else if (params[i].equals(Type.LONG)) {
            il.insert(pos, new LLOAD(param));
            param++;
        } else if (params[i].equals(Type.DOUBLE)) {
            il.insert(pos, new DLOAD(param));
            param++;
        } else {
            il.insert(pos, new ALOAD(param));
        }
    }

    return pos;
}
 
开发者ID:pieterhijma,项目名称:cashmere,代码行数:25,代码来源:Cashmerec.java


示例8: rewriteStore

import org.apache.bcel.generic.InstructionList; //导入依赖的package包/类
InstructionHandle rewriteStore(MethodGen m, InstructionList il,
    InstructionHandle i, int maxLocals, String localClassName) {
    LocalVariableInstruction curr = (LocalVariableInstruction) (i
        .getInstruction());
    Type type = mtab.getLocalType(m, curr, i.getPosition());
    if (type == null) {
        return i;
    }
    String name = mtab.getLocalName(m, curr, i.getPosition());
    String fieldName = MethodTable.generatedLocalName(type, name);

    i.setInstruction(new ALOAD(maxLocals));
    i = i.getNext();

    if (type.equals(Type.LONG) || type.equals(Type.DOUBLE)) {
        il.insert(i, new DUP_X2());
        il.insert(i, new POP());
    } else {
        il.insert(i, new SWAP());
    }

    i = il.insert(i, ins_f.createFieldAccess(localClassName, fieldName,
        type, Constants.PUTFIELD));
    return i;
}
 
开发者ID:pieterhijma,项目名称:cashmere,代码行数:26,代码来源:Cashmerec.java


示例9: rewriteLoad

import org.apache.bcel.generic.InstructionList; //导入依赖的package包/类
InstructionHandle rewriteLoad(MethodGen m, InstructionList il,
    InstructionHandle i, int maxLocals, String localClassName) {
    LocalVariableInstruction curr = (LocalVariableInstruction) (i
        .getInstruction());
    Type type = mtab.getLocalType(m, curr, i.getPosition());
    if (type == null) {
        return i;
    }
    String name = mtab.getLocalName(m, curr, i.getPosition());
    String fieldName = MethodTable.generatedLocalName(type, name);

    i.setInstruction(new ALOAD(maxLocals));
    i = i.getNext();
    i = il.insert(i, ins_f.createFieldAccess(localClassName, fieldName,
        type, Constants.GETFIELD));

    return i;
}
 
开发者ID:pieterhijma,项目名称:cashmere,代码行数:19,代码来源:Cashmerec.java


示例10: insertSync

import org.apache.bcel.generic.InstructionList; //导入依赖的package包/类
private void insertSync(Analyzer analyzer) throws MethodRewriteFailure {
d.log(1, "trying to insert sync statement(s)\n");
InstructionHandle[] ihs = 
    analyzer.proposeSyncInsertion(this, new Debug(d.turnedOn(), d.getStartLevel() + 2));

InstructionList instructionList = getInstructionList();

for (InstructionHandle ih : ihs) {
    InstructionHandle syncInvoke = 
	instructionList.insert(ih, 
		new INVOKEVIRTUAL(indexSync));
    InstructionHandle newTarget = instructionList.insert(syncInvoke, 
	    spawnableCalls.get(0).getObjectReference().getInstruction());
    // the same objectReference for every sync insertion
    instructionList.redirectBranches(ih, newTarget);
    d.log(2, "inserted sync()\n");
}
d.log(1, "inserted sync statement(s)\n");
   }
 
开发者ID:pieterhijma,项目名称:cashmere,代码行数:20,代码来源:SpawningMethod.java


示例11: callsSync

import org.apache.bcel.generic.InstructionList; //导入依赖的package包/类
private boolean callsSync() {
ConstantPoolGen cpg = getConstantPool();
InstructionList instructionList = getInstructionList();
InstructionHandle handle = instructionList.getStart();
while (handle != null) {
    Instruction ins = handle.getInstruction();
    if (ins instanceof INVOKEVIRTUAL) {
	INVOKEVIRTUAL inv = (INVOKEVIRTUAL) ins;
	if (inv.getMethodName(cpg).equals("sync") &&
		inv.getSignature(cpg).equals("()V")) {
	    JavaClass cl = findMethodClass(inv, cpg);
	    if (cl != null && cl.getClassName().equals("ibis.cashmere.CashmereObject")) {
		return true;
	    }
	}
    }
    handle = handle.getNext();
}
return false;
   }
 
开发者ID:pieterhijma,项目名称:cashmere,代码行数:21,代码来源:SpawningMethod.java


示例12: getLoadInstruction

import org.apache.bcel.generic.InstructionList; //导入依赖的package包/类
private InstructionHandle getLoadInstruction(InstructionList il, 
    SpawnableCall spawnableCall) throws SyncInsertionProposalFailure {

InstructionHandle ih = spawnableCall.getInvokeInstruction();
while ((ih = ih.getNext()) != null) {
    try {
	LoadInstruction loadInstruction = 
	    (LoadInstruction) (ih.getInstruction());
	if (spawnableCall.storesIn(loadInstruction.getIndex(), ih)) {
	    return ih;
		}
    }
    catch (ClassCastException e) {
    }
}
throw new SyncInsertionProposalFailure();
   }
 
开发者ID:pieterhijma,项目名称:cashmere,代码行数:18,代码来源:EarliestLoad.java


示例13: createHelperMethodForDotClassCalls

import org.apache.bcel.generic.InstructionList; //导入依赖的package包/类
/**
 * Creates a method class$(String) which is used
 * during SomeClass.class instruction
 *
 * @param generatedClassName the instance class name
 */
protected void createHelperMethodForDotClassCalls(String generatedClassName) {
    InstructionList il = new InstructionList();
    MethodGen method = new MethodGen(Constants.ACC_STATIC, new ObjectType("java.lang.Class"), new Type[]{Type.STRING}, new String[]{"arg0"}, "class$", generatedClassName, il, constantsPool);
    InstructionHandle ih0 = il.append(InstructionFactory.createLoad(Type.OBJECT, 0));
    il.append(factory.createInvoke("java.lang.Class", "forName", new ObjectType("java.lang.Class"), new Type[]{Type.STRING}, Constants.INVOKESTATIC));
    InstructionHandle ih4 = il.append(InstructionFactory.createReturn(Type.OBJECT));
    InstructionHandle ih5 = il.append(InstructionFactory.createStore(Type.OBJECT, 1));
    il.append(factory.createNew("java.lang.NoClassDefFoundError"));
    il.append(InstructionConstants.DUP);
    il.append(InstructionFactory.createLoad(Type.OBJECT, 1));
    il.append(factory.createInvoke("java.lang.Throwable", "getMessage", Type.STRING, Type.NO_ARGS, Constants.INVOKEVIRTUAL));
    il.append(factory.createInvoke("java.lang.NoClassDefFoundError", "<init>", Type.VOID, new Type[]{Type.STRING}, Constants.INVOKESPECIAL));
    il.append(InstructionConstants.ATHROW);
    method.addExceptionHandler(ih0, ih4, ih5, new ObjectType("java.lang.ClassNotFoundException"));
    method.setMaxStack();
    method.setMaxLocals();
    classGen.addMethod(method.getMethod());
    il.dispose();
}
 
开发者ID:paul-hammant,项目名称:JRemoting,代码行数:26,代码来源:BcelStubGenerator.java


示例14: generateEqualsMethod

import org.apache.bcel.generic.InstructionList; //导入依赖的package包/类
private void generateEqualsMethod(String generatedClassName) {

        /* public boolean equals(Object o) {
         *   return stubHelper.isEquals(this,o);
         * }
         */

        InstructionList il = new InstructionList();
        MethodGen method = new MethodGen(Constants.ACC_PUBLIC, Type.BOOLEAN, new Type[]{Type.OBJECT}, new String[]{"arg0"}, "equals", generatedClassName, il, constantsPool);

        il.append(InstructionFactory.createLoad(Type.OBJECT, 0));

        il.append(factory.createFieldAccess(generatedClassName, "stubHelper", new ObjectType("org.codehaus.jremoting.client.StubHelper"), Constants.GETFIELD));
        il.append(InstructionFactory.createLoad(Type.OBJECT, 0));
        il.append(InstructionFactory.createLoad(Type.OBJECT, 1));

        il.append(factory.createInvoke("org.codehaus.jremoting.client.StubHelper", "isEquals", Type.BOOLEAN, new Type[]{Type.OBJECT, Type.OBJECT}, Constants.INVOKEINTERFACE));
        il.append(InstructionFactory.createReturn(Type.INT));
        method.setMaxStack();
        method.setMaxLocals();
        classGen.addMethod(method.getMethod());
        il.dispose();
    }
 
开发者ID:paul-hammant,项目名称:JRemoting,代码行数:24,代码来源:BcelStubGenerator.java


示例15: handleCodeFragment

import org.apache.bcel.generic.InstructionList; //导入依赖的package包/类
/** Handles a single code fragment. */
private void handleCodeFragment(List<String> resultList,
		ConstantPoolGen cpg, Code code) {
	for (Instruction i : new InstructionList(code.getCode())
			.getInstructions()) {
		if (i instanceof NEW) {
			NEW newInstruction = (NEW) i;
			ObjectType ot = newInstruction.getLoadClassType(cpg);

			if (ot == null) { // ot is primitive type
				continue;
			}

			String newClassName = ot.getClassName();
			if (!resultList.contains(newClassName)
					&& !isBlacklisted(newClassName)) {
				resultList.add(newClassName);
			}
		}
	}
}
 
开发者ID:vimaier,项目名称:conqat,代码行数:22,代码来源:CreationListBuilder.java


示例16: get_instr

import org.apache.bcel.generic.InstructionList; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private static List<InstructionHandle> get_instr(int mid, long pid) {
	Util.log("-----------------------------------instr for (" + mid + ", " + pid + ")");
	List<InstructionHandle> ret = new ArrayList<InstructionHandle>();

	String prefix = "/var/tmp/sifa/path/reconstruction/";
	CFG dag = (CFG) Util.readFromFile(prefix + "epp_data/" + mid + ".dag");
	Hashtable<Edge, Long> labeled_edge = (Hashtable<Edge, Long>) Util.readFromFile(prefix + "epp_data/" + mid + ".le");
	Hashtable<Edge, Long> ldde = (Hashtable<Edge, Long>) Util.readFromFile(prefix + "epp_data/" + mid + ".ldde");
	InstructionList ilist = (InstructionList) Util.readFromFile(prefix + "epp_data/" + mid + ".ilist");

	PathRegenerator pr = new PathRegenerator(dag, labeled_edge, ldde);
	List<Integer> path = pr.findPath(pid);
	Util.log(path.toString());
	// for no path sensitivity calculation

	for (int j = 0; j < path.size(); j++) {
		InstructionHandle ihdl = ilist.findHandle(path.get(j));
		ret.add(ihdl);
	}

	// Util.log(new SIFInstructionBlock(mid, ret).toString());

	return ret;
}
 
开发者ID:USC-NSL,项目名称:SIF,代码行数:26,代码来源:PathStitcher.java


示例17: addTransactionMethod

import org.apache.bcel.generic.InstructionList; //导入依赖的package包/类
protected void addTransactionMethod(ParsedMethod pm) {
    String et = EntityTransaction.class.getCanonicalName();

    GeneratedMethod gm = new GeneratedMethod(pm);
    InstructionList il = gm.start();

    writeMethodPreamble(gm, il);
    il.append(_factory.createInvoke(EM_TYPE, "getTransaction",
        new ObjectType(et), Type.NO_ARGS, Constants.INVOKEINTERFACE));
    il.append(_factory.createInvoke(et, pm.getMethod().getName(),
        Type.VOID, Type.NO_ARGS, Constants.INVOKEINTERFACE));

    il.append(InstructionFactory.createReturn(Type.VOID));

    gm.done();
}
 
开发者ID:abassouk,项目名称:autodao,代码行数:17,代码来源:DAOAnalysis.java


示例18: addPassThruMethod

import org.apache.bcel.generic.InstructionList; //导入依赖的package包/类
protected void addPassThruMethod(ParsedMethod m) {
    GeneratedMethod gm = new GeneratedMethod(m);
    InstructionList il = gm.start();
    Type returnType = gm.getReturnType();

    boolean hasArg = m.getArgumentLength() > 0;

    writeMethodPreamble(gm, il);
    if (hasArg)
        il.append(InstructionFactory.createLoad(Type.OBJECT, 1));
    il.append(_factory.createInvoke(EM_TYPE, m.getMethod().getName(),
        returnType == Type.VOID ? Type.VOID : Type.OBJECT,
        hasArg ? new Type[] { Type.OBJECT } : Type.NO_ARGS,
        Constants.INVOKEINTERFACE));

    if (returnType != Type.VOID) {
        il.append(_factory.createCheckCast(((ReferenceType) returnType)));
    }
    il.append(InstructionFactory.createReturn(returnType));

    gm.done();
}
 
开发者ID:abassouk,项目名称:autodao,代码行数:23,代码来源:DAOAnalysis.java


示例19: addFindMethod

import org.apache.bcel.generic.InstructionList; //导入依赖的package包/类
protected void addFindMethod(ParsedMethod m) {
    GeneratedMethod gm = new GeneratedMethod(m);
    InstructionList il = gm.start();

    writeMethodPreamble(gm, il);
    il.append(new PUSH(_cp, (ObjectType) gm.getReturnType()));

    m.getArguments()[0].pushAsObject(il);

    il.append(_factory.createInvoke(EM_TYPE, "find", Type.OBJECT,
        new Type[] { Type.CLASS, Type.OBJECT }, Constants.INVOKEINTERFACE));

    il.append(_factory.createCheckCast(((ReferenceType) gm.getReturnType())));
    il.append(InstructionFactory.createReturn(gm.getReturnType()));

    gm.done();
}
 
开发者ID:abassouk,项目名称:autodao,代码行数:18,代码来源:DAOAnalysis.java


示例20: processMethodAnnotations

import org.apache.bcel.generic.InstructionList; //导入依赖的package包/类
protected void processMethodAnnotations(ParsedMethod m, InstructionList il) {
    MaxResults mr = m.getMethod().getAnnotation(MaxResults.class);
    if (mr != null) {
        if (mr.value() < 0) {
            throw new IllegalArgumentException(
                    "MaxResults without a value on " + m.getMethod());
        }
        il.append(new PUSH(_cp, mr.value()));
        il.append(_factory.createInvoke(TQ_CLASS, "setMaxResults",
            new ObjectType(TQ_CLASS), new Type[] { Type.INT },
            Constants.INVOKEINTERFACE));
    }

    FirstResult fr = m.getMethod().getAnnotation(FirstResult.class);
    if (fr != null && fr.value() > -1) {
        il.append(new PUSH(_cp, fr.value()));
        il.append(_factory.createInvoke(TQ_CLASS, "setFirstResult",
            new ObjectType(TQ_CLASS), new Type[] { Type.INT },
            Constants.INVOKEINTERFACE));
    }
}
 
开发者ID:abassouk,项目名称:autodao,代码行数:22,代码来源:DAOAnalysis.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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