當前位置: 首頁>>代碼示例>>Java>>正文


Java GeneratorAdapter.storeLocal方法代碼示例

本文整理匯總了Java中org.objectweb.asm.commons.GeneratorAdapter.storeLocal方法的典型用法代碼示例。如果您正苦於以下問題:Java GeneratorAdapter.storeLocal方法的具體用法?Java GeneratorAdapter.storeLocal怎麽用?Java GeneratorAdapter.storeLocal使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.objectweb.asm.commons.GeneratorAdapter的用法示例。


在下文中一共展示了GeneratorAdapter.storeLocal方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createLocals

import org.objectweb.asm.commons.GeneratorAdapter; //導入方法依賴的package包/類
@Override
protected void createLocals(GeneratorAdapter mv, List<Type> args) {
    super.createLocals(mv, args);

    // Override the locals creation to keep a reference to it. We keep a reference to this
    // array because we use it to receive the values of the local variables after the
    // redirection is done.
    locals = mv.newLocal(Type.getType("[Ljava/lang/Object;"));
    mv.dup();
    mv.storeLocal(locals);
}
 
開發者ID:dodola,項目名稱:AnoleFix,代碼行數:12,代碼來源:ConstructorArgsRedirection.java

示例2: 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());
}
 
開發者ID:dodola,項目名稱:AnoleFix,代碼行數:46,代碼來源:ConstructorArgsRedirection.java


注:本文中的org.objectweb.asm.commons.GeneratorAdapter.storeLocal方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。