mirror of
https://github.com/revanced/smali.git
synced 2025-05-29 04:10:13 +02:00
Misc cleanup
git-svn-id: https://smali.googlecode.com/svn/trunk@201 55b6fa8a-2a1e-11de-a435-ffa8d773f76a
This commit is contained in:
parent
b797aa581a
commit
ed91584410
@ -114,27 +114,21 @@ public class ClassDataItem extends OffsettedItem<ClassDataItem> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<EncodedField> getStaticFields() {
|
public List<EncodedField> getStaticFields() {
|
||||||
return (List<EncodedField>)staticFieldList.clone();
|
return Collections.unmodifiableList(staticFieldList);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<EncodedField> getInstanceFields() {
|
public List<EncodedField> getInstanceFields() {
|
||||||
return (List<EncodedField>)instanceFieldList.clone();
|
return Collections.unmodifiableList(instanceFieldList);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<EncodedMethod> getDirectMethods() {
|
public List<EncodedMethod> getDirectMethods() {
|
||||||
return (List<EncodedMethod>)directMethodList.clone();
|
return Collections.unmodifiableList(directMethodList);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<EncodedMethod> getVirtualMethods() {
|
public List<EncodedMethod> getVirtualMethods() {
|
||||||
return (List<EncodedMethod>)virtualMethodList.clone();
|
return Collections.unmodifiableList(virtualMethodList);
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: GROT
|
|
||||||
public EncodedField getStaticFieldAtIndex(int i)
|
|
||||||
{
|
|
||||||
return staticFieldList.get(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static abstract class EncodedMember<T extends EncodedMember<T>> extends CompositeField<T> implements Field<T>, Comparable<T>
|
private static abstract class EncodedMember<T extends EncodedMember<T>> extends CompositeField<T> implements Field<T>, Comparable<T>
|
||||||
{
|
{
|
||||||
public EncodedMember(String fieldName) {
|
public EncodedMember(String fieldName) {
|
||||||
|
@ -187,7 +187,7 @@ public class ClassDefItem extends IndexedItem<ClassDefItem> {
|
|||||||
|
|
||||||
//All static fields before this one must have an initial value. Add any default values as needed
|
//All static fields before this one must have an initial value. Add any default values as needed
|
||||||
for (int i=staticFieldInitialValuesList.size(); i < fieldIndex; i++) {
|
for (int i=staticFieldInitialValuesList.size(); i < fieldIndex; i++) {
|
||||||
ClassDataItem.EncodedField staticField = classDataItem.getStaticFieldAtIndex(i);
|
ClassDataItem.EncodedField staticField = classDataItem.getStaticFields().get(i);
|
||||||
EncodedValueSubField subField = TypeUtils.makeDefaultValueForType(dexFile,
|
EncodedValueSubField subField = TypeUtils.makeDefaultValueForType(dexFile,
|
||||||
staticField.getField().getFieldType().getTypeDescriptor());
|
staticField.getField().getFieldType().getTypeDescriptor());
|
||||||
EncodedValue encodedValue = new EncodedValue(dexFile, subField);
|
EncodedValue encodedValue = new EncodedValue(dexFile, subField);
|
||||||
@ -207,6 +207,10 @@ public class ClassDefItem extends IndexedItem<ClassDefItem> {
|
|||||||
this.classAnnotationsReferenceField.setReference(annotations);
|
this.classAnnotationsReferenceField.setReference(annotations);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setClassDataItem(ClassDataItem classDataItem) {
|
||||||
|
this.classDataReferenceField.setReference(classDataItem);
|
||||||
|
}
|
||||||
|
|
||||||
public static int placeClassDefItems(IndexedSection<ClassDefItem> section, int offset) {
|
public static int placeClassDefItems(IndexedSection<ClassDefItem> section, int offset) {
|
||||||
ClassDefPlacer cdp = new ClassDefPlacer(section);
|
ClassDefPlacer cdp = new ClassDefPlacer(section);
|
||||||
return cdp.placeSection(offset);
|
return cdp.placeSection(offset);
|
||||||
|
@ -126,6 +126,14 @@ smali_file
|
|||||||
}
|
}
|
||||||
|
|
||||||
classDefItem.setAnnotations(annotationDirectoryItem);
|
classDefItem.setAnnotations(annotationDirectoryItem);
|
||||||
|
|
||||||
|
if ((classDataItem.getStaticFields().size() +
|
||||||
|
classDataItem.getInstanceFields().size() +
|
||||||
|
classDataItem.getDirectMethods().size() +
|
||||||
|
classDataItem.getVirtualMethods().size()) == 0) {
|
||||||
|
|
||||||
|
classDefItem.setClassDataItem(null);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
catch [Exception ex] {
|
catch [Exception ex] {
|
||||||
reportError(new SemanticException(input, ex));
|
reportError(new SemanticException(input, ex));
|
||||||
@ -136,7 +144,6 @@ smali_file
|
|||||||
header returns[TypeIdItem classType, int accessFlags, TypeIdItem superType, TypeListItem implementsList, StringIdItem sourceSpec]
|
header returns[TypeIdItem classType, int accessFlags, TypeIdItem superType, TypeListItem implementsList, StringIdItem sourceSpec]
|
||||||
: class_spec super_spec implements_list source_spec
|
: class_spec super_spec implements_list source_spec
|
||||||
{
|
{
|
||||||
//TODO: if a class has no fields or methods, it shouldn't have a ClassDataItem
|
|
||||||
classDataItem = new ClassDataItem(dexFile, 0);
|
classDataItem = new ClassDataItem(dexFile, 0);
|
||||||
classDefItem = new ClassDefItem(dexFile, $class_spec.type, $class_spec.accessFlags,
|
classDefItem = new ClassDefItem(dexFile, $class_spec.type, $class_spec.accessFlags,
|
||||||
$super_spec.type, $implements_list.implementsList, $source_spec.source, classDataItem);
|
$super_spec.type, $implements_list.implementsList, $source_spec.source, classDataItem);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user