Move remaining backports to cf constructions.
Bug: 136596951
Change-Id: I7e6014c2a88867f8416cfc383dac79aba7b84f4a
diff --git a/src/main/java/com/android/tools/r8/cf/CfCodePrinter.java b/src/main/java/com/android/tools/r8/cf/CfCodePrinter.java
index eef1bfa..9943f5b 100644
--- a/src/main/java/com/android/tools/r8/cf/CfCodePrinter.java
+++ b/src/main/java/com/android/tools/r8/cf/CfCodePrinter.java
@@ -158,6 +158,10 @@
return "\"" + string + "\"";
}
+ private String longValue(long value) {
+ return (value < Integer.MIN_VALUE || Integer.MAX_VALUE < value) ? (value + "l") : ("" + value);
+ }
+
// Ensure a type import for a given type.
// Note that the package should be given as individual parts to avoid the repackage "fixing" it...
private String type(String name, List<String> pkg) {
@@ -284,7 +288,7 @@
@Override
public void print(CfConstNumber constNumber) {
printNewInstruction(
- "CfConstNumber", "" + constNumber.getRawValue(), valueType(constNumber.getType()));
+ "CfConstNumber", longValue(constNumber.getRawValue()), valueType(constNumber.getType()));
}
@Override
@@ -317,7 +321,8 @@
@Override
public void print(CfCmp cmp) {
- throw new Unimplemented(cmp.getClass().getSimpleName());
+ printNewInstruction(
+ "CfCmp", irType("Cmp") + ".Bias." + cmp.getBias().name(), numericType(cmp.getType()));
}
@Override
@@ -330,12 +335,15 @@
@Override
public void print(CfNeg neg) {
- throw new Unimplemented(neg.getClass().getSimpleName());
+ printNewInstruction("CfNeg", numericType(neg.getType()));
}
@Override
public void print(CfNumberConversion numberConversion) {
- throw new Unimplemented(numberConversion.getClass().getSimpleName());
+ printNewInstruction(
+ "CfNumberConversion",
+ numericType(numberConversion.getFromType()),
+ numericType(numberConversion.getToType()));
}
@Override
@@ -355,7 +363,7 @@
@Override
public void print(CfArrayStore arrayStore) {
- throw new Unimplemented(arrayStore.getClass().getSimpleName());
+ printNewInstruction("CfArrayStore", memberType(arrayStore.getType()));
}
@Override
@@ -399,7 +407,7 @@
@Override
public void print(CfNewArray newArray) {
- throw new Unimplemented(newArray.getClass().getSimpleName());
+ printNewInstruction("CfNewArray", dexType(newArray.getType()));
}
@Override
diff --git a/src/main/java/com/android/tools/r8/cf/code/CfCmp.java b/src/main/java/com/android/tools/r8/cf/code/CfCmp.java
index a19be75..10c8eab 100644
--- a/src/main/java/com/android/tools/r8/cf/code/CfCmp.java
+++ b/src/main/java/com/android/tools/r8/cf/code/CfCmp.java
@@ -36,6 +36,14 @@
this.type = type;
}
+ public Bias getBias() {
+ return bias;
+ }
+
+ public NumericType getType() {
+ return type;
+ }
+
public static CfCmp fromAsm(int opcode) {
switch (opcode) {
case Opcodes.LCMP:
diff --git a/src/main/java/com/android/tools/r8/cf/code/CfNeg.java b/src/main/java/com/android/tools/r8/cf/code/CfNeg.java
index a38433b..cbd67ae 100644
--- a/src/main/java/com/android/tools/r8/cf/code/CfNeg.java
+++ b/src/main/java/com/android/tools/r8/cf/code/CfNeg.java
@@ -27,6 +27,10 @@
this.type = type;
}
+ public NumericType getType() {
+ return type;
+ }
+
@Override
public void write(MethodVisitor visitor, NamingLens lens) {
visitor.visitInsn(getAsmOpcode());
diff --git a/src/main/java/com/android/tools/r8/cf/code/CfNumberConversion.java b/src/main/java/com/android/tools/r8/cf/code/CfNumberConversion.java
index b33c1b8..73d8f34 100644
--- a/src/main/java/com/android/tools/r8/cf/code/CfNumberConversion.java
+++ b/src/main/java/com/android/tools/r8/cf/code/CfNumberConversion.java
@@ -33,6 +33,14 @@
this.to = to;
}
+ public NumericType getFromType() {
+ return from;
+ }
+
+ public NumericType getToType() {
+ return to;
+ }
+
@Override
public void write(MethodVisitor visitor, NamingLens lens) {
visitor.visitInsn(this.getAsmOpcode());
diff --git a/src/main/java/com/android/tools/r8/ir/desugar/BackportedMethodRewriter.java b/src/main/java/com/android/tools/r8/ir/desugar/BackportedMethodRewriter.java
index 51077a1..9ca8849 100644
--- a/src/main/java/com/android/tools/r8/ir/desugar/BackportedMethodRewriter.java
+++ b/src/main/java/com/android/tools/r8/ir/desugar/BackportedMethodRewriter.java
@@ -30,24 +30,16 @@
import com.android.tools.r8.ir.code.InvokeStatic;
import com.android.tools.r8.ir.conversion.IRConverter;
import com.android.tools.r8.ir.desugar.backports.BackportedMethods;
-import com.android.tools.r8.ir.desugar.backports.ByteMethods;
-import com.android.tools.r8.ir.desugar.backports.CharacterMethods;
-import com.android.tools.r8.ir.desugar.backports.CollectionsMethods;
-import com.android.tools.r8.ir.desugar.backports.DoubleMethods;
-import com.android.tools.r8.ir.desugar.backports.FloatMethods;
-import com.android.tools.r8.ir.desugar.backports.IntegerMethods;
-import com.android.tools.r8.ir.desugar.backports.ListMethods;
-import com.android.tools.r8.ir.desugar.backports.LongMethods;
-import com.android.tools.r8.ir.desugar.backports.MathMethods;
+import com.android.tools.r8.ir.desugar.backports.ListMethodRewrites;
+import com.android.tools.r8.ir.desugar.backports.LongMethodRewrites;
import com.android.tools.r8.ir.desugar.backports.NumericOperations;
import com.android.tools.r8.ir.desugar.backports.ObjectsMethodRewrites;
-import com.android.tools.r8.ir.desugar.backports.OptionalMethods;
-import com.android.tools.r8.ir.desugar.backports.ShortMethods;
import com.android.tools.r8.ir.synthetic.TemplateMethodCode;
import com.android.tools.r8.origin.SynthesizedOrigin;
import com.android.tools.r8.utils.AndroidApiLevel;
import com.android.tools.r8.utils.InternalOptions;
import com.android.tools.r8.utils.StringDiagnostic;
+import com.google.common.collect.ImmutableList;
import com.google.common.collect.Sets;
import java.util.ArrayList;
import java.util.Collection;
@@ -278,7 +270,7 @@
DexString name = factory.createString("compare");
DexProto proto = factory.createProto(factory.intType, factory.byteType, factory.byteType);
DexMethod method = factory.createMethod(type, proto, name);
- addProvider(new MethodGenerator(method, ByteMethods::new));
+ addProvider(new MethodGenerator(method, BackportedMethods::ByteMethods_compare));
// Short
type = factory.boxedShortType;
@@ -286,7 +278,7 @@
name = factory.createString("compare");
proto = factory.createProto(factory.intType, factory.shortType, factory.shortType);
method = factory.createMethod(type, proto, name);
- addProvider(new MethodGenerator(method, ShortMethods::new));
+ addProvider(new MethodGenerator(method, BackportedMethods::ShortMethods_compare));
// Integer
type = factory.boxedIntType;
@@ -294,7 +286,7 @@
name = factory.createString("compare");
proto = factory.createProto(factory.intType, factory.intType, factory.intType);
method = factory.createMethod(type, proto, name);
- addProvider(new MethodGenerator(method, IntegerMethods::new));
+ addProvider(new MethodGenerator(method, BackportedMethods::IntegerMethods_compare));
// Long
type = factory.boxedLongType;
@@ -302,7 +294,7 @@
name = factory.createString("compare");
proto = factory.createProto(factory.intType, factory.longType, factory.longType);
method = factory.createMethod(type, proto, name);
- addProvider(new InvokeRewriter(method, LongMethods::rewriteCompare));
+ addProvider(new InvokeRewriter(method, LongMethodRewrites::rewriteCompare));
// Boolean
type = factory.boxedBooleanType;
@@ -318,7 +310,7 @@
name = factory.createString("compare");
proto = factory.createProto(factory.intType, factory.charType, factory.charType);
method = factory.createMethod(type, proto, name);
- addProvider(new MethodGenerator(method, CharacterMethods::new));
+ addProvider(new MethodGenerator(method, BackportedMethods::CharacterMethods_compare));
// Objects
type = factory.objectsType;
@@ -391,19 +383,21 @@
name = factory.createString("emptyEnumeration");
proto = factory.createProto(factory.enumerationType);
method = factory.createMethod(type, proto, name);
- addProvider(new MethodGenerator(method, CollectionsMethods::new));
+ addProvider(
+ new MethodGenerator(method, BackportedMethods::CollectionsMethods_emptyEnumeration));
// Iterator<T> Collections.emptyIterator();
name = factory.createString("emptyIterator");
proto = factory.createProto(factory.iteratorType);
method = factory.createMethod(type, proto, name);
- addProvider(new MethodGenerator(method, CollectionsMethods::new));
+ addProvider(new MethodGenerator(method, BackportedMethods::CollectionsMethods_emptyIterator));
// ListIterator<T> Collections.emptyListIterator();
name = factory.createString("emptyListIterator");
proto = factory.createProto(factory.listIteratorType);
method = factory.createMethod(type, proto, name);
- addProvider(new MethodGenerator(method, CollectionsMethods::new));
+ addProvider(
+ new MethodGenerator(method, BackportedMethods::CollectionsMethods_emptyListIterator));
}
private void initializeAndroidNMethodProviders(DexItemFactory factory) {
@@ -413,7 +407,7 @@
DexString name = factory.createString("hashCode");
DexProto proto = factory.createProto(factory.intType, factory.byteType);
DexMethod method = factory.createMethod(type, proto, name);
- addProvider(new MethodGenerator(method, ByteMethods::new));
+ addProvider(new MethodGenerator(method, BackportedMethods::ByteMethods_hashCode));
// Short
type = factory.boxedShortType;
@@ -421,7 +415,7 @@
name = factory.createString("hashCode");
proto = factory.createProto(factory.intType, factory.shortType);
method = factory.createMethod(type, proto, name);
- addProvider(new MethodGenerator(method, ShortMethods::new));
+ addProvider(new MethodGenerator(method, BackportedMethods::ShortMethods_hashCode));
// Integer
type = factory.boxedIntType;
@@ -430,7 +424,7 @@
name = factory.createString("hashCode");
proto = factory.createProto(factory.intType, factory.intType);
method = factory.createMethod(type, proto, name);
- addProvider(new MethodGenerator(method, IntegerMethods::new));
+ addProvider(new MethodGenerator(method, BackportedMethods::IntegerMethods_hashCode));
// int Integer.max(int a, int b)
name = factory.createString("max");
@@ -457,7 +451,7 @@
name = factory.createString("hashCode");
proto = factory.createProto(factory.intType, factory.doubleType);
method = factory.createMethod(type, proto, name);
- addProvider(new MethodGenerator(method, DoubleMethods::new));
+ addProvider(new MethodGenerator(method, BackportedMethods::DoubleMethods_hashCode));
// double Double.max(double a, double b)
name = factory.createString("max");
@@ -481,7 +475,7 @@
name = factory.createString("isFinite");
proto = factory.createProto(factory.booleanType, factory.doubleType);
method = factory.createMethod(type, proto, name);
- addProvider(new MethodGenerator(method, DoubleMethods::new));
+ addProvider(new MethodGenerator(method, BackportedMethods::DoubleMethods_isFinite));
// Float
type = factory.boxedFloatType;
@@ -490,7 +484,7 @@
name = factory.createString("hashCode");
proto = factory.createProto(factory.intType, factory.floatType);
method = factory.createMethod(type, proto, name);
- addProvider(new MethodGenerator(method, FloatMethods::new));
+ addProvider(new MethodGenerator(method, BackportedMethods::FloatMethods_hashCode));
// float Float.max(float a, float b)
name = factory.createString("max");
@@ -514,7 +508,7 @@
name = factory.createString("isFinite");
proto = factory.createProto(factory.booleanType, factory.floatType);
method = factory.createMethod(type, proto, name);
- addProvider(new MethodGenerator(method, FloatMethods::new));
+ addProvider(new MethodGenerator(method, BackportedMethods::FloatMethods_isFinite));
// Boolean
type = factory.boxedBooleanType;
@@ -550,7 +544,7 @@
name = factory.createString("hashCode");
proto = factory.createProto(factory.intType, factory.longType);
method = factory.createMethod(type, proto, name);
- addProvider(new MethodGenerator(method, LongMethods::new));
+ addProvider(new MethodGenerator(method, BackportedMethods::LongMethods_hashCode));
// long Long.max(long a, long b)
name = factory.createString("max");
@@ -577,7 +571,7 @@
name = factory.createString("hashCode");
proto = factory.createProto(factory.intType, factory.charType);
method = factory.createMethod(type, proto, name);
- addProvider(new MethodGenerator(method, CharacterMethods::new));
+ addProvider(new MethodGenerator(method, BackportedMethods::CharacterMethods_hashCode));
// Objects
type = factory.objectsType;
@@ -603,79 +597,100 @@
name = factory.createString("addExact");
proto = factory.createProto(factory.intType, factory.intType, factory.intType);
method = factory.createMethod(type, proto, name);
- addProvider(new MethodGenerator(method, MathMethods::new, "addExactInt"));
+ addProvider(
+ new MethodGenerator(method, BackportedMethods::MathMethods_addExactInt, "addExactInt"));
// long {Math,StrictMath}.addExact(long, long)
name = factory.createString("addExact");
proto = factory.createProto(factory.longType, factory.longType, factory.longType);
method = factory.createMethod(type, proto, name);
- addProvider(new MethodGenerator(method, MathMethods::new, "addExactLong"));
+ addProvider(
+ new MethodGenerator(
+ method, BackportedMethods::MathMethods_addExactLong, "addExactLong"));
// int {Math,StrictMath}.floorDiv(int, int)
name = factory.createString("floorDiv");
proto = factory.createProto(factory.intType, factory.intType, factory.intType);
method = factory.createMethod(type, proto, name);
- addProvider(new MethodGenerator(method, MathMethods::new, "floorDivInt"));
+ addProvider(
+ new MethodGenerator(method, BackportedMethods::MathMethods_floorDivInt, "floorDivInt"));
// long {Math,StrictMath}.floorDiv(long, long)
name = factory.createString("floorDiv");
proto = factory.createProto(factory.longType, factory.longType, factory.longType);
method = factory.createMethod(type, proto, name);
- addProvider(new MethodGenerator(method, MathMethods::new, "floorDivLong"));
+ addProvider(
+ new MethodGenerator(
+ method, BackportedMethods::MathMethods_floorDivLong, "floorDivLong"));
// int {Math,StrictMath}.floorMod(int, int)
name = factory.createString("floorMod");
proto = factory.createProto(factory.intType, factory.intType, factory.intType);
method = factory.createMethod(type, proto, name);
- addProvider(new MethodGenerator(method, MathMethods::new, "floorModInt"));
+ addProvider(
+ new MethodGenerator(method, BackportedMethods::MathMethods_floorModInt, "floorModInt"));
// long {Math,StrictMath}.floorMod(long, long)
name = factory.createString("floorMod");
proto = factory.createProto(factory.longType, factory.longType, factory.longType);
method = factory.createMethod(type, proto, name);
- addProvider(new MethodGenerator(method, MathMethods::new, "floorModLong"));
+ addProvider(
+ new MethodGenerator(
+ method, BackportedMethods::MathMethods_floorModLong, "floorModLong"));
// int {Math,StrictMath}.multiplyExact(int, int)
name = factory.createString("multiplyExact");
proto = factory.createProto(factory.intType, factory.intType, factory.intType);
method = factory.createMethod(type, proto, name);
- addProvider(new MethodGenerator(method, MathMethods::new, "multiplyExactInt"));
+ addProvider(
+ new MethodGenerator(
+ method, BackportedMethods::MathMethods_multiplyExactInt, "multiplyExactInt"));
// long {Math,StrictMath}.multiplyExact(long, long)
name = factory.createString("multiplyExact");
proto = factory.createProto(factory.longType, factory.longType, factory.longType);
method = factory.createMethod(type, proto, name);
- addProvider(new MethodGenerator(method, MathMethods::new, "multiplyExactLong"));
+ addProvider(
+ new MethodGenerator(
+ method, BackportedMethods::MathMethods_multiplyExactLong, "multiplyExactLong"));
// double {Math,StrictMath}.nextDown(double)
name = factory.createString("nextDown");
proto = factory.createProto(factory.doubleType, factory.doubleType);
method = factory.createMethod(type, proto, name);
- addProvider(new MethodGenerator(method, MathMethods::new, "nextDownDouble"));
+ addProvider(
+ new MethodGenerator(
+ method, BackportedMethods::MathMethods_nextDownDouble, "nextDownDouble"));
// float {Math,StrictMath}.nextDown(float)
name = factory.createString("nextDown");
proto = factory.createProto(factory.floatType, factory.floatType);
method = factory.createMethod(type, proto, name);
- addProvider(new MethodGenerator(method, MathMethods::new, "nextDownFloat"));
+ addProvider(
+ new MethodGenerator(
+ method, BackportedMethods::MathMethods_nextDownFloat, "nextDownFloat"));
// int {Math,StrictMath}.subtractExact(int, int)
name = factory.createString("subtractExact");
proto = factory.createProto(factory.intType, factory.intType, factory.intType);
method = factory.createMethod(type, proto, name);
- addProvider(new MethodGenerator(method, MathMethods::new, "subtractExactInt"));
+ addProvider(
+ new MethodGenerator(
+ method, BackportedMethods::MathMethods_subtractExactInt, "subtractExactInt"));
// long {Math,StrictMath}.subtractExact(long, long)
name = factory.createString("subtractExact");
proto = factory.createProto(factory.longType, factory.longType, factory.longType);
method = factory.createMethod(type, proto, name);
- addProvider(new MethodGenerator(method, MathMethods::new, "subtractExactLong"));
+ addProvider(
+ new MethodGenerator(
+ method, BackportedMethods::MathMethods_subtractExactLong, "subtractExactLong"));
// int {Math,StrictMath}.toIntExact(long)
name = factory.createString("toIntExact");
proto = factory.createProto(factory.intType, factory.longType);
method = factory.createMethod(type, proto, name);
- addProvider(new MethodGenerator(method, MathMethods::new));
+ addProvider(new MethodGenerator(method, BackportedMethods::MathMethods_toIntExact));
}
// Math (APIs which are not mirrored by StrictMath)
@@ -685,37 +700,49 @@
name = factory.createString("decrementExact");
proto = factory.createProto(factory.intType, factory.intType);
method = factory.createMethod(type, proto, name);
- addProvider(new MethodGenerator(method, MathMethods::new, "decrementExactInt"));
+ addProvider(
+ new MethodGenerator(
+ method, BackportedMethods::MathMethods_decrementExactInt, "decrementExactInt"));
// long Math.decrementExact(long)
name = factory.createString("decrementExact");
proto = factory.createProto(factory.longType, factory.longType);
method = factory.createMethod(type, proto, name);
- addProvider(new MethodGenerator(method, MathMethods::new, "decrementExactLong"));
+ addProvider(
+ new MethodGenerator(
+ method, BackportedMethods::MathMethods_decrementExactLong, "decrementExactLong"));
// int Math.incrementExact(int)
name = factory.createString("incrementExact");
proto = factory.createProto(factory.intType, factory.intType);
method = factory.createMethod(type, proto, name);
- addProvider(new MethodGenerator(method, MathMethods::new, "incrementExactInt"));
+ addProvider(
+ new MethodGenerator(
+ method, BackportedMethods::MathMethods_incrementExactInt, "incrementExactInt"));
// long Math.incrementExact(long)
name = factory.createString("incrementExact");
proto = factory.createProto(factory.longType, factory.longType);
method = factory.createMethod(type, proto, name);
- addProvider(new MethodGenerator(method, MathMethods::new, "incrementExactLong"));
+ addProvider(
+ new MethodGenerator(
+ method, BackportedMethods::MathMethods_incrementExactLong, "incrementExactLong"));
// int Math.negateExact(int)
name = factory.createString("negateExact");
proto = factory.createProto(factory.intType, factory.intType);
method = factory.createMethod(type, proto, name);
- addProvider(new MethodGenerator(method, MathMethods::new, "negateExactInt"));
+ addProvider(
+ new MethodGenerator(
+ method, BackportedMethods::MathMethods_negateExactInt, "negateExactInt"));
// long Math.negateExact(long)
name = factory.createString("negateExact");
proto = factory.createProto(factory.longType, factory.longType);
method = factory.createMethod(type, proto, name);
- addProvider(new MethodGenerator(method, MathMethods::new, "negateExactLong"));
+ addProvider(
+ new MethodGenerator(
+ method, BackportedMethods::MathMethods_negateExactLong, "negateExactLong"));
}
private void initializeAndroidOMethodProviders(DexItemFactory factory) {
@@ -726,13 +753,13 @@
DexString name = factory.createString("toUnsignedInt");
DexProto proto = factory.createProto(factory.intType, factory.byteType);
DexMethod method = factory.createMethod(type, proto, name);
- addProvider(new MethodGenerator(method, ByteMethods::new));
+ addProvider(new MethodGenerator(method, BackportedMethods::ByteMethods_toUnsignedInt));
// long Byte.toUnsignedLong(byte value)
name = factory.createString("toUnsignedLong");
proto = factory.createProto(factory.longType, factory.byteType);
method = factory.createMethod(type, proto, name);
- addProvider(new MethodGenerator(method, ByteMethods::new));
+ addProvider(new MethodGenerator(method, BackportedMethods::ByteMethods_toUnsignedLong));
// Short
type = factory.boxedShortType;
@@ -741,13 +768,13 @@
name = factory.createString("toUnsignedInt");
proto = factory.createProto(factory.intType, factory.shortType);
method = factory.createMethod(type, proto, name);
- addProvider(new MethodGenerator(method, ShortMethods::new));
+ addProvider(new MethodGenerator(method, BackportedMethods::ShortMethods_toUnsignedInt));
// long Short.toUnsignedLong(short value)
name = factory.createString("toUnsignedLong");
proto = factory.createProto(factory.longType, factory.shortType);
method = factory.createMethod(type, proto, name);
- addProvider(new MethodGenerator(method, ShortMethods::new));
+ addProvider(new MethodGenerator(method, BackportedMethods::ShortMethods_toUnsignedLong));
// Integer
type = factory.boxedIntType;
@@ -756,49 +783,57 @@
name = factory.createString("divideUnsigned");
proto = factory.createProto(factory.intType, factory.intType, factory.intType);
method = factory.createMethod(type, proto, name);
- addProvider(new MethodGenerator(method, IntegerMethods::new));
+ addProvider(new MethodGenerator(method, BackportedMethods::IntegerMethods_divideUnsigned));
// int Integer.remainderUnsigned(int a, int b)
name = factory.createString("remainderUnsigned");
proto = factory.createProto(factory.intType, factory.intType, factory.intType);
method = factory.createMethod(type, proto, name);
- addProvider(new MethodGenerator(method, IntegerMethods::new));
+ addProvider(new MethodGenerator(method, BackportedMethods::IntegerMethods_remainderUnsigned));
// int Integer.compareUnsigned(int a, int b)
name = factory.createString("compareUnsigned");
proto = factory.createProto(factory.intType, factory.intType, factory.intType);
method = factory.createMethod(type, proto, name);
- addProvider(new MethodGenerator(method, IntegerMethods::new));
+ addProvider(new MethodGenerator(method, BackportedMethods::IntegerMethods_compareUnsigned));
// long Integer.toUnsignedLong(int value)
name = factory.createString("toUnsignedLong");
proto = factory.createProto(factory.longType, factory.intType);
method = factory.createMethod(type, proto, name);
- addProvider(new MethodGenerator(method, IntegerMethods::new));
+ addProvider(new MethodGenerator(method, BackportedMethods::IntegerMethods_toUnsignedLong));
// int Integer.parseUnsignedInt(String value)
name = factory.createString("parseUnsignedInt");
proto = factory.createProto(factory.intType, factory.stringType);
method = factory.createMethod(type, proto, name);
- addProvider(new MethodGenerator(method, IntegerMethods::new));
+ addProvider(new MethodGenerator(method, BackportedMethods::IntegerMethods_parseUnsignedInt));
// int Integer.parseUnsignedInt(String value, int radix)
name = factory.createString("parseUnsignedInt");
proto = factory.createProto(factory.intType, factory.stringType, factory.intType);
method = factory.createMethod(type, proto, name);
- addProvider(new MethodGenerator(method, IntegerMethods::new, "parseUnsignedIntWithRadix"));
+ addProvider(
+ new MethodGenerator(
+ method,
+ BackportedMethods::IntegerMethods_parseUnsignedIntWithRadix,
+ "parseUnsignedIntWithRadix"));
// String Integer.toUnsignedString(int value)
name = factory.createString("toUnsignedString");
proto = factory.createProto(factory.stringType, factory.intType);
method = factory.createMethod(type, proto, name);
- addProvider(new MethodGenerator(method, IntegerMethods::new));
+ addProvider(new MethodGenerator(method, BackportedMethods::IntegerMethods_toUnsignedString));
// String Integer.toUnsignedString(int value, int radix)
name = factory.createString("toUnsignedString");
proto = factory.createProto(factory.stringType, factory.intType, factory.intType);
method = factory.createMethod(type, proto, name);
- addProvider(new MethodGenerator(method, IntegerMethods::new, "toUnsignedStringWithRadix"));
+ addProvider(
+ new MethodGenerator(
+ method,
+ BackportedMethods::IntegerMethods_toUnsignedStringWithRadix,
+ "toUnsignedStringWithRadix"));
// Long
type = factory.boxedLongType;
@@ -807,43 +842,51 @@
name = factory.createString("divideUnsigned");
proto = factory.createProto(factory.longType, factory.longType, factory.longType);
method = factory.createMethod(type, proto, name);
- addProvider(new MethodGenerator(method, LongMethods::new));
+ addProvider(new MethodGenerator(method, BackportedMethods::LongMethods_divideUnsigned));
// long Long.remainderUnsigned(long a, long b)
name = factory.createString("remainderUnsigned");
proto = factory.createProto(factory.longType, factory.longType, factory.longType);
method = factory.createMethod(type, proto, name);
- addProvider(new MethodGenerator(method, LongMethods::new));
+ addProvider(new MethodGenerator(method, BackportedMethods::LongMethods_remainderUnsigned));
// int Long.compareUnsigned(long a, long b)
name = factory.createString("compareUnsigned");
proto = factory.createProto(factory.intType, factory.longType, factory.longType);
method = factory.createMethod(type, proto, name);
- addProvider(new MethodGenerator(method, LongMethods::new));
+ addProvider(new MethodGenerator(method, BackportedMethods::LongMethods_compareUnsigned));
// long Long.parseUnsignedLong(String value)
name = factory.createString("parseUnsignedLong");
proto = factory.createProto(factory.longType, factory.stringType);
method = factory.createMethod(type, proto, name);
- addProvider(new MethodGenerator(method, LongMethods::new));
+ addProvider(new MethodGenerator(method, BackportedMethods::LongMethods_parseUnsignedLong));
// long Long.parseUnsignedLong(String value, int radix)
name = factory.createString("parseUnsignedLong");
proto = factory.createProto(factory.longType, factory.stringType, factory.intType);
method = factory.createMethod(type, proto, name);
- addProvider(new MethodGenerator(method, LongMethods::new, "parseUnsignedLongWithRadix"));
+ addProvider(
+ new MethodGenerator(
+ method,
+ BackportedMethods::LongMethods_parseUnsignedLongWithRadix,
+ "parseUnsignedLongWithRadix"));
// String Long.toUnsignedString(long value)
name = factory.createString("toUnsignedString");
proto = factory.createProto(factory.stringType, factory.longType);
method = factory.createMethod(type, proto, name);
- addProvider(new MethodGenerator(method, LongMethods::new));
+ addProvider(new MethodGenerator(method, BackportedMethods::LongMethods_toUnsignedString));
// String Long.toUnsignedString(long value, int radix)
name = factory.createString("toUnsignedString");
proto = factory.createProto(factory.stringType, factory.longType, factory.intType);
method = factory.createMethod(type, proto, name);
- addProvider(new MethodGenerator(method, LongMethods::new, "toUnsignedStringWithRadix"));
+ addProvider(
+ new MethodGenerator(
+ method,
+ BackportedMethods::LongMethods_toUnsignedStringWithRadix,
+ "toUnsignedStringWithRadix"));
// String
type = factory.stringType;
@@ -876,19 +919,27 @@
DexString name = factory.createString("multiplyExact");
DexProto proto = factory.createProto(factory.longType, factory.longType, factory.intType);
DexMethod method = factory.createMethod(type, proto, name);
- addProvider(new MethodGenerator(method, MathMethods::new, "multiplyExactLongInt"));
+ addProvider(
+ new MethodGenerator(
+ method,
+ BackportedMethods::MathMethods_multiplyExactLongInt,
+ "multiplyExactLongInt"));
// long {Math,StrictMath}.floorDiv(long, int)
name = factory.createString("floorDiv");
proto = factory.createProto(factory.longType, factory.longType, factory.intType);
method = factory.createMethod(type, proto, name);
- addProvider(new MethodGenerator(method, MathMethods::new, "floorDivLongInt"));
+ addProvider(
+ new MethodGenerator(
+ method, BackportedMethods::MathMethods_floorDivLongInt, "floorDivLongInt"));
// int {Math,StrictMath}.floorMod(long, int)
name = factory.createString("floorMod");
proto = factory.createProto(factory.intType, factory.longType, factory.intType);
method = factory.createMethod(type, proto, name);
- addProvider(new MethodGenerator(method, MathMethods::new, "floorModLongInt"));
+ addProvider(
+ new MethodGenerator(
+ method, BackportedMethods::MathMethods_floorModLongInt, "floorModLongInt"));
}
// Byte
@@ -898,7 +949,7 @@
DexString name = factory.createString("compareUnsigned");
DexProto proto = factory.createProto(factory.intType, factory.byteType, factory.byteType);
DexMethod method = factory.createMethod(type, proto, name);
- addProvider(new MethodGenerator(method, ByteMethods::new));
+ addProvider(new MethodGenerator(method, BackportedMethods::ByteMethods_compareUnsigned));
// Short
type = factory.boxedShortType;
@@ -907,7 +958,7 @@
name = factory.createString("compareUnsigned");
proto = factory.createProto(factory.intType, factory.shortType, factory.shortType);
method = factory.createMethod(type, proto, name);
- addProvider(new MethodGenerator(method, ShortMethods::new));
+ addProvider(new MethodGenerator(method, BackportedMethods::ShortMethods_compareUnsigned));
// Objects
type = factory.objectsType;
@@ -950,16 +1001,29 @@
// List<E> List.of(<args>) for 0 to 10 arguments and List.of(E[])
type = factory.listType;
name = factory.createString("of");
+ List<TemplateMethodFactory> ofFactories =
+ ImmutableList.of(
+ BackportedMethods::ListMethods_of1,
+ BackportedMethods::ListMethods_of2,
+ BackportedMethods::ListMethods_of3,
+ BackportedMethods::ListMethods_of4,
+ BackportedMethods::ListMethods_of5,
+ BackportedMethods::ListMethods_of6,
+ BackportedMethods::ListMethods_of7,
+ BackportedMethods::ListMethods_of8,
+ BackportedMethods::ListMethods_of9,
+ BackportedMethods::ListMethods_of10);
for (int i = 0; i <= 10; i++) {
proto = factory.createProto(factory.listType, Collections.nCopies(i, factory.objectType));
method = factory.createMethod(type, proto, name);
- addProvider(i == 0
- ? new InvokeRewriter(method, ListMethods::rewriteEmptyOf)
- : new MethodGenerator(method, ListMethods::new));
+ addProvider(
+ i == 0
+ ? new InvokeRewriter(method, ListMethodRewrites::rewriteEmptyOf)
+ : new MethodGenerator(method, ofFactories.get(i - 1)));
}
proto = factory.createProto(factory.listType, factory.objectArrayType);
method = factory.createMethod(type, proto, name);
- addProvider(new MethodGenerator(method, ListMethods::new, "ofArray"));
+ addProvider(new MethodGenerator(method, BackportedMethods::ListMethods_ofArray, "ofArray"));
}
private void initializeJava11MethodProviders(DexItemFactory factory) {
@@ -970,7 +1034,9 @@
DexString name = factory.createString("toString");
DexProto proto = factory.createProto(factory.stringType, factory.intType);
DexMethod method = factory.createMethod(type, proto, name);
- addProvider(new MethodGenerator(method, CharacterMethods::new, "toStringCodepoint"));
+ addProvider(
+ new MethodGenerator(
+ method, BackportedMethods::CharacterMethods_toStringCodepoint, "toStringCodepoint"));
}
private void initializeOptionalMethodProviders(DexItemFactory factory) {
@@ -981,14 +1047,17 @@
DexString name = factory.createString("or");
DexProto proto = factory.createProto(optionalType, factory.supplierType);
DexMethod method = factory.createMethod(optionalType, proto, name);
- addProvider(new StatifyingMethodGenerator(method, OptionalMethods::new, "or", optionalType));
+ addProvider(
+ new StatifyingMethodGenerator(
+ method, BackportedMethods::OptionalMethods_or, "or", optionalType));
// Optional.stream()
name = factory.createString("stream");
proto = factory.createProto(factory.createType("Ljava/util/stream/Stream;"));
method = factory.createMethod(optionalType, proto, name);
addProvider(
- new StatifyingMethodGenerator(method, OptionalMethods::new, "stream", optionalType));
+ new StatifyingMethodGenerator(
+ method, BackportedMethods::OptionalMethods_stream, "stream", optionalType));
// Optional{void,Int,Long,Double}.ifPresentOrElse(consumer,runnable)
DexType[] optionalTypes =
@@ -1005,6 +1074,13 @@
factory.createType("Ljava/util/function/LongConsumer;"),
factory.createType("Ljava/util/function/IntConsumer;")
};
+ TemplateMethodFactory[] methodFactories =
+ new TemplateMethodFactory[] {
+ BackportedMethods::OptionalMethods_ifPresentOrElse,
+ BackportedMethods::OptionalMethods_ifPresentOrElseDouble,
+ BackportedMethods::OptionalMethods_ifPresentOrElseLong,
+ BackportedMethods::OptionalMethods_ifPresentOrElseInt
+ };
for (int i = 0; i < optionalTypes.length; i++) {
DexType optional = optionalTypes[i];
DexType consumer = consumerTypes[i];
@@ -1012,8 +1088,7 @@
proto = factory.createProto(factory.voidType, consumer, factory.runnableType);
method = factory.createMethod(optional, proto, name);
addProvider(
- new StatifyingMethodGenerator(
- method, OptionalMethods::new, "ifPresentOrElse", optional));
+ new StatifyingMethodGenerator(method, methodFactories[i], "ifPresentOrElse", optional));
}
}
diff --git a/src/main/java/com/android/tools/r8/ir/desugar/backports/BackportedMethods.java b/src/main/java/com/android/tools/r8/ir/desugar/backports/BackportedMethods.java
index 53dabe6..b17f9d6 100644
--- a/src/main/java/com/android/tools/r8/ir/desugar/backports/BackportedMethods.java
+++ b/src/main/java/com/android/tools/r8/ir/desugar/backports/BackportedMethods.java
@@ -11,7 +11,9 @@
import com.android.tools.r8.cf.code.CfArithmeticBinop;
import com.android.tools.r8.cf.code.CfArrayLength;
import com.android.tools.r8.cf.code.CfArrayLoad;
+import com.android.tools.r8.cf.code.CfArrayStore;
import com.android.tools.r8.cf.code.CfCheckCast;
+import com.android.tools.r8.cf.code.CfCmp;
import com.android.tools.r8.cf.code.CfConstNumber;
import com.android.tools.r8.cf.code.CfConstString;
import com.android.tools.r8.cf.code.CfGoto;
@@ -23,13 +25,18 @@
import com.android.tools.r8.cf.code.CfLabel;
import com.android.tools.r8.cf.code.CfLoad;
import com.android.tools.r8.cf.code.CfLogicalBinop;
+import com.android.tools.r8.cf.code.CfNeg;
import com.android.tools.r8.cf.code.CfNew;
+import com.android.tools.r8.cf.code.CfNewArray;
+import com.android.tools.r8.cf.code.CfNumberConversion;
import com.android.tools.r8.cf.code.CfReturn;
+import com.android.tools.r8.cf.code.CfReturnVoid;
import com.android.tools.r8.cf.code.CfStackInstruction;
import com.android.tools.r8.cf.code.CfStore;
import com.android.tools.r8.cf.code.CfThrow;
import com.android.tools.r8.graph.CfCode;
import com.android.tools.r8.graph.DexMethod;
+import com.android.tools.r8.ir.code.Cmp;
import com.android.tools.r8.ir.code.If;
import com.android.tools.r8.ir.code.MemberType;
import com.android.tools.r8.ir.code.NumericType;
@@ -171,6 +178,3993 @@
ImmutableList.of());
}
+ public static CfCode ByteMethods_compare(InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 2,
+ 2,
+ ImmutableList.of(
+ label0,
+ new CfLoad(ValueType.INT, 0),
+ new CfLoad(ValueType.INT, 1),
+ new CfArithmeticBinop(CfArithmeticBinop.Opcode.Sub, NumericType.INT),
+ new CfReturn(ValueType.INT),
+ label1),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode ByteMethods_compareUnsigned(
+ InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 3,
+ 2,
+ ImmutableList.of(
+ label0,
+ new CfLoad(ValueType.INT, 0),
+ new CfConstNumber(255, ValueType.INT),
+ new CfLogicalBinop(CfLogicalBinop.Opcode.And, NumericType.INT),
+ new CfLoad(ValueType.INT, 1),
+ new CfConstNumber(255, ValueType.INT),
+ new CfLogicalBinop(CfLogicalBinop.Opcode.And, NumericType.INT),
+ new CfArithmeticBinop(CfArithmeticBinop.Opcode.Sub, NumericType.INT),
+ new CfReturn(ValueType.INT),
+ label1),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode ByteMethods_hashCode(
+ InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 1,
+ 1,
+ ImmutableList.of(label0, new CfLoad(ValueType.INT, 0), new CfReturn(ValueType.INT), label1),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode ByteMethods_toUnsignedInt(
+ InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 2,
+ 1,
+ ImmutableList.of(
+ label0,
+ new CfLoad(ValueType.INT, 0),
+ new CfConstNumber(255, ValueType.INT),
+ new CfLogicalBinop(CfLogicalBinop.Opcode.And, NumericType.INT),
+ new CfReturn(ValueType.INT),
+ label1),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode ByteMethods_toUnsignedLong(
+ InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 4,
+ 1,
+ ImmutableList.of(
+ label0,
+ new CfLoad(ValueType.INT, 0),
+ new CfNumberConversion(NumericType.INT, NumericType.LONG),
+ new CfConstNumber(255, ValueType.LONG),
+ new CfLogicalBinop(CfLogicalBinop.Opcode.And, NumericType.LONG),
+ new CfReturn(ValueType.LONG),
+ label1),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode CharacterMethods_compare(
+ InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 2,
+ 2,
+ ImmutableList.of(
+ label0,
+ new CfLoad(ValueType.INT, 0),
+ new CfLoad(ValueType.INT, 1),
+ new CfArithmeticBinop(CfArithmeticBinop.Opcode.Sub, NumericType.INT),
+ new CfReturn(ValueType.INT),
+ label1),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode CharacterMethods_hashCode(
+ InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 1,
+ 1,
+ ImmutableList.of(label0, new CfLoad(ValueType.INT, 0), new CfReturn(ValueType.INT), label1),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode CharacterMethods_toStringCodepoint(
+ InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 3,
+ 1,
+ ImmutableList.of(
+ label0,
+ new CfNew(options.itemFactory.createType("Ljava/lang/String;")),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfLoad(ValueType.INT, 0),
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/lang/Character;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("[C"), options.itemFactory.createType("I")),
+ options.itemFactory.createString("toChars")),
+ false),
+ new CfInvoke(
+ 183,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/lang/String;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("V"), options.itemFactory.createType("[C")),
+ options.itemFactory.createString("<init>")),
+ false),
+ new CfReturn(ValueType.OBJECT),
+ label1),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode CollectionsMethods_emptyEnumeration(
+ InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 1,
+ 0,
+ ImmutableList.of(
+ label0,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Collections;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/util/List;")),
+ options.itemFactory.createString("emptyList")),
+ false),
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Collections;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/util/Enumeration;"),
+ options.itemFactory.createType("Ljava/util/Collection;")),
+ options.itemFactory.createString("enumeration")),
+ false),
+ new CfReturn(ValueType.OBJECT)),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode CollectionsMethods_emptyIterator(
+ InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 1,
+ 0,
+ ImmutableList.of(
+ label0,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Collections;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/util/List;")),
+ options.itemFactory.createString("emptyList")),
+ false),
+ new CfInvoke(
+ 185,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/List;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/util/Iterator;")),
+ options.itemFactory.createString("iterator")),
+ true),
+ new CfReturn(ValueType.OBJECT)),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode CollectionsMethods_emptyListIterator(
+ InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 1,
+ 0,
+ ImmutableList.of(
+ label0,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Collections;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/util/List;")),
+ options.itemFactory.createString("emptyList")),
+ false),
+ new CfInvoke(
+ 185,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/List;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/util/ListIterator;")),
+ options.itemFactory.createString("listIterator")),
+ true),
+ new CfReturn(ValueType.OBJECT)),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode DoubleMethods_hashCode(
+ InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ CfLabel label2 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 5,
+ 4,
+ ImmutableList.of(
+ label0,
+ new CfLoad(ValueType.DOUBLE, 0),
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/lang/Double;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("J"), options.itemFactory.createType("D")),
+ options.itemFactory.createString("doubleToLongBits")),
+ false),
+ new CfStore(ValueType.LONG, 2),
+ label1,
+ new CfLoad(ValueType.LONG, 2),
+ new CfLoad(ValueType.LONG, 2),
+ new CfConstNumber(32, ValueType.INT),
+ new CfLogicalBinop(CfLogicalBinop.Opcode.Ushr, NumericType.LONG),
+ new CfLogicalBinop(CfLogicalBinop.Opcode.Xor, NumericType.LONG),
+ new CfNumberConversion(NumericType.LONG, NumericType.INT),
+ new CfReturn(ValueType.INT),
+ label2),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode DoubleMethods_isFinite(
+ InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ CfLabel label2 = new CfLabel();
+ CfLabel label3 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 2,
+ 2,
+ ImmutableList.of(
+ label0,
+ new CfLoad(ValueType.DOUBLE, 0),
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/lang/Double;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Z"), options.itemFactory.createType("D")),
+ options.itemFactory.createString("isInfinite")),
+ false),
+ new CfIf(If.Type.NE, ValueType.INT, label1),
+ new CfLoad(ValueType.DOUBLE, 0),
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/lang/Double;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Z"), options.itemFactory.createType("D")),
+ options.itemFactory.createString("isNaN")),
+ false),
+ new CfIf(If.Type.NE, ValueType.INT, label1),
+ new CfConstNumber(1, ValueType.INT),
+ new CfGoto(label2),
+ label1,
+ new CfConstNumber(0, ValueType.INT),
+ label2,
+ new CfReturn(ValueType.INT),
+ label3),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode FloatMethods_hashCode(
+ InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 1,
+ 1,
+ ImmutableList.of(
+ label0,
+ new CfLoad(ValueType.FLOAT, 0),
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/lang/Float;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("I"), options.itemFactory.createType("F")),
+ options.itemFactory.createString("floatToIntBits")),
+ false),
+ new CfReturn(ValueType.INT),
+ label1),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode FloatMethods_isFinite(
+ InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ CfLabel label2 = new CfLabel();
+ CfLabel label3 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 1,
+ 1,
+ ImmutableList.of(
+ label0,
+ new CfLoad(ValueType.FLOAT, 0),
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/lang/Float;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Z"), options.itemFactory.createType("F")),
+ options.itemFactory.createString("isInfinite")),
+ false),
+ new CfIf(If.Type.NE, ValueType.INT, label1),
+ new CfLoad(ValueType.FLOAT, 0),
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/lang/Float;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Z"), options.itemFactory.createType("F")),
+ options.itemFactory.createString("isNaN")),
+ false),
+ new CfIf(If.Type.NE, ValueType.INT, label1),
+ new CfConstNumber(1, ValueType.INT),
+ new CfGoto(label2),
+ label1,
+ new CfConstNumber(0, ValueType.INT),
+ label2,
+ new CfReturn(ValueType.INT),
+ label3),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode IntegerMethods_compare(
+ InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ CfLabel label2 = new CfLabel();
+ CfLabel label3 = new CfLabel();
+ CfLabel label4 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 2,
+ 2,
+ ImmutableList.of(
+ label0,
+ new CfLoad(ValueType.INT, 0),
+ new CfLoad(ValueType.INT, 1),
+ new CfIfCmp(If.Type.NE, ValueType.INT, label1),
+ new CfConstNumber(0, ValueType.INT),
+ new CfGoto(label3),
+ label1,
+ new CfLoad(ValueType.INT, 0),
+ new CfLoad(ValueType.INT, 1),
+ new CfIfCmp(If.Type.GE, ValueType.INT, label2),
+ new CfConstNumber(-1, ValueType.INT),
+ new CfGoto(label3),
+ label2,
+ new CfConstNumber(1, ValueType.INT),
+ label3,
+ new CfReturn(ValueType.INT),
+ label4),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode IntegerMethods_compareUnsigned(
+ InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ CfLabel label2 = new CfLabel();
+ CfLabel label3 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 2,
+ 4,
+ ImmutableList.of(
+ label0,
+ new CfLoad(ValueType.INT, 0),
+ new CfConstNumber(-2147483648, ValueType.INT),
+ new CfLogicalBinop(CfLogicalBinop.Opcode.Xor, NumericType.INT),
+ new CfStore(ValueType.INT, 2),
+ label1,
+ new CfLoad(ValueType.INT, 1),
+ new CfConstNumber(-2147483648, ValueType.INT),
+ new CfLogicalBinop(CfLogicalBinop.Opcode.Xor, NumericType.INT),
+ new CfStore(ValueType.INT, 3),
+ label2,
+ new CfLoad(ValueType.INT, 2),
+ new CfLoad(ValueType.INT, 3),
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/lang/Integer;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("I"),
+ options.itemFactory.createType("I"),
+ options.itemFactory.createType("I")),
+ options.itemFactory.createString("compare")),
+ false),
+ new CfReturn(ValueType.INT),
+ label3),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode IntegerMethods_divideUnsigned(
+ InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ CfLabel label2 = new CfLabel();
+ CfLabel label3 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 4,
+ 6,
+ ImmutableList.of(
+ label0,
+ new CfLoad(ValueType.INT, 0),
+ new CfNumberConversion(NumericType.INT, NumericType.LONG),
+ new CfConstNumber(4294967295l, ValueType.LONG),
+ new CfLogicalBinop(CfLogicalBinop.Opcode.And, NumericType.LONG),
+ new CfStore(ValueType.LONG, 2),
+ label1,
+ new CfLoad(ValueType.INT, 1),
+ new CfNumberConversion(NumericType.INT, NumericType.LONG),
+ new CfConstNumber(4294967295l, ValueType.LONG),
+ new CfLogicalBinop(CfLogicalBinop.Opcode.And, NumericType.LONG),
+ new CfStore(ValueType.LONG, 4),
+ label2,
+ new CfLoad(ValueType.LONG, 2),
+ new CfLoad(ValueType.LONG, 4),
+ new CfArithmeticBinop(CfArithmeticBinop.Opcode.Div, NumericType.LONG),
+ new CfNumberConversion(NumericType.LONG, NumericType.INT),
+ new CfReturn(ValueType.INT),
+ label3),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode IntegerMethods_hashCode(
+ InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 1,
+ 1,
+ ImmutableList.of(label0, new CfLoad(ValueType.INT, 0), new CfReturn(ValueType.INT), label1),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode IntegerMethods_parseUnsignedInt(
+ InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 2,
+ 1,
+ ImmutableList.of(
+ label0,
+ new CfLoad(ValueType.OBJECT, 0),
+ new CfConstNumber(10, ValueType.INT),
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/lang/Integer;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("I"),
+ options.itemFactory.createType("Ljava/lang/String;"),
+ options.itemFactory.createType("I")),
+ options.itemFactory.createString("parseUnsignedInt")),
+ false),
+ new CfReturn(ValueType.INT),
+ label1),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode IntegerMethods_parseUnsignedIntWithRadix(
+ InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ CfLabel label2 = new CfLabel();
+ CfLabel label3 = new CfLabel();
+ CfLabel label4 = new CfLabel();
+ CfLabel label5 = new CfLabel();
+ CfLabel label6 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 4,
+ 4,
+ ImmutableList.of(
+ label0,
+ new CfLoad(ValueType.OBJECT, 0),
+ new CfInvoke(
+ 182,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/lang/String;"),
+ options.itemFactory.createProto(options.itemFactory.createType("I")),
+ options.itemFactory.createString("length")),
+ false),
+ new CfConstNumber(1, ValueType.INT),
+ new CfIfCmp(If.Type.LE, ValueType.INT, label2),
+ new CfLoad(ValueType.OBJECT, 0),
+ new CfConstNumber(0, ValueType.INT),
+ new CfInvoke(
+ 182,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/lang/String;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("C"), options.itemFactory.createType("I")),
+ options.itemFactory.createString("charAt")),
+ false),
+ new CfConstNumber(43, ValueType.INT),
+ new CfIfCmp(If.Type.NE, ValueType.INT, label2),
+ label1,
+ new CfLoad(ValueType.OBJECT, 0),
+ new CfConstNumber(1, ValueType.INT),
+ new CfInvoke(
+ 182,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/lang/String;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/String;"),
+ options.itemFactory.createType("I")),
+ options.itemFactory.createString("substring")),
+ false),
+ new CfStore(ValueType.OBJECT, 0),
+ label2,
+ new CfLoad(ValueType.OBJECT, 0),
+ new CfLoad(ValueType.INT, 1),
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/lang/Long;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("J"),
+ options.itemFactory.createType("Ljava/lang/String;"),
+ options.itemFactory.createType("I")),
+ options.itemFactory.createString("parseLong")),
+ false),
+ new CfStore(ValueType.LONG, 2),
+ label3,
+ new CfLoad(ValueType.LONG, 2),
+ new CfConstNumber(4294967295l, ValueType.LONG),
+ new CfLogicalBinop(CfLogicalBinop.Opcode.And, NumericType.LONG),
+ new CfLoad(ValueType.LONG, 2),
+ new CfCmp(Cmp.Bias.NONE, NumericType.LONG),
+ new CfIf(If.Type.EQ, ValueType.INT, label5),
+ label4,
+ new CfNew(options.itemFactory.createType("Ljava/lang/NumberFormatException;")),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfNew(options.itemFactory.createType("Ljava/lang/StringBuilder;")),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfInvoke(
+ 183,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/lang/StringBuilder;"),
+ options.itemFactory.createProto(options.itemFactory.createType("V")),
+ options.itemFactory.createString("<init>")),
+ false),
+ new CfConstString(options.itemFactory.createString("Input ")),
+ new CfInvoke(
+ 182,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/lang/StringBuilder;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/StringBuilder;"),
+ options.itemFactory.createType("Ljava/lang/String;")),
+ options.itemFactory.createString("append")),
+ false),
+ new CfLoad(ValueType.OBJECT, 0),
+ new CfInvoke(
+ 182,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/lang/StringBuilder;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/StringBuilder;"),
+ options.itemFactory.createType("Ljava/lang/String;")),
+ options.itemFactory.createString("append")),
+ false),
+ new CfConstString(options.itemFactory.createString(" in base ")),
+ new CfInvoke(
+ 182,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/lang/StringBuilder;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/StringBuilder;"),
+ options.itemFactory.createType("Ljava/lang/String;")),
+ options.itemFactory.createString("append")),
+ false),
+ new CfLoad(ValueType.INT, 1),
+ new CfInvoke(
+ 182,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/lang/StringBuilder;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/StringBuilder;"),
+ options.itemFactory.createType("I")),
+ options.itemFactory.createString("append")),
+ false),
+ new CfConstString(
+ options.itemFactory.createString(" is not in the range of an unsigned integer")),
+ new CfInvoke(
+ 182,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/lang/StringBuilder;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/StringBuilder;"),
+ options.itemFactory.createType("Ljava/lang/String;")),
+ options.itemFactory.createString("append")),
+ false),
+ new CfInvoke(
+ 182,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/lang/StringBuilder;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/String;")),
+ options.itemFactory.createString("toString")),
+ false),
+ new CfInvoke(
+ 183,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/lang/NumberFormatException;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("V"),
+ options.itemFactory.createType("Ljava/lang/String;")),
+ options.itemFactory.createString("<init>")),
+ false),
+ new CfThrow(),
+ label5,
+ new CfLoad(ValueType.LONG, 2),
+ new CfNumberConversion(NumericType.LONG, NumericType.INT),
+ new CfReturn(ValueType.INT),
+ label6),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode IntegerMethods_remainderUnsigned(
+ InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ CfLabel label2 = new CfLabel();
+ CfLabel label3 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 4,
+ 6,
+ ImmutableList.of(
+ label0,
+ new CfLoad(ValueType.INT, 0),
+ new CfNumberConversion(NumericType.INT, NumericType.LONG),
+ new CfConstNumber(4294967295l, ValueType.LONG),
+ new CfLogicalBinop(CfLogicalBinop.Opcode.And, NumericType.LONG),
+ new CfStore(ValueType.LONG, 2),
+ label1,
+ new CfLoad(ValueType.INT, 1),
+ new CfNumberConversion(NumericType.INT, NumericType.LONG),
+ new CfConstNumber(4294967295l, ValueType.LONG),
+ new CfLogicalBinop(CfLogicalBinop.Opcode.And, NumericType.LONG),
+ new CfStore(ValueType.LONG, 4),
+ label2,
+ new CfLoad(ValueType.LONG, 2),
+ new CfLoad(ValueType.LONG, 4),
+ new CfArithmeticBinop(CfArithmeticBinop.Opcode.Rem, NumericType.LONG),
+ new CfNumberConversion(NumericType.LONG, NumericType.INT),
+ new CfReturn(ValueType.INT),
+ label3),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode IntegerMethods_toUnsignedLong(
+ InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 4,
+ 1,
+ ImmutableList.of(
+ label0,
+ new CfLoad(ValueType.INT, 0),
+ new CfNumberConversion(NumericType.INT, NumericType.LONG),
+ new CfConstNumber(4294967295l, ValueType.LONG),
+ new CfLogicalBinop(CfLogicalBinop.Opcode.And, NumericType.LONG),
+ new CfReturn(ValueType.LONG),
+ label1),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode IntegerMethods_toUnsignedString(
+ InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 2,
+ 1,
+ ImmutableList.of(
+ label0,
+ new CfLoad(ValueType.INT, 0),
+ new CfConstNumber(10, ValueType.INT),
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/lang/Integer;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/String;"),
+ options.itemFactory.createType("I"),
+ options.itemFactory.createType("I")),
+ options.itemFactory.createString("toUnsignedString")),
+ false),
+ new CfReturn(ValueType.OBJECT),
+ label1),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode IntegerMethods_toUnsignedStringWithRadix(
+ InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ CfLabel label2 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 4,
+ 4,
+ ImmutableList.of(
+ label0,
+ new CfLoad(ValueType.INT, 0),
+ new CfNumberConversion(NumericType.INT, NumericType.LONG),
+ new CfConstNumber(4294967295l, ValueType.LONG),
+ new CfLogicalBinop(CfLogicalBinop.Opcode.And, NumericType.LONG),
+ new CfStore(ValueType.LONG, 2),
+ label1,
+ new CfLoad(ValueType.LONG, 2),
+ new CfLoad(ValueType.INT, 1),
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/lang/Long;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/String;"),
+ options.itemFactory.createType("J"),
+ options.itemFactory.createType("I")),
+ options.itemFactory.createString("toString")),
+ false),
+ new CfReturn(ValueType.OBJECT),
+ label2),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode ListMethods_of1(InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 1,
+ 1,
+ ImmutableList.of(
+ label0,
+ new CfLoad(ValueType.OBJECT, 0),
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Objects;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/Object;"),
+ options.itemFactory.createType("Ljava/lang/Object;")),
+ options.itemFactory.createString("requireNonNull")),
+ false),
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Collections;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/util/List;"),
+ options.itemFactory.createType("Ljava/lang/Object;")),
+ options.itemFactory.createString("singletonList")),
+ false),
+ new CfReturn(ValueType.OBJECT),
+ label1),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode ListMethods_of10(InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ CfLabel label2 = new CfLabel();
+ CfLabel label3 = new CfLabel();
+ CfLabel label4 = new CfLabel();
+ CfLabel label5 = new CfLabel();
+ CfLabel label6 = new CfLabel();
+ CfLabel label7 = new CfLabel();
+ CfLabel label8 = new CfLabel();
+ CfLabel label9 = new CfLabel();
+ CfLabel label10 = new CfLabel();
+ CfLabel label11 = new CfLabel();
+ CfLabel label12 = new CfLabel();
+ CfLabel label13 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 4,
+ 10,
+ ImmutableList.of(
+ label0,
+ new CfConstNumber(10, ValueType.INT),
+ new CfNewArray(options.itemFactory.createType("[Ljava/lang/Object;")),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfConstNumber(0, ValueType.INT),
+ new CfLoad(ValueType.OBJECT, 0),
+ label1,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Objects;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/Object;"),
+ options.itemFactory.createType("Ljava/lang/Object;")),
+ options.itemFactory.createString("requireNonNull")),
+ false),
+ new CfArrayStore(MemberType.OBJECT),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfConstNumber(1, ValueType.INT),
+ new CfLoad(ValueType.OBJECT, 1),
+ label2,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Objects;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/Object;"),
+ options.itemFactory.createType("Ljava/lang/Object;")),
+ options.itemFactory.createString("requireNonNull")),
+ false),
+ new CfArrayStore(MemberType.OBJECT),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfConstNumber(2, ValueType.INT),
+ new CfLoad(ValueType.OBJECT, 2),
+ label3,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Objects;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/Object;"),
+ options.itemFactory.createType("Ljava/lang/Object;")),
+ options.itemFactory.createString("requireNonNull")),
+ false),
+ new CfArrayStore(MemberType.OBJECT),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfConstNumber(3, ValueType.INT),
+ new CfLoad(ValueType.OBJECT, 3),
+ label4,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Objects;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/Object;"),
+ options.itemFactory.createType("Ljava/lang/Object;")),
+ options.itemFactory.createString("requireNonNull")),
+ false),
+ new CfArrayStore(MemberType.OBJECT),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfConstNumber(4, ValueType.INT),
+ new CfLoad(ValueType.OBJECT, 4),
+ label5,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Objects;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/Object;"),
+ options.itemFactory.createType("Ljava/lang/Object;")),
+ options.itemFactory.createString("requireNonNull")),
+ false),
+ new CfArrayStore(MemberType.OBJECT),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfConstNumber(5, ValueType.INT),
+ new CfLoad(ValueType.OBJECT, 5),
+ label6,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Objects;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/Object;"),
+ options.itemFactory.createType("Ljava/lang/Object;")),
+ options.itemFactory.createString("requireNonNull")),
+ false),
+ new CfArrayStore(MemberType.OBJECT),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfConstNumber(6, ValueType.INT),
+ new CfLoad(ValueType.OBJECT, 6),
+ label7,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Objects;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/Object;"),
+ options.itemFactory.createType("Ljava/lang/Object;")),
+ options.itemFactory.createString("requireNonNull")),
+ false),
+ new CfArrayStore(MemberType.OBJECT),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfConstNumber(7, ValueType.INT),
+ new CfLoad(ValueType.OBJECT, 7),
+ label8,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Objects;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/Object;"),
+ options.itemFactory.createType("Ljava/lang/Object;")),
+ options.itemFactory.createString("requireNonNull")),
+ false),
+ new CfArrayStore(MemberType.OBJECT),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfConstNumber(8, ValueType.INT),
+ new CfLoad(ValueType.OBJECT, 8),
+ label9,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Objects;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/Object;"),
+ options.itemFactory.createType("Ljava/lang/Object;")),
+ options.itemFactory.createString("requireNonNull")),
+ false),
+ new CfArrayStore(MemberType.OBJECT),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfConstNumber(9, ValueType.INT),
+ new CfLoad(ValueType.OBJECT, 9),
+ label10,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Objects;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/Object;"),
+ options.itemFactory.createType("Ljava/lang/Object;")),
+ options.itemFactory.createString("requireNonNull")),
+ false),
+ new CfArrayStore(MemberType.OBJECT),
+ label11,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Arrays;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/util/List;"),
+ options.itemFactory.createType("[Ljava/lang/Object;")),
+ options.itemFactory.createString("asList")),
+ false),
+ label12,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Collections;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/util/List;"),
+ options.itemFactory.createType("Ljava/util/List;")),
+ options.itemFactory.createString("unmodifiableList")),
+ false),
+ new CfReturn(ValueType.OBJECT),
+ label13),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode ListMethods_of2(InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ CfLabel label2 = new CfLabel();
+ CfLabel label3 = new CfLabel();
+ CfLabel label4 = new CfLabel();
+ CfLabel label5 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 4,
+ 2,
+ ImmutableList.of(
+ label0,
+ new CfConstNumber(2, ValueType.INT),
+ new CfNewArray(options.itemFactory.createType("[Ljava/lang/Object;")),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfConstNumber(0, ValueType.INT),
+ new CfLoad(ValueType.OBJECT, 0),
+ label1,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Objects;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/Object;"),
+ options.itemFactory.createType("Ljava/lang/Object;")),
+ options.itemFactory.createString("requireNonNull")),
+ false),
+ new CfArrayStore(MemberType.OBJECT),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfConstNumber(1, ValueType.INT),
+ new CfLoad(ValueType.OBJECT, 1),
+ label2,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Objects;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/Object;"),
+ options.itemFactory.createType("Ljava/lang/Object;")),
+ options.itemFactory.createString("requireNonNull")),
+ false),
+ new CfArrayStore(MemberType.OBJECT),
+ label3,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Arrays;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/util/List;"),
+ options.itemFactory.createType("[Ljava/lang/Object;")),
+ options.itemFactory.createString("asList")),
+ false),
+ label4,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Collections;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/util/List;"),
+ options.itemFactory.createType("Ljava/util/List;")),
+ options.itemFactory.createString("unmodifiableList")),
+ false),
+ new CfReturn(ValueType.OBJECT),
+ label5),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode ListMethods_of3(InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ CfLabel label2 = new CfLabel();
+ CfLabel label3 = new CfLabel();
+ CfLabel label4 = new CfLabel();
+ CfLabel label5 = new CfLabel();
+ CfLabel label6 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 4,
+ 3,
+ ImmutableList.of(
+ label0,
+ new CfConstNumber(3, ValueType.INT),
+ new CfNewArray(options.itemFactory.createType("[Ljava/lang/Object;")),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfConstNumber(0, ValueType.INT),
+ new CfLoad(ValueType.OBJECT, 0),
+ label1,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Objects;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/Object;"),
+ options.itemFactory.createType("Ljava/lang/Object;")),
+ options.itemFactory.createString("requireNonNull")),
+ false),
+ new CfArrayStore(MemberType.OBJECT),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfConstNumber(1, ValueType.INT),
+ new CfLoad(ValueType.OBJECT, 1),
+ label2,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Objects;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/Object;"),
+ options.itemFactory.createType("Ljava/lang/Object;")),
+ options.itemFactory.createString("requireNonNull")),
+ false),
+ new CfArrayStore(MemberType.OBJECT),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfConstNumber(2, ValueType.INT),
+ new CfLoad(ValueType.OBJECT, 2),
+ label3,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Objects;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/Object;"),
+ options.itemFactory.createType("Ljava/lang/Object;")),
+ options.itemFactory.createString("requireNonNull")),
+ false),
+ new CfArrayStore(MemberType.OBJECT),
+ label4,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Arrays;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/util/List;"),
+ options.itemFactory.createType("[Ljava/lang/Object;")),
+ options.itemFactory.createString("asList")),
+ false),
+ label5,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Collections;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/util/List;"),
+ options.itemFactory.createType("Ljava/util/List;")),
+ options.itemFactory.createString("unmodifiableList")),
+ false),
+ new CfReturn(ValueType.OBJECT),
+ label6),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode ListMethods_of4(InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ CfLabel label2 = new CfLabel();
+ CfLabel label3 = new CfLabel();
+ CfLabel label4 = new CfLabel();
+ CfLabel label5 = new CfLabel();
+ CfLabel label6 = new CfLabel();
+ CfLabel label7 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 4,
+ 4,
+ ImmutableList.of(
+ label0,
+ new CfConstNumber(4, ValueType.INT),
+ new CfNewArray(options.itemFactory.createType("[Ljava/lang/Object;")),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfConstNumber(0, ValueType.INT),
+ new CfLoad(ValueType.OBJECT, 0),
+ label1,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Objects;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/Object;"),
+ options.itemFactory.createType("Ljava/lang/Object;")),
+ options.itemFactory.createString("requireNonNull")),
+ false),
+ new CfArrayStore(MemberType.OBJECT),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfConstNumber(1, ValueType.INT),
+ new CfLoad(ValueType.OBJECT, 1),
+ label2,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Objects;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/Object;"),
+ options.itemFactory.createType("Ljava/lang/Object;")),
+ options.itemFactory.createString("requireNonNull")),
+ false),
+ new CfArrayStore(MemberType.OBJECT),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfConstNumber(2, ValueType.INT),
+ new CfLoad(ValueType.OBJECT, 2),
+ label3,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Objects;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/Object;"),
+ options.itemFactory.createType("Ljava/lang/Object;")),
+ options.itemFactory.createString("requireNonNull")),
+ false),
+ new CfArrayStore(MemberType.OBJECT),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfConstNumber(3, ValueType.INT),
+ new CfLoad(ValueType.OBJECT, 3),
+ label4,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Objects;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/Object;"),
+ options.itemFactory.createType("Ljava/lang/Object;")),
+ options.itemFactory.createString("requireNonNull")),
+ false),
+ new CfArrayStore(MemberType.OBJECT),
+ label5,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Arrays;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/util/List;"),
+ options.itemFactory.createType("[Ljava/lang/Object;")),
+ options.itemFactory.createString("asList")),
+ false),
+ label6,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Collections;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/util/List;"),
+ options.itemFactory.createType("Ljava/util/List;")),
+ options.itemFactory.createString("unmodifiableList")),
+ false),
+ new CfReturn(ValueType.OBJECT),
+ label7),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode ListMethods_of5(InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ CfLabel label2 = new CfLabel();
+ CfLabel label3 = new CfLabel();
+ CfLabel label4 = new CfLabel();
+ CfLabel label5 = new CfLabel();
+ CfLabel label6 = new CfLabel();
+ CfLabel label7 = new CfLabel();
+ CfLabel label8 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 4,
+ 5,
+ ImmutableList.of(
+ label0,
+ new CfConstNumber(5, ValueType.INT),
+ new CfNewArray(options.itemFactory.createType("[Ljava/lang/Object;")),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfConstNumber(0, ValueType.INT),
+ new CfLoad(ValueType.OBJECT, 0),
+ label1,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Objects;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/Object;"),
+ options.itemFactory.createType("Ljava/lang/Object;")),
+ options.itemFactory.createString("requireNonNull")),
+ false),
+ new CfArrayStore(MemberType.OBJECT),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfConstNumber(1, ValueType.INT),
+ new CfLoad(ValueType.OBJECT, 1),
+ label2,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Objects;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/Object;"),
+ options.itemFactory.createType("Ljava/lang/Object;")),
+ options.itemFactory.createString("requireNonNull")),
+ false),
+ new CfArrayStore(MemberType.OBJECT),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfConstNumber(2, ValueType.INT),
+ new CfLoad(ValueType.OBJECT, 2),
+ label3,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Objects;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/Object;"),
+ options.itemFactory.createType("Ljava/lang/Object;")),
+ options.itemFactory.createString("requireNonNull")),
+ false),
+ new CfArrayStore(MemberType.OBJECT),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfConstNumber(3, ValueType.INT),
+ new CfLoad(ValueType.OBJECT, 3),
+ label4,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Objects;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/Object;"),
+ options.itemFactory.createType("Ljava/lang/Object;")),
+ options.itemFactory.createString("requireNonNull")),
+ false),
+ new CfArrayStore(MemberType.OBJECT),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfConstNumber(4, ValueType.INT),
+ new CfLoad(ValueType.OBJECT, 4),
+ label5,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Objects;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/Object;"),
+ options.itemFactory.createType("Ljava/lang/Object;")),
+ options.itemFactory.createString("requireNonNull")),
+ false),
+ new CfArrayStore(MemberType.OBJECT),
+ label6,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Arrays;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/util/List;"),
+ options.itemFactory.createType("[Ljava/lang/Object;")),
+ options.itemFactory.createString("asList")),
+ false),
+ label7,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Collections;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/util/List;"),
+ options.itemFactory.createType("Ljava/util/List;")),
+ options.itemFactory.createString("unmodifiableList")),
+ false),
+ new CfReturn(ValueType.OBJECT),
+ label8),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode ListMethods_of6(InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ CfLabel label2 = new CfLabel();
+ CfLabel label3 = new CfLabel();
+ CfLabel label4 = new CfLabel();
+ CfLabel label5 = new CfLabel();
+ CfLabel label6 = new CfLabel();
+ CfLabel label7 = new CfLabel();
+ CfLabel label8 = new CfLabel();
+ CfLabel label9 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 4,
+ 6,
+ ImmutableList.of(
+ label0,
+ new CfConstNumber(6, ValueType.INT),
+ new CfNewArray(options.itemFactory.createType("[Ljava/lang/Object;")),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfConstNumber(0, ValueType.INT),
+ new CfLoad(ValueType.OBJECT, 0),
+ label1,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Objects;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/Object;"),
+ options.itemFactory.createType("Ljava/lang/Object;")),
+ options.itemFactory.createString("requireNonNull")),
+ false),
+ new CfArrayStore(MemberType.OBJECT),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfConstNumber(1, ValueType.INT),
+ new CfLoad(ValueType.OBJECT, 1),
+ label2,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Objects;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/Object;"),
+ options.itemFactory.createType("Ljava/lang/Object;")),
+ options.itemFactory.createString("requireNonNull")),
+ false),
+ new CfArrayStore(MemberType.OBJECT),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfConstNumber(2, ValueType.INT),
+ new CfLoad(ValueType.OBJECT, 2),
+ label3,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Objects;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/Object;"),
+ options.itemFactory.createType("Ljava/lang/Object;")),
+ options.itemFactory.createString("requireNonNull")),
+ false),
+ new CfArrayStore(MemberType.OBJECT),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfConstNumber(3, ValueType.INT),
+ new CfLoad(ValueType.OBJECT, 3),
+ label4,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Objects;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/Object;"),
+ options.itemFactory.createType("Ljava/lang/Object;")),
+ options.itemFactory.createString("requireNonNull")),
+ false),
+ new CfArrayStore(MemberType.OBJECT),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfConstNumber(4, ValueType.INT),
+ new CfLoad(ValueType.OBJECT, 4),
+ label5,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Objects;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/Object;"),
+ options.itemFactory.createType("Ljava/lang/Object;")),
+ options.itemFactory.createString("requireNonNull")),
+ false),
+ new CfArrayStore(MemberType.OBJECT),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfConstNumber(5, ValueType.INT),
+ new CfLoad(ValueType.OBJECT, 5),
+ label6,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Objects;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/Object;"),
+ options.itemFactory.createType("Ljava/lang/Object;")),
+ options.itemFactory.createString("requireNonNull")),
+ false),
+ new CfArrayStore(MemberType.OBJECT),
+ label7,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Arrays;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/util/List;"),
+ options.itemFactory.createType("[Ljava/lang/Object;")),
+ options.itemFactory.createString("asList")),
+ false),
+ label8,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Collections;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/util/List;"),
+ options.itemFactory.createType("Ljava/util/List;")),
+ options.itemFactory.createString("unmodifiableList")),
+ false),
+ new CfReturn(ValueType.OBJECT),
+ label9),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode ListMethods_of7(InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ CfLabel label2 = new CfLabel();
+ CfLabel label3 = new CfLabel();
+ CfLabel label4 = new CfLabel();
+ CfLabel label5 = new CfLabel();
+ CfLabel label6 = new CfLabel();
+ CfLabel label7 = new CfLabel();
+ CfLabel label8 = new CfLabel();
+ CfLabel label9 = new CfLabel();
+ CfLabel label10 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 4,
+ 7,
+ ImmutableList.of(
+ label0,
+ new CfConstNumber(7, ValueType.INT),
+ new CfNewArray(options.itemFactory.createType("[Ljava/lang/Object;")),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfConstNumber(0, ValueType.INT),
+ new CfLoad(ValueType.OBJECT, 0),
+ label1,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Objects;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/Object;"),
+ options.itemFactory.createType("Ljava/lang/Object;")),
+ options.itemFactory.createString("requireNonNull")),
+ false),
+ new CfArrayStore(MemberType.OBJECT),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfConstNumber(1, ValueType.INT),
+ new CfLoad(ValueType.OBJECT, 1),
+ label2,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Objects;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/Object;"),
+ options.itemFactory.createType("Ljava/lang/Object;")),
+ options.itemFactory.createString("requireNonNull")),
+ false),
+ new CfArrayStore(MemberType.OBJECT),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfConstNumber(2, ValueType.INT),
+ new CfLoad(ValueType.OBJECT, 2),
+ label3,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Objects;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/Object;"),
+ options.itemFactory.createType("Ljava/lang/Object;")),
+ options.itemFactory.createString("requireNonNull")),
+ false),
+ new CfArrayStore(MemberType.OBJECT),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfConstNumber(3, ValueType.INT),
+ new CfLoad(ValueType.OBJECT, 3),
+ label4,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Objects;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/Object;"),
+ options.itemFactory.createType("Ljava/lang/Object;")),
+ options.itemFactory.createString("requireNonNull")),
+ false),
+ new CfArrayStore(MemberType.OBJECT),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfConstNumber(4, ValueType.INT),
+ new CfLoad(ValueType.OBJECT, 4),
+ label5,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Objects;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/Object;"),
+ options.itemFactory.createType("Ljava/lang/Object;")),
+ options.itemFactory.createString("requireNonNull")),
+ false),
+ new CfArrayStore(MemberType.OBJECT),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfConstNumber(5, ValueType.INT),
+ new CfLoad(ValueType.OBJECT, 5),
+ label6,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Objects;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/Object;"),
+ options.itemFactory.createType("Ljava/lang/Object;")),
+ options.itemFactory.createString("requireNonNull")),
+ false),
+ new CfArrayStore(MemberType.OBJECT),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfConstNumber(6, ValueType.INT),
+ new CfLoad(ValueType.OBJECT, 6),
+ label7,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Objects;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/Object;"),
+ options.itemFactory.createType("Ljava/lang/Object;")),
+ options.itemFactory.createString("requireNonNull")),
+ false),
+ new CfArrayStore(MemberType.OBJECT),
+ label8,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Arrays;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/util/List;"),
+ options.itemFactory.createType("[Ljava/lang/Object;")),
+ options.itemFactory.createString("asList")),
+ false),
+ label9,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Collections;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/util/List;"),
+ options.itemFactory.createType("Ljava/util/List;")),
+ options.itemFactory.createString("unmodifiableList")),
+ false),
+ new CfReturn(ValueType.OBJECT),
+ label10),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode ListMethods_of8(InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ CfLabel label2 = new CfLabel();
+ CfLabel label3 = new CfLabel();
+ CfLabel label4 = new CfLabel();
+ CfLabel label5 = new CfLabel();
+ CfLabel label6 = new CfLabel();
+ CfLabel label7 = new CfLabel();
+ CfLabel label8 = new CfLabel();
+ CfLabel label9 = new CfLabel();
+ CfLabel label10 = new CfLabel();
+ CfLabel label11 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 4,
+ 8,
+ ImmutableList.of(
+ label0,
+ new CfConstNumber(8, ValueType.INT),
+ new CfNewArray(options.itemFactory.createType("[Ljava/lang/Object;")),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfConstNumber(0, ValueType.INT),
+ new CfLoad(ValueType.OBJECT, 0),
+ label1,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Objects;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/Object;"),
+ options.itemFactory.createType("Ljava/lang/Object;")),
+ options.itemFactory.createString("requireNonNull")),
+ false),
+ new CfArrayStore(MemberType.OBJECT),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfConstNumber(1, ValueType.INT),
+ new CfLoad(ValueType.OBJECT, 1),
+ label2,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Objects;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/Object;"),
+ options.itemFactory.createType("Ljava/lang/Object;")),
+ options.itemFactory.createString("requireNonNull")),
+ false),
+ new CfArrayStore(MemberType.OBJECT),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfConstNumber(2, ValueType.INT),
+ new CfLoad(ValueType.OBJECT, 2),
+ label3,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Objects;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/Object;"),
+ options.itemFactory.createType("Ljava/lang/Object;")),
+ options.itemFactory.createString("requireNonNull")),
+ false),
+ new CfArrayStore(MemberType.OBJECT),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfConstNumber(3, ValueType.INT),
+ new CfLoad(ValueType.OBJECT, 3),
+ label4,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Objects;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/Object;"),
+ options.itemFactory.createType("Ljava/lang/Object;")),
+ options.itemFactory.createString("requireNonNull")),
+ false),
+ new CfArrayStore(MemberType.OBJECT),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfConstNumber(4, ValueType.INT),
+ new CfLoad(ValueType.OBJECT, 4),
+ label5,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Objects;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/Object;"),
+ options.itemFactory.createType("Ljava/lang/Object;")),
+ options.itemFactory.createString("requireNonNull")),
+ false),
+ new CfArrayStore(MemberType.OBJECT),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfConstNumber(5, ValueType.INT),
+ new CfLoad(ValueType.OBJECT, 5),
+ label6,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Objects;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/Object;"),
+ options.itemFactory.createType("Ljava/lang/Object;")),
+ options.itemFactory.createString("requireNonNull")),
+ false),
+ new CfArrayStore(MemberType.OBJECT),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfConstNumber(6, ValueType.INT),
+ new CfLoad(ValueType.OBJECT, 6),
+ label7,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Objects;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/Object;"),
+ options.itemFactory.createType("Ljava/lang/Object;")),
+ options.itemFactory.createString("requireNonNull")),
+ false),
+ new CfArrayStore(MemberType.OBJECT),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfConstNumber(7, ValueType.INT),
+ new CfLoad(ValueType.OBJECT, 7),
+ label8,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Objects;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/Object;"),
+ options.itemFactory.createType("Ljava/lang/Object;")),
+ options.itemFactory.createString("requireNonNull")),
+ false),
+ new CfArrayStore(MemberType.OBJECT),
+ label9,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Arrays;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/util/List;"),
+ options.itemFactory.createType("[Ljava/lang/Object;")),
+ options.itemFactory.createString("asList")),
+ false),
+ label10,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Collections;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/util/List;"),
+ options.itemFactory.createType("Ljava/util/List;")),
+ options.itemFactory.createString("unmodifiableList")),
+ false),
+ new CfReturn(ValueType.OBJECT),
+ label11),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode ListMethods_of9(InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ CfLabel label2 = new CfLabel();
+ CfLabel label3 = new CfLabel();
+ CfLabel label4 = new CfLabel();
+ CfLabel label5 = new CfLabel();
+ CfLabel label6 = new CfLabel();
+ CfLabel label7 = new CfLabel();
+ CfLabel label8 = new CfLabel();
+ CfLabel label9 = new CfLabel();
+ CfLabel label10 = new CfLabel();
+ CfLabel label11 = new CfLabel();
+ CfLabel label12 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 4,
+ 9,
+ ImmutableList.of(
+ label0,
+ new CfConstNumber(9, ValueType.INT),
+ new CfNewArray(options.itemFactory.createType("[Ljava/lang/Object;")),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfConstNumber(0, ValueType.INT),
+ new CfLoad(ValueType.OBJECT, 0),
+ label1,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Objects;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/Object;"),
+ options.itemFactory.createType("Ljava/lang/Object;")),
+ options.itemFactory.createString("requireNonNull")),
+ false),
+ new CfArrayStore(MemberType.OBJECT),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfConstNumber(1, ValueType.INT),
+ new CfLoad(ValueType.OBJECT, 1),
+ label2,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Objects;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/Object;"),
+ options.itemFactory.createType("Ljava/lang/Object;")),
+ options.itemFactory.createString("requireNonNull")),
+ false),
+ new CfArrayStore(MemberType.OBJECT),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfConstNumber(2, ValueType.INT),
+ new CfLoad(ValueType.OBJECT, 2),
+ label3,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Objects;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/Object;"),
+ options.itemFactory.createType("Ljava/lang/Object;")),
+ options.itemFactory.createString("requireNonNull")),
+ false),
+ new CfArrayStore(MemberType.OBJECT),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfConstNumber(3, ValueType.INT),
+ new CfLoad(ValueType.OBJECT, 3),
+ label4,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Objects;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/Object;"),
+ options.itemFactory.createType("Ljava/lang/Object;")),
+ options.itemFactory.createString("requireNonNull")),
+ false),
+ new CfArrayStore(MemberType.OBJECT),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfConstNumber(4, ValueType.INT),
+ new CfLoad(ValueType.OBJECT, 4),
+ label5,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Objects;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/Object;"),
+ options.itemFactory.createType("Ljava/lang/Object;")),
+ options.itemFactory.createString("requireNonNull")),
+ false),
+ new CfArrayStore(MemberType.OBJECT),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfConstNumber(5, ValueType.INT),
+ new CfLoad(ValueType.OBJECT, 5),
+ label6,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Objects;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/Object;"),
+ options.itemFactory.createType("Ljava/lang/Object;")),
+ options.itemFactory.createString("requireNonNull")),
+ false),
+ new CfArrayStore(MemberType.OBJECT),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfConstNumber(6, ValueType.INT),
+ new CfLoad(ValueType.OBJECT, 6),
+ label7,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Objects;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/Object;"),
+ options.itemFactory.createType("Ljava/lang/Object;")),
+ options.itemFactory.createString("requireNonNull")),
+ false),
+ new CfArrayStore(MemberType.OBJECT),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfConstNumber(7, ValueType.INT),
+ new CfLoad(ValueType.OBJECT, 7),
+ label8,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Objects;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/Object;"),
+ options.itemFactory.createType("Ljava/lang/Object;")),
+ options.itemFactory.createString("requireNonNull")),
+ false),
+ new CfArrayStore(MemberType.OBJECT),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfConstNumber(8, ValueType.INT),
+ new CfLoad(ValueType.OBJECT, 8),
+ label9,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Objects;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/Object;"),
+ options.itemFactory.createType("Ljava/lang/Object;")),
+ options.itemFactory.createString("requireNonNull")),
+ false),
+ new CfArrayStore(MemberType.OBJECT),
+ label10,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Arrays;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/util/List;"),
+ options.itemFactory.createType("[Ljava/lang/Object;")),
+ options.itemFactory.createString("asList")),
+ false),
+ label11,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Collections;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/util/List;"),
+ options.itemFactory.createType("Ljava/util/List;")),
+ options.itemFactory.createString("unmodifiableList")),
+ false),
+ new CfReturn(ValueType.OBJECT),
+ label12),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode ListMethods_ofArray(InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ CfLabel label2 = new CfLabel();
+ CfLabel label3 = new CfLabel();
+ CfLabel label4 = new CfLabel();
+ CfLabel label5 = new CfLabel();
+ CfLabel label6 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 3,
+ 6,
+ ImmutableList.of(
+ label0,
+ new CfNew(options.itemFactory.createType("Ljava/util/ArrayList;")),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfLoad(ValueType.OBJECT, 0),
+ new CfArrayLength(),
+ new CfInvoke(
+ 183,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/ArrayList;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("V"), options.itemFactory.createType("I")),
+ options.itemFactory.createString("<init>")),
+ false),
+ new CfStore(ValueType.OBJECT, 1),
+ label1,
+ new CfLoad(ValueType.OBJECT, 0),
+ new CfStore(ValueType.OBJECT, 2),
+ new CfLoad(ValueType.OBJECT, 2),
+ new CfArrayLength(),
+ new CfStore(ValueType.INT, 3),
+ new CfConstNumber(0, ValueType.INT),
+ new CfStore(ValueType.INT, 4),
+ label2,
+ new CfLoad(ValueType.INT, 4),
+ new CfLoad(ValueType.INT, 3),
+ new CfIfCmp(If.Type.GE, ValueType.INT, label5),
+ new CfLoad(ValueType.OBJECT, 2),
+ new CfLoad(ValueType.INT, 4),
+ new CfArrayLoad(MemberType.OBJECT),
+ new CfStore(ValueType.OBJECT, 5),
+ label3,
+ new CfLoad(ValueType.OBJECT, 1),
+ new CfLoad(ValueType.OBJECT, 5),
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Objects;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/Object;"),
+ options.itemFactory.createType("Ljava/lang/Object;")),
+ options.itemFactory.createString("requireNonNull")),
+ false),
+ new CfInvoke(
+ 182,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/ArrayList;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Z"),
+ options.itemFactory.createType("Ljava/lang/Object;")),
+ options.itemFactory.createString("add")),
+ false),
+ new CfStackInstruction(CfStackInstruction.Opcode.Pop),
+ label4,
+ new CfIinc(4, 1),
+ new CfGoto(label2),
+ label5,
+ new CfLoad(ValueType.OBJECT, 1),
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Collections;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/util/List;"),
+ options.itemFactory.createType("Ljava/util/List;")),
+ options.itemFactory.createString("unmodifiableList")),
+ false),
+ new CfReturn(ValueType.OBJECT),
+ label6),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode LongMethods_compareUnsigned(
+ InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ CfLabel label2 = new CfLabel();
+ CfLabel label3 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 4,
+ 8,
+ ImmutableList.of(
+ label0,
+ new CfLoad(ValueType.LONG, 0),
+ new CfConstNumber(-9223372036854775808l, ValueType.LONG),
+ new CfLogicalBinop(CfLogicalBinop.Opcode.Xor, NumericType.LONG),
+ new CfStore(ValueType.LONG, 4),
+ label1,
+ new CfLoad(ValueType.LONG, 2),
+ new CfConstNumber(-9223372036854775808l, ValueType.LONG),
+ new CfLogicalBinop(CfLogicalBinop.Opcode.Xor, NumericType.LONG),
+ new CfStore(ValueType.LONG, 6),
+ label2,
+ new CfLoad(ValueType.LONG, 4),
+ new CfLoad(ValueType.LONG, 6),
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/lang/Long;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("I"),
+ options.itemFactory.createType("J"),
+ options.itemFactory.createType("J")),
+ options.itemFactory.createString("compare")),
+ false),
+ new CfReturn(ValueType.INT),
+ label3),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode LongMethods_divideUnsigned(
+ InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ CfLabel label2 = new CfLabel();
+ CfLabel label3 = new CfLabel();
+ CfLabel label4 = new CfLabel();
+ CfLabel label5 = new CfLabel();
+ CfLabel label6 = new CfLabel();
+ CfLabel label7 = new CfLabel();
+ CfLabel label8 = new CfLabel();
+ CfLabel label9 = new CfLabel();
+ CfLabel label10 = new CfLabel();
+ CfLabel label11 = new CfLabel();
+ CfLabel label12 = new CfLabel();
+ CfLabel label13 = new CfLabel();
+ CfLabel label14 = new CfLabel();
+ CfLabel label15 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 6,
+ 12,
+ ImmutableList.of(
+ label0,
+ new CfLoad(ValueType.LONG, 2),
+ new CfConstNumber(0, ValueType.LONG),
+ new CfCmp(Cmp.Bias.NONE, NumericType.LONG),
+ new CfIf(If.Type.GE, ValueType.INT, label6),
+ label1,
+ new CfLoad(ValueType.LONG, 0),
+ new CfConstNumber(-9223372036854775808l, ValueType.LONG),
+ new CfLogicalBinop(CfLogicalBinop.Opcode.Xor, NumericType.LONG),
+ new CfStore(ValueType.LONG, 4),
+ label2,
+ new CfLoad(ValueType.LONG, 2),
+ new CfConstNumber(-9223372036854775808l, ValueType.LONG),
+ new CfLogicalBinop(CfLogicalBinop.Opcode.Xor, NumericType.LONG),
+ new CfStore(ValueType.LONG, 6),
+ label3,
+ new CfLoad(ValueType.LONG, 4),
+ new CfLoad(ValueType.LONG, 6),
+ new CfCmp(Cmp.Bias.NONE, NumericType.LONG),
+ new CfIf(If.Type.GE, ValueType.INT, label5),
+ label4,
+ new CfConstNumber(0, ValueType.LONG),
+ new CfReturn(ValueType.LONG),
+ label5,
+ new CfConstNumber(1, ValueType.LONG),
+ new CfReturn(ValueType.LONG),
+ label6,
+ new CfLoad(ValueType.LONG, 0),
+ new CfConstNumber(0, ValueType.LONG),
+ new CfCmp(Cmp.Bias.NONE, NumericType.LONG),
+ new CfIf(If.Type.LT, ValueType.INT, label8),
+ label7,
+ new CfLoad(ValueType.LONG, 0),
+ new CfLoad(ValueType.LONG, 2),
+ new CfArithmeticBinop(CfArithmeticBinop.Opcode.Div, NumericType.LONG),
+ new CfReturn(ValueType.LONG),
+ label8,
+ new CfLoad(ValueType.LONG, 0),
+ new CfConstNumber(1, ValueType.INT),
+ new CfLogicalBinop(CfLogicalBinop.Opcode.Ushr, NumericType.LONG),
+ new CfLoad(ValueType.LONG, 2),
+ new CfArithmeticBinop(CfArithmeticBinop.Opcode.Div, NumericType.LONG),
+ new CfConstNumber(1, ValueType.INT),
+ new CfLogicalBinop(CfLogicalBinop.Opcode.Shl, NumericType.LONG),
+ new CfStore(ValueType.LONG, 4),
+ label9,
+ new CfLoad(ValueType.LONG, 0),
+ new CfLoad(ValueType.LONG, 4),
+ new CfLoad(ValueType.LONG, 2),
+ new CfArithmeticBinop(CfArithmeticBinop.Opcode.Mul, NumericType.LONG),
+ new CfArithmeticBinop(CfArithmeticBinop.Opcode.Sub, NumericType.LONG),
+ new CfStore(ValueType.LONG, 6),
+ label10,
+ new CfLoad(ValueType.LONG, 6),
+ new CfConstNumber(-9223372036854775808l, ValueType.LONG),
+ new CfLogicalBinop(CfLogicalBinop.Opcode.Xor, NumericType.LONG),
+ new CfStore(ValueType.LONG, 8),
+ label11,
+ new CfLoad(ValueType.LONG, 2),
+ new CfConstNumber(-9223372036854775808l, ValueType.LONG),
+ new CfLogicalBinop(CfLogicalBinop.Opcode.Xor, NumericType.LONG),
+ new CfStore(ValueType.LONG, 10),
+ label12,
+ new CfLoad(ValueType.LONG, 4),
+ new CfLoad(ValueType.LONG, 8),
+ new CfLoad(ValueType.LONG, 10),
+ new CfCmp(Cmp.Bias.NONE, NumericType.LONG),
+ new CfIf(If.Type.LT, ValueType.INT, label13),
+ new CfConstNumber(1, ValueType.INT),
+ new CfGoto(label14),
+ label13,
+ new CfConstNumber(0, ValueType.INT),
+ label14,
+ new CfNumberConversion(NumericType.INT, NumericType.LONG),
+ new CfArithmeticBinop(CfArithmeticBinop.Opcode.Add, NumericType.LONG),
+ new CfReturn(ValueType.LONG),
+ label15),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode LongMethods_hashCode(
+ InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 5,
+ 2,
+ ImmutableList.of(
+ label0,
+ new CfLoad(ValueType.LONG, 0),
+ new CfLoad(ValueType.LONG, 0),
+ new CfConstNumber(32, ValueType.INT),
+ new CfLogicalBinop(CfLogicalBinop.Opcode.Ushr, NumericType.LONG),
+ new CfLogicalBinop(CfLogicalBinop.Opcode.Xor, NumericType.LONG),
+ new CfNumberConversion(NumericType.LONG, NumericType.INT),
+ new CfReturn(ValueType.INT),
+ label1),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode LongMethods_parseUnsignedLong(
+ InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 2,
+ 1,
+ ImmutableList.of(
+ label0,
+ new CfLoad(ValueType.OBJECT, 0),
+ new CfConstNumber(10, ValueType.INT),
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/lang/Long;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("J"),
+ options.itemFactory.createType("Ljava/lang/String;"),
+ options.itemFactory.createType("I")),
+ options.itemFactory.createString("parseUnsignedLong")),
+ false),
+ new CfReturn(ValueType.LONG),
+ label1),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode LongMethods_parseUnsignedLongWithRadix(
+ InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ CfLabel label2 = new CfLabel();
+ CfLabel label3 = new CfLabel();
+ CfLabel label4 = new CfLabel();
+ CfLabel label5 = new CfLabel();
+ CfLabel label6 = new CfLabel();
+ CfLabel label7 = new CfLabel();
+ CfLabel label8 = new CfLabel();
+ CfLabel label9 = new CfLabel();
+ CfLabel label10 = new CfLabel();
+ CfLabel label11 = new CfLabel();
+ CfLabel label12 = new CfLabel();
+ CfLabel label13 = new CfLabel();
+ CfLabel label14 = new CfLabel();
+ CfLabel label15 = new CfLabel();
+ CfLabel label16 = new CfLabel();
+ CfLabel label17 = new CfLabel();
+ CfLabel label18 = new CfLabel();
+ CfLabel label19 = new CfLabel();
+ CfLabel label20 = new CfLabel();
+ CfLabel label21 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 5,
+ 10,
+ ImmutableList.of(
+ label0,
+ new CfLoad(ValueType.OBJECT, 0),
+ new CfInvoke(
+ 182,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/lang/String;"),
+ options.itemFactory.createProto(options.itemFactory.createType("I")),
+ options.itemFactory.createString("length")),
+ false),
+ new CfStore(ValueType.INT, 2),
+ label1,
+ new CfLoad(ValueType.INT, 2),
+ new CfIf(If.Type.NE, ValueType.INT, label3),
+ label2,
+ new CfNew(options.itemFactory.createType("Ljava/lang/NumberFormatException;")),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfConstString(options.itemFactory.createString("empty string")),
+ new CfInvoke(
+ 183,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/lang/NumberFormatException;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("V"),
+ options.itemFactory.createType("Ljava/lang/String;")),
+ options.itemFactory.createString("<init>")),
+ false),
+ new CfThrow(),
+ label3,
+ new CfLoad(ValueType.INT, 1),
+ new CfConstNumber(2, ValueType.INT),
+ new CfIfCmp(If.Type.LT, ValueType.INT, label4),
+ new CfLoad(ValueType.INT, 1),
+ new CfConstNumber(36, ValueType.INT),
+ new CfIfCmp(If.Type.LE, ValueType.INT, label5),
+ label4,
+ new CfNew(options.itemFactory.createType("Ljava/lang/NumberFormatException;")),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfConstString(options.itemFactory.createString("illegal radix: ")),
+ new CfLoad(ValueType.INT, 1),
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/lang/String;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/String;"),
+ options.itemFactory.createType("I")),
+ options.itemFactory.createString("valueOf")),
+ false),
+ new CfInvoke(
+ 182,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/lang/String;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/String;"),
+ options.itemFactory.createType("Ljava/lang/String;")),
+ options.itemFactory.createString("concat")),
+ false),
+ new CfInvoke(
+ 183,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/lang/NumberFormatException;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("V"),
+ options.itemFactory.createType("Ljava/lang/String;")),
+ options.itemFactory.createString("<init>")),
+ false),
+ new CfThrow(),
+ label5,
+ new CfConstNumber(-1, ValueType.LONG),
+ new CfLoad(ValueType.INT, 1),
+ new CfNumberConversion(NumericType.INT, NumericType.LONG),
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/lang/Long;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("J"),
+ options.itemFactory.createType("J"),
+ options.itemFactory.createType("J")),
+ options.itemFactory.createString("divideUnsigned")),
+ false),
+ new CfStore(ValueType.LONG, 3),
+ label6,
+ new CfLoad(ValueType.OBJECT, 0),
+ new CfConstNumber(0, ValueType.INT),
+ new CfInvoke(
+ 182,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/lang/String;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("C"), options.itemFactory.createType("I")),
+ options.itemFactory.createString("charAt")),
+ false),
+ new CfConstNumber(43, ValueType.INT),
+ new CfIfCmp(If.Type.NE, ValueType.INT, label7),
+ new CfLoad(ValueType.INT, 2),
+ new CfConstNumber(1, ValueType.INT),
+ new CfIfCmp(If.Type.LE, ValueType.INT, label7),
+ new CfConstNumber(1, ValueType.INT),
+ new CfGoto(label8),
+ label7,
+ new CfConstNumber(0, ValueType.INT),
+ label8,
+ new CfStore(ValueType.INT, 5),
+ label9,
+ new CfConstNumber(0, ValueType.LONG),
+ new CfStore(ValueType.LONG, 6),
+ label10,
+ new CfLoad(ValueType.INT, 5),
+ new CfStore(ValueType.INT, 8),
+ label11,
+ new CfLoad(ValueType.INT, 8),
+ new CfLoad(ValueType.INT, 2),
+ new CfIfCmp(If.Type.GE, ValueType.INT, label20),
+ label12,
+ new CfLoad(ValueType.OBJECT, 0),
+ new CfLoad(ValueType.INT, 8),
+ new CfInvoke(
+ 182,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/lang/String;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("C"), options.itemFactory.createType("I")),
+ options.itemFactory.createString("charAt")),
+ false),
+ new CfLoad(ValueType.INT, 1),
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/lang/Character;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("I"),
+ options.itemFactory.createType("C"),
+ options.itemFactory.createType("I")),
+ options.itemFactory.createString("digit")),
+ false),
+ new CfStore(ValueType.INT, 9),
+ label13,
+ new CfLoad(ValueType.INT, 9),
+ new CfConstNumber(-1, ValueType.INT),
+ new CfIfCmp(If.Type.NE, ValueType.INT, label15),
+ label14,
+ new CfNew(options.itemFactory.createType("Ljava/lang/NumberFormatException;")),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfLoad(ValueType.OBJECT, 0),
+ new CfInvoke(
+ 183,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/lang/NumberFormatException;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("V"),
+ options.itemFactory.createType("Ljava/lang/String;")),
+ options.itemFactory.createString("<init>")),
+ false),
+ new CfThrow(),
+ label15,
+ new CfLoad(ValueType.LONG, 6),
+ new CfConstNumber(0, ValueType.LONG),
+ new CfCmp(Cmp.Bias.NONE, NumericType.LONG),
+ new CfIf(If.Type.LT, ValueType.INT, label17),
+ new CfLoad(ValueType.LONG, 6),
+ new CfLoad(ValueType.LONG, 3),
+ new CfCmp(Cmp.Bias.NONE, NumericType.LONG),
+ new CfIf(If.Type.GT, ValueType.INT, label17),
+ new CfLoad(ValueType.LONG, 6),
+ new CfLoad(ValueType.LONG, 3),
+ new CfCmp(Cmp.Bias.NONE, NumericType.LONG),
+ new CfIf(If.Type.NE, ValueType.INT, label18),
+ new CfLoad(ValueType.INT, 9),
+ new CfConstNumber(-1, ValueType.LONG),
+ new CfLoad(ValueType.INT, 1),
+ new CfNumberConversion(NumericType.INT, NumericType.LONG),
+ label16,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/lang/Long;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("J"),
+ options.itemFactory.createType("J"),
+ options.itemFactory.createType("J")),
+ options.itemFactory.createString("remainderUnsigned")),
+ false),
+ new CfNumberConversion(NumericType.LONG, NumericType.INT),
+ new CfIfCmp(If.Type.LE, ValueType.INT, label18),
+ label17,
+ new CfNew(options.itemFactory.createType("Ljava/lang/NumberFormatException;")),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfConstString(options.itemFactory.createString("Too large for unsigned long: ")),
+ new CfLoad(ValueType.OBJECT, 0),
+ new CfInvoke(
+ 182,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/lang/String;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/String;"),
+ options.itemFactory.createType("Ljava/lang/String;")),
+ options.itemFactory.createString("concat")),
+ false),
+ new CfInvoke(
+ 183,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/lang/NumberFormatException;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("V"),
+ options.itemFactory.createType("Ljava/lang/String;")),
+ options.itemFactory.createString("<init>")),
+ false),
+ new CfThrow(),
+ label18,
+ new CfLoad(ValueType.LONG, 6),
+ new CfLoad(ValueType.INT, 1),
+ new CfNumberConversion(NumericType.INT, NumericType.LONG),
+ new CfArithmeticBinop(CfArithmeticBinop.Opcode.Mul, NumericType.LONG),
+ new CfLoad(ValueType.INT, 9),
+ new CfNumberConversion(NumericType.INT, NumericType.LONG),
+ new CfArithmeticBinop(CfArithmeticBinop.Opcode.Add, NumericType.LONG),
+ new CfStore(ValueType.LONG, 6),
+ label19,
+ new CfIinc(8, 1),
+ new CfGoto(label11),
+ label20,
+ new CfLoad(ValueType.LONG, 6),
+ new CfReturn(ValueType.LONG),
+ label21),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode LongMethods_remainderUnsigned(
+ InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ CfLabel label2 = new CfLabel();
+ CfLabel label3 = new CfLabel();
+ CfLabel label4 = new CfLabel();
+ CfLabel label5 = new CfLabel();
+ CfLabel label6 = new CfLabel();
+ CfLabel label7 = new CfLabel();
+ CfLabel label8 = new CfLabel();
+ CfLabel label9 = new CfLabel();
+ CfLabel label10 = new CfLabel();
+ CfLabel label11 = new CfLabel();
+ CfLabel label12 = new CfLabel();
+ CfLabel label13 = new CfLabel();
+ CfLabel label14 = new CfLabel();
+ CfLabel label15 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 6,
+ 12,
+ ImmutableList.of(
+ label0,
+ new CfLoad(ValueType.LONG, 2),
+ new CfConstNumber(0, ValueType.LONG),
+ new CfCmp(Cmp.Bias.NONE, NumericType.LONG),
+ new CfIf(If.Type.GE, ValueType.INT, label6),
+ label1,
+ new CfLoad(ValueType.LONG, 0),
+ new CfConstNumber(-9223372036854775808l, ValueType.LONG),
+ new CfLogicalBinop(CfLogicalBinop.Opcode.Xor, NumericType.LONG),
+ new CfStore(ValueType.LONG, 4),
+ label2,
+ new CfLoad(ValueType.LONG, 2),
+ new CfConstNumber(-9223372036854775808l, ValueType.LONG),
+ new CfLogicalBinop(CfLogicalBinop.Opcode.Xor, NumericType.LONG),
+ new CfStore(ValueType.LONG, 6),
+ label3,
+ new CfLoad(ValueType.LONG, 4),
+ new CfLoad(ValueType.LONG, 6),
+ new CfCmp(Cmp.Bias.NONE, NumericType.LONG),
+ new CfIf(If.Type.GE, ValueType.INT, label5),
+ label4,
+ new CfLoad(ValueType.LONG, 0),
+ new CfReturn(ValueType.LONG),
+ label5,
+ new CfLoad(ValueType.LONG, 0),
+ new CfLoad(ValueType.LONG, 2),
+ new CfArithmeticBinop(CfArithmeticBinop.Opcode.Sub, NumericType.LONG),
+ new CfReturn(ValueType.LONG),
+ label6,
+ new CfLoad(ValueType.LONG, 0),
+ new CfConstNumber(0, ValueType.LONG),
+ new CfCmp(Cmp.Bias.NONE, NumericType.LONG),
+ new CfIf(If.Type.LT, ValueType.INT, label8),
+ label7,
+ new CfLoad(ValueType.LONG, 0),
+ new CfLoad(ValueType.LONG, 2),
+ new CfArithmeticBinop(CfArithmeticBinop.Opcode.Rem, NumericType.LONG),
+ new CfReturn(ValueType.LONG),
+ label8,
+ new CfLoad(ValueType.LONG, 0),
+ new CfConstNumber(1, ValueType.INT),
+ new CfLogicalBinop(CfLogicalBinop.Opcode.Ushr, NumericType.LONG),
+ new CfLoad(ValueType.LONG, 2),
+ new CfArithmeticBinop(CfArithmeticBinop.Opcode.Div, NumericType.LONG),
+ new CfConstNumber(1, ValueType.INT),
+ new CfLogicalBinop(CfLogicalBinop.Opcode.Shl, NumericType.LONG),
+ new CfStore(ValueType.LONG, 4),
+ label9,
+ new CfLoad(ValueType.LONG, 0),
+ new CfLoad(ValueType.LONG, 4),
+ new CfLoad(ValueType.LONG, 2),
+ new CfArithmeticBinop(CfArithmeticBinop.Opcode.Mul, NumericType.LONG),
+ new CfArithmeticBinop(CfArithmeticBinop.Opcode.Sub, NumericType.LONG),
+ new CfStore(ValueType.LONG, 6),
+ label10,
+ new CfLoad(ValueType.LONG, 6),
+ new CfConstNumber(-9223372036854775808l, ValueType.LONG),
+ new CfLogicalBinop(CfLogicalBinop.Opcode.Xor, NumericType.LONG),
+ new CfStore(ValueType.LONG, 8),
+ label11,
+ new CfLoad(ValueType.LONG, 2),
+ new CfConstNumber(-9223372036854775808l, ValueType.LONG),
+ new CfLogicalBinop(CfLogicalBinop.Opcode.Xor, NumericType.LONG),
+ new CfStore(ValueType.LONG, 10),
+ label12,
+ new CfLoad(ValueType.LONG, 6),
+ new CfLoad(ValueType.LONG, 8),
+ new CfLoad(ValueType.LONG, 10),
+ new CfCmp(Cmp.Bias.NONE, NumericType.LONG),
+ new CfIf(If.Type.LT, ValueType.INT, label13),
+ new CfLoad(ValueType.LONG, 2),
+ new CfGoto(label14),
+ label13,
+ new CfConstNumber(0, ValueType.LONG),
+ label14,
+ new CfArithmeticBinop(CfArithmeticBinop.Opcode.Sub, NumericType.LONG),
+ new CfReturn(ValueType.LONG),
+ label15),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode LongMethods_toUnsignedString(
+ InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 3,
+ 2,
+ ImmutableList.of(
+ label0,
+ new CfLoad(ValueType.LONG, 0),
+ new CfConstNumber(10, ValueType.INT),
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/lang/Long;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/String;"),
+ options.itemFactory.createType("J"),
+ options.itemFactory.createType("I")),
+ options.itemFactory.createString("toUnsignedString")),
+ false),
+ new CfReturn(ValueType.OBJECT),
+ label1),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode LongMethods_toUnsignedStringWithRadix(
+ InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ CfLabel label2 = new CfLabel();
+ CfLabel label3 = new CfLabel();
+ CfLabel label4 = new CfLabel();
+ CfLabel label5 = new CfLabel();
+ CfLabel label6 = new CfLabel();
+ CfLabel label7 = new CfLabel();
+ CfLabel label8 = new CfLabel();
+ CfLabel label9 = new CfLabel();
+ CfLabel label10 = new CfLabel();
+ CfLabel label11 = new CfLabel();
+ CfLabel label12 = new CfLabel();
+ CfLabel label13 = new CfLabel();
+ CfLabel label14 = new CfLabel();
+ CfLabel label15 = new CfLabel();
+ CfLabel label16 = new CfLabel();
+ CfLabel label17 = new CfLabel();
+ CfLabel label18 = new CfLabel();
+ CfLabel label19 = new CfLabel();
+ CfLabel label20 = new CfLabel();
+ CfLabel label21 = new CfLabel();
+ CfLabel label22 = new CfLabel();
+ CfLabel label23 = new CfLabel();
+ CfLabel label24 = new CfLabel();
+ CfLabel label25 = new CfLabel();
+ CfLabel label26 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 6,
+ 9,
+ ImmutableList.of(
+ label0,
+ new CfLoad(ValueType.LONG, 0),
+ new CfConstNumber(0, ValueType.LONG),
+ new CfCmp(Cmp.Bias.NONE, NumericType.LONG),
+ new CfIf(If.Type.NE, ValueType.INT, label2),
+ label1,
+ new CfConstString(options.itemFactory.createString("0")),
+ new CfReturn(ValueType.OBJECT),
+ label2,
+ new CfLoad(ValueType.LONG, 0),
+ new CfConstNumber(0, ValueType.LONG),
+ new CfCmp(Cmp.Bias.NONE, NumericType.LONG),
+ new CfIf(If.Type.LE, ValueType.INT, label4),
+ label3,
+ new CfLoad(ValueType.LONG, 0),
+ new CfLoad(ValueType.INT, 2),
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/lang/Long;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/String;"),
+ options.itemFactory.createType("J"),
+ options.itemFactory.createType("I")),
+ options.itemFactory.createString("toString")),
+ false),
+ new CfReturn(ValueType.OBJECT),
+ label4,
+ new CfLoad(ValueType.INT, 2),
+ new CfConstNumber(2, ValueType.INT),
+ new CfIfCmp(If.Type.LT, ValueType.INT, label5),
+ new CfLoad(ValueType.INT, 2),
+ new CfConstNumber(36, ValueType.INT),
+ new CfIfCmp(If.Type.LE, ValueType.INT, label6),
+ label5,
+ new CfConstNumber(10, ValueType.INT),
+ new CfStore(ValueType.INT, 2),
+ label6,
+ new CfConstNumber(64, ValueType.INT),
+ new CfNewArray(options.itemFactory.createType("[C")),
+ new CfStore(ValueType.OBJECT, 3),
+ label7,
+ new CfLoad(ValueType.OBJECT, 3),
+ new CfArrayLength(),
+ new CfStore(ValueType.INT, 4),
+ label8,
+ new CfLoad(ValueType.INT, 2),
+ new CfLoad(ValueType.INT, 2),
+ new CfConstNumber(1, ValueType.INT),
+ new CfArithmeticBinop(CfArithmeticBinop.Opcode.Sub, NumericType.INT),
+ new CfLogicalBinop(CfLogicalBinop.Opcode.And, NumericType.INT),
+ new CfIf(If.Type.NE, ValueType.INT, label15),
+ label9,
+ new CfLoad(ValueType.INT, 2),
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/lang/Integer;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("I"), options.itemFactory.createType("I")),
+ options.itemFactory.createString("numberOfTrailingZeros")),
+ false),
+ new CfStore(ValueType.INT, 5),
+ label10,
+ new CfLoad(ValueType.INT, 2),
+ new CfConstNumber(1, ValueType.INT),
+ new CfArithmeticBinop(CfArithmeticBinop.Opcode.Sub, NumericType.INT),
+ new CfStore(ValueType.INT, 6),
+ label11,
+ new CfLoad(ValueType.OBJECT, 3),
+ new CfIinc(4, -1),
+ new CfLoad(ValueType.INT, 4),
+ new CfLoad(ValueType.LONG, 0),
+ new CfNumberConversion(NumericType.LONG, NumericType.INT),
+ new CfLoad(ValueType.INT, 6),
+ new CfLogicalBinop(CfLogicalBinop.Opcode.And, NumericType.INT),
+ new CfLoad(ValueType.INT, 2),
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/lang/Character;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("C"),
+ options.itemFactory.createType("I"),
+ options.itemFactory.createType("I")),
+ options.itemFactory.createString("forDigit")),
+ false),
+ new CfArrayStore(MemberType.CHAR),
+ label12,
+ new CfLoad(ValueType.LONG, 0),
+ new CfLoad(ValueType.INT, 5),
+ new CfLogicalBinop(CfLogicalBinop.Opcode.Ushr, NumericType.LONG),
+ new CfStore(ValueType.LONG, 0),
+ label13,
+ new CfLoad(ValueType.LONG, 0),
+ new CfConstNumber(0, ValueType.LONG),
+ new CfCmp(Cmp.Bias.NONE, NumericType.LONG),
+ new CfIf(If.Type.NE, ValueType.INT, label11),
+ label14,
+ new CfGoto(label25),
+ label15,
+ new CfLoad(ValueType.INT, 2),
+ new CfConstNumber(1, ValueType.INT),
+ new CfLogicalBinop(CfLogicalBinop.Opcode.And, NumericType.INT),
+ new CfIf(If.Type.NE, ValueType.INT, label18),
+ label16,
+ new CfLoad(ValueType.LONG, 0),
+ new CfConstNumber(1, ValueType.INT),
+ new CfLogicalBinop(CfLogicalBinop.Opcode.Ushr, NumericType.LONG),
+ new CfLoad(ValueType.INT, 2),
+ new CfConstNumber(1, ValueType.INT),
+ new CfLogicalBinop(CfLogicalBinop.Opcode.Ushr, NumericType.INT),
+ new CfNumberConversion(NumericType.INT, NumericType.LONG),
+ new CfArithmeticBinop(CfArithmeticBinop.Opcode.Div, NumericType.LONG),
+ new CfStore(ValueType.LONG, 5),
+ label17,
+ new CfGoto(label19),
+ label18,
+ new CfLoad(ValueType.LONG, 0),
+ new CfLoad(ValueType.INT, 2),
+ new CfNumberConversion(NumericType.INT, NumericType.LONG),
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/lang/Long;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("J"),
+ options.itemFactory.createType("J"),
+ options.itemFactory.createType("J")),
+ options.itemFactory.createString("divideUnsigned")),
+ false),
+ new CfStore(ValueType.LONG, 5),
+ label19,
+ new CfLoad(ValueType.LONG, 0),
+ new CfLoad(ValueType.LONG, 5),
+ new CfLoad(ValueType.INT, 2),
+ new CfNumberConversion(NumericType.INT, NumericType.LONG),
+ new CfArithmeticBinop(CfArithmeticBinop.Opcode.Mul, NumericType.LONG),
+ new CfArithmeticBinop(CfArithmeticBinop.Opcode.Sub, NumericType.LONG),
+ new CfStore(ValueType.LONG, 7),
+ label20,
+ new CfLoad(ValueType.OBJECT, 3),
+ new CfIinc(4, -1),
+ new CfLoad(ValueType.INT, 4),
+ new CfLoad(ValueType.LONG, 7),
+ new CfNumberConversion(NumericType.LONG, NumericType.INT),
+ new CfLoad(ValueType.INT, 2),
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/lang/Character;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("C"),
+ options.itemFactory.createType("I"),
+ options.itemFactory.createType("I")),
+ options.itemFactory.createString("forDigit")),
+ false),
+ new CfArrayStore(MemberType.CHAR),
+ label21,
+ new CfLoad(ValueType.LONG, 5),
+ new CfStore(ValueType.LONG, 0),
+ label22,
+ new CfLoad(ValueType.LONG, 0),
+ new CfConstNumber(0, ValueType.LONG),
+ new CfCmp(Cmp.Bias.NONE, NumericType.LONG),
+ new CfIf(If.Type.LE, ValueType.INT, label25),
+ label23,
+ new CfLoad(ValueType.OBJECT, 3),
+ new CfIinc(4, -1),
+ new CfLoad(ValueType.INT, 4),
+ new CfLoad(ValueType.LONG, 0),
+ new CfLoad(ValueType.INT, 2),
+ new CfNumberConversion(NumericType.INT, NumericType.LONG),
+ new CfArithmeticBinop(CfArithmeticBinop.Opcode.Rem, NumericType.LONG),
+ new CfNumberConversion(NumericType.LONG, NumericType.INT),
+ new CfLoad(ValueType.INT, 2),
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/lang/Character;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("C"),
+ options.itemFactory.createType("I"),
+ options.itemFactory.createType("I")),
+ options.itemFactory.createString("forDigit")),
+ false),
+ new CfArrayStore(MemberType.CHAR),
+ label24,
+ new CfLoad(ValueType.LONG, 0),
+ new CfLoad(ValueType.INT, 2),
+ new CfNumberConversion(NumericType.INT, NumericType.LONG),
+ new CfArithmeticBinop(CfArithmeticBinop.Opcode.Div, NumericType.LONG),
+ new CfStore(ValueType.LONG, 0),
+ new CfGoto(label22),
+ label25,
+ new CfNew(options.itemFactory.createType("Ljava/lang/String;")),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfLoad(ValueType.OBJECT, 3),
+ new CfLoad(ValueType.INT, 4),
+ new CfLoad(ValueType.OBJECT, 3),
+ new CfArrayLength(),
+ new CfLoad(ValueType.INT, 4),
+ new CfArithmeticBinop(CfArithmeticBinop.Opcode.Sub, NumericType.INT),
+ new CfInvoke(
+ 183,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/lang/String;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("V"),
+ options.itemFactory.createType("[C"),
+ options.itemFactory.createType("I"),
+ options.itemFactory.createType("I")),
+ options.itemFactory.createString("<init>")),
+ false),
+ new CfReturn(ValueType.OBJECT),
+ label26),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode MathMethods_addExactInt(
+ InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ CfLabel label2 = new CfLabel();
+ CfLabel label3 = new CfLabel();
+ CfLabel label4 = new CfLabel();
+ CfLabel label5 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 4,
+ 5,
+ ImmutableList.of(
+ label0,
+ new CfLoad(ValueType.INT, 0),
+ new CfNumberConversion(NumericType.INT, NumericType.LONG),
+ new CfLoad(ValueType.INT, 1),
+ new CfNumberConversion(NumericType.INT, NumericType.LONG),
+ new CfArithmeticBinop(CfArithmeticBinop.Opcode.Add, NumericType.LONG),
+ new CfStore(ValueType.LONG, 2),
+ label1,
+ new CfLoad(ValueType.LONG, 2),
+ new CfNumberConversion(NumericType.LONG, NumericType.INT),
+ new CfStore(ValueType.INT, 4),
+ label2,
+ new CfLoad(ValueType.LONG, 2),
+ new CfLoad(ValueType.INT, 4),
+ new CfNumberConversion(NumericType.INT, NumericType.LONG),
+ new CfCmp(Cmp.Bias.NONE, NumericType.LONG),
+ new CfIf(If.Type.NE, ValueType.INT, label4),
+ label3,
+ new CfLoad(ValueType.INT, 4),
+ new CfReturn(ValueType.INT),
+ label4,
+ new CfNew(options.itemFactory.createType("Ljava/lang/ArithmeticException;")),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfInvoke(
+ 183,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/lang/ArithmeticException;"),
+ options.itemFactory.createProto(options.itemFactory.createType("V")),
+ options.itemFactory.createString("<init>")),
+ false),
+ new CfThrow(),
+ label5),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode MathMethods_addExactLong(
+ InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ CfLabel label2 = new CfLabel();
+ CfLabel label3 = new CfLabel();
+ CfLabel label4 = new CfLabel();
+ CfLabel label5 = new CfLabel();
+ CfLabel label6 = new CfLabel();
+ CfLabel label7 = new CfLabel();
+ CfLabel label8 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 5,
+ 6,
+ ImmutableList.of(
+ label0,
+ new CfLoad(ValueType.LONG, 0),
+ new CfLoad(ValueType.LONG, 2),
+ new CfArithmeticBinop(CfArithmeticBinop.Opcode.Add, NumericType.LONG),
+ new CfStore(ValueType.LONG, 4),
+ label1,
+ new CfLoad(ValueType.LONG, 0),
+ new CfLoad(ValueType.LONG, 2),
+ new CfLogicalBinop(CfLogicalBinop.Opcode.Xor, NumericType.LONG),
+ new CfConstNumber(0, ValueType.LONG),
+ new CfCmp(Cmp.Bias.NONE, NumericType.LONG),
+ new CfIf(If.Type.GE, ValueType.INT, label2),
+ new CfConstNumber(1, ValueType.INT),
+ new CfGoto(label3),
+ label2,
+ new CfConstNumber(0, ValueType.INT),
+ label3,
+ new CfLoad(ValueType.LONG, 0),
+ new CfLoad(ValueType.LONG, 4),
+ new CfLogicalBinop(CfLogicalBinop.Opcode.Xor, NumericType.LONG),
+ new CfConstNumber(0, ValueType.LONG),
+ new CfCmp(Cmp.Bias.NONE, NumericType.LONG),
+ new CfIf(If.Type.LT, ValueType.INT, label4),
+ new CfConstNumber(1, ValueType.INT),
+ new CfGoto(label5),
+ label4,
+ new CfConstNumber(0, ValueType.INT),
+ label5,
+ new CfLogicalBinop(CfLogicalBinop.Opcode.Or, NumericType.INT),
+ new CfIf(If.Type.EQ, ValueType.INT, label7),
+ label6,
+ new CfLoad(ValueType.LONG, 4),
+ new CfReturn(ValueType.LONG),
+ label7,
+ new CfNew(options.itemFactory.createType("Ljava/lang/ArithmeticException;")),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfInvoke(
+ 183,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/lang/ArithmeticException;"),
+ options.itemFactory.createProto(options.itemFactory.createType("V")),
+ options.itemFactory.createString("<init>")),
+ false),
+ new CfThrow(),
+ label8),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode MathMethods_decrementExactInt(
+ InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ CfLabel label2 = new CfLabel();
+ CfLabel label3 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 2,
+ 1,
+ ImmutableList.of(
+ label0,
+ new CfLoad(ValueType.INT, 0),
+ new CfConstNumber(-2147483648, ValueType.INT),
+ new CfIfCmp(If.Type.NE, ValueType.INT, label2),
+ label1,
+ new CfNew(options.itemFactory.createType("Ljava/lang/ArithmeticException;")),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfInvoke(
+ 183,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/lang/ArithmeticException;"),
+ options.itemFactory.createProto(options.itemFactory.createType("V")),
+ options.itemFactory.createString("<init>")),
+ false),
+ new CfThrow(),
+ label2,
+ new CfLoad(ValueType.INT, 0),
+ new CfConstNumber(1, ValueType.INT),
+ new CfArithmeticBinop(CfArithmeticBinop.Opcode.Sub, NumericType.INT),
+ new CfReturn(ValueType.INT),
+ label3),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode MathMethods_decrementExactLong(
+ InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ CfLabel label2 = new CfLabel();
+ CfLabel label3 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 4,
+ 2,
+ ImmutableList.of(
+ label0,
+ new CfLoad(ValueType.LONG, 0),
+ new CfConstNumber(-9223372036854775808l, ValueType.LONG),
+ new CfCmp(Cmp.Bias.NONE, NumericType.LONG),
+ new CfIf(If.Type.NE, ValueType.INT, label2),
+ label1,
+ new CfNew(options.itemFactory.createType("Ljava/lang/ArithmeticException;")),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfInvoke(
+ 183,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/lang/ArithmeticException;"),
+ options.itemFactory.createProto(options.itemFactory.createType("V")),
+ options.itemFactory.createString("<init>")),
+ false),
+ new CfThrow(),
+ label2,
+ new CfLoad(ValueType.LONG, 0),
+ new CfConstNumber(1, ValueType.LONG),
+ new CfArithmeticBinop(CfArithmeticBinop.Opcode.Sub, NumericType.LONG),
+ new CfReturn(ValueType.LONG),
+ label3),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode MathMethods_floorDivInt(
+ InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ CfLabel label2 = new CfLabel();
+ CfLabel label3 = new CfLabel();
+ CfLabel label4 = new CfLabel();
+ CfLabel label5 = new CfLabel();
+ CfLabel label6 = new CfLabel();
+ CfLabel label7 = new CfLabel();
+ CfLabel label8 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 3,
+ 5,
+ ImmutableList.of(
+ label0,
+ new CfLoad(ValueType.INT, 0),
+ new CfLoad(ValueType.INT, 1),
+ new CfArithmeticBinop(CfArithmeticBinop.Opcode.Div, NumericType.INT),
+ new CfStore(ValueType.INT, 2),
+ label1,
+ new CfLoad(ValueType.INT, 0),
+ new CfLoad(ValueType.INT, 1),
+ new CfLoad(ValueType.INT, 2),
+ new CfArithmeticBinop(CfArithmeticBinop.Opcode.Mul, NumericType.INT),
+ new CfArithmeticBinop(CfArithmeticBinop.Opcode.Sub, NumericType.INT),
+ new CfStore(ValueType.INT, 3),
+ label2,
+ new CfLoad(ValueType.INT, 3),
+ new CfIf(If.Type.NE, ValueType.INT, label4),
+ label3,
+ new CfLoad(ValueType.INT, 2),
+ new CfReturn(ValueType.INT),
+ label4,
+ new CfConstNumber(1, ValueType.INT),
+ new CfLoad(ValueType.INT, 0),
+ new CfLoad(ValueType.INT, 1),
+ new CfLogicalBinop(CfLogicalBinop.Opcode.Xor, NumericType.INT),
+ new CfConstNumber(31, ValueType.INT),
+ new CfLogicalBinop(CfLogicalBinop.Opcode.Shr, NumericType.INT),
+ new CfLogicalBinop(CfLogicalBinop.Opcode.Or, NumericType.INT),
+ new CfStore(ValueType.INT, 4),
+ label5,
+ new CfLoad(ValueType.INT, 4),
+ new CfIf(If.Type.GE, ValueType.INT, label6),
+ new CfLoad(ValueType.INT, 2),
+ new CfConstNumber(1, ValueType.INT),
+ new CfArithmeticBinop(CfArithmeticBinop.Opcode.Sub, NumericType.INT),
+ new CfGoto(label7),
+ label6,
+ new CfLoad(ValueType.INT, 2),
+ label7,
+ new CfReturn(ValueType.INT),
+ label8),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode MathMethods_floorDivLong(
+ InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ CfLabel label2 = new CfLabel();
+ CfLabel label3 = new CfLabel();
+ CfLabel label4 = new CfLabel();
+ CfLabel label5 = new CfLabel();
+ CfLabel label6 = new CfLabel();
+ CfLabel label7 = new CfLabel();
+ CfLabel label8 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 6,
+ 10,
+ ImmutableList.of(
+ label0,
+ new CfLoad(ValueType.LONG, 0),
+ new CfLoad(ValueType.LONG, 2),
+ new CfArithmeticBinop(CfArithmeticBinop.Opcode.Div, NumericType.LONG),
+ new CfStore(ValueType.LONG, 4),
+ label1,
+ new CfLoad(ValueType.LONG, 0),
+ new CfLoad(ValueType.LONG, 2),
+ new CfLoad(ValueType.LONG, 4),
+ new CfArithmeticBinop(CfArithmeticBinop.Opcode.Mul, NumericType.LONG),
+ new CfArithmeticBinop(CfArithmeticBinop.Opcode.Sub, NumericType.LONG),
+ new CfStore(ValueType.LONG, 6),
+ label2,
+ new CfLoad(ValueType.LONG, 6),
+ new CfConstNumber(0, ValueType.LONG),
+ new CfCmp(Cmp.Bias.NONE, NumericType.LONG),
+ new CfIf(If.Type.NE, ValueType.INT, label4),
+ label3,
+ new CfLoad(ValueType.LONG, 4),
+ new CfReturn(ValueType.LONG),
+ label4,
+ new CfConstNumber(1, ValueType.LONG),
+ new CfLoad(ValueType.LONG, 0),
+ new CfLoad(ValueType.LONG, 2),
+ new CfLogicalBinop(CfLogicalBinop.Opcode.Xor, NumericType.LONG),
+ new CfConstNumber(63, ValueType.INT),
+ new CfLogicalBinop(CfLogicalBinop.Opcode.Shr, NumericType.LONG),
+ new CfLogicalBinop(CfLogicalBinop.Opcode.Or, NumericType.LONG),
+ new CfStore(ValueType.LONG, 8),
+ label5,
+ new CfLoad(ValueType.LONG, 8),
+ new CfConstNumber(0, ValueType.LONG),
+ new CfCmp(Cmp.Bias.NONE, NumericType.LONG),
+ new CfIf(If.Type.GE, ValueType.INT, label6),
+ new CfLoad(ValueType.LONG, 4),
+ new CfConstNumber(1, ValueType.LONG),
+ new CfArithmeticBinop(CfArithmeticBinop.Opcode.Sub, NumericType.LONG),
+ new CfGoto(label7),
+ label6,
+ new CfLoad(ValueType.LONG, 4),
+ label7,
+ new CfReturn(ValueType.LONG),
+ label8),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode MathMethods_floorDivLongInt(
+ InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 4,
+ 3,
+ ImmutableList.of(
+ label0,
+ new CfLoad(ValueType.LONG, 0),
+ new CfLoad(ValueType.INT, 2),
+ new CfNumberConversion(NumericType.INT, NumericType.LONG),
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/lang/Math;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("J"),
+ options.itemFactory.createType("J"),
+ options.itemFactory.createType("J")),
+ options.itemFactory.createString("floorDiv")),
+ false),
+ new CfReturn(ValueType.LONG),
+ label1),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode MathMethods_floorModInt(
+ InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ CfLabel label2 = new CfLabel();
+ CfLabel label3 = new CfLabel();
+ CfLabel label4 = new CfLabel();
+ CfLabel label5 = new CfLabel();
+ CfLabel label6 = new CfLabel();
+ CfLabel label7 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 3,
+ 4,
+ ImmutableList.of(
+ label0,
+ new CfLoad(ValueType.INT, 0),
+ new CfLoad(ValueType.INT, 1),
+ new CfArithmeticBinop(CfArithmeticBinop.Opcode.Rem, NumericType.INT),
+ new CfStore(ValueType.INT, 2),
+ label1,
+ new CfLoad(ValueType.INT, 2),
+ new CfIf(If.Type.NE, ValueType.INT, label3),
+ label2,
+ new CfConstNumber(0, ValueType.INT),
+ new CfReturn(ValueType.INT),
+ label3,
+ new CfConstNumber(1, ValueType.INT),
+ new CfLoad(ValueType.INT, 0),
+ new CfLoad(ValueType.INT, 1),
+ new CfLogicalBinop(CfLogicalBinop.Opcode.Xor, NumericType.INT),
+ new CfConstNumber(31, ValueType.INT),
+ new CfLogicalBinop(CfLogicalBinop.Opcode.Shr, NumericType.INT),
+ new CfLogicalBinop(CfLogicalBinop.Opcode.Or, NumericType.INT),
+ new CfStore(ValueType.INT, 3),
+ label4,
+ new CfLoad(ValueType.INT, 3),
+ new CfIf(If.Type.LE, ValueType.INT, label5),
+ new CfLoad(ValueType.INT, 2),
+ new CfGoto(label6),
+ label5,
+ new CfLoad(ValueType.INT, 2),
+ new CfLoad(ValueType.INT, 1),
+ new CfArithmeticBinop(CfArithmeticBinop.Opcode.Add, NumericType.INT),
+ label6,
+ new CfReturn(ValueType.INT),
+ label7),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode MathMethods_floorModLong(
+ InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ CfLabel label2 = new CfLabel();
+ CfLabel label3 = new CfLabel();
+ CfLabel label4 = new CfLabel();
+ CfLabel label5 = new CfLabel();
+ CfLabel label6 = new CfLabel();
+ CfLabel label7 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 6,
+ 8,
+ ImmutableList.of(
+ label0,
+ new CfLoad(ValueType.LONG, 0),
+ new CfLoad(ValueType.LONG, 2),
+ new CfArithmeticBinop(CfArithmeticBinop.Opcode.Rem, NumericType.LONG),
+ new CfStore(ValueType.LONG, 4),
+ label1,
+ new CfLoad(ValueType.LONG, 4),
+ new CfConstNumber(0, ValueType.LONG),
+ new CfCmp(Cmp.Bias.NONE, NumericType.LONG),
+ new CfIf(If.Type.NE, ValueType.INT, label3),
+ label2,
+ new CfConstNumber(0, ValueType.LONG),
+ new CfReturn(ValueType.LONG),
+ label3,
+ new CfConstNumber(1, ValueType.LONG),
+ new CfLoad(ValueType.LONG, 0),
+ new CfLoad(ValueType.LONG, 2),
+ new CfLogicalBinop(CfLogicalBinop.Opcode.Xor, NumericType.LONG),
+ new CfConstNumber(63, ValueType.INT),
+ new CfLogicalBinop(CfLogicalBinop.Opcode.Shr, NumericType.LONG),
+ new CfLogicalBinop(CfLogicalBinop.Opcode.Or, NumericType.LONG),
+ new CfStore(ValueType.LONG, 6),
+ label4,
+ new CfLoad(ValueType.LONG, 6),
+ new CfConstNumber(0, ValueType.LONG),
+ new CfCmp(Cmp.Bias.NONE, NumericType.LONG),
+ new CfIf(If.Type.LE, ValueType.INT, label5),
+ new CfLoad(ValueType.LONG, 4),
+ new CfGoto(label6),
+ label5,
+ new CfLoad(ValueType.LONG, 4),
+ new CfLoad(ValueType.LONG, 2),
+ new CfArithmeticBinop(CfArithmeticBinop.Opcode.Add, NumericType.LONG),
+ label6,
+ new CfReturn(ValueType.LONG),
+ label7),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode MathMethods_floorModLongInt(
+ InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 4,
+ 3,
+ ImmutableList.of(
+ label0,
+ new CfLoad(ValueType.LONG, 0),
+ new CfLoad(ValueType.INT, 2),
+ new CfNumberConversion(NumericType.INT, NumericType.LONG),
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/lang/Math;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("J"),
+ options.itemFactory.createType("J"),
+ options.itemFactory.createType("J")),
+ options.itemFactory.createString("floorMod")),
+ false),
+ new CfNumberConversion(NumericType.LONG, NumericType.INT),
+ new CfReturn(ValueType.INT),
+ label1),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode MathMethods_incrementExactInt(
+ InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ CfLabel label2 = new CfLabel();
+ CfLabel label3 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 2,
+ 1,
+ ImmutableList.of(
+ label0,
+ new CfLoad(ValueType.INT, 0),
+ new CfConstNumber(2147483647, ValueType.INT),
+ new CfIfCmp(If.Type.NE, ValueType.INT, label2),
+ label1,
+ new CfNew(options.itemFactory.createType("Ljava/lang/ArithmeticException;")),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfInvoke(
+ 183,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/lang/ArithmeticException;"),
+ options.itemFactory.createProto(options.itemFactory.createType("V")),
+ options.itemFactory.createString("<init>")),
+ false),
+ new CfThrow(),
+ label2,
+ new CfLoad(ValueType.INT, 0),
+ new CfConstNumber(1, ValueType.INT),
+ new CfArithmeticBinop(CfArithmeticBinop.Opcode.Add, NumericType.INT),
+ new CfReturn(ValueType.INT),
+ label3),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode MathMethods_incrementExactLong(
+ InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ CfLabel label2 = new CfLabel();
+ CfLabel label3 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 4,
+ 2,
+ ImmutableList.of(
+ label0,
+ new CfLoad(ValueType.LONG, 0),
+ new CfConstNumber(9223372036854775807l, ValueType.LONG),
+ new CfCmp(Cmp.Bias.NONE, NumericType.LONG),
+ new CfIf(If.Type.NE, ValueType.INT, label2),
+ label1,
+ new CfNew(options.itemFactory.createType("Ljava/lang/ArithmeticException;")),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfInvoke(
+ 183,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/lang/ArithmeticException;"),
+ options.itemFactory.createProto(options.itemFactory.createType("V")),
+ options.itemFactory.createString("<init>")),
+ false),
+ new CfThrow(),
+ label2,
+ new CfLoad(ValueType.LONG, 0),
+ new CfConstNumber(1, ValueType.LONG),
+ new CfArithmeticBinop(CfArithmeticBinop.Opcode.Add, NumericType.LONG),
+ new CfReturn(ValueType.LONG),
+ label3),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode MathMethods_multiplyExactInt(
+ InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ CfLabel label2 = new CfLabel();
+ CfLabel label3 = new CfLabel();
+ CfLabel label4 = new CfLabel();
+ CfLabel label5 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 4,
+ 5,
+ ImmutableList.of(
+ label0,
+ new CfLoad(ValueType.INT, 0),
+ new CfNumberConversion(NumericType.INT, NumericType.LONG),
+ new CfLoad(ValueType.INT, 1),
+ new CfNumberConversion(NumericType.INT, NumericType.LONG),
+ new CfArithmeticBinop(CfArithmeticBinop.Opcode.Mul, NumericType.LONG),
+ new CfStore(ValueType.LONG, 2),
+ label1,
+ new CfLoad(ValueType.LONG, 2),
+ new CfNumberConversion(NumericType.LONG, NumericType.INT),
+ new CfStore(ValueType.INT, 4),
+ label2,
+ new CfLoad(ValueType.LONG, 2),
+ new CfLoad(ValueType.INT, 4),
+ new CfNumberConversion(NumericType.INT, NumericType.LONG),
+ new CfCmp(Cmp.Bias.NONE, NumericType.LONG),
+ new CfIf(If.Type.NE, ValueType.INT, label4),
+ label3,
+ new CfLoad(ValueType.INT, 4),
+ new CfReturn(ValueType.INT),
+ label4,
+ new CfNew(options.itemFactory.createType("Ljava/lang/ArithmeticException;")),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfInvoke(
+ 183,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/lang/ArithmeticException;"),
+ options.itemFactory.createProto(options.itemFactory.createType("V")),
+ options.itemFactory.createString("<init>")),
+ false),
+ new CfThrow(),
+ label5),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode MathMethods_multiplyExactLong(
+ InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ CfLabel label2 = new CfLabel();
+ CfLabel label3 = new CfLabel();
+ CfLabel label4 = new CfLabel();
+ CfLabel label5 = new CfLabel();
+ CfLabel label6 = new CfLabel();
+ CfLabel label7 = new CfLabel();
+ CfLabel label8 = new CfLabel();
+ CfLabel label9 = new CfLabel();
+ CfLabel label10 = new CfLabel();
+ CfLabel label11 = new CfLabel();
+ CfLabel label12 = new CfLabel();
+ CfLabel label13 = new CfLabel();
+ CfLabel label14 = new CfLabel();
+ CfLabel label15 = new CfLabel();
+ CfLabel label16 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 5,
+ 7,
+ ImmutableList.of(
+ label0,
+ new CfLoad(ValueType.LONG, 0),
+ label1,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/lang/Long;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("I"), options.itemFactory.createType("J")),
+ options.itemFactory.createString("numberOfLeadingZeros")),
+ false),
+ new CfLoad(ValueType.LONG, 0),
+ new CfConstNumber(-1, ValueType.LONG),
+ new CfLogicalBinop(CfLogicalBinop.Opcode.Xor, NumericType.LONG),
+ label2,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/lang/Long;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("I"), options.itemFactory.createType("J")),
+ options.itemFactory.createString("numberOfLeadingZeros")),
+ false),
+ new CfArithmeticBinop(CfArithmeticBinop.Opcode.Add, NumericType.INT),
+ new CfLoad(ValueType.LONG, 2),
+ label3,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/lang/Long;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("I"), options.itemFactory.createType("J")),
+ options.itemFactory.createString("numberOfLeadingZeros")),
+ false),
+ new CfArithmeticBinop(CfArithmeticBinop.Opcode.Add, NumericType.INT),
+ new CfLoad(ValueType.LONG, 2),
+ new CfConstNumber(-1, ValueType.LONG),
+ new CfLogicalBinop(CfLogicalBinop.Opcode.Xor, NumericType.LONG),
+ label4,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/lang/Long;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("I"), options.itemFactory.createType("J")),
+ options.itemFactory.createString("numberOfLeadingZeros")),
+ false),
+ new CfArithmeticBinop(CfArithmeticBinop.Opcode.Add, NumericType.INT),
+ new CfStore(ValueType.INT, 4),
+ label5,
+ new CfLoad(ValueType.INT, 4),
+ new CfConstNumber(65, ValueType.INT),
+ new CfIfCmp(If.Type.LE, ValueType.INT, label7),
+ label6,
+ new CfLoad(ValueType.LONG, 0),
+ new CfLoad(ValueType.LONG, 2),
+ new CfArithmeticBinop(CfArithmeticBinop.Opcode.Mul, NumericType.LONG),
+ new CfReturn(ValueType.LONG),
+ label7,
+ new CfLoad(ValueType.INT, 4),
+ new CfConstNumber(64, ValueType.INT),
+ new CfIfCmp(If.Type.LT, ValueType.INT, label15),
+ new CfLoad(ValueType.LONG, 0),
+ new CfConstNumber(0, ValueType.LONG),
+ new CfCmp(Cmp.Bias.NONE, NumericType.LONG),
+ new CfIf(If.Type.LT, ValueType.INT, label8),
+ new CfConstNumber(1, ValueType.INT),
+ new CfGoto(label9),
+ label8,
+ new CfConstNumber(0, ValueType.INT),
+ label9,
+ new CfLoad(ValueType.LONG, 2),
+ new CfConstNumber(-9223372036854775808l, ValueType.LONG),
+ new CfCmp(Cmp.Bias.NONE, NumericType.LONG),
+ new CfIf(If.Type.EQ, ValueType.INT, label10),
+ new CfConstNumber(1, ValueType.INT),
+ new CfGoto(label11),
+ label10,
+ new CfConstNumber(0, ValueType.INT),
+ label11,
+ new CfLogicalBinop(CfLogicalBinop.Opcode.Or, NumericType.INT),
+ new CfIf(If.Type.EQ, ValueType.INT, label15),
+ label12,
+ new CfLoad(ValueType.LONG, 0),
+ new CfLoad(ValueType.LONG, 2),
+ new CfArithmeticBinop(CfArithmeticBinop.Opcode.Mul, NumericType.LONG),
+ new CfStore(ValueType.LONG, 5),
+ label13,
+ new CfLoad(ValueType.LONG, 0),
+ new CfConstNumber(0, ValueType.LONG),
+ new CfCmp(Cmp.Bias.NONE, NumericType.LONG),
+ new CfIf(If.Type.EQ, ValueType.INT, label14),
+ new CfLoad(ValueType.LONG, 5),
+ new CfLoad(ValueType.LONG, 0),
+ new CfArithmeticBinop(CfArithmeticBinop.Opcode.Div, NumericType.LONG),
+ new CfLoad(ValueType.LONG, 2),
+ new CfCmp(Cmp.Bias.NONE, NumericType.LONG),
+ new CfIf(If.Type.NE, ValueType.INT, label15),
+ label14,
+ new CfLoad(ValueType.LONG, 5),
+ new CfReturn(ValueType.LONG),
+ label15,
+ new CfNew(options.itemFactory.createType("Ljava/lang/ArithmeticException;")),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfInvoke(
+ 183,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/lang/ArithmeticException;"),
+ options.itemFactory.createProto(options.itemFactory.createType("V")),
+ options.itemFactory.createString("<init>")),
+ false),
+ new CfThrow(),
+ label16),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode MathMethods_multiplyExactLongInt(
+ InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 4,
+ 3,
+ ImmutableList.of(
+ label0,
+ new CfLoad(ValueType.LONG, 0),
+ new CfLoad(ValueType.INT, 2),
+ new CfNumberConversion(NumericType.INT, NumericType.LONG),
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/lang/Math;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("J"),
+ options.itemFactory.createType("J"),
+ options.itemFactory.createType("J")),
+ options.itemFactory.createString("multiplyExact")),
+ false),
+ new CfReturn(ValueType.LONG),
+ label1),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode MathMethods_negateExactInt(
+ InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ CfLabel label2 = new CfLabel();
+ CfLabel label3 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 2,
+ 1,
+ ImmutableList.of(
+ label0,
+ new CfLoad(ValueType.INT, 0),
+ new CfConstNumber(-2147483648, ValueType.INT),
+ new CfIfCmp(If.Type.NE, ValueType.INT, label2),
+ label1,
+ new CfNew(options.itemFactory.createType("Ljava/lang/ArithmeticException;")),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfInvoke(
+ 183,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/lang/ArithmeticException;"),
+ options.itemFactory.createProto(options.itemFactory.createType("V")),
+ options.itemFactory.createString("<init>")),
+ false),
+ new CfThrow(),
+ label2,
+ new CfLoad(ValueType.INT, 0),
+ new CfNeg(NumericType.INT),
+ new CfReturn(ValueType.INT),
+ label3),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode MathMethods_negateExactLong(
+ InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ CfLabel label2 = new CfLabel();
+ CfLabel label3 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 4,
+ 2,
+ ImmutableList.of(
+ label0,
+ new CfLoad(ValueType.LONG, 0),
+ new CfConstNumber(-9223372036854775808l, ValueType.LONG),
+ new CfCmp(Cmp.Bias.NONE, NumericType.LONG),
+ new CfIf(If.Type.NE, ValueType.INT, label2),
+ label1,
+ new CfNew(options.itemFactory.createType("Ljava/lang/ArithmeticException;")),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfInvoke(
+ 183,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/lang/ArithmeticException;"),
+ options.itemFactory.createProto(options.itemFactory.createType("V")),
+ options.itemFactory.createString("<init>")),
+ false),
+ new CfThrow(),
+ label2,
+ new CfLoad(ValueType.LONG, 0),
+ new CfNeg(NumericType.LONG),
+ new CfReturn(ValueType.LONG),
+ label3),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode MathMethods_nextDownDouble(
+ InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 2,
+ 2,
+ ImmutableList.of(
+ label0,
+ new CfLoad(ValueType.DOUBLE, 0),
+ new CfNeg(NumericType.DOUBLE),
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/lang/Math;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("D"), options.itemFactory.createType("D")),
+ options.itemFactory.createString("nextUp")),
+ false),
+ new CfNeg(NumericType.DOUBLE),
+ new CfReturn(ValueType.DOUBLE),
+ label1),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode MathMethods_nextDownFloat(
+ InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 1,
+ 1,
+ ImmutableList.of(
+ label0,
+ new CfLoad(ValueType.FLOAT, 0),
+ new CfNeg(NumericType.FLOAT),
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/lang/Math;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("F"), options.itemFactory.createType("F")),
+ options.itemFactory.createString("nextUp")),
+ false),
+ new CfNeg(NumericType.FLOAT),
+ new CfReturn(ValueType.FLOAT),
+ label1),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode MathMethods_subtractExactInt(
+ InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ CfLabel label2 = new CfLabel();
+ CfLabel label3 = new CfLabel();
+ CfLabel label4 = new CfLabel();
+ CfLabel label5 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 4,
+ 5,
+ ImmutableList.of(
+ label0,
+ new CfLoad(ValueType.INT, 0),
+ new CfNumberConversion(NumericType.INT, NumericType.LONG),
+ new CfLoad(ValueType.INT, 1),
+ new CfNumberConversion(NumericType.INT, NumericType.LONG),
+ new CfArithmeticBinop(CfArithmeticBinop.Opcode.Sub, NumericType.LONG),
+ new CfStore(ValueType.LONG, 2),
+ label1,
+ new CfLoad(ValueType.LONG, 2),
+ new CfNumberConversion(NumericType.LONG, NumericType.INT),
+ new CfStore(ValueType.INT, 4),
+ label2,
+ new CfLoad(ValueType.LONG, 2),
+ new CfLoad(ValueType.INT, 4),
+ new CfNumberConversion(NumericType.INT, NumericType.LONG),
+ new CfCmp(Cmp.Bias.NONE, NumericType.LONG),
+ new CfIf(If.Type.NE, ValueType.INT, label4),
+ label3,
+ new CfLoad(ValueType.INT, 4),
+ new CfReturn(ValueType.INT),
+ label4,
+ new CfNew(options.itemFactory.createType("Ljava/lang/ArithmeticException;")),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfInvoke(
+ 183,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/lang/ArithmeticException;"),
+ options.itemFactory.createProto(options.itemFactory.createType("V")),
+ options.itemFactory.createString("<init>")),
+ false),
+ new CfThrow(),
+ label5),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode MathMethods_subtractExactLong(
+ InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ CfLabel label2 = new CfLabel();
+ CfLabel label3 = new CfLabel();
+ CfLabel label4 = new CfLabel();
+ CfLabel label5 = new CfLabel();
+ CfLabel label6 = new CfLabel();
+ CfLabel label7 = new CfLabel();
+ CfLabel label8 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 5,
+ 6,
+ ImmutableList.of(
+ label0,
+ new CfLoad(ValueType.LONG, 0),
+ new CfLoad(ValueType.LONG, 2),
+ new CfArithmeticBinop(CfArithmeticBinop.Opcode.Sub, NumericType.LONG),
+ new CfStore(ValueType.LONG, 4),
+ label1,
+ new CfLoad(ValueType.LONG, 0),
+ new CfLoad(ValueType.LONG, 2),
+ new CfLogicalBinop(CfLogicalBinop.Opcode.Xor, NumericType.LONG),
+ new CfConstNumber(0, ValueType.LONG),
+ new CfCmp(Cmp.Bias.NONE, NumericType.LONG),
+ new CfIf(If.Type.LT, ValueType.INT, label2),
+ new CfConstNumber(1, ValueType.INT),
+ new CfGoto(label3),
+ label2,
+ new CfConstNumber(0, ValueType.INT),
+ label3,
+ new CfLoad(ValueType.LONG, 0),
+ new CfLoad(ValueType.LONG, 4),
+ new CfLogicalBinop(CfLogicalBinop.Opcode.Xor, NumericType.LONG),
+ new CfConstNumber(0, ValueType.LONG),
+ new CfCmp(Cmp.Bias.NONE, NumericType.LONG),
+ new CfIf(If.Type.LT, ValueType.INT, label4),
+ new CfConstNumber(1, ValueType.INT),
+ new CfGoto(label5),
+ label4,
+ new CfConstNumber(0, ValueType.INT),
+ label5,
+ new CfLogicalBinop(CfLogicalBinop.Opcode.Or, NumericType.INT),
+ new CfIf(If.Type.EQ, ValueType.INT, label7),
+ label6,
+ new CfLoad(ValueType.LONG, 4),
+ new CfReturn(ValueType.LONG),
+ label7,
+ new CfNew(options.itemFactory.createType("Ljava/lang/ArithmeticException;")),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfInvoke(
+ 183,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/lang/ArithmeticException;"),
+ options.itemFactory.createProto(options.itemFactory.createType("V")),
+ options.itemFactory.createString("<init>")),
+ false),
+ new CfThrow(),
+ label8),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode MathMethods_toIntExact(
+ InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ CfLabel label2 = new CfLabel();
+ CfLabel label3 = new CfLabel();
+ CfLabel label4 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 4,
+ 3,
+ ImmutableList.of(
+ label0,
+ new CfLoad(ValueType.LONG, 0),
+ new CfNumberConversion(NumericType.LONG, NumericType.INT),
+ new CfStore(ValueType.INT, 2),
+ label1,
+ new CfLoad(ValueType.LONG, 0),
+ new CfLoad(ValueType.INT, 2),
+ new CfNumberConversion(NumericType.INT, NumericType.LONG),
+ new CfCmp(Cmp.Bias.NONE, NumericType.LONG),
+ new CfIf(If.Type.EQ, ValueType.INT, label3),
+ label2,
+ new CfNew(options.itemFactory.createType("Ljava/lang/ArithmeticException;")),
+ new CfStackInstruction(CfStackInstruction.Opcode.Dup),
+ new CfInvoke(
+ 183,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/lang/ArithmeticException;"),
+ options.itemFactory.createProto(options.itemFactory.createType("V")),
+ options.itemFactory.createString("<init>")),
+ false),
+ new CfThrow(),
+ label3,
+ new CfLoad(ValueType.INT, 2),
+ new CfReturn(ValueType.INT),
+ label4),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
public static CfCode ObjectsMethods_checkFromIndexSize(
InternalOptions options, DexMethod method, String name) {
CfLabel label0 = new CfLabel();
@@ -1213,6 +5207,453 @@
ImmutableList.of());
}
+ public static CfCode OptionalMethods_ifPresentOrElse(
+ InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ CfLabel label2 = new CfLabel();
+ CfLabel label3 = new CfLabel();
+ CfLabel label4 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 2,
+ 3,
+ ImmutableList.of(
+ label0,
+ new CfLoad(ValueType.OBJECT, 0),
+ new CfInvoke(
+ 182,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Optional;"),
+ options.itemFactory.createProto(options.itemFactory.createType("Z")),
+ options.itemFactory.createString("isPresent")),
+ false),
+ new CfIf(If.Type.EQ, ValueType.INT, label2),
+ label1,
+ new CfLoad(ValueType.OBJECT, 1),
+ new CfLoad(ValueType.OBJECT, 0),
+ new CfInvoke(
+ 182,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Optional;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/Object;")),
+ options.itemFactory.createString("get")),
+ false),
+ new CfInvoke(
+ 185,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/function/Consumer;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("V"),
+ options.itemFactory.createType("Ljava/lang/Object;")),
+ options.itemFactory.createString("accept")),
+ true),
+ new CfGoto(label3),
+ label2,
+ new CfLoad(ValueType.OBJECT, 2),
+ new CfInvoke(
+ 185,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/lang/Runnable;"),
+ options.itemFactory.createProto(options.itemFactory.createType("V")),
+ options.itemFactory.createString("run")),
+ true),
+ label3,
+ new CfReturnVoid(),
+ label4),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode OptionalMethods_ifPresentOrElseDouble(
+ InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ CfLabel label2 = new CfLabel();
+ CfLabel label3 = new CfLabel();
+ CfLabel label4 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 3,
+ 3,
+ ImmutableList.of(
+ label0,
+ new CfLoad(ValueType.OBJECT, 0),
+ new CfInvoke(
+ 182,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/OptionalDouble;"),
+ options.itemFactory.createProto(options.itemFactory.createType("Z")),
+ options.itemFactory.createString("isPresent")),
+ false),
+ new CfIf(If.Type.EQ, ValueType.INT, label2),
+ label1,
+ new CfLoad(ValueType.OBJECT, 1),
+ new CfLoad(ValueType.OBJECT, 0),
+ new CfInvoke(
+ 182,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/OptionalDouble;"),
+ options.itemFactory.createProto(options.itemFactory.createType("D")),
+ options.itemFactory.createString("getAsDouble")),
+ false),
+ new CfInvoke(
+ 185,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/function/DoubleConsumer;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("V"), options.itemFactory.createType("D")),
+ options.itemFactory.createString("accept")),
+ true),
+ new CfGoto(label3),
+ label2,
+ new CfLoad(ValueType.OBJECT, 2),
+ new CfInvoke(
+ 185,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/lang/Runnable;"),
+ options.itemFactory.createProto(options.itemFactory.createType("V")),
+ options.itemFactory.createString("run")),
+ true),
+ label3,
+ new CfReturnVoid(),
+ label4),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode OptionalMethods_ifPresentOrElseInt(
+ InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ CfLabel label2 = new CfLabel();
+ CfLabel label3 = new CfLabel();
+ CfLabel label4 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 2,
+ 3,
+ ImmutableList.of(
+ label0,
+ new CfLoad(ValueType.OBJECT, 0),
+ new CfInvoke(
+ 182,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/OptionalInt;"),
+ options.itemFactory.createProto(options.itemFactory.createType("Z")),
+ options.itemFactory.createString("isPresent")),
+ false),
+ new CfIf(If.Type.EQ, ValueType.INT, label2),
+ label1,
+ new CfLoad(ValueType.OBJECT, 1),
+ new CfLoad(ValueType.OBJECT, 0),
+ new CfInvoke(
+ 182,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/OptionalInt;"),
+ options.itemFactory.createProto(options.itemFactory.createType("I")),
+ options.itemFactory.createString("getAsInt")),
+ false),
+ new CfInvoke(
+ 185,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/function/IntConsumer;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("V"), options.itemFactory.createType("I")),
+ options.itemFactory.createString("accept")),
+ true),
+ new CfGoto(label3),
+ label2,
+ new CfLoad(ValueType.OBJECT, 2),
+ new CfInvoke(
+ 185,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/lang/Runnable;"),
+ options.itemFactory.createProto(options.itemFactory.createType("V")),
+ options.itemFactory.createString("run")),
+ true),
+ label3,
+ new CfReturnVoid(),
+ label4),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode OptionalMethods_ifPresentOrElseLong(
+ InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ CfLabel label2 = new CfLabel();
+ CfLabel label3 = new CfLabel();
+ CfLabel label4 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 3,
+ 3,
+ ImmutableList.of(
+ label0,
+ new CfLoad(ValueType.OBJECT, 0),
+ new CfInvoke(
+ 182,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/OptionalLong;"),
+ options.itemFactory.createProto(options.itemFactory.createType("Z")),
+ options.itemFactory.createString("isPresent")),
+ false),
+ new CfIf(If.Type.EQ, ValueType.INT, label2),
+ label1,
+ new CfLoad(ValueType.OBJECT, 1),
+ new CfLoad(ValueType.OBJECT, 0),
+ new CfInvoke(
+ 182,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/OptionalLong;"),
+ options.itemFactory.createProto(options.itemFactory.createType("J")),
+ options.itemFactory.createString("getAsLong")),
+ false),
+ new CfInvoke(
+ 185,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/function/LongConsumer;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("V"), options.itemFactory.createType("J")),
+ options.itemFactory.createString("accept")),
+ true),
+ new CfGoto(label3),
+ label2,
+ new CfLoad(ValueType.OBJECT, 2),
+ new CfInvoke(
+ 185,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/lang/Runnable;"),
+ options.itemFactory.createProto(options.itemFactory.createType("V")),
+ options.itemFactory.createString("run")),
+ true),
+ label3,
+ new CfReturnVoid(),
+ label4),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode OptionalMethods_or(InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ CfLabel label2 = new CfLabel();
+ CfLabel label3 = new CfLabel();
+ CfLabel label4 = new CfLabel();
+ CfLabel label5 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 1,
+ 3,
+ ImmutableList.of(
+ label0,
+ new CfLoad(ValueType.OBJECT, 1),
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Objects;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/Object;"),
+ options.itemFactory.createType("Ljava/lang/Object;")),
+ options.itemFactory.createString("requireNonNull")),
+ false),
+ new CfStackInstruction(CfStackInstruction.Opcode.Pop),
+ label1,
+ new CfLoad(ValueType.OBJECT, 0),
+ new CfInvoke(
+ 182,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Optional;"),
+ options.itemFactory.createProto(options.itemFactory.createType("Z")),
+ options.itemFactory.createString("isPresent")),
+ false),
+ new CfIf(If.Type.EQ, ValueType.INT, label3),
+ label2,
+ new CfLoad(ValueType.OBJECT, 0),
+ new CfReturn(ValueType.OBJECT),
+ label3,
+ new CfLoad(ValueType.OBJECT, 1),
+ new CfInvoke(
+ 185,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/function/Supplier;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/Object;")),
+ options.itemFactory.createString("get")),
+ true),
+ new CfCheckCast(options.itemFactory.createType("Ljava/util/Optional;")),
+ new CfStore(ValueType.OBJECT, 2),
+ label4,
+ new CfLoad(ValueType.OBJECT, 2),
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Objects;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/Object;"),
+ options.itemFactory.createType("Ljava/lang/Object;")),
+ options.itemFactory.createString("requireNonNull")),
+ false),
+ new CfCheckCast(options.itemFactory.createType("Ljava/util/Optional;")),
+ new CfReturn(ValueType.OBJECT),
+ label5),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode OptionalMethods_stream(
+ InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ CfLabel label2 = new CfLabel();
+ CfLabel label3 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 1,
+ 1,
+ ImmutableList.of(
+ label0,
+ new CfLoad(ValueType.OBJECT, 0),
+ new CfInvoke(
+ 182,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Optional;"),
+ options.itemFactory.createProto(options.itemFactory.createType("Z")),
+ options.itemFactory.createString("isPresent")),
+ false),
+ new CfIf(If.Type.EQ, ValueType.INT, label2),
+ label1,
+ new CfLoad(ValueType.OBJECT, 0),
+ new CfInvoke(
+ 182,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/Optional;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/lang/Object;")),
+ options.itemFactory.createString("get")),
+ false),
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/stream/Stream;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/util/stream/Stream;"),
+ options.itemFactory.createType("Ljava/lang/Object;")),
+ options.itemFactory.createString("of")),
+ true),
+ new CfReturn(ValueType.OBJECT),
+ label2,
+ new CfInvoke(
+ 184,
+ options.itemFactory.createMethod(
+ options.itemFactory.createType("Ljava/util/stream/Stream;"),
+ options.itemFactory.createProto(
+ options.itemFactory.createType("Ljava/util/stream/Stream;")),
+ options.itemFactory.createString("empty")),
+ true),
+ new CfReturn(ValueType.OBJECT),
+ label3),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode ShortMethods_compare(
+ InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 2,
+ 2,
+ ImmutableList.of(
+ label0,
+ new CfLoad(ValueType.INT, 0),
+ new CfLoad(ValueType.INT, 1),
+ new CfArithmeticBinop(CfArithmeticBinop.Opcode.Sub, NumericType.INT),
+ new CfReturn(ValueType.INT),
+ label1),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode ShortMethods_compareUnsigned(
+ InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 3,
+ 2,
+ ImmutableList.of(
+ label0,
+ new CfLoad(ValueType.INT, 0),
+ new CfConstNumber(65535, ValueType.INT),
+ new CfLogicalBinop(CfLogicalBinop.Opcode.And, NumericType.INT),
+ new CfLoad(ValueType.INT, 1),
+ new CfConstNumber(65535, ValueType.INT),
+ new CfLogicalBinop(CfLogicalBinop.Opcode.And, NumericType.INT),
+ new CfArithmeticBinop(CfArithmeticBinop.Opcode.Sub, NumericType.INT),
+ new CfReturn(ValueType.INT),
+ label1),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode ShortMethods_hashCode(
+ InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 1,
+ 1,
+ ImmutableList.of(label0, new CfLoad(ValueType.INT, 0), new CfReturn(ValueType.INT), label1),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode ShortMethods_toUnsignedInt(
+ InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 2,
+ 1,
+ ImmutableList.of(
+ label0,
+ new CfLoad(ValueType.INT, 0),
+ new CfConstNumber(65535, ValueType.INT),
+ new CfLogicalBinop(CfLogicalBinop.Opcode.And, NumericType.INT),
+ new CfReturn(ValueType.INT),
+ label1),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
+ public static CfCode ShortMethods_toUnsignedLong(
+ InternalOptions options, DexMethod method, String name) {
+ CfLabel label0 = new CfLabel();
+ CfLabel label1 = new CfLabel();
+ return new CfCode(
+ method.holder,
+ 4,
+ 1,
+ ImmutableList.of(
+ label0,
+ new CfLoad(ValueType.INT, 0),
+ new CfNumberConversion(NumericType.INT, NumericType.LONG),
+ new CfConstNumber(65535, ValueType.LONG),
+ new CfLogicalBinop(CfLogicalBinop.Opcode.And, NumericType.LONG),
+ new CfReturn(ValueType.LONG),
+ label1),
+ ImmutableList.of(),
+ ImmutableList.of());
+ }
+
public static CfCode StringMethods_joinArray(
InternalOptions options, DexMethod method, String name) {
CfLabel label0 = new CfLabel();
diff --git a/src/main/java/com/android/tools/r8/ir/desugar/backports/CharacterMethods.java b/src/main/java/com/android/tools/r8/ir/desugar/backports/CharacterMethods.java
deleted file mode 100644
index 2cf14d4..0000000
--- a/src/main/java/com/android/tools/r8/ir/desugar/backports/CharacterMethods.java
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright (c) 2019, the R8 project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-package com.android.tools.r8.ir.desugar.backports;
-
-import com.android.tools.r8.graph.DexMethod;
-import com.android.tools.r8.ir.synthetic.TemplateMethodCode;
-import com.android.tools.r8.utils.InternalOptions;
-
-public final class CharacterMethods extends TemplateMethodCode {
- public CharacterMethods(InternalOptions options, DexMethod method, String methodName) {
- super(options, method, methodName, method.proto.toDescriptorString());
- }
-
- public static int hashCode(char i) {
- return i;
- }
-
- public static int compare(char a, char b) {
- return (int) a - (int) b;
- }
-
- public static String toStringCodepoint(int codepoint) {
- return new String(Character.toChars(codepoint));
- }
-}
diff --git a/src/main/java/com/android/tools/r8/ir/desugar/backports/DoubleMethods.java b/src/main/java/com/android/tools/r8/ir/desugar/backports/DoubleMethods.java
deleted file mode 100644
index af13d8b..0000000
--- a/src/main/java/com/android/tools/r8/ir/desugar/backports/DoubleMethods.java
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright (c) 2019, the R8 project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-package com.android.tools.r8.ir.desugar.backports;
-
-import com.android.tools.r8.graph.DexMethod;
-import com.android.tools.r8.ir.synthetic.TemplateMethodCode;
-import com.android.tools.r8.utils.InternalOptions;
-
-public final class DoubleMethods extends TemplateMethodCode {
- public DoubleMethods(InternalOptions options, DexMethod method, String methodName) {
- super(options, method, methodName, method.proto.toDescriptorString());
- }
-
- public static int hashCode(double d) {
- long l = Double.doubleToLongBits(d);
- return (int) (l ^ (l >>> 32));
- }
-
- public static boolean isFinite(double d) {
- return !Double.isInfinite(d) && !Double.isNaN(d);
- }
-}
diff --git a/src/main/java/com/android/tools/r8/ir/desugar/backports/FloatMethods.java b/src/main/java/com/android/tools/r8/ir/desugar/backports/FloatMethods.java
deleted file mode 100644
index eb545d9..0000000
--- a/src/main/java/com/android/tools/r8/ir/desugar/backports/FloatMethods.java
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright (c) 2019, the R8 project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-package com.android.tools.r8.ir.desugar.backports;
-
-import com.android.tools.r8.graph.DexMethod;
-import com.android.tools.r8.ir.synthetic.TemplateMethodCode;
-import com.android.tools.r8.utils.InternalOptions;
-
-public final class FloatMethods extends TemplateMethodCode {
- public FloatMethods(InternalOptions options, DexMethod method, String methodName) {
- super(options, method, methodName, method.proto.toDescriptorString());
- }
-
- public static int hashCode(float f) {
- return Float.floatToIntBits(f);
- }
-
- public static boolean isFinite(float f) {
- return !Float.isInfinite(f) && !Float.isNaN(f);
- }
-}
diff --git a/src/main/java/com/android/tools/r8/ir/desugar/backports/ListMethodRewrites.java b/src/main/java/com/android/tools/r8/ir/desugar/backports/ListMethodRewrites.java
new file mode 100644
index 0000000..c3245d8
--- /dev/null
+++ b/src/main/java/com/android/tools/r8/ir/desugar/backports/ListMethodRewrites.java
@@ -0,0 +1,28 @@
+// Copyright (c) 2019, the R8 project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+package com.android.tools.r8.ir.desugar.backports;
+
+import com.android.tools.r8.graph.DexItemFactory;
+import com.android.tools.r8.graph.DexMethod;
+import com.android.tools.r8.ir.code.InstructionListIterator;
+import com.android.tools.r8.ir.code.InvokeMethod;
+import com.android.tools.r8.ir.code.InvokeStatic;
+import java.util.Collections;
+
+public final class ListMethodRewrites {
+
+ private ListMethodRewrites() {}
+
+ public static void rewriteEmptyOf(
+ InvokeMethod invoke, InstructionListIterator iterator, DexItemFactory factory) {
+ assert invoke.inValues().isEmpty();
+
+ DexMethod collectionsEmptyList =
+ factory.createMethod(factory.collectionsType, invoke.getInvokedMethod().proto, "emptyList");
+ InvokeStatic newInvoke =
+ new InvokeStatic(collectionsEmptyList, invoke.outValue(), Collections.emptyList());
+ iterator.replaceCurrentInstruction(newInvoke);
+ }
+}
diff --git a/src/main/java/com/android/tools/r8/ir/desugar/backports/LongMethodRewrites.java b/src/main/java/com/android/tools/r8/ir/desugar/backports/LongMethodRewrites.java
new file mode 100644
index 0000000..b842b71
--- /dev/null
+++ b/src/main/java/com/android/tools/r8/ir/desugar/backports/LongMethodRewrites.java
@@ -0,0 +1,27 @@
+// Copyright (c) 2019, the R8 project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+package com.android.tools.r8.ir.desugar.backports;
+
+import com.android.tools.r8.graph.DexItemFactory;
+import com.android.tools.r8.ir.code.Cmp;
+import com.android.tools.r8.ir.code.Cmp.Bias;
+import com.android.tools.r8.ir.code.InstructionListIterator;
+import com.android.tools.r8.ir.code.InvokeMethod;
+import com.android.tools.r8.ir.code.NumericType;
+import com.android.tools.r8.ir.code.Value;
+import java.util.List;
+
+public final class LongMethodRewrites {
+
+ private LongMethodRewrites() {}
+
+ public static void rewriteCompare(
+ InvokeMethod invoke, InstructionListIterator iterator, DexItemFactory factory) {
+ List<Value> inValues = invoke.inValues();
+ assert inValues.size() == 2;
+ iterator.replaceCurrentInstruction(
+ new Cmp(NumericType.LONG, Bias.NONE, invoke.outValue(), inValues.get(0), inValues.get(1)));
+ }
+}
diff --git a/src/main/java/com/android/tools/r8/ir/desugar/backports/ByteMethods.java b/src/test/java/com/android/tools/r8/ir/desugar/backports/ByteMethods.java
similarity index 63%
rename from src/main/java/com/android/tools/r8/ir/desugar/backports/ByteMethods.java
rename to src/test/java/com/android/tools/r8/ir/desugar/backports/ByteMethods.java
index dc1b630..6aaa078 100644
--- a/src/main/java/com/android/tools/r8/ir/desugar/backports/ByteMethods.java
+++ b/src/test/java/com/android/tools/r8/ir/desugar/backports/ByteMethods.java
@@ -4,14 +4,7 @@
package com.android.tools.r8.ir.desugar.backports;
-import com.android.tools.r8.graph.DexMethod;
-import com.android.tools.r8.ir.synthetic.TemplateMethodCode;
-import com.android.tools.r8.utils.InternalOptions;
-
-public final class ByteMethods extends TemplateMethodCode {
- public ByteMethods(InternalOptions options, DexMethod method, String methodName) {
- super(options, method, methodName, method.proto.toDescriptorString());
- }
+public final class ByteMethods {
public static int hashCode(byte i) {
return i;
diff --git a/src/test/java/com/android/tools/r8/ir/desugar/backports/CharacterMethods.java b/src/test/java/com/android/tools/r8/ir/desugar/backports/CharacterMethods.java
new file mode 100644
index 0000000..ea21398
--- /dev/null
+++ b/src/test/java/com/android/tools/r8/ir/desugar/backports/CharacterMethods.java
@@ -0,0 +1,20 @@
+// Copyright (c) 2019, the R8 project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+package com.android.tools.r8.ir.desugar.backports;
+
+public final class CharacterMethods {
+
+ public static int hashCode(char i) {
+ return i;
+ }
+
+ public static int compare(char a, char b) {
+ return (int) a - (int) b;
+ }
+
+ public static String toStringCodepoint(int codepoint) {
+ return new String(Character.toChars(codepoint));
+ }
+}
diff --git a/src/main/java/com/android/tools/r8/ir/desugar/backports/CollectionsMethods.java b/src/test/java/com/android/tools/r8/ir/desugar/backports/CollectionsMethods.java
similarity index 65%
rename from src/main/java/com/android/tools/r8/ir/desugar/backports/CollectionsMethods.java
rename to src/test/java/com/android/tools/r8/ir/desugar/backports/CollectionsMethods.java
index 1083ac1..dd300da 100644
--- a/src/main/java/com/android/tools/r8/ir/desugar/backports/CollectionsMethods.java
+++ b/src/test/java/com/android/tools/r8/ir/desugar/backports/CollectionsMethods.java
@@ -4,18 +4,12 @@
package com.android.tools.r8.ir.desugar.backports;
-import com.android.tools.r8.graph.DexMethod;
-import com.android.tools.r8.ir.synthetic.TemplateMethodCode;
-import com.android.tools.r8.utils.InternalOptions;
import java.util.Collections;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.ListIterator;
-public final class CollectionsMethods extends TemplateMethodCode {
- public CollectionsMethods(InternalOptions options, DexMethod method, String methodName) {
- super(options, method, methodName, method.proto.toDescriptorString());
- }
+public final class CollectionsMethods {
public static <T> Enumeration<T> emptyEnumeration() {
return Collections.enumeration(Collections.emptyList());
diff --git a/src/test/java/com/android/tools/r8/ir/desugar/backports/DoubleMethods.java b/src/test/java/com/android/tools/r8/ir/desugar/backports/DoubleMethods.java
new file mode 100644
index 0000000..4ab814f
--- /dev/null
+++ b/src/test/java/com/android/tools/r8/ir/desugar/backports/DoubleMethods.java
@@ -0,0 +1,17 @@
+// Copyright (c) 2019, the R8 project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+package com.android.tools.r8.ir.desugar.backports;
+
+public final class DoubleMethods {
+
+ public static int hashCode(double d) {
+ long l = Double.doubleToLongBits(d);
+ return (int) (l ^ (l >>> 32));
+ }
+
+ public static boolean isFinite(double d) {
+ return !Double.isInfinite(d) && !Double.isNaN(d);
+ }
+}
diff --git a/src/test/java/com/android/tools/r8/ir/desugar/backports/FloatMethods.java b/src/test/java/com/android/tools/r8/ir/desugar/backports/FloatMethods.java
new file mode 100644
index 0000000..3b4932f
--- /dev/null
+++ b/src/test/java/com/android/tools/r8/ir/desugar/backports/FloatMethods.java
@@ -0,0 +1,16 @@
+// Copyright (c) 2019, the R8 project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+package com.android.tools.r8.ir.desugar.backports;
+
+public final class FloatMethods {
+
+ public static int hashCode(float f) {
+ return Float.floatToIntBits(f);
+ }
+
+ public static boolean isFinite(float f) {
+ return !Float.isInfinite(f) && !Float.isNaN(f);
+ }
+}
diff --git a/src/test/java/com/android/tools/r8/ir/desugar/backports/GenerateBackportMethods.java b/src/test/java/com/android/tools/r8/ir/desugar/backports/GenerateBackportMethods.java
index 2309fee..62049c3 100644
--- a/src/test/java/com/android/tools/r8/ir/desugar/backports/GenerateBackportMethods.java
+++ b/src/test/java/com/android/tools/r8/ir/desugar/backports/GenerateBackportMethods.java
@@ -28,6 +28,7 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
+import java.util.ArrayList;
import java.util.List;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -67,7 +68,21 @@
"package com.android.tools.r8.ir.desugar.backports;");
static final List<Class<?>> methodTemplateClasses =
- ImmutableList.of(BooleanMethods.class, ObjectsMethods.class, StringMethods.class);
+ ImmutableList.of(
+ BooleanMethods.class,
+ ByteMethods.class,
+ CharacterMethods.class,
+ CollectionsMethods.class,
+ DoubleMethods.class,
+ FloatMethods.class,
+ IntegerMethods.class,
+ ListMethods.class,
+ LongMethods.class,
+ MathMethods.class,
+ ObjectsMethods.class,
+ OptionalMethods.class,
+ ShortMethods.class,
+ StringMethods.class);
final TestParameters parameters;
@@ -82,6 +97,9 @@
@Test
public void test() throws Exception {
+ ArrayList<Class<?>> sorted = new ArrayList<>(methodTemplateClasses);
+ sorted.sort((a, b) -> a.getTypeName().compareTo(b.getTypeName()));
+ assertEquals("Classes should be listed in sorted order", sorted, methodTemplateClasses);
assertEquals(
FileUtils.readTextFile(backportMethodsFile, StandardCharsets.UTF_8),
generateBackportMethods());
diff --git a/src/main/java/com/android/tools/r8/ir/desugar/backports/IntegerMethods.java b/src/test/java/com/android/tools/r8/ir/desugar/backports/IntegerMethods.java
similarity index 83%
rename from src/main/java/com/android/tools/r8/ir/desugar/backports/IntegerMethods.java
rename to src/test/java/com/android/tools/r8/ir/desugar/backports/IntegerMethods.java
index 5c1a8d5..8cc53b7 100644
--- a/src/main/java/com/android/tools/r8/ir/desugar/backports/IntegerMethods.java
+++ b/src/test/java/com/android/tools/r8/ir/desugar/backports/IntegerMethods.java
@@ -4,14 +4,7 @@
package com.android.tools.r8.ir.desugar.backports;
-import com.android.tools.r8.graph.DexMethod;
-import com.android.tools.r8.ir.synthetic.TemplateMethodCode;
-import com.android.tools.r8.utils.InternalOptions;
-
-public final class IntegerMethods extends TemplateMethodCode {
- public IntegerMethods(InternalOptions options, DexMethod method, String methodName) {
- super(options, method, methodName, method.proto.toDescriptorString());
- }
+public final class IntegerMethods {
public static int hashCode(int i) {
return i;
diff --git a/src/main/java/com/android/tools/r8/ir/desugar/backports/ListMethods.java b/src/test/java/com/android/tools/r8/ir/desugar/backports/ListMethods.java
similarity index 61%
rename from src/main/java/com/android/tools/r8/ir/desugar/backports/ListMethods.java
rename to src/test/java/com/android/tools/r8/ir/desugar/backports/ListMethods.java
index d5ca043..51f8d11 100644
--- a/src/main/java/com/android/tools/r8/ir/desugar/backports/ListMethods.java
+++ b/src/test/java/com/android/tools/r8/ir/desugar/backports/ListMethods.java
@@ -4,37 +4,26 @@
package com.android.tools.r8.ir.desugar.backports;
-import com.android.tools.r8.graph.DexItemFactory;
-import com.android.tools.r8.graph.DexMethod;
-import com.android.tools.r8.ir.code.InstructionListIterator;
-import com.android.tools.r8.ir.code.InvokeMethod;
-import com.android.tools.r8.ir.code.InvokeStatic;
-import com.android.tools.r8.ir.synthetic.TemplateMethodCode;
-import com.android.tools.r8.utils.InternalOptions;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
-public class ListMethods extends TemplateMethodCode {
+public class ListMethods {
- public ListMethods(InternalOptions options, DexMethod method, String methodName) {
- super(options, method, methodName, method.proto.toDescriptorString());
- }
-
- public static <E> List<E> of(E e0) {
+ public static <E> List<E> of1(E e0) {
return Collections.singletonList(Objects.requireNonNull(e0));
}
- public static <E> List<E> of(E e0, E e1) {
+ public static <E> List<E> of2(E e0, E e1) {
return Collections.unmodifiableList(
Arrays.asList(
Objects.requireNonNull(e0),
Objects.requireNonNull(e1)));
}
- public static <E> List<E> of(E e0, E e1, E e2) {
+ public static <E> List<E> of3(E e0, E e1, E e2) {
return Collections.unmodifiableList(
Arrays.asList(
Objects.requireNonNull(e0),
@@ -42,7 +31,7 @@
Objects.requireNonNull(e2)));
}
- public static <E> List<E> of(E e0, E e1, E e2, E e3) {
+ public static <E> List<E> of4(E e0, E e1, E e2, E e3) {
return Collections.unmodifiableList(
Arrays.asList(
Objects.requireNonNull(e0),
@@ -51,7 +40,7 @@
Objects.requireNonNull(e3)));
}
- public static <E> List<E> of(E e0, E e1, E e2, E e3, E e4) {
+ public static <E> List<E> of5(E e0, E e1, E e2, E e3, E e4) {
return Collections.unmodifiableList(
Arrays.asList(
Objects.requireNonNull(e0),
@@ -61,7 +50,7 @@
Objects.requireNonNull(e4)));
}
- public static <E> List<E> of(E e0, E e1, E e2, E e3, E e4, E e5) {
+ public static <E> List<E> of6(E e0, E e1, E e2, E e3, E e4, E e5) {
return Collections.unmodifiableList(
Arrays.asList(
Objects.requireNonNull(e0),
@@ -72,7 +61,7 @@
Objects.requireNonNull(e5)));
}
- public static <E> List<E> of(E e0, E e1, E e2, E e3, E e4, E e5, E e6) {
+ public static <E> List<E> of7(E e0, E e1, E e2, E e3, E e4, E e5, E e6) {
return Collections.unmodifiableList(
Arrays.asList(
Objects.requireNonNull(e0),
@@ -84,7 +73,7 @@
Objects.requireNonNull(e6)));
}
- public static <E> List<E> of(E e0, E e1, E e2, E e3, E e4, E e5, E e6, E e7) {
+ public static <E> List<E> of8(E e0, E e1, E e2, E e3, E e4, E e5, E e6, E e7) {
return Collections.unmodifiableList(
Arrays.asList(
Objects.requireNonNull(e0),
@@ -97,7 +86,7 @@
Objects.requireNonNull(e7)));
}
- public static <E> List<E> of(E e0, E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8) {
+ public static <E> List<E> of9(E e0, E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8) {
return Collections.unmodifiableList(
Arrays.asList(
Objects.requireNonNull(e0),
@@ -111,7 +100,7 @@
Objects.requireNonNull(e8)));
}
- public static <E> List<E> of(E e0, E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8, E e9) {
+ public static <E> List<E> of10(E e0, E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8, E e9) {
return Collections.unmodifiableList(
Arrays.asList(
Objects.requireNonNull(e0),
@@ -126,22 +115,6 @@
Objects.requireNonNull(e9)));
}
- public static <E> List<E> of(E e0, E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8, E e9, E e10) {
- return Collections.unmodifiableList(
- Arrays.asList(
- Objects.requireNonNull(e0),
- Objects.requireNonNull(e1),
- Objects.requireNonNull(e2),
- Objects.requireNonNull(e3),
- Objects.requireNonNull(e4),
- Objects.requireNonNull(e5),
- Objects.requireNonNull(e6),
- Objects.requireNonNull(e7),
- Objects.requireNonNull(e8),
- Objects.requireNonNull(e9),
- Objects.requireNonNull(e10)));
- }
-
public static <E> List<E> ofArray(E[] elements) {
// TODO(140709356): The other overloads should call into this method to ensure consistent
// behavior, but we cannot link against List.of(E[]) because it's only available in Java 9.
@@ -151,15 +124,4 @@
}
return Collections.unmodifiableList(list);
}
-
- public static void rewriteEmptyOf(InvokeMethod invoke, InstructionListIterator iterator,
- DexItemFactory factory) {
- assert invoke.inValues().isEmpty();
-
- DexMethod collectionsEmptyList =
- factory.createMethod(factory.collectionsType, invoke.getInvokedMethod().proto, "emptyList");
- InvokeStatic newInvoke =
- new InvokeStatic(collectionsEmptyList, invoke.outValue(), Collections.emptyList());
- iterator.replaceCurrentInstruction(newInvoke);
- }
}
diff --git a/src/main/java/com/android/tools/r8/ir/desugar/backports/LongMethods.java b/src/test/java/com/android/tools/r8/ir/desugar/backports/LongMethods.java
similarity index 86%
rename from src/main/java/com/android/tools/r8/ir/desugar/backports/LongMethods.java
rename to src/test/java/com/android/tools/r8/ir/desugar/backports/LongMethods.java
index 8ed48b3..643d295 100644
--- a/src/main/java/com/android/tools/r8/ir/desugar/backports/LongMethods.java
+++ b/src/test/java/com/android/tools/r8/ir/desugar/backports/LongMethods.java
@@ -4,22 +4,7 @@
package com.android.tools.r8.ir.desugar.backports;
-import com.android.tools.r8.graph.DexItemFactory;
-import com.android.tools.r8.graph.DexMethod;
-import com.android.tools.r8.ir.code.Cmp;
-import com.android.tools.r8.ir.code.Cmp.Bias;
-import com.android.tools.r8.ir.code.InstructionListIterator;
-import com.android.tools.r8.ir.code.InvokeMethod;
-import com.android.tools.r8.ir.code.NumericType;
-import com.android.tools.r8.ir.code.Value;
-import com.android.tools.r8.ir.synthetic.TemplateMethodCode;
-import com.android.tools.r8.utils.InternalOptions;
-import java.util.List;
-
-public final class LongMethods extends TemplateMethodCode {
- public LongMethods(InternalOptions options, DexMethod method, String methodName) {
- super(options, method, methodName, method.proto.toDescriptorString());
- }
+public final class LongMethods {
public static int hashCode(long l) {
return (int) (l ^ (l >>> 32));
@@ -194,12 +179,4 @@
return new String(buf, i, buf.length - i);
}
}
-
- public static void rewriteCompare(InvokeMethod invoke, InstructionListIterator iterator,
- DexItemFactory factory) {
- List<Value> inValues = invoke.inValues();
- assert inValues.size() == 2;
- iterator.replaceCurrentInstruction(
- new Cmp(NumericType.LONG, Bias.NONE, invoke.outValue(), inValues.get(0), inValues.get(1)));
- }
}
diff --git a/src/main/java/com/android/tools/r8/ir/desugar/backports/MathMethods.java b/src/test/java/com/android/tools/r8/ir/desugar/backports/MathMethods.java
similarity index 94%
rename from src/main/java/com/android/tools/r8/ir/desugar/backports/MathMethods.java
rename to src/test/java/com/android/tools/r8/ir/desugar/backports/MathMethods.java
index 394823f..2f112ab 100644
--- a/src/main/java/com/android/tools/r8/ir/desugar/backports/MathMethods.java
+++ b/src/test/java/com/android/tools/r8/ir/desugar/backports/MathMethods.java
@@ -4,14 +4,7 @@
package com.android.tools.r8.ir.desugar.backports;
-import com.android.tools.r8.graph.DexMethod;
-import com.android.tools.r8.ir.synthetic.TemplateMethodCode;
-import com.android.tools.r8.utils.InternalOptions;
-
-public final class MathMethods extends TemplateMethodCode {
- public MathMethods(InternalOptions options, DexMethod method, String methodName) {
- super(options, method, methodName, method.proto.toDescriptorString());
- }
+public final class MathMethods {
public static int addExactInt(int x, int y) {
long longResult = (long) x + y;
diff --git a/src/main/java/com/android/tools/r8/ir/desugar/backports/OptionalMethods.java b/src/test/java/com/android/tools/r8/ir/desugar/backports/OptionalMethods.java
similarity index 80%
rename from src/main/java/com/android/tools/r8/ir/desugar/backports/OptionalMethods.java
rename to src/test/java/com/android/tools/r8/ir/desugar/backports/OptionalMethods.java
index 87e6053..43c749a 100644
--- a/src/main/java/com/android/tools/r8/ir/desugar/backports/OptionalMethods.java
+++ b/src/test/java/com/android/tools/r8/ir/desugar/backports/OptionalMethods.java
@@ -4,9 +4,6 @@
package com.android.tools.r8.ir.desugar.backports;
-import com.android.tools.r8.graph.DexMethod;
-import com.android.tools.r8.ir.synthetic.TemplateMethodCode;
-import com.android.tools.r8.utils.InternalOptions;
import java.util.Objects;
import java.util.Optional;
import java.util.OptionalDouble;
@@ -19,11 +16,7 @@
import java.util.function.Supplier;
import java.util.stream.Stream;
-public class OptionalMethods extends TemplateMethodCode {
-
- public OptionalMethods(InternalOptions options, DexMethod method, String methodName) {
- super(options, method, methodName, method.proto.toDescriptorString());
- }
+public class OptionalMethods {
public static <T> Optional<T> or(
Optional<T> receiver, Supplier<? extends Optional<? extends T>> supplier) {
@@ -46,7 +39,7 @@
}
}
- public static void ifPresentOrElse(
+ public static void ifPresentOrElseInt(
OptionalInt receiver, IntConsumer action, Runnable emptyAction) {
if (receiver.isPresent()) {
action.accept(receiver.getAsInt());
@@ -55,7 +48,7 @@
}
}
- public static void ifPresentOrElse(
+ public static void ifPresentOrElseLong(
OptionalLong receiver, LongConsumer action, Runnable emptyAction) {
if (receiver.isPresent()) {
action.accept(receiver.getAsLong());
@@ -64,7 +57,7 @@
}
}
- public static void ifPresentOrElse(
+ public static void ifPresentOrElseDouble(
OptionalDouble receiver, DoubleConsumer action, Runnable emptyAction) {
if (receiver.isPresent()) {
action.accept(receiver.getAsDouble());
diff --git a/src/main/java/com/android/tools/r8/ir/desugar/backports/ShortMethods.java b/src/test/java/com/android/tools/r8/ir/desugar/backports/ShortMethods.java
similarity index 63%
rename from src/main/java/com/android/tools/r8/ir/desugar/backports/ShortMethods.java
rename to src/test/java/com/android/tools/r8/ir/desugar/backports/ShortMethods.java
index bea7dd3..23fadb4 100644
--- a/src/main/java/com/android/tools/r8/ir/desugar/backports/ShortMethods.java
+++ b/src/test/java/com/android/tools/r8/ir/desugar/backports/ShortMethods.java
@@ -4,14 +4,7 @@
package com.android.tools.r8.ir.desugar.backports;
-import com.android.tools.r8.graph.DexMethod;
-import com.android.tools.r8.ir.synthetic.TemplateMethodCode;
-import com.android.tools.r8.utils.InternalOptions;
-
-public final class ShortMethods extends TemplateMethodCode {
- public ShortMethods(InternalOptions options, DexMethod method, String methodName) {
- super(options, method, methodName, method.proto.toDescriptorString());
- }
+public final class ShortMethods {
public static int hashCode(short i) {
return i;