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