本文整理汇总了Java中org.apache.bcel.generic.PUSH类的典型用法代码示例。如果您正苦于以下问题:Java PUSH类的具体用法?Java PUSH怎么用?Java PUSH使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PUSH类属于org.apache.bcel.generic包,在下文中一共展示了PUSH类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createInstructionPush
import org.apache.bcel.generic.PUSH; //导入依赖的package包/类
private CompoundInstruction createInstructionPush(Element inst) throws IllegalXMLVMException {
String t = inst.getAttributeValue("type");
Type type = parseTypeString(t);
String value = inst.getAttributeValue("value");
if (type == Type.STRING)
return new PUSH(constantPoolGen, value);
else if (type == Type.INT)
return new PUSH(constantPoolGen, Integer.parseInt(value));
else if (type == Type.FLOAT)
return new PUSH(constantPoolGen, Float.parseFloat(value));
else if (type == Type.DOUBLE)
return new PUSH(constantPoolGen, Double.parseDouble(value));
else if (type == Type.LONG)
return new PUSH(constantPoolGen, Long.parseLong(value));
else
throw new IllegalXMLVMException(inst.getName() + " with bad type '" + t + "'");
}
示例2: storeLocal
import org.apache.bcel.generic.PUSH; //导入依赖的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));
}
}
示例3: createLuaStringField
import org.apache.bcel.generic.PUSH; //导入依赖的package包/类
private String createLuaStringField(LuaString value) {
String name = PREFIX_CONSTANT+constants.size();
FieldGen fg = new FieldGen(Constants.ACC_STATIC | Constants.ACC_FINAL,
TYPE_LUAVALUE, name, cp);
cg.addField(fg.getField());
LuaString ls = value.checkstring();
if ( ls.isValidUtf8() ) {
init.append(new PUSH(cp, value.tojstring()));
init.append(factory.createInvoke(STR_LUASTRING, "valueOf",
TYPE_LUASTRING, ARG_TYPES_STRING, Constants.INVOKESTATIC));
} else {
char[] c = new char[ls.m_length];
for ( int j=0; j<ls.m_length; j++ )
c[j] = (char) (0xff & (int) (ls.m_bytes[ls.m_offset+j]));
init.append(new PUSH(cp, new String(c)));
init.append(factory.createInvoke(STR_STRING, "toCharArray",
TYPE_CHARARRAY, Type.NO_ARGS,
Constants.INVOKEVIRTUAL));
init.append(factory.createInvoke(STR_LUASTRING, "valueOf",
TYPE_LUASTRING, ARG_TYPES_CHARARRAY,
Constants.INVOKESTATIC));
}
init.append(factory.createPutStatic(classname, name, TYPE_LUAVALUE));
return name;
}
示例4: addFindMethod
import org.apache.bcel.generic.PUSH; //导入依赖的package包/类
protected void addFindMethod(ParsedMethod m) {
GeneratedMethod gm = new GeneratedMethod(m);
InstructionList il = gm.start();
writeMethodPreamble(gm, il);
il.append(new PUSH(_cp, (ObjectType) gm.getReturnType()));
m.getArguments()[0].pushAsObject(il);
il.append(_factory.createInvoke(EM_TYPE, "find", Type.OBJECT,
new Type[] { Type.CLASS, Type.OBJECT }, Constants.INVOKEINTERFACE));
il.append(_factory.createCheckCast(((ReferenceType) gm.getReturnType())));
il.append(InstructionFactory.createReturn(gm.getReturnType()));
gm.done();
}
示例5: processMethodAnnotations
import org.apache.bcel.generic.PUSH; //导入依赖的package包/类
protected void processMethodAnnotations(ParsedMethod m, InstructionList il) {
MaxResults mr = m.getMethod().getAnnotation(MaxResults.class);
if (mr != null) {
if (mr.value() < 0) {
throw new IllegalArgumentException(
"MaxResults without a value on " + m.getMethod());
}
il.append(new PUSH(_cp, mr.value()));
il.append(_factory.createInvoke(TQ_CLASS, "setMaxResults",
new ObjectType(TQ_CLASS), new Type[] { Type.INT },
Constants.INVOKEINTERFACE));
}
FirstResult fr = m.getMethod().getAnnotation(FirstResult.class);
if (fr != null && fr.value() > -1) {
il.append(new PUSH(_cp, fr.value()));
il.append(_factory.createInvoke(TQ_CLASS, "setFirstResult",
new ObjectType(TQ_CLASS), new Type[] { Type.INT },
Constants.INVOKEINTERFACE));
}
}
示例6: generateReadArrayCode
import org.apache.bcel.generic.PUSH; //导入依赖的package包/类
public void generateReadArrayCode(InstructionList il, InstructionFactory factory, ConstantPoolGen cp, int dim, int[] maxIndex)
{
for (int i = 0; i < dim; i++)
il.append(new PUSH(cp, maxIndex[i]));
il.append((Instruction) factory.createNewArray(type, (short) dim));
il.append(InstructionFactory.DUP_X1);
if (dim == 1)
il.append(factory.createInvoke("org.dianahep.root4j.core.RootInput", "readFixedArray", Type.VOID, arrayArgType, INVOKEINTERFACE));
else
il.append(factory.createInvoke("org.dianahep.root4j.core.RootInput", "readMultiArray", Type.VOID, objectArrayArgType, INVOKEINTERFACE));
}
示例7: injectCommonExceptionCatchBlock
import org.apache.bcel.generic.PUSH; //导入依赖的package包/类
/**
* Inject common exception catch blocks
*/
public void injectCommonExceptionCatchBlock(InstructionList il, MethodGen method, int variableIndex) {
il.append(new INSTANCEOF(constantsPool.addClass(new ObjectType("java.lang.RuntimeException"))));
BranchInstruction b1 = InstructionFactory.createBranchInstruction(Constants.IFEQ, null);
il.append(b1);
il.append(InstructionFactory.createLoad(Type.OBJECT, variableIndex));
il.append(factory.createCheckCast(new ObjectType("java.lang.RuntimeException")));
il.append(InstructionConstants.ATHROW);
InstructionHandle ih1 = il.append(InstructionFactory.createLoad(Type.OBJECT, variableIndex));
il.append(new INSTANCEOF(constantsPool.addClass(new ObjectType("java.lang.Error"))));
BranchInstruction b2 = InstructionFactory.createBranchInstruction(Constants.IFEQ, null);
il.append(b2);
il.append(InstructionFactory.createLoad(Type.OBJECT, variableIndex));
il.append(factory.createCheckCast(new ObjectType("java.lang.Error")));
il.append(InstructionConstants.ATHROW);
InstructionHandle ih2 = il.append(InstructionFactory.createLoad(Type.OBJECT, variableIndex));
il.append(factory.createInvoke("java.lang.Throwable", "printStackTrace", Type.VOID, Type.NO_ARGS, Constants.INVOKEVIRTUAL));
il.append(factory.createNew("org.codehaus.jremoting.client.InvocationException"));
il.append(InstructionConstants.DUP);
il.append(factory.createNew("java.lang.StringBuffer"));
il.append(InstructionConstants.DUP);
il.append(new PUSH(constantsPool, "Should never get here: "));
il.append(factory.createInvoke("java.lang.StringBuffer", "<init>", Type.VOID, new Type[]{Type.STRING}, Constants.INVOKESPECIAL));
il.append(InstructionFactory.createLoad(Type.OBJECT, variableIndex));
il.append(factory.createInvoke("java.lang.Throwable", "getMessage", Type.STRING, Type.NO_ARGS, Constants.INVOKEVIRTUAL));
il.append(factory.createInvoke("java.lang.StringBuffer", "append", Type.STRINGBUFFER, new Type[]{Type.STRING}, Constants.INVOKEVIRTUAL));
il.append(factory.createInvoke("java.lang.StringBuffer", "toString", Type.STRING, Type.NO_ARGS, Constants.INVOKEVIRTUAL));
il.append(factory.createInvoke("org.codehaus.jremoting.client.InvocationException", "<init>", Type.VOID, new Type[]{Type.STRING}, Constants.INVOKESPECIAL));
il.append(InstructionConstants.ATHROW);
b1.setTarget(ih1);
b2.setTarget(ih2);
}
示例8: translateUnallowedExtension
import org.apache.bcel.generic.PUSH; //导入依赖的package包/类
/**
* Translate code to call the BasisLibrary.unallowed_extensionF(String)
* method.
*/
private void translateUnallowedExtension(ConstantPoolGen cpg,
InstructionList il) {
int index = cpg.addMethodref(BASIS_LIBRARY_CLASS,
"unallowed_extension_functionF",
"(Ljava/lang/String;)V");
il.append(new PUSH(cpg, _fname.toString()));
il.append(new INVOKESTATIC(index));
}
示例9: initializeSlots
import org.apache.bcel.generic.PUSH; //导入依赖的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);
}
}
}
示例10: loadLocal
import org.apache.bcel.generic.PUSH; //导入依赖的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);
}
}
示例11: loadUpvalue
import org.apache.bcel.generic.PUSH; //导入依赖的package包/类
public void loadUpvalue(int upindex) {
boolean isrw = pi.isReadWriteUpvalue( pi.upvals[upindex] );
append(InstructionConstants.THIS);
if ( isrw ) {
append(factory.createFieldAccess(classname, upvalueName(upindex), TYPE_LOCALUPVALUE, Constants.GETFIELD));
append(new PUSH(cp,0));
append(InstructionConstants.AALOAD);
} else {
append(factory.createFieldAccess(classname, upvalueName(upindex), TYPE_LUAVALUE, Constants.GETFIELD));
}
}
示例12: storeUpvalue
import org.apache.bcel.generic.PUSH; //导入依赖的package包/类
public void storeUpvalue(int pc, int upindex, int slot) {
boolean isrw = pi.isReadWriteUpvalue( pi.upvals[upindex] );
append(InstructionConstants.THIS);
if ( isrw ) {
append(factory.createFieldAccess(classname, upvalueName(upindex), TYPE_LOCALUPVALUE, Constants.GETFIELD));
append(new PUSH(cp,0));
loadLocal(pc, slot);
append(InstructionConstants.AASTORE);
} else {
loadLocal(pc, slot);
append(factory.createFieldAccess(classname, upvalueName(upindex), TYPE_LUAVALUE, Constants.PUTFIELD));
}
}
示例13: arg
import org.apache.bcel.generic.PUSH; //导入依赖的package包/类
public void arg(int argindex) {
if ( argindex == 1 ) {
append(factory.createInvoke(STR_VARARGS, "arg1", TYPE_LUAVALUE, ARG_TYPES_NONE, Constants.INVOKEVIRTUAL));
} else {
append(new PUSH(cp, argindex));
append(factory.createInvoke(STR_VARARGS, "arg", TYPE_LUAVALUE, ARG_TYPES_INT, Constants.INVOKEVIRTUAL));
}
}
示例14: loadArrayArgs
import org.apache.bcel.generic.PUSH; //导入依赖的package包/类
public void loadArrayArgs(int pc, int firstslot, int nargs) {
append(new PUSH(cp, nargs));
append(new ANEWARRAY(cp.addClass(STR_LUAVALUE)));
for ( int i=0; i<nargs; i++ ) {
append(InstructionConstants.DUP);
append(new PUSH(cp, i));
loadLocal(pc, firstslot++);
append(new AASTORE());
}
}
示例15: createLuaIntegerField
import org.apache.bcel.generic.PUSH; //导入依赖的package包/类
private String createLuaIntegerField(int value) {
String name = PREFIX_CONSTANT+constants.size();
FieldGen fg = new FieldGen(Constants.ACC_STATIC | Constants.ACC_FINAL,
TYPE_LUAVALUE, name, cp);
cg.addField(fg.getField());
init.append(new PUSH(cp, value));
init.append(factory.createInvoke(STR_LUAVALUE, "valueOf",
TYPE_LUAINTEGER, ARG_TYPES_INT, Constants.INVOKESTATIC));
init.append(factory.createPutStatic(classname, name, TYPE_LUAVALUE));
return name;
}