use of org.jf.dexlib2.iface.reference.MethodHandleReference in project smali by JesusFreke.
the class BaksmaliWriter method writeCallSite.
@Override
public void writeCallSite(CallSiteReference callSiteReference) throws IOException {
writeSimpleName(callSiteReference.getName());
writer.write('(');
writeQuotedString(callSiteReference.getMethodName());
writer.write(", ");
writeMethodProtoDescriptor(callSiteReference.getMethodProto());
for (EncodedValue encodedValue : callSiteReference.getExtraArguments()) {
writer.write(", ");
writeEncodedValue(encodedValue);
}
writer.write(")@");
MethodHandleReference methodHandle = callSiteReference.getMethodHandle();
if (methodHandle.getMethodHandleType() != MethodHandleType.INVOKE_STATIC) {
throw new IllegalArgumentException("The linker method handle for a call site must be of type invoke-static");
}
writeMethodDescriptor((MethodReference) callSiteReference.getMethodHandle().getMemberReference());
}
use of org.jf.dexlib2.iface.reference.MethodHandleReference in project smali by JesusFreke.
the class BaseMethodHandleReference method compareTo.
@Override
public int compareTo(@Nonnull MethodHandleReference o) {
int res = Ints.compare(getMethodHandleType(), o.getMethodHandleType());
if (res != 0)
return res;
Reference reference = getMemberReference();
if (reference instanceof FieldReference) {
// a method reference
if (!(o.getMemberReference() instanceof FieldReference)) {
return -1;
}
return ((FieldReference) reference).compareTo((FieldReference) o.getMemberReference());
} else {
if (!(o.getMemberReference() instanceof MethodReference)) {
return 1;
}
return ((MethodReference) reference).compareTo((MethodReference) o.getMemberReference());
}
}
use of org.jf.dexlib2.iface.reference.MethodHandleReference in project smali by JesusFreke.
the class ReferenceUtil method writeCallSite.
public static void writeCallSite(Writer writer, CallSiteReference callSiteReference) throws IOException {
writer.write(callSiteReference.getName());
writer.write('(');
writer.write('"');
StringUtils.writeEscapedString(writer, callSiteReference.getMethodName());
writer.write('"');
writer.write(", ");
writeMethodProtoDescriptor(writer, callSiteReference.getMethodProto());
for (EncodedValue encodedValue : callSiteReference.getExtraArguments()) {
writer.write(", ");
EncodedValueUtils.writeEncodedValue(writer, encodedValue);
}
writer.write(")@");
MethodHandleReference methodHandle = callSiteReference.getMethodHandle();
if (methodHandle.getMethodHandleType() != MethodHandleType.INVOKE_STATIC) {
throw new IllegalArgumentException("The linker method handle for a call site must be of type invoke-static");
}
writeMethodDescriptor(writer, (MethodReference) callSiteReference.getMethodHandle().getMemberReference());
}
use of org.jf.dexlib2.iface.reference.MethodHandleReference in project smali by JesusFreke.
the class DexBackedCallSiteReference method getMethodHandle.
@Nonnull
@Override
public MethodHandleReference getMethodHandle() {
EncodedArrayItemIterator iter = getCallSiteIterator();
if (iter.getItemCount() < 3) {
throw new ExceptionWithContext("Invalid call site item: must contain at least 3 entries.");
}
EncodedValue encodedValue = getCallSiteIterator().getNextOrNull();
assert encodedValue != null;
if (encodedValue.getValueType() != ValueType.METHOD_HANDLE) {
throw new ExceptionWithContext("Invalid encoded value type (%d) for the first item in call site %d", encodedValue.getValueType(), callSiteIndex);
}
return ((MethodHandleEncodedValue) encodedValue).getValue();
}
use of org.jf.dexlib2.iface.reference.MethodHandleReference 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;
}
};
}
Aggregations