本文整理汇总了Java中org.apache.bcel.generic.ALOAD类的典型用法代码示例。如果您正苦于以下问题:Java ALOAD类的具体用法?Java ALOAD怎么用?Java ALOAD使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ALOAD类属于org.apache.bcel.generic包,在下文中一共展示了ALOAD类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: insertDeleteSpawncounter
import org.apache.bcel.generic.ALOAD; //导入依赖的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;
}
示例2: pushParams
import org.apache.bcel.generic.ALOAD; //导入依赖的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;
}
示例3: rewriteStore
import org.apache.bcel.generic.ALOAD; //导入依赖的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;
}
示例4: rewriteLoad
import org.apache.bcel.generic.ALOAD; //导入依赖的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;
}
示例5: storeLocal
import org.apache.bcel.generic.ALOAD; //导入依赖的package包/类
public void storeLocal(int pc, int slot) {
boolean isupval = pi.isUpvalueAssign(pc, slot);
int index = findSlotIndex( slot, isupval );
if (isupval) {
boolean isupcreate = pi.isUpvalueCreate(pc, slot);
if ( isupcreate ) {
append(factory.createInvoke(classname, "newupe", TYPE_LOCALUPVALUE, ARG_TYPES_NONE, Constants.INVOKESTATIC));
append(InstructionConstants.DUP);
append(new ASTORE(index));
} else {
append(new ALOAD(index));
}
append(InstructionConstants.SWAP);
append(new PUSH(cp, 0));
append(InstructionConstants.SWAP);
append(InstructionConstants.AASTORE);
} else {
append(new ASTORE(index));
}
}
示例6: getCookieInstructionLocation
import org.apache.bcel.generic.ALOAD; //导入依赖的package包/类
/**
* This method is used to track calls made on a specific object. For instance, this could be used to track if "setHttpOnly(true)"
* was executed on a specific cookie object.
*
* This allows the detector to find interchanged calls like this
*
* Cookie cookie1 = new Cookie("f", "foo"); <- This cookie is unsafe
* Cookie cookie2 = new Cookie("b", "bar"); <- This cookie is safe
* cookie1.setHttpOnly(false);
* cookie2.setHttpOnly(true);
*
* @param cpg ConstantPoolGen
* @param startLocation The Location of the cookie initialization call.
* @param objectStackLocation The index of the cookie on the stack.
* @param invokeInstruction The instruction we want to detect.s
* @return The location of the invoke instruction provided for the cookie at a specific index on the stack.
*/
private Location getCookieInstructionLocation(ConstantPoolGen cpg, Location startLocation, int objectStackLocation, String invokeInstruction) {
Location location = startLocation;
InstructionHandle handle = location.getHandle();
int loadedStackValue = 0;
// Loop until we find the setSecure call for this cookie
while (handle.getNext() != null) {
handle = handle.getNext();
Instruction nextInst = handle.getInstruction();
// We check if the index of the cookie used for this invoke is the same as the one provided
if (nextInst instanceof ALOAD) {
ALOAD loadInst = (ALOAD)nextInst;
loadedStackValue = loadInst.getIndex();
}
if (nextInst instanceof INVOKEVIRTUAL
&& loadedStackValue == objectStackLocation) {
INVOKEVIRTUAL invoke = (INVOKEVIRTUAL) nextInst;
String methodNameWithSignature = invoke.getClassName(cpg) + "." + invoke.getMethodName(cpg);
if (methodNameWithSignature.equals(invokeInstruction)) {
Integer val = ByteCode.getConstantInt(handle.getPrev());
if (val != null && val == TRUE_INT_VALUE) {
return new Location(handle, location.getBasicBlock());
}
}
}
}
return null;
}
示例7: insertDeleteLocalRecord
import org.apache.bcel.generic.ALOAD; //导入依赖的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;
}
示例8: removeUnusedLocals
import org.apache.bcel.generic.ALOAD; //导入依赖的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);
}
}
}
}
}
示例9: insertTypecheckCode
import org.apache.bcel.generic.ALOAD; //导入依赖的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;
}
示例10: isUsedForArrayLength
import org.apache.bcel.generic.ALOAD; //导入依赖的package包/类
/** Tests whether an object load instruction is used for computing an array length.
*
* @param loadInstruction the load instruction that loads the object
* reference onto the stack.
* @return true if the instruction is a load instruction of an object which
* is used for computing an array length.
*/
public boolean isUsedForArrayLength(InstructionHandle loadInstruction) {
if (loadInstruction.getInstruction() instanceof ALOAD) {
InstructionHandle next = loadInstruction.getNext();
if (next != null && (next.getInstruction() instanceof ARRAYLENGTH)) {
return true;
}
}
return false;
}
示例11: getAllObjectLoadInstructions
import org.apache.bcel.generic.ALOAD; //导入依赖的package包/类
private ArrayList<InstructionHandle> getAllObjectLoadInstructions(InstructionList il) {
ArrayList<InstructionHandle> objectLoadInstructions = new ArrayList<InstructionHandle>();
InstructionHandle current = il.getStart();
while(current != null) {
Instruction instruction = current.getInstruction();
if (instruction instanceof ALOAD || instruction instanceof GETSTATIC) {
objectLoadInstructions.add(current);
}
current = current.getNext();
}
return objectLoadInstructions;
}
示例12: indexToCheckForAlias
import org.apache.bcel.generic.ALOAD; //导入依赖的package包/类
private int indexToCheckForAlias(InstructionHandle ih, MethodGen mg) {
if (mg.isArrayStore(ih.getInstruction()) || ih.getInstruction() instanceof PUTFIELD) {
ih = mg.getObjectReferenceLoadInstruction(ih);
ALOAD objectLoadInstruction = (ALOAD) ih.getInstruction();
// The 'not an ALOAD' case is already dealt with.
return objectLoadInstruction.getIndex();
}
return -1;
}
示例13: initializeSlots
import org.apache.bcel.generic.ALOAD; //导入依赖的package包/类
public void initializeSlots() {
int slot = 0;
createUpvalues(-1, 0, p.maxstacksize);
if ( superclassType == SUPERTYPE_VARARGS ) {
for ( slot=0; slot<p.numparams; slot++ ) {
if ( pi.isInitialValueUsed(slot) ) {
append(new ALOAD(1));
append(new PUSH(cp, slot+1));
append(factory.createInvoke(STR_VARARGS, "arg", TYPE_LUAVALUE, ARG_TYPES_INT, Constants.INVOKEVIRTUAL));
storeLocal(-1, slot);
}
}
append(new ALOAD(1));
append(new PUSH(cp, 1 + p.numparams));
append(factory.createInvoke(STR_VARARGS, "subargs", TYPE_VARARGS, ARG_TYPES_INT, Constants.INVOKEVIRTUAL));
append(new ASTORE(1));
} else {
// fixed arg function between 0 and 3 arguments
for ( slot=0; slot<p.numparams; slot++ ) {
this.plainSlotVars.put( Integer.valueOf(slot), Integer.valueOf(1+slot) );
if ( pi.isUpvalueCreate(-1, slot) ) {
append(new ALOAD(1+slot));
storeLocal(-1, slot);
}
}
}
// nil parameters
// TODO: remove this for lua 5.2, not needed
for ( ; slot<p.maxstacksize; slot++ ) {
if ( pi.isInitialValueUsed(slot) ) {
loadNil();
storeLocal(-1, slot);
}
}
}
示例14: loadLocal
import org.apache.bcel.generic.ALOAD; //导入依赖的package包/类
public void loadLocal(int pc, int slot) {
boolean isupval = pi.isUpvalueRefer(pc, slot);
int index = findSlotIndex( slot, isupval );
append(new ALOAD(index));
if (isupval) {
append(new PUSH(cp, 0));
append(InstructionConstants.AALOAD);
}
}
示例15: convertToUpvalue
import org.apache.bcel.generic.ALOAD; //导入依赖的package包/类
public void convertToUpvalue(int pc, int slot) {
boolean isupassign = pi.isUpvalueAssign(pc, slot);
if ( isupassign ) {
int index = findSlotIndex( slot, false );
append(new ALOAD(index));
append(factory.createInvoke(classname, "newupl", TYPE_LOCALUPVALUE, ARG_TYPES_LUAVALUE, Constants.INVOKESTATIC));
int upindex = findSlotIndex( slot, true );
append(new ASTORE(upindex));
}
}