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


Java InstructionList.insert方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: insertDeleteLocalRecord

import org.apache.bcel.generic.InstructionList; //导入方法依赖的package包/类
InstructionHandle insertDeleteLocalRecord(MethodGen m, InstructionList il,
    InstructionHandle i, int maxLocals) {
    String local_record_name = localRecordName(m);

    // Note: maxLocals has been recomputed at this point.
    il.insert(i, new ALOAD(maxLocals - 5));
    il.insert(i, ins_f.createInvoke(local_record_name, "delete", Type.VOID,
        new Type[] { new ObjectType(local_record_name) },
        Constants.INVOKESTATIC));

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

示例6: insertThrowAbort

import org.apache.bcel.generic.InstructionList; //导入方法依赖的package包/类
InstructionHandle insertThrowAbort(MethodGen m, InstructionList il,
    InstructionHandle pos) {
    InstructionHandle retval;

    retval = il.insert(pos, ins_f
        .createNew("ibis.cashmere.impl.aborts.AbortException"));
    il.insert(pos, new DUP());
    il.insert(pos, ins_f.createInvoke(
        "ibis.cashmere.impl.aborts.AbortException", "<init>", Type.VOID,
        Type.NO_ARGS, Constants.INVOKESPECIAL));
    il.insert(pos, new ATHROW());

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

示例7: insertTypecheckCode

import org.apache.bcel.generic.InstructionList; //导入方法依赖的package包/类
InstructionHandle insertTypecheckCode(MethodGen m, InstructionList il,
    InstructionHandle pos, int spawnId, int exceptionPos) {
    ArrayList<CodeExceptionGen> catches = mtab.getCatchTypes(m, spawnId);

    InstructionHandle[] jumpTargets = new InstructionHandle[catches.size() + 1];

    BranchHandle[] jumps = new BranchHandle[catches.size()];

    for (int i = 0; i < catches.size(); i++) {
        CodeExceptionGen e = catches.get(i);
        ObjectType type = e.getCatchType();
        InstructionHandle catchTarget = e.getHandlerPC();

        jumpTargets[i] = il.insert(pos, new ALOAD(exceptionPos));
        il.insert(pos, new INSTANCEOF(cpg.addClass(type)));
        il.insert(pos, new BIPUSH((byte) 1));
        jumps[i] = il.insert(pos, new IF_ICMPNE(null));
        il.insert(pos, new ALOAD(exceptionPos));
        il.insert(pos, ins_f.createCheckCast(type));
        il.insert(pos, new GOTO(catchTarget));
    }

    InstructionHandle t = il.insert(pos, new ALOAD(exceptionPos));
    il.insert(pos, new ATHROW());

    jumpTargets[catches.size()] = t;

    for (int i = 0; i < catches.size(); i++) {
        jumps[i].setTarget(jumpTargets[i + 1]);
    }

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

示例8: rewriteAbort

import org.apache.bcel.generic.InstructionList; //导入方法依赖的package包/类
void rewriteAbort(MethodGen m, InstructionList il, InstructionHandle i,
    int maxLocals) {
    // in a clone, we have to abort two lists: the outstanding spawns of
    // the parent, and the outstanding spawns of the clone.
    Instruction fa = getCashmere(ins_f);
    Instruction ab = ins_f.createInvoke("ibis.cashmere.impl.Cashmere", "abort",
        Type.VOID, new Type[] { irType, irType }, Constants.INVOKEVIRTUAL);
    if (mtab.isClone(m)) {
        int parentPos = 3;

        if (!m.isStatic()) { // we have an additional 'this' param
            parentPos++;
        }

        i.getPrev().getPrev().setInstruction(fa);
        // push outstanding spawns
        i.getPrev().setInstruction(new ALOAD(maxLocals - 3));

        // push parent invocationrecord
        i.setInstruction(new ALOAD(parentPos));
        i = i.getNext();
    } else if (mtab.containsInlet(m)) {
        i.getPrev().getPrev().setInstruction(fa);

        // push outstanding spawns
        i.getPrev().setInstruction(new ALOAD(maxLocals - 3));
        i.setInstruction(new ACONST_NULL());
        i = i.getNext();
    } else {
        i.getPrev().setInstruction(fa);
        // push outstanding spawns
        i.setInstruction(new ALOAD(maxLocals - 3));
        i = i.getNext();
        il.insert(i, new ACONST_NULL());
    }

    // and call Cashmere.abort
    il.insert(i, ab);

    // all jobs were killed, set outstandingSpawns to null
    il.insert(i, new ACONST_NULL()); // push null
    il.insert(i, new ASTORE(maxLocals - 3)); // write
}
 
开发者ID:pieterhijma,项目名称:cashmere,代码行数:44,代码来源:Cashmerec.java

示例9: insertAbortedCheck

import org.apache.bcel.generic.InstructionList; //导入方法依赖的package包/类
void insertAbortedCheck(MethodGen m, InstructionList il,
    InstructionHandle pos) {
    // Generates:
    //       if (cashmere.getParent() != null && cashmere.getParent().aborted) {
    //           throw new ibis.cashmere.impl.aborts.AbortException();
    //       }
    InstructionHandle abo = insertThrowAbort(m, il, pos);

    il.insert(abo, getCashmere(ins_f));
    il.insert(abo, ins_f.createInvoke("ibis.cashmere.impl.Cashmere", "getParent",
        irType, Type.NO_ARGS, Constants.INVOKEVIRTUAL));

    // test for null (root job)
    il.insert(abo, new IFNULL(pos));

    il.insert(abo, getCashmere(ins_f));
    il.insert(abo, ins_f.createInvoke("ibis.cashmere.impl.Cashmere", "getParent",
        irType, Type.NO_ARGS, Constants.INVOKEVIRTUAL));

    il.insert(abo, ins_f.createFieldAccess(
        "ibis.cashmere.impl.spawnSync.InvocationRecord", "aborted",
        Type.BOOLEAN, Constants.GETFIELD));
    il.insert(abo, new IFEQ(pos));

    /*
     ////@@@@@@@@@@2 this needs fixing :-(
     // Test for parent.eek, if non-null, throw it (exception in inlet).
     il.insert(abo, getCashmere(ins_f));
     il.insert(abo, ins_f.createInvoke("ibis.cashmere.impl.Cashmere", "getParent",
     irType, Type.NO_ARGS, Constants.INVOKEVIRTUAL));
     il.insert(abo, ins_f.createFieldAccess(
     "ibis.cashmere.impl.spawnSync.InvocationRecord", "eek",
     new ObjectType("java.lang.Throwable"), Constants.GETFIELD));
     il.insert(abo, new IFNULL(abo));
     il.insert(abo, getCashmere(ins_f));
     il.insert(abo, ins_f.createInvoke("ibis.cashmere.impl.Cashmere", "getParent",
     irType, Type.NO_ARGS, Constants.INVOKEVIRTUAL));
     il.insert(abo, ins_f.createFieldAccess(
     "ibis.cashmere.impl.spawnSync.InvocationRecord", "eek",
     new ObjectType("java.lang.Throwable"), Constants.GETFIELD));

     il.insert(abo, new ATHROW());
     */
}
 
开发者ID:pieterhijma,项目名称:cashmere,代码行数:45,代码来源:Cashmerec.java

示例10: initSpawnTargets

import org.apache.bcel.generic.InstructionList; //导入方法依赖的package包/类
void initSpawnTargets(InstructionList il) {
    for (int i = 0; i < idTable.size(); i++) {
        InstructionList storeIns = getStoreIns(i);

        if (storeIns == null) {
            continue;
        }

        if (isArrayStore(storeIns.getStart())) {
            continue;
        }

        Instruction store = storeIns.getStart().getInstruction();

        if (store instanceof LSTORE) {
            il.insert(new LCONST(0));
            il.append(il.getStart(), store);
        } else if (store instanceof ISTORE) {
            il.insert(new ICONST(0));
            il.append(il.getStart(), store);
        } else if (store instanceof FSTORE) {
            il.insert(new FCONST((float) 0.0));
            il.append(il.getStart(), store);
        } else if (store instanceof DSTORE) {
            il.insert(new DCONST(0.0));
            il.append(il.getStart(), store);
        } else if (store instanceof ASTORE) {
            il.insert(new ACONST_NULL());
            il.append(il.getStart(), store);
        } else if (store instanceof PUTFIELD) {
            // no need to init.
        } else if (store instanceof PUTSTATIC) {
            // no need to init.
        } else if (store instanceof ALOAD) {
            // no need to init.
        } else {
            System.err.println("WARNING: Unhandled store instruction in "
                + "initSpawnTargets, opcode = " + store.getOpcode()
                + " ins = " + store);
            // System.exit(1);
        }
    }
}
 
开发者ID:pieterhijma,项目名称:cashmere,代码行数:44,代码来源:Cashmerec.java

示例11: change2

import org.apache.bcel.generic.InstructionList; //导入方法依赖的package包/类
private boolean change2(MethodGen mg)
{
    InstructionList il = mg.getInstructionList();
    InstructionFinder f   = new InstructionFinder(il);
    String            pat = "ALOAD_0 ALOAD_1 PUTFIELD ALOAD_0 INVOKESPECIAL";

    boolean changed = false;
    for(Iterator j = f.search(pat, new IsInnerConstructor()); j.hasNext(); )
    {
        InstructionHandle[] match = (InstructionHandle[]) j.next();

        // replace
        //    ALOAD_0       [0] 
        //    ALOAD_1		[1]
        //    PUTFIELD		[2]
        //    ALOAD_0		[3]
        //    INVOKESPECIAL	[4]
        // with
        //    ALOAD_0		[0]
        //    INVOKESPECIAL	[4]
        //    ALOAD_0		[3]
        //    ALOAD_1		[1]
        //    PUTFIELD		[2]

        changed = true;
        try
        {
            InstructionList il2 = new InstructionList();
            il2.append(match[3].getInstruction());
            il2.append(match[4].getInstruction());
            il.delete(match[3], match[4]);
            il.insert(match[0], il2);
        }
        catch (TargetLostException e)
        {
        	System.err.println("ERROR IN "+mg);
            e.printStackTrace();
        }
    }
    return changed;
}
 
开发者ID:BowlerHatLLC,项目名称:feathers-sdk,代码行数:42,代码来源:Downgrader.java


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