本文整理汇总了Java中org.apache.bcel.generic.ALOAD类的典型用法代码示例。如果您正苦于以下问题:Java ALOAD类的具体用法?Java ALOAD怎么用?Java ALOAD使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ALOAD类属于org.apache.bcel.generic包,在下文中一共展示了ALOAD类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:pieterhijma,项目名称:cashmere,代码行数:20,代码来源:Cashmerec.java
示例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;
}
开发者ID:pieterhijma,项目名称:cashmere,代码行数:25,代码来源:Cashmerec.java
示例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;
}
开发者ID:pieterhijma,项目名称:cashmere,代码行数:26,代码来源:Cashmerec.java
示例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;
}
开发者ID:pieterhijma,项目名称:cashmere,代码行数:19,代码来源:Cashmerec.java
示例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));
}
}
开发者ID:gnosygnu,项目名称:luaj_xowa,代码行数:21,代码来源:JavaBuilder.java
示例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;
}
开发者ID:blackarbiter,项目名称:Android_Code_Arbiter,代码行数:54,代码来源:CookieFlagsDetector.java
示例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;
}
开发者ID:pieterhijma,项目名称:cashmere,代码行数:13,代码来源:Cashmerec.java
示例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);
}
}
}
}
}
开发者ID:pieterhijma,项目名称:cashmere,代码行数:37,代码来源:Cashmerec.java
示例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;
}
开发者ID:pieterhijma,项目名称:cashmere,代码行数:34,代码来源:Cashmerec.java
示例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;
}
开发者ID:pieterhijma,项目名称:cashmere,代码行数:17,代码来源:MethodGen.java
示例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;
}
开发者ID:pieterhijma,项目名称:cashmere,代码行数:15,代码来源:MethodGen.java
示例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;
}
开发者ID:pieterhijma,项目名称:cashmere,代码行数:10,代码来源:SpawnableCallAnalysis.java
示例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);
}
}
}
开发者ID:gnosygnu,项目名称:luaj_xowa,代码行数:37,代码来源:JavaBuilder.java
示例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);
}
}
开发者ID:gnosygnu,项目名称:luaj_xowa,代码行数:10,代码来源:JavaBuilder.java
示例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));
}
}
开发者ID:gnosygnu,项目名称:luaj_xowa,代码行数:11,代码来源:JavaBuilder.java
示例16: closureInitUpvalueFromLocal
import org.apache.bcel.generic.ALOAD; //导入依赖的package包/类
public void closureInitUpvalueFromLocal(String protoname, int newup, int pc, int srcslot) {
boolean isrw = pi.isReadWriteUpvalue( pi.vars[srcslot][pc].upvalue );
Type uptype = isrw? (Type) TYPE_LOCALUPVALUE: (Type) TYPE_LUAVALUE;
String destname = upvalueName(newup);
int index = findSlotIndex( srcslot, isrw );
append(new ALOAD(index));
append(factory.createFieldAccess(protoname, destname, uptype, Constants.PUTFIELD));
}
开发者ID:gnosygnu,项目名称:luaj_xowa,代码行数:9,代码来源:JavaBuilder.java
示例17: visitALOAD
import org.apache.bcel.generic.ALOAD; //导入依赖的package包/类
/** Checks if the constraints of operands of the said instruction(s) are satisfied. */
public void visitALOAD(ALOAD o){
int idx = o.getIndex();
if (idx < 0){
constraintViolated(o, "Index '"+idx+"' must be non-negative.");
}
else{
int maxminus1 = max_locals()-1;
if (idx > maxminus1){
constraintViolated(o, "Index '"+idx+"' must not be greater than max_locals-1 '"+maxminus1+"'.");
}
}
}
开发者ID:Hu6,项目名称:VestaClient,代码行数:14,代码来源:Pass3aVerifier.java
示例18: loadLocalVariable
import org.apache.bcel.generic.ALOAD; //导入依赖的package包/类
protected boolean loadLocalVariable(Variable variable, InstructionList il) {
if ( currentMethod == null ) throw new IllegalStateException();
for (LocalVariableGen lvg : currentMethod.getLocalVariables()) {
if (lvg.getName().equals( variable.getName()) ) {
il.append(new ALOAD(lvg.getIndex()));
return true;
}
}
return false;
}
开发者ID:jesusc,项目名称:eclectic,代码行数:12,代码来源:GenScope.java
示例19: createConstructor
import org.apache.bcel.generic.ALOAD; //导入依赖的package包/类
private void createConstructor(GenScope scope, ClassGen closureClass) {
InstructionList il = new InstructionList();
il.append(InstructionConstants.THIS); // Push `this'
il.append(new INVOKESPECIAL(closureClass.getConstantPool().addMethodref(closureClass.getSuperclassName(), "<init>", "()V")));
il.append(InstructionConstants.THIS); // Push `this'
il.append(scope.getInstructionFactory().createConstant(this.getFormalParameters().size()));
il.append(scope.getInstructionFactory().createPutField(DefaultTypes.IClosure.getClassName(), "numParameters_", Type.INT));
il.append(InstructionConstants.THIS); // Push `this'
il.append(new ALOAD(1)); // first parameter
il.append(scope.getInstructionFactory().createPutField(DefaultTypes.IClosure.getClassName(), "transformation_", DefaultTypes.IdcTransformation));
il.append(InstructionConstants.THIS); // Push `this'
il.append(new ALOAD(2)); // second parameter
il.append(scope.getInstructionFactory().createPutField(DefaultTypes.IClosure.getClassName(), "modelManager_", DefaultTypes.ModelManager));
// TODO: It would be nice to have cross-checking between code being generated and framework code
/*
il.append(InstructionConstants.THIS); // Push `this'
il.append(new ALOAD(1)); // first parameter
il.append(scope.getInstructionFactory().createPutField(DefaultTypes.IClosure.getClassName(), "modelManager_", DefaultTypes.ModelManager));
*/
il.append(InstructionConstants.RETURN);
MethodGen mg = new MethodGen(Constants.ACC_PUBLIC, Type.VOID, new Type[] { DefaultTypes.IdcTransformation, DefaultTypes.ModelManager } , null, "<init>",
closureClass.getClassName(), il, closureClass.getConstantPool());
// mg.setMaxStack(3);
mg.setMaxStack();
closureClass.addMethod(mg.getMethod());
}
开发者ID:jesusc,项目名称:eclectic,代码行数:36,代码来源:ClosureDefJVMGen.java
示例20: generateMain
import org.apache.bcel.generic.ALOAD; //导入依赖的package包/类
void generateMain(ClassGen clg, Method origMain) {
InstructionList il = new InstructionList();
MethodGen new_main = new MethodGen(Constants.ACC_STATIC
| Constants.ACC_PUBLIC, Type.VOID, new Type[] { new ArrayType(
Type.STRING, 1) }, new String[] { "argv" }, "main", clg
.getClassName(), il, clg.getConstantPool());
il.append(ins_f.createNew(cashmereType));
il.append(new DUP());
il.append(ins_f.createInvoke("ibis.cashmere.impl.Cashmere", "<init>",
Type.VOID, Type.NO_ARGS, Constants.INVOKESPECIAL));
il.append(ins_f.createInvoke("ibis.cashmere.impl.Cashmere", "isMaster",
Type.BOOLEAN, Type.NO_ARGS, Constants.INVOKEVIRTUAL));
BranchHandle ifcmp = il.append(new IFEQ(null));
InstructionHandle origMain_handle = il.append(new ALOAD(0));
InstructionHandle try_start = il.append(ins_f.createInvoke(clg
.getClassName(), origMain.getName(), Type.VOID,
new Type[] { new ArrayType(Type.STRING, 1) },
Constants.INVOKESTATIC));
BranchHandle try_end = il.append(new GOTO(null));
InstructionHandle e_handler = il.append(getCashmere(ins_f));
il.append(new SWAP());
il.append(ins_f.createInvoke("ibis.cashmere.impl.Cashmere", "exit",
Type.VOID, new Type[] { new ObjectType("java.lang.Throwable")},
Constants.INVOKEVIRTUAL));
BranchHandle gto2 = il.append(new GOTO(null));
InstructionHandle ifeq_target = il.append(getCashmere(ins_f));
ifcmp.setTarget(ifeq_target);
il.append(ins_f.createInvoke("ibis.cashmere.impl.Cashmere", "client",
Type.VOID, Type.NO_ARGS, Constants.INVOKEVIRTUAL));
il.append(getCashmere(ins_f));
il.append(ins_f.createInvoke("ibis.cashmere.impl.Cashmere", "isMaster",
Type.BOOLEAN, Type.NO_ARGS, Constants.INVOKEVIRTUAL));
il.append(new IFNE(origMain_handle));
InstructionHandle gto_target = il.append(getCashmere(ins_f));
try_end.setTarget(gto_target);
il.append(ins_f.createInvoke("ibis.cashmere.impl.Cashmere", "exit",
Type.VOID, Type.NO_ARGS, Constants.INVOKEVIRTUAL));
InstructionHandle gto2_target = il.append(new RETURN());
gto2.setTarget(gto2_target);
new_main.addExceptionHandler(try_start, try_end, e_handler,
new ObjectType("java.lang.Throwable"));
new_main.setMaxStack();
new_main.setMaxLocals();
new_main.addLocalVariable("argv", new ArrayType(Type.STRING, 1), 0,
origMain_handle, null);
removeLocalTypeTables(new_main);
Method main = new_main.getMethod();
gen_c.addMethod(main);
}
开发者ID:pieterhijma,项目名称:cashmere,代码行数:66,代码来源:Cashmerec.java
注:本文中的org.apache.bcel.generic.ALOAD类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论