mirror of
https://github.com/revanced/smali.git
synced 2025-05-07 18:04:32 +02:00
Change the name of the invoke method handle types
Change the names to match the name used in the smali grammar
This commit is contained in:
parent
9ccda3a1bf
commit
858d264db9
@ -31,37 +31,58 @@
|
||||
|
||||
package org.jf.dexlib2;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import org.jf.util.ExceptionWithContext;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Map;
|
||||
|
||||
public class MethodHandleType {
|
||||
public static final int STATIC_PUT = 0;
|
||||
public static final int STATIC_GET = 1;
|
||||
public static final int INSTANCE_PUT = 2;
|
||||
public static final int INSTANCE_GET = 3;
|
||||
public static final int INVOKE_STATIC = 4;
|
||||
public static final int INVOKE_INSTANCE = 5;
|
||||
public static final int STATIC_INVOKE = 4;
|
||||
public static final int INSTANCE_INVOKE = 5;
|
||||
|
||||
private static final Map<String, Integer> methodHandleTypeNames = Maps.newHashMap();
|
||||
|
||||
static {
|
||||
methodHandleTypeNames.put("static-put", STATIC_PUT);
|
||||
methodHandleTypeNames.put("static-get", STATIC_GET);
|
||||
methodHandleTypeNames.put("instance-put", INSTANCE_PUT);
|
||||
methodHandleTypeNames.put("instance-get", INSTANCE_GET);
|
||||
methodHandleTypeNames.put("static-invoke", STATIC_INVOKE);
|
||||
methodHandleTypeNames.put("instance-invoke", INSTANCE_INVOKE);
|
||||
}
|
||||
|
||||
@Nonnull public static String toString(int methodHandleType) {
|
||||
switch (methodHandleType) {
|
||||
case STATIC_PUT:
|
||||
return "static_put";
|
||||
return "static-put";
|
||||
case STATIC_GET:
|
||||
return "static_get";
|
||||
return "static-get";
|
||||
case INSTANCE_PUT:
|
||||
return "instance_put";
|
||||
return "instance-put";
|
||||
case INSTANCE_GET:
|
||||
return "instance_get";
|
||||
case INVOKE_STATIC:
|
||||
return "invoke_static";
|
||||
case INVOKE_INSTANCE:
|
||||
return "invoke_instance";
|
||||
return "instance-get";
|
||||
case STATIC_INVOKE:
|
||||
return "static-invoke";
|
||||
case INSTANCE_INVOKE:
|
||||
return "instance-invoke";
|
||||
default:
|
||||
throw new InvalidMethodHandleTypeException(methodHandleType);
|
||||
}
|
||||
}
|
||||
|
||||
public static int getMethodHandleType(String methodHandleType) {
|
||||
Integer ret = methodHandleTypeNames.get(methodHandleType);
|
||||
if (ret == null) {
|
||||
throw new ExceptionWithContext("Invalid method handle type: %s", methodHandleType);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static class InvalidMethodHandleTypeException extends ExceptionWithContext {
|
||||
private final int methodHandleType;
|
||||
|
||||
|
@ -66,8 +66,8 @@ public class DexBackedMethodHandleReference extends BaseMethodHandleReference {
|
||||
case MethodHandleType.STATIC_GET:
|
||||
case MethodHandleType.STATIC_PUT:
|
||||
return new DexBackedFieldReference(dexFile, memberIndex);
|
||||
case MethodHandleType.INVOKE_INSTANCE:
|
||||
case MethodHandleType.INVOKE_STATIC:
|
||||
case MethodHandleType.INSTANCE_INVOKE:
|
||||
case MethodHandleType.STATIC_INVOKE:
|
||||
return new DexBackedMethodReference(dexFile, memberIndex);
|
||||
default:
|
||||
throw new ExceptionWithContext("Invalid method handle type: %d", getMethodHandleType());
|
||||
|
@ -48,7 +48,7 @@ public interface MethodHandleReference extends Reference, Comparable<MethodHandl
|
||||
/**
|
||||
* Gets the member that is being referenced by this method handle.
|
||||
*
|
||||
* For INVOKE_STATIC and INVOKE_INSTANCE method handle types, this should be a MethodReference.
|
||||
* For STATIC_INVOKE and INSTANCE_INVOKE method handle types, this should be a MethodReference.
|
||||
* For the other method handle types, this should be a FieldReference.
|
||||
*
|
||||
* @return A MethodReference or FieldReference, depending on the method handle type
|
||||
|
@ -71,8 +71,8 @@ public class ImmutableMethodHandleReference extends BaseMethodHandleReference im
|
||||
memberReference = ImmutableFieldReference.of(
|
||||
(FieldReference) methodHandleReference.getMemberReference());
|
||||
break;
|
||||
case MethodHandleType.INVOKE_INSTANCE:
|
||||
case MethodHandleType.INVOKE_STATIC:
|
||||
case MethodHandleType.INSTANCE_INVOKE:
|
||||
case MethodHandleType.STATIC_INVOKE:
|
||||
memberReference = ImmutableMethodReference.of(
|
||||
(MethodReference) methodHandleReference.getMemberReference());
|
||||
break;
|
||||
|
@ -588,8 +588,8 @@ public abstract class DexWriter<
|
||||
memberIndex = fieldSection.getItemIndex(
|
||||
methodHandleSection.getFieldReference(methodHandleReference));
|
||||
break;
|
||||
case MethodHandleType.INVOKE_INSTANCE:
|
||||
case MethodHandleType.INVOKE_STATIC:
|
||||
case MethodHandleType.INSTANCE_INVOKE:
|
||||
case MethodHandleType.STATIC_INVOKE:
|
||||
memberIndex = methodSection.getItemIndex(
|
||||
methodHandleSection.getMethodReference(methodHandleReference));
|
||||
break;
|
||||
|
@ -68,8 +68,8 @@ public class BuilderMethodHandlePool extends BaseBuilderPool
|
||||
memberReference = dexBuilder.internFieldReference(
|
||||
(FieldReference) methodHandleReference.getMemberReference());
|
||||
break;
|
||||
case MethodHandleType.INVOKE_INSTANCE:
|
||||
case MethodHandleType.INVOKE_STATIC:
|
||||
case MethodHandleType.INSTANCE_INVOKE:
|
||||
case MethodHandleType.STATIC_INVOKE:
|
||||
memberReference = dexBuilder.internMethodReference(
|
||||
(MethodReference) methodHandleReference.getMemberReference());
|
||||
break;
|
||||
|
@ -56,8 +56,8 @@ public class MethodHandlePool extends BaseIndexPool<MethodHandleReference>
|
||||
case MethodHandleType.STATIC_PUT:
|
||||
dexPool.fieldSection.intern((FieldReference) methodHandleReference.getMemberReference());
|
||||
break;
|
||||
case MethodHandleType.INVOKE_INSTANCE:
|
||||
case MethodHandleType.INVOKE_STATIC:
|
||||
case MethodHandleType.INSTANCE_INVOKE:
|
||||
case MethodHandleType.STATIC_INVOKE:
|
||||
dexPool.methodSection.intern((MethodReference) methodHandleReference.getMemberReference());
|
||||
break;
|
||||
default:
|
||||
|
@ -74,7 +74,7 @@ public class CallSiteTest {
|
||||
new ImmutableMethodImplementation(10, ImmutableList.of(
|
||||
new ImmutableInstruction35c(Opcode.INVOKE_CUSTOM, 0, 0, 0, 0, 0, 0,
|
||||
new ImmutableCallSiteReference("call_site_1",
|
||||
new ImmutableMethodHandleReference(MethodHandleType.INVOKE_STATIC,
|
||||
new ImmutableMethodHandleReference(MethodHandleType.STATIC_INVOKE,
|
||||
new ImmutableMethodReference("Lcls1", "loader",
|
||||
ImmutableList.of("Ljava/lang/invoke/Lookup;",
|
||||
"Ljava/lang/String;",
|
||||
@ -96,7 +96,7 @@ public class CallSiteTest {
|
||||
|
||||
BuilderCallSiteReference callSite = dexBuilder.internCallSite(new ImmutableCallSiteReference("call_site_1",
|
||||
new ImmutableMethodHandleReference(
|
||||
MethodHandleType.INVOKE_STATIC,
|
||||
MethodHandleType.STATIC_INVOKE,
|
||||
new ImmutableMethodReference("Lcls1", "loader", ImmutableList.of("Ljava/lang/invoke/Lookup;",
|
||||
"Ljava/lang/String;",
|
||||
"Ljava/lang/invoke/MethodType;"),
|
||||
|
Loading…
x
Reference in New Issue
Block a user