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


Java Type.getSize方法代碼示例

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


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

示例1: visitInvokeDynamicInsn

import org.objectweb.asm.Type; //導入方法依賴的package包/類
@Override
public void visitInvokeDynamicInsn(String name, String desc, Handle bsm,
        Object... bsmArgs) {
    mv.visitInvokeDynamicInsn(name, desc, bsm, bsmArgs);
    if (constructor) {
        Type[] types = Type.getArgumentTypes(desc);
        for (int i = 0; i < types.length; i++) {
            popValue();
            if (types[i].getSize() == 2) {
                popValue();
            }
        }

        Type returnType = Type.getReturnType(desc);
        if (returnType != Type.VOID_TYPE) {
            pushValue(OTHER);
            if (returnType.getSize() == 2) {
                pushValue(OTHER);
            }
        }
    }
}
 
開發者ID:ItzSomebody,項目名稱:DirectLeaks-AntiReleak-Remover,代碼行數:23,代碼來源:AdviceAdapter.java

示例2: swap

import org.objectweb.asm.Type; //導入方法依賴的package包/類
/**
 * Generates the instructions to swap the top two stack values.
 * 
 * @param prev
 *            type of the top - 1 stack value.
 * @param type
 *            type of the top stack value.
 */
public void swap(final Type prev, final Type type) {
    if (type.getSize() == 1) {
        if (prev.getSize() == 1) {
            swap(); // same as dupX1(), pop();
        } else {
            dupX2();
            pop();
        }
    } else {
        if (prev.getSize() == 1) {
            dup2X1();
            pop2();
        } else {
            dup2X2();
            pop2();
        }
    }
}
 
開發者ID:ItzSomebody,項目名稱:DirectLeaks-AntiReleak-Remover,代碼行數:27,代碼來源:GeneratorAdapter.java

示例3: loadArgumentsAndValidateArguments

import org.objectweb.asm.Type; //導入方法依賴的package包/類
private static int loadArgumentsAndValidateArguments(MethodVisitor mv, Type[] paramTypes, ClassMetadata classMetadata, MethodInfo minfo) {
    int var = 0; // <- counts the used local variables
    for (int i = 0; i < paramTypes.length; i++) {
        Type paramType = paramTypes[i];
        mv.visitVarInsn(paramType.getOpcode(ILOAD), var);
        if (VALIDATE.enabled) {
            if (paramType.getSort() == Type.OBJECT && Util.isBuffer(paramType.getInternalName())) {
                mv.visitInsn(DUP);
                mv.visitMethodInsn(INVOKESTATIC, RT_InternalName, "checkBuffer", "(" + paramType.getDescriptor() + ")V", false);
            }
            if (ClassMetadata.hasNullables && (paramType.getSort() == Type.OBJECT || paramType.getSort() == Type.ARRAY) && !minfo.nullable[i]) {
                mv.visitInsn(DUP);
                mv.visitLdcInsn(i);
                if (minfo.parameterNames[i] != null)
                    mv.visitLdcInsn(minfo.parameterNames[i]);
                else
                    mv.visitInsn(ACONST_NULL);
                mv.visitMethodInsn(INVOKESTATIC, RT_InternalName, "checkNotNull", "(Ljava/lang/Object;ILjava/lang/String;)V", false);
            }
        }
        var += paramType.getSize();
    }
    return var;
}
 
開發者ID:LWJGLX,項目名稱:debug,代碼行數:25,代碼來源:InterceptClassGenerator.java

示例4: box

import org.objectweb.asm.Type; //導入方法依賴的package包/類
/**
 * Generates the instructions to box the top stack value. This value is
 * replaced by its boxed equivalent on top of the stack.
 * 
 * @param type
 *            the type of the top stack value.
 */
public void box(final Type type) {
    if (type.getSort() == Type.OBJECT || type.getSort() == Type.ARRAY) {
        return;
    }
    if (type == Type.VOID_TYPE) {
        push((String) null);
    } else {
        Type boxed = getBoxedType(type);
        newInstance(boxed);
        if (type.getSize() == 2) {
            // Pp -> Ppo -> oPpo -> ooPpo -> ooPp -> o
            dupX2();
            dupX2();
            pop();
        } else {
            // p -> po -> opo -> oop -> o
            dupX1();
            swap();
        }
        invokeConstructor(boxed, new Method("<init>", Type.VOID_TYPE,
                new Type[] { type }));
    }
}
 
開發者ID:ItzSomebody,項目名稱:Spigot-Attribute-Remover,代碼行數:31,代碼來源:GeneratorAdapter.java

示例5: remap

import org.objectweb.asm.Type; //導入方法依賴的package包/類
private int remap(final int var, final Type type) {
    if (var + type.getSize() <= firstLocal) {
        return var;
    }
    int key = 2 * var + type.getSize() - 1;
    int size = mapping.length;
    if (key >= size) {
        int[] newMapping = new int[Math.max(2 * size, key + 1)];
        System.arraycopy(mapping, 0, newMapping, 0, size);
        mapping = newMapping;
    }
    int value = mapping[key];
    if (value == 0) {
        value = newLocalMapping(type);
        setLocalType(value, type);
        mapping[key] = value + 1;
    } else {
        value--;
    }
    return value;
}
 
開發者ID:ItzSomebody,項目名稱:Spigot-Attribute-Remover,代碼行數:22,代碼來源:LocalVariablesSorter.java

示例6: newValue

import org.objectweb.asm.Type; //導入方法依賴的package包/類
@Override
public SourceValue newValue(final Type type) {
    if (type == Type.VOID_TYPE) {
        return null;
    }
    return new SourceValue(type == null ? 1 : type.getSize());
}
 
開發者ID:acmerli,項目名稱:fastAOP,代碼行數:8,代碼來源:SourceInterpreter.java

示例7: doVisitMethodInsn

import org.objectweb.asm.Type; //導入方法依賴的package包/類
private void doVisitMethodInsn(int opcode, final String owner,
        final String name, final String desc, final boolean itf) {
    mv.visitMethodInsn(opcode, owner, name, desc, itf);
    if (constructor) {
        Type[] types = Type.getArgumentTypes(desc);
        for (int i = 0; i < types.length; i++) {
            popValue();
            if (types[i].getSize() == 2) {
                popValue();
            }
        }
        switch (opcode) {
        // case INVOKESTATIC:
        // break;
        case INVOKEINTERFACE:
        case INVOKEVIRTUAL:
            popValue(); // objectref
            break;
        case INVOKESPECIAL:
            Object type = popValue(); // objectref
            if (type == THIS && !superInitialized) {
                onMethodEnter();
                superInitialized = true;
                // once super has been initialized it is no longer
                // necessary to keep track of stack state
                constructor = false;
            }
            break;
        }

        Type returnType = Type.getReturnType(desc);
        if (returnType != Type.VOID_TYPE) {
            pushValue(OTHER);
            if (returnType.getSize() == 2) {
                pushValue(OTHER);
            }
        }
    }
}
 
開發者ID:acmerli,項目名稱:fastAOP,代碼行數:40,代碼來源:AdviceAdapter.java

示例8: transferToExternal

import org.objectweb.asm.Type; //導入方法依賴的package包/類
/**
 *
 * @param adder
 * @param owner
 * @param name
 * @param desc
 * @return amount of additional stack space that will be required for this instruction stream
 */
public int transferToExternal(final DirectSorter adder, final String owner,
    final String name, final String desc) {
  // create a new object and assign it to the desired field.
  adder.visitTypeInsn(Opcodes.NEW, type.getInternalName());
  adder.visitInsn(getDupOpcode(type));
  adder.visitMethodInsn(Opcodes.INVOKESPECIAL, type.getInternalName(), "<init>", "()V", false);

  // now we need to set all of the values of this new object.
  int additionalStack = 0;
  for (int i = 0; i < types.length; i++) {
    final Type t = types[i];

    // dup the object where we are putting the field.
    adder.visitInsn(getDupOpcode(type)); // dup for every as we want to save in place at end.
    adder.directVarInsn(t.getOpcode(Opcodes.ILOAD), first + offsets[i]);
    adder.visitFieldInsn(Opcodes.PUTFIELD, type.getInternalName(), names[i], t.getDescriptor());

    /*
     * The above substitutes a reference to a scalar in a holder with a direct reference to
     * the scalar.
     *
     * In the case of longs or doubles, this requires more stack space than was used before;
     * if we were moving a reference to a holder with a long, we were previously moving the
     * reference. But now we're moving the long, which is twice as big. So we may need more
     * stack space than has currently been allocated.
     */
    if (t.getSize() > additionalStack) {
      additionalStack = t.getSize();
    }
  }

  // lastly we save it to the desired field.
  adder.visitFieldInsn(Opcodes.PUTFIELD, owner, name, desc);

  return additionalStack;
}
 
開發者ID:skhalifa,項目名稱:QDrill,代碼行數:45,代碼來源:ValueHolderIden.java

示例9: toLocalVariables

import org.objectweb.asm.Type; //導入方法依賴的package包/類
/**
 * Converts Types to LocalVariables, assuming they start from variable 0.
 */
static List<LocalVariable> toLocalVariables( List<Type> types) {
    List<LocalVariable> variables = Lists.newArrayList();
    int stack = 0;
    for (int i = 0; i < types.size(); i++) {
        Type type = types.get(i);
        variables.add(new LocalVariable(type, stack));
        stack += type.getSize();
    }
    return variables;
}
 
開發者ID:meili,項目名稱:Aceso,代碼行數:14,代碼來源:ByteCodeUtils.java

示例10: newLocalMapping

import org.objectweb.asm.Type; //導入方法依賴的package包/類
protected int newLocalMapping(final Type type) {
    int local = nextLocal;
    nextLocal += type.getSize();
    return local;
}
 
開發者ID:acmerli,項目名稱:fastAOP,代碼行數:6,代碼來源:LocalVariablesSorter.java

示例11: loadArgs

import org.objectweb.asm.Type; //導入方法依賴的package包/類
/**
 * Generates the instructions to load the given method arguments on the
 * stack.
 * 
 * @param arg
 *            the index of the first method argument to be loaded.
 * @param count
 *            the number of method arguments to be loaded.
 */
public void loadArgs(final int arg, final int count) {
    int index = getArgIndex(arg);
    for (int i = 0; i < count; ++i) {
        Type t = argumentTypes[arg + i];
        loadInsn(t, index);
        index += t.getSize();
    }
}
 
開發者ID:ItzSomebody,項目名稱:Spigot-Attribute-Remover,代碼行數:18,代碼來源:GeneratorAdapter.java


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