本文整理匯總了Java中org.objectweb.asm.commons.GeneratorAdapter.pop方法的典型用法代碼示例。如果您正苦於以下問題:Java GeneratorAdapter.pop方法的具體用法?Java GeneratorAdapter.pop怎麽用?Java GeneratorAdapter.pop使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.objectweb.asm.commons.GeneratorAdapter
的用法示例。
在下文中一共展示了GeneratorAdapter.pop方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: redirect
import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
/**
* Adds the instructions to do a generic redirection.
*/
protected void redirect(GeneratorAdapter mv, int change) {
// code to check if a new implementation of the current class is available.
Label l0 = new Label();
mv.loadLocal(change);
mv.visitJumpInsn(Opcodes.IFNULL, l0);
doRedirect(mv, change);
// Return
if (type == Type.VOID_TYPE) {
mv.pop();
} else {
ByteCodeUtils.unbox(mv, type);
}
mv.returnValue();
// jump label for classes without any new implementation, just invoke the original
// method implementation.
mv.visitLabel(l0);
}
示例2: emit
import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
public void emit(C context, ObjExpr objx, GeneratorAdapter gen){
boolean allKeysConstant = true;
boolean allConstantKeysUnique = true;
IPersistentSet constantKeys = PersistentHashSet.EMPTY;
for(int i = 0; i < keyvals.count(); i+=2)
{
Expr k = (Expr) keyvals.nth(i);
if(k instanceof LiteralExpr)
{
Object kval = k.eval();
if (constantKeys.contains(kval))
allConstantKeysUnique = false;
else
constantKeys = (IPersistentSet)constantKeys.cons(kval);
}
else
allKeysConstant = false;
}
MethodExpr.emitArgsAsArray(keyvals, objx, gen);
if((allKeysConstant && allConstantKeysUnique) || (keyvals.count() <= 2))
gen.invokeStatic(RT_TYPE, mapUniqueKeysMethod);
else
gen.invokeStatic(RT_TYPE, mapMethod);
if(context == C.STATEMENT)
gen.pop();
}
示例3: emit
import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
public void emit(C context, ObjExpr objx, GeneratorAdapter gen){
if(isProtocol)
{
gen.visitLineNumber(line, gen.mark());
emitProto(context,objx,gen);
}
else
{
fexpr.emit(C.EXPRESSION, objx, gen);
gen.visitLineNumber(line, gen.mark());
gen.checkCast(IFN_TYPE);
emitArgsAndCall(0, context,objx,gen);
}
if(context == C.STATEMENT)
gen.pop();
}
示例4: emitAssign
import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
public void emitAssign(C context, ObjExpr objx, GeneratorAdapter gen,
Expr val){
objx.emitVar(gen, var);
val.emit(C.EXPRESSION, objx, gen);
gen.invokeVirtual(VAR_TYPE, setMethod);
if(context == C.STATEMENT)
gen.pop();
}
示例5: doEmit
import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
public void doEmit(C context, ObjExpr objx, GeneratorAdapter gen, boolean emitUnboxed){
Label nullLabel = gen.newLabel();
Label falseLabel = gen.newLabel();
Label endLabel = gen.newLabel();
gen.visitLineNumber(line, gen.mark());
if(testExpr instanceof StaticMethodExpr && ((StaticMethodExpr)testExpr).canEmitIntrinsicPredicate())
{
((StaticMethodExpr) testExpr).emitIntrinsicPredicate(C.EXPRESSION, objx, gen, falseLabel);
}
else if(maybePrimitiveType(testExpr) == boolean.class)
{
((MaybePrimitiveExpr) testExpr).emitUnboxed(C.EXPRESSION, objx, gen);
gen.ifZCmp(gen.EQ, falseLabel);
}
else
{
testExpr.emit(C.EXPRESSION, objx, gen);
gen.dup();
gen.ifNull(nullLabel);
gen.getStatic(BOOLEAN_OBJECT_TYPE, "FALSE", BOOLEAN_OBJECT_TYPE);
gen.visitJumpInsn(IF_ACMPEQ, falseLabel);
}
if(emitUnboxed)
((MaybePrimitiveExpr)thenExpr).emitUnboxed(context, objx, gen);
else
thenExpr.emit(context, objx, gen);
gen.goTo(endLabel);
gen.mark(nullLabel);
gen.pop();
gen.mark(falseLabel);
if(emitUnboxed)
((MaybePrimitiveExpr)elseExpr).emitUnboxed(context, objx, gen);
else
elseExpr.emit(context, objx, gen);
gen.mark(endLabel);
}
示例6: restore
import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
@Override
protected void restore(GeneratorAdapter mv, List<Type> args) {
// At this point, init$args has been called and the result Object is on the stack.
// The value of that Object is Object[] with exactly n + 1 elements.
// The first element is a string with the qualified name of the constructor to call.
// The remaining elements are the constructtor arguments.
// Create a new local that holds the result of init$args call.
mv.visitTypeInsn(Opcodes.CHECKCAST, "[Ljava/lang/Object;");
int constructorArgs = mv.newLocal(Type.getType("[Ljava/lang/Object;"));
mv.storeLocal(constructorArgs);
// Reinstate local values
mv.loadLocal(locals);
int stackIndex = 0;
for (int arrayIndex = 0; arrayIndex < args.size(); arrayIndex++) {
Type arg = args.get(arrayIndex);
// Do not restore "this"
if (arrayIndex > 0) {
// duplicates the array
mv.dup();
// index in the array of objects to restore the boxed parameter.
mv.push(arrayIndex);
// get it from the array
mv.arrayLoad(Type.getType(Object.class));
// unbox the argument
ByteCodeUtils.unbox(mv, arg);
// restore the argument
mv.visitVarInsn(arg.getOpcode(Opcodes.ISTORE), stackIndex);
}
// stack index must progress according to the parameter type we just processed.
stackIndex += arg.getSize();
}
// pops the array
mv.pop();
// Push a null for the marker parameter.
mv.loadLocal(constructorArgs);
mv.visitInsn(Opcodes.ACONST_NULL);
// Invoke the constructor
mv.visitMethodInsn(Opcodes.INVOKESPECIAL, thisClassName, "<init>", DISPATCHING_THIS_SIGNATURE, false);
mv.goTo(end.getLabel());
}
示例7: emitBody
import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
static void emitBody(ObjExpr objx, GeneratorAdapter gen, Class retClass, Expr body) {
MaybePrimitiveExpr be = (MaybePrimitiveExpr) body;
if(Util.isPrimitive(retClass) && be.canEmitPrimitive())
{
Class bc = maybePrimitiveType(be);
if(bc == retClass)
be.emitUnboxed(C.RETURN, objx, gen);
else if(retClass == long.class && bc == int.class)
{
be.emitUnboxed(C.RETURN, objx, gen);
gen.visitInsn(I2L);
}
else if(retClass == double.class && bc == float.class)
{
be.emitUnboxed(C.RETURN, objx, gen);
gen.visitInsn(F2D);
}
else if(retClass == int.class && bc == long.class)
{
be.emitUnboxed(C.RETURN, objx, gen);
gen.invokeStatic(RT_TYPE, Method.getMethod("int intCast(long)"));
}
else if(retClass == float.class && bc == double.class)
{
be.emitUnboxed(C.RETURN, objx, gen);
gen.visitInsn(D2F);
}
else
throw new IllegalArgumentException("Mismatched primitive return, expected: "
+ retClass + ", had: " + be.getJavaClass());
}
else
{
body.emit(C.RETURN, objx, gen);
if(retClass == void.class)
{
gen.pop();
}
else
gen.unbox(Type.getType(retClass));
}
}