mirror of
https://github.com/revanced/smali.git
synced 2025-05-21 16:37:04 +02:00
- Added accessors for encoded arrays
- Fixes a couple of issues with the way static field initializers were being handled git-svn-id: https://smali.googlecode.com/svn/trunk@156 55b6fa8a-2a1e-11de-a435-ffa8d773f76a
This commit is contained in:
parent
ec90e0d1a4
commit
5118f3aa29
@ -96,13 +96,21 @@ public class ClassDataItem extends OffsettedItem<ClassDataItem> {
|
|||||||
|
|
||||||
public int addField(EncodedField encodedField) {
|
public int addField(EncodedField encodedField) {
|
||||||
if (encodedField.isStatic()) {
|
if (encodedField.isStatic()) {
|
||||||
staticFieldList.add(encodedField);
|
int index = Collections.binarySearch(staticFieldList, encodedField);
|
||||||
Collections.sort(staticFieldList);
|
if (index >= 0) {
|
||||||
return Collections.binarySearch(staticFieldList, encodedField);
|
throw new RuntimeException("A static field of that name and type is already present");
|
||||||
|
}
|
||||||
|
index = (index + 1) * -1;
|
||||||
|
staticFieldList.add(index, encodedField);
|
||||||
|
return index;
|
||||||
} else {
|
} else {
|
||||||
instanceFieldList.add(encodedField);
|
int index = Collections.binarySearch(instanceFieldList, encodedField);
|
||||||
Collections.sort(instanceFieldList);
|
if (index >= 0) {
|
||||||
return Collections.binarySearch(instanceFieldList, encodedField);
|
throw new RuntimeException("An instance field of that name and type is already present");
|
||||||
|
}
|
||||||
|
index = (index + 1) * -1;
|
||||||
|
instanceFieldList.add(index, encodedField);
|
||||||
|
return index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,6 +146,10 @@ public class ClassDefItem extends IndexedItem<ClassDefItem> {
|
|||||||
return classTypeReferenceField.equals(other.classTypeReferenceField);
|
return classTypeReferenceField.equals(other.classTypeReferenceField);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public EncodedArrayItem getStaticInitializers() {
|
||||||
|
return staticFieldInitialValuesReferenceField.getReference();
|
||||||
|
}
|
||||||
|
|
||||||
public int compareTo(ClassDefItem o) {
|
public int compareTo(ClassDefItem o) {
|
||||||
//sorting is implemented in SortClassDefItemSection, so this class doesn't
|
//sorting is implemented in SortClassDefItemSection, so this class doesn't
|
||||||
//need an implementation of compareTo
|
//need an implementation of compareTo
|
||||||
@ -180,6 +184,11 @@ public class ClassDefItem extends IndexedItem<ClassDefItem> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
staticFieldInitialValuesList.add(fieldIndex, initialValue);
|
staticFieldInitialValuesList.add(fieldIndex, initialValue);
|
||||||
|
} else if (staticFieldInitialValuesList != null && encodedField.isStatic() && fieldIndex < staticFieldInitialValuesList.size()) {
|
||||||
|
EncodedValueSubField subField = TypeUtils.makeDefaultValueForType(dexFile,
|
||||||
|
encodedField.getFieldReference().getFieldType().getTypeDescriptor());
|
||||||
|
EncodedValue encodedValue = new EncodedValue(dexFile, subField);
|
||||||
|
staticFieldInitialValuesList.add(fieldIndex, encodedValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,6 +35,7 @@ import org.jf.dexlib.util.Input;
|
|||||||
import org.jf.dexlib.util.AnnotatedOutput;
|
import org.jf.dexlib.util.AnnotatedOutput;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class EncodedArrayItem extends OffsettedItem<EncodedArrayItem> {
|
public class EncodedArrayItem extends OffsettedItem<EncodedArrayItem> {
|
||||||
private final ArrayEncodedValueSubField encodedArray;
|
private final ArrayEncodedValueSubField encodedArray;
|
||||||
@ -86,4 +87,8 @@ public class EncodedArrayItem extends OffsettedItem<EncodedArrayItem> {
|
|||||||
public String getConciseIdentity() {
|
public String getConciseIdentity() {
|
||||||
return "encoded_array @0x" + Integer.toHexString(getOffset());
|
return "encoded_array @0x" + Integer.toHexString(getOffset());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ArrayEncodedValueSubField getEncodedArray() {
|
||||||
|
return encodedArray;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,7 @@ package org.jf.dexlib.EncodedValue;
|
|||||||
import org.jf.dexlib.*;
|
import org.jf.dexlib.*;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class ArrayEncodedValueSubField extends CompositeField<ArrayEncodedValueSubField>
|
public class ArrayEncodedValueSubField extends CompositeField<ArrayEncodedValueSubField>
|
||||||
implements EncodedValueSubField<ArrayEncodedValueSubField>
|
implements EncodedValueSubField<ArrayEncodedValueSubField>
|
||||||
@ -82,4 +83,8 @@ public class ArrayEncodedValueSubField extends CompositeField<ArrayEncodedValueS
|
|||||||
public void add(int index, EncodedValue encodedValue) {
|
public void add(int index, EncodedValue encodedValue) {
|
||||||
encodedValues.add(index, encodedValue);
|
encodedValues.add(index, encodedValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<EncodedValue> getValues() {
|
||||||
|
return (List<EncodedValue>)encodedValues.clone();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -175,4 +175,8 @@ public class EncodedValue extends CompositeField<EncodedValue> {
|
|||||||
public byte getValueArg() {
|
public byte getValueArg() {
|
||||||
return valueTypeArg.getValueArg();
|
return valueTypeArg.getValueArg();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public EncodedValueSubField getValue() {
|
||||||
|
return encodedValue.getEncodedValueSubField();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,6 +36,7 @@ public class IntEncodedValueSubField
|
|||||||
extends SimpleEncodedValueSubField<Integer, IntEncodedValueSubField>
|
extends SimpleEncodedValueSubField<Integer, IntEncodedValueSubField>
|
||||||
{
|
{
|
||||||
public IntEncodedValueSubField() {
|
public IntEncodedValueSubField() {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IntEncodedValueSubField(int value) {
|
public IntEncodedValueSubField(int value) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user