Java Code Examples for com.android.dx.rop.cst.CstBaseMethodRef#getParameterWordCount()
The following examples show how to use
com.android.dx.rop.cst.CstBaseMethodRef#getParameterWordCount() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DalvInsnList.java From Box with Apache License 2.0 | 4 votes |
/** * Gets the size of the outgoing arguments area required by this * method. This is equal to the largest argument word count of any * method referred to by this instance. * * @return {@code >= 0;} the required outgoing arguments size */ public int getOutsSize() { int sz = size(); int result = 0; for (int i = 0; i < sz; i++) { DalvInsn insn = (DalvInsn) get0(i); int count = 0; if (insn instanceof CstInsn) { Constant cst = ((CstInsn) insn).getConstant(); if (cst instanceof CstBaseMethodRef) { CstBaseMethodRef methodRef = (CstBaseMethodRef) cst; boolean isStatic = (insn.getOpcode().getFamily() == Opcodes.INVOKE_STATIC); count = methodRef.getParameterWordCount(isStatic); } else if (cst instanceof CstCallSiteRef) { CstCallSiteRef invokeDynamicRef = (CstCallSiteRef) cst; count = invokeDynamicRef.getPrototype().getParameterTypes().getWordCount(); } } else if (insn instanceof MultiCstInsn) { if (insn.getOpcode().getFamily() != Opcodes.INVOKE_POLYMORPHIC) { throw new RuntimeException("Expecting invoke-polymorphic"); } MultiCstInsn mci = (MultiCstInsn) insn; // Invoke-polymorphic has two constants: [0] method-ref and // [1] call site prototype. The number of arguments is based // on the call site prototype since these are the arguments // presented. The method-ref is always MethodHandle.invoke(Object[]) // or MethodHandle.invokeExact(Object[]). CstProtoRef proto = (CstProtoRef) mci.getConstant(1); count = proto.getPrototype().getParameterTypes().getWordCount(); count = count + 1; // And one for receiver (method handle). } else { continue; } if (count > result) { result = count; } } return result; }
Example 2
Source File: DalvInsnList.java From Box with Apache License 2.0 | 4 votes |
/** * Gets the size of the outgoing arguments area required by this * method. This is equal to the largest argument word count of any * method referred to by this instance. * * @return {@code >= 0;} the required outgoing arguments size */ public int getOutsSize() { int sz = size(); int result = 0; for (int i = 0; i < sz; i++) { DalvInsn insn = (DalvInsn) get0(i); int count = 0; if (insn instanceof CstInsn) { Constant cst = ((CstInsn) insn).getConstant(); if (cst instanceof CstBaseMethodRef) { CstBaseMethodRef methodRef = (CstBaseMethodRef) cst; boolean isStatic = (insn.getOpcode().getFamily() == Opcodes.INVOKE_STATIC); count = methodRef.getParameterWordCount(isStatic); } else if (cst instanceof CstCallSiteRef) { CstCallSiteRef invokeDynamicRef = (CstCallSiteRef) cst; count = invokeDynamicRef.getPrototype().getParameterTypes().getWordCount(); } } else if (insn instanceof MultiCstInsn) { if (insn.getOpcode().getFamily() != Opcodes.INVOKE_POLYMORPHIC) { throw new RuntimeException("Expecting invoke-polymorphic"); } MultiCstInsn mci = (MultiCstInsn) insn; // Invoke-polymorphic has two constants: [0] method-ref and // [1] call site prototype. The number of arguments is based // on the call site prototype since these are the arguments // presented. The method-ref is always MethodHandle.invoke(Object[]) // or MethodHandle.invokeExact(Object[]). CstProtoRef proto = (CstProtoRef) mci.getConstant(1); count = proto.getPrototype().getParameterTypes().getWordCount(); count = count + 1; // And one for receiver (method handle). } else { continue; } if (count > result) { result = count; } } return result; }
Example 3
Source File: DalvInsnList.java From J2ME-Loader with Apache License 2.0 | 4 votes |
/** * Gets the size of the outgoing arguments area required by this * method. This is equal to the largest argument word count of any * method referred to by this instance. * * @return {@code >= 0;} the required outgoing arguments size */ public int getOutsSize() { int sz = size(); int result = 0; for (int i = 0; i < sz; i++) { DalvInsn insn = (DalvInsn) get0(i); int count = 0; if (insn instanceof CstInsn) { Constant cst = ((CstInsn) insn).getConstant(); if (cst instanceof CstBaseMethodRef) { CstBaseMethodRef methodRef = (CstBaseMethodRef) cst; boolean isStatic = (insn.getOpcode().getFamily() == Opcodes.INVOKE_STATIC); count = methodRef.getParameterWordCount(isStatic); } } else if (insn instanceof MultiCstInsn) { if (insn.getOpcode().getFamily() != Opcodes.INVOKE_POLYMORPHIC) { throw new RuntimeException("Expecting invoke-polymorphic"); } MultiCstInsn mci = (MultiCstInsn) insn; // Invoke-polymorphic has two constants: [0] method-ref and // [1] call site prototype. The number of arguments is based // on the call site prototype since these are the arguments // presented. The method-ref is always MethodHandle.invoke(Object[]) // or MethodHandle.invokeExact(Object[]). CstProtoRef proto = (CstProtoRef) mci.getConstant(1); count = proto.getPrototype().getParameterTypes().getWordCount(); count = count + 1; // And one for receiver (method handle). } else { continue; } if (count > result) { result = count; } } return result; }