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


Java LocalVariableInstruction.getIndex方法代码示例

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


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

示例1: rewriteLocal

import org.apache.bcel.generic.LocalVariableInstruction; //导入方法依赖的package包/类
void rewriteLocal(InstructionHandle fromH, InstructionHandle toH,
    int oldindex, int newindex) {

InstructionHandle h = fromH;
if (h.getPrev() != null) {
    h = h.getPrev();
    // This instruction should contain the store.
}
while (h != null && h != toH) {
    Instruction ins = h.getInstruction();
    if (ins instanceof LocalVariableInstruction) {
	LocalVariableInstruction lins = (LocalVariableInstruction) ins;
	if (lins.getIndex() == oldindex) {
	    lins.setIndex(newindex);
	}
    }
    h = h.getNext();
}
   }
 
开发者ID:pieterhijma,项目名称:cashmere,代码行数:20,代码来源:MethodTable.java

示例2: getLocal

import org.apache.bcel.generic.LocalVariableInstruction; //导入方法依赖的package包/类
final LocalVariableGen getLocal(MethodGen m, LocalVariableInstruction curr,
    int pos) {
int localNr = curr.getIndex();
LocalVariableGen[] lt = getLocalTable(m);

for (int i = 0; i < lt.length; i++) {
    // Watch out. The first initialization seems not to be included in
    // the range given in the local variable table!

    if (localNr == lt[i].getIndex()) {
	// System.err.println("Looking for local " + localNr
	// + " on position " + pos);
	// System.err.println("found one with range "
	// + lt[i].getStart().getPrev().getPosition() + ", "
	// + lt[i].getEnd().getPosition());

	if (pos >= lt[i].getStart().getPrev().getPosition()
		&& pos < (lt[i].getEnd().getPosition())) {
	    return lt[i];
	}
    }
}

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

示例3: removeUnusedLocals

import org.apache.bcel.generic.LocalVariableInstruction; //导入方法依赖的package包/类
void removeUnusedLocals(Method mOrig, MethodGen m) {
    InstructionList il = m.getInstructionList();
    InstructionHandle[] ins = il.getInstructionHandles();
    for (int i = 0; i < ins.length; i++) {
        Instruction in = ins[i].getInstruction();

        if (in instanceof LocalVariableInstruction) {
            LocalVariableInstruction curr = (LocalVariableInstruction) in;
            if (mtab.getLocal(m, curr, ins[i].getPosition()) != null
                && curr.getIndex() < m.getMaxLocals() - 5
                && !mtab.isLocalUsedInInlet(mOrig, curr.getIndex())) {
                if (curr instanceof IINC) {
                    ins[i].setInstruction(new NOP());
                } else if (curr instanceof LSTORE || curr instanceof DSTORE) {
                    ins[i].setInstruction(new POP2());
                } else if (curr instanceof StoreInstruction) {
                    ins[i].setInstruction(new POP());
                } else if (curr instanceof ALOAD) {
                    ins[i].setInstruction(new ACONST_NULL());
                } else if (curr instanceof FLOAD) {
                    ins[i].setInstruction(new FCONST((float) 0.0));
                } else if (curr instanceof ILOAD) {
                    ins[i].setInstruction(new ICONST(0));
                } else if (curr instanceof DLOAD) {
                    ins[i].setInstruction(new DCONST(0.0));
                } else if (curr instanceof LLOAD) {
                    ins[i].setInstruction(new LCONST(0L));
                } else {
                    System.out.println("unhandled ins in "
                        + "removeUnusedLocals: " + curr);
                    System.exit(1);
                }
            }
        }
    }
}
 
开发者ID:pieterhijma,项目名称:cashmere,代码行数:37,代码来源:Cashmerec.java


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