Search in sources :

Example 1 with MethodProtoReference

use of org.jf.dexlib2.iface.reference.MethodProtoReference in project smali by JesusFreke.

the class CallSiteUtil method getEncodedCallSite.

public static ArrayEncodedValue getEncodedCallSite(CallSiteReference callSiteReference) {
    return new BaseArrayEncodedValue() {

        @Nonnull
        @Override
        public List<? extends EncodedValue> getValue() {
            List<EncodedValue> encodedCallSite = Lists.newArrayList();
            encodedCallSite.add(new BaseMethodHandleEncodedValue() {

                @Nonnull
                @Override
                public MethodHandleReference getValue() {
                    return callSiteReference.getMethodHandle();
                }
            });
            encodedCallSite.add(new ImmutableStringEncodedValue(callSiteReference.getMethodName()));
            encodedCallSite.add(new BaseMethodTypeEncodedValue() {

                @Nonnull
                @Override
                public MethodProtoReference getValue() {
                    return callSiteReference.getMethodProto();
                }
            });
            encodedCallSite.addAll(callSiteReference.getExtraArguments());
            return encodedCallSite;
        }
    };
}
Also used : ImmutableStringEncodedValue(org.jf.dexlib2.immutable.value.ImmutableStringEncodedValue) BaseArrayEncodedValue(org.jf.dexlib2.base.value.BaseArrayEncodedValue) BaseMethodHandleEncodedValue(org.jf.dexlib2.base.value.BaseMethodHandleEncodedValue) BaseMethodTypeEncodedValue(org.jf.dexlib2.base.value.BaseMethodTypeEncodedValue) EncodedValue(org.jf.dexlib2.iface.value.EncodedValue) ArrayEncodedValue(org.jf.dexlib2.iface.value.ArrayEncodedValue) BaseArrayEncodedValue(org.jf.dexlib2.base.value.BaseArrayEncodedValue) Nonnull(javax.annotation.Nonnull) ImmutableStringEncodedValue(org.jf.dexlib2.immutable.value.ImmutableStringEncodedValue) MethodProtoReference(org.jf.dexlib2.iface.reference.MethodProtoReference) MethodHandleReference(org.jf.dexlib2.iface.reference.MethodHandleReference) BaseMethodHandleEncodedValue(org.jf.dexlib2.base.value.BaseMethodHandleEncodedValue) BaseMethodTypeEncodedValue(org.jf.dexlib2.base.value.BaseMethodTypeEncodedValue)

Example 2 with MethodProtoReference

use of org.jf.dexlib2.iface.reference.MethodProtoReference in project smali by JesusFreke.

the class DexBackedCallSiteReference method getMethodProto.

@Nonnull
@Override
public MethodProtoReference getMethodProto() {
    EncodedArrayItemIterator iter = getCallSiteIterator();
    if (iter.getItemCount() < 3) {
        throw new ExceptionWithContext("Invalid call site item: must contain at least 3 entries.");
    }
    iter.skipNext();
    iter.skipNext();
    EncodedValue encodedValue = iter.getNextOrNull();
    assert encodedValue != null;
    if (encodedValue.getValueType() != ValueType.METHOD_TYPE) {
        throw new ExceptionWithContext("Invalid encoded value type (%d) for the second item in call site %d", encodedValue.getValueType(), callSiteIndex);
    }
    return ((MethodTypeEncodedValue) encodedValue).getValue();
}
Also used : EncodedValue(org.jf.dexlib2.iface.value.EncodedValue) MethodTypeEncodedValue(org.jf.dexlib2.iface.value.MethodTypeEncodedValue) StringEncodedValue(org.jf.dexlib2.iface.value.StringEncodedValue) MethodHandleEncodedValue(org.jf.dexlib2.iface.value.MethodHandleEncodedValue) ExceptionWithContext(org.jf.util.ExceptionWithContext) MethodTypeEncodedValue(org.jf.dexlib2.iface.value.MethodTypeEncodedValue) EncodedArrayItemIterator(org.jf.dexlib2.dexbacked.util.EncodedArrayItemIterator) Nonnull(javax.annotation.Nonnull)

Aggregations

Nonnull (javax.annotation.Nonnull)2 EncodedValue (org.jf.dexlib2.iface.value.EncodedValue)2 BaseArrayEncodedValue (org.jf.dexlib2.base.value.BaseArrayEncodedValue)1 BaseMethodHandleEncodedValue (org.jf.dexlib2.base.value.BaseMethodHandleEncodedValue)1 BaseMethodTypeEncodedValue (org.jf.dexlib2.base.value.BaseMethodTypeEncodedValue)1 EncodedArrayItemIterator (org.jf.dexlib2.dexbacked.util.EncodedArrayItemIterator)1 MethodHandleReference (org.jf.dexlib2.iface.reference.MethodHandleReference)1 MethodProtoReference (org.jf.dexlib2.iface.reference.MethodProtoReference)1 ArrayEncodedValue (org.jf.dexlib2.iface.value.ArrayEncodedValue)1 MethodHandleEncodedValue (org.jf.dexlib2.iface.value.MethodHandleEncodedValue)1 MethodTypeEncodedValue (org.jf.dexlib2.iface.value.MethodTypeEncodedValue)1 StringEncodedValue (org.jf.dexlib2.iface.value.StringEncodedValue)1 ImmutableStringEncodedValue (org.jf.dexlib2.immutable.value.ImmutableStringEncodedValue)1 ExceptionWithContext (org.jf.util.ExceptionWithContext)1