Search in sources :

Example 1 with MethodTypeEncodedValue

use of org.jf.dexlib2.iface.value.MethodTypeEncodedValue in project smali by JesusFreke.

the class DexPool method internEncodedValue.

void internEncodedValue(@Nonnull EncodedValue encodedValue) {
    switch(encodedValue.getValueType()) {
        case ValueType.ANNOTATION:
            AnnotationEncodedValue annotationEncodedValue = (AnnotationEncodedValue) encodedValue;
            typeSection.intern(annotationEncodedValue.getType());
            for (AnnotationElement element : annotationEncodedValue.getElements()) {
                stringSection.intern(element.getName());
                internEncodedValue(element.getValue());
            }
            break;
        case ValueType.ARRAY:
            for (EncodedValue element : ((ArrayEncodedValue) encodedValue).getValue()) {
                internEncodedValue(element);
            }
            break;
        case ValueType.STRING:
            stringSection.intern(((StringEncodedValue) encodedValue).getValue());
            break;
        case ValueType.TYPE:
            typeSection.intern(((TypeEncodedValue) encodedValue).getValue());
            break;
        case ValueType.ENUM:
            fieldSection.intern(((EnumEncodedValue) encodedValue).getValue());
            break;
        case ValueType.FIELD:
            fieldSection.intern(((FieldEncodedValue) encodedValue).getValue());
            break;
        case ValueType.METHOD:
            methodSection.intern(((MethodEncodedValue) encodedValue).getValue());
            break;
        case ValueType.METHOD_HANDLE:
            methodHandleSection.intern(((MethodHandleEncodedValue) encodedValue).getValue());
            break;
        case ValueType.METHOD_TYPE:
            protoSection.intern(((MethodTypeEncodedValue) encodedValue).getValue());
            break;
    }
}
Also used : AnnotationElement(org.jf.dexlib2.iface.AnnotationElement)

Example 2 with MethodTypeEncodedValue

use of org.jf.dexlib2.iface.value.MethodTypeEncodedValue 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)1 EncodedArrayItemIterator (org.jf.dexlib2.dexbacked.util.EncodedArrayItemIterator)1 AnnotationElement (org.jf.dexlib2.iface.AnnotationElement)1 EncodedValue (org.jf.dexlib2.iface.value.EncodedValue)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 ExceptionWithContext (org.jf.util.ExceptionWithContext)1