mirror of
https://github.com/revanced/smali.git
synced 2025-05-05 09:04:25 +02:00
Fix up makeDefaultValueForType method
1. Remove the unused DexFile parameter 2. Add a convenience wrapper that accepts a TypeIdItem
This commit is contained in:
parent
662e425150
commit
0d2ce20ee4
@ -359,8 +359,8 @@ public class ClassDefItem extends Item<ClassDefItem> {
|
|||||||
StaticFieldInitializer staticFieldInitializer = staticFieldInitializers.get(i);
|
StaticFieldInitializer staticFieldInitializer = staticFieldInitializers.get(i);
|
||||||
|
|
||||||
if (staticFieldInitializer.value != null &&
|
if (staticFieldInitializer.value != null &&
|
||||||
(staticFieldInitializer.value.compareTo(TypeUtils.makeDefaultValueForType(dexFile,
|
(staticFieldInitializer.value.compareTo(TypeUtils.makeDefaultValueForType(
|
||||||
staticFieldInitializer.field.field.getFieldType().getTypeDescriptor())) != 0)) {
|
staticFieldInitializer.field.field.getFieldType())) != 0)) {
|
||||||
lastIndex = i;
|
lastIndex = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -377,8 +377,7 @@ public class ClassDefItem extends Item<ClassDefItem> {
|
|||||||
StaticFieldInitializer staticFieldInitializer = staticFieldInitializers.get(i);
|
StaticFieldInitializer staticFieldInitializer = staticFieldInitializers.get(i);
|
||||||
EncodedValue encodedValue = staticFieldInitializer.value;
|
EncodedValue encodedValue = staticFieldInitializer.value;
|
||||||
if (encodedValue == null) {
|
if (encodedValue == null) {
|
||||||
encodedValue = TypeUtils.makeDefaultValueForType(dexFile,
|
encodedValue = TypeUtils.makeDefaultValueForType(staticFieldInitializer.field.field.getFieldType());
|
||||||
staticFieldInitializer.field.field.getFieldType().getTypeDescriptor());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
values[i] = encodedValue;
|
values[i] = encodedValue;
|
||||||
|
@ -28,13 +28,12 @@
|
|||||||
|
|
||||||
package org.jf.dexlib.Util;
|
package org.jf.dexlib.Util;
|
||||||
|
|
||||||
import org.jf.dexlib.DexFile;
|
|
||||||
import org.jf.dexlib.EncodedValue.*;
|
import org.jf.dexlib.EncodedValue.*;
|
||||||
|
import org.jf.dexlib.TypeIdItem;
|
||||||
|
|
||||||
public class TypeUtils
|
public class TypeUtils
|
||||||
{
|
{
|
||||||
public static EncodedValue makeDefaultValueForType(DexFile dexFile, String type) {
|
public static EncodedValue makeDefaultValueForType(String type) {
|
||||||
EncodedValue subField;
|
|
||||||
switch (type.charAt(0)) {
|
switch (type.charAt(0)) {
|
||||||
case 'Z':
|
case 'Z':
|
||||||
return BooleanEncodedValue.FalseValue;
|
return BooleanEncodedValue.FalseValue;
|
||||||
@ -58,4 +57,8 @@ public class TypeUtils
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static EncodedValue makeDefaultValueForType(TypeIdItem type) {
|
||||||
|
return makeDefaultValueForType(type.getTypeDescriptor());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user