mirror of
https://github.com/revanced/smali.git
synced 2025-06-12 04:17:36 +02:00
Added various acccessors
git-svn-id: https://smali.googlecode.com/svn/trunk@169 55b6fa8a-2a1e-11de-a435-ffa8d773f76a
This commit is contained in:
@ -124,9 +124,15 @@ public class AnnotationDirectoryItem extends OffsettedItem<AnnotationDirectoryIt
|
||||
}
|
||||
|
||||
public List<MethodAnnotation> getMethodAnnotations() {
|
||||
return methodAnnotationList;
|
||||
return (List<MethodAnnotation>)methodAnnotationList.clone();
|
||||
}
|
||||
|
||||
public List<FieldAnnotation> getFieldAnnotations() {
|
||||
return (List<FieldAnnotation>)fieldAnnotationList.clone();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static class FieldAnnotation extends CompositeField<FieldAnnotation>
|
||||
implements Comparable<FieldAnnotation> {
|
||||
private final IndexedItemReference<FieldIdItem> fieldReferenceField;
|
||||
@ -152,39 +158,47 @@ public class AnnotationDirectoryItem extends OffsettedItem<AnnotationDirectoryIt
|
||||
return ((Integer) fieldReferenceField.getReference().getIndex()).compareTo(
|
||||
o.fieldReferenceField.getReference().getIndex());
|
||||
}
|
||||
|
||||
public FieldIdItem getField() {
|
||||
return fieldReferenceField.getReference();
|
||||
}
|
||||
|
||||
public AnnotationSetItem getAnnotationSet() {
|
||||
return annotationSetReferenceField.getReference();
|
||||
}
|
||||
}
|
||||
|
||||
public static class MethodAnnotation extends CompositeField<MethodAnnotation>
|
||||
implements Comparable<MethodAnnotation> {
|
||||
private final IndexedItemReference<MethodIdItem> method;
|
||||
private final OffsettedItemReference<AnnotationSetItem> annotationSet;
|
||||
private final IndexedItemReference<MethodIdItem> methodReferenceField;
|
||||
private final OffsettedItemReference<AnnotationSetItem> annotationSetReferenceField;
|
||||
|
||||
public MethodAnnotation(DexFile dexFile) {
|
||||
super("method_annotation");
|
||||
fields = new Field[] {
|
||||
method = new IndexedItemReference<MethodIdItem>(dexFile.MethodIdsSection,
|
||||
methodReferenceField = new IndexedItemReference<MethodIdItem>(dexFile.MethodIdsSection,
|
||||
new IntegerField(null), "method_idx"),
|
||||
annotationSet = new OffsettedItemReference<AnnotationSetItem>(dexFile.AnnotationSetsSection,
|
||||
annotationSetReferenceField = new OffsettedItemReference<AnnotationSetItem>(dexFile.AnnotationSetsSection,
|
||||
new IntegerField(null), "annotations_off")
|
||||
};
|
||||
}
|
||||
|
||||
public MethodAnnotation(DexFile dexFile, MethodIdItem method, AnnotationSetItem annotationSet) {
|
||||
this(dexFile);
|
||||
this.method.setReference(method);
|
||||
this.annotationSet.setReference(annotationSet);
|
||||
this.methodReferenceField.setReference(method);
|
||||
this.annotationSetReferenceField.setReference(annotationSet);
|
||||
}
|
||||
|
||||
public int compareTo(MethodAnnotation o) {
|
||||
return ((Integer)method.getReference().getIndex()).compareTo(o.method.getReference().getIndex());
|
||||
return ((Integer) methodReferenceField.getReference().getIndex()).compareTo(o.methodReferenceField.getReference().getIndex());
|
||||
}
|
||||
|
||||
public MethodIdItem getMethod() {
|
||||
return method.getReference();
|
||||
return methodReferenceField.getReference();
|
||||
}
|
||||
|
||||
public AnnotationSetItem getAnnotationSet() {
|
||||
return annotationSet.getReference();
|
||||
return annotationSetReferenceField.getReference();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -276,7 +276,7 @@ public class ClassDataItem extends OffsettedItem<ClassDataItem> {
|
||||
return (accessFlagsField.getCachedValue() & AccessFlags.STATIC.getValue()) != 0;
|
||||
}
|
||||
|
||||
public FieldIdItem getFieldReference() {
|
||||
public FieldIdItem getField() {
|
||||
return fieldReferenceField.getReference();
|
||||
}
|
||||
|
||||
|
@ -112,6 +112,14 @@ public class ClassDefItem extends IndexedItem<ClassDefItem> {
|
||||
return classTypeReferenceField.getReference().getTypeDescriptor();
|
||||
}
|
||||
|
||||
public String getSourceFile() {
|
||||
StringIdItem stringIdItem = sourceFileReferenceField.getReference();
|
||||
if (stringIdItem == null) {
|
||||
return null;
|
||||
}
|
||||
return stringIdItem.getStringValue();
|
||||
}
|
||||
|
||||
public int getAccessFlags() {
|
||||
return accessFlagsField.getCachedValue();
|
||||
}
|
||||
@ -181,7 +189,7 @@ public class ClassDefItem extends IndexedItem<ClassDefItem> {
|
||||
for (int i=staticFieldInitialValuesList.size(); i < fieldIndex; i++) {
|
||||
ClassDataItem.EncodedField staticField = classDataItem.getStaticFieldAtIndex(i);
|
||||
EncodedValueSubField subField = TypeUtils.makeDefaultValueForType(dexFile,
|
||||
staticField.getFieldReference().getFieldType().getTypeDescriptor());
|
||||
staticField.getField().getFieldType().getTypeDescriptor());
|
||||
EncodedValue encodedValue = new EncodedValue(dexFile, subField);
|
||||
staticFieldInitialValuesList.add(i, encodedValue);
|
||||
}
|
||||
@ -189,7 +197,7 @@ public class ClassDefItem extends IndexedItem<ClassDefItem> {
|
||||
staticFieldInitialValuesList.add(fieldIndex, initialValue);
|
||||
} else if (staticFieldInitialValuesList != null && encodedField.isStatic() && fieldIndex < staticFieldInitialValuesList.size()) {
|
||||
EncodedValueSubField subField = TypeUtils.makeDefaultValueForType(dexFile,
|
||||
encodedField.getFieldReference().getFieldType().getTypeDescriptor());
|
||||
encodedField.getField().getFieldType().getTypeDescriptor());
|
||||
EncodedValue encodedValue = new EncodedValue(dexFile, subField);
|
||||
staticFieldInitialValuesList.add(fieldIndex, encodedValue);
|
||||
}
|
||||
|
@ -122,6 +122,14 @@ public class CodeItem extends OffsettedItem<CodeItem> {
|
||||
return (List<InstructionField>)instructionList.clone();
|
||||
}
|
||||
|
||||
public List<TryItem> getTries() {
|
||||
return (List<TryItem>)tryItems.clone();
|
||||
}
|
||||
|
||||
public DebugInfoItem getDebugInfo() {
|
||||
return debugInfoReferenceField.getReference();
|
||||
}
|
||||
|
||||
public void copyTo(DexFile dexFile, CodeItem copy)
|
||||
{
|
||||
for (int i = 0; i < fields.length-2; i++) {
|
||||
@ -408,13 +416,19 @@ public class CodeItem extends OffsettedItem<CodeItem> {
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: GROT
|
||||
public int getHandlerCount() {
|
||||
return list.size();
|
||||
}
|
||||
|
||||
//TODO: GROT
|
||||
public EncodedTypeAddrPair getHandler(int index) {
|
||||
return list.get(index);
|
||||
}
|
||||
|
||||
public List<EncodedTypeAddrPair> getHandlers() {
|
||||
return (List<EncodedTypeAddrPair>)list.clone();
|
||||
}
|
||||
}
|
||||
|
||||
public static class EncodedTypeAddrPair extends CompositeField<EncodedTypeAddrPair> {
|
||||
|
@ -90,6 +90,16 @@ public class DebugInfoItem extends OffsettedItem<DebugInfoItem> {
|
||||
return "debug_info_item @0x" + Integer.toHexString(getOffset());
|
||||
}
|
||||
|
||||
public int getLineStart() {
|
||||
return lineStartField.getCachedValue();
|
||||
}
|
||||
|
||||
public List<DebugInstruction> getDebugInstructions() {
|
||||
return (List<DebugInstruction>)instructionFields.clone();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private class DebugInstructionList implements Field<DebugInstructionList> {
|
||||
private final DexFile dexFile;
|
||||
private final ArrayList<DebugInstruction> list;
|
||||
|
@ -53,4 +53,8 @@ public class AdvanceLine extends CompositeField<AdvanceLine> implements DebugIns
|
||||
public byte getOpcode() {
|
||||
return 0x02;
|
||||
}
|
||||
|
||||
public int getLineDelta() {
|
||||
return lineDeltaField.getCachedValue();
|
||||
}
|
||||
}
|
||||
|
@ -53,4 +53,8 @@ public class AdvancePC extends CompositeField<AdvancePC> implements DebugInstruc
|
||||
public byte getOpcode() {
|
||||
return 0x01;
|
||||
}
|
||||
|
||||
public int getAddressDelta() {
|
||||
return addressDeltaField.getCachedValue();
|
||||
}
|
||||
}
|
||||
|
@ -53,4 +53,8 @@ public class EndLocal extends CompositeField<EndLocal> implements DebugInstructi
|
||||
public byte getOpcode() {
|
||||
return 0x05;
|
||||
}
|
||||
|
||||
public int getRegisterNumber() {
|
||||
return registerNumber.getCachedValue();
|
||||
}
|
||||
}
|
||||
|
@ -53,4 +53,8 @@ public class RestartLocal extends CompositeField<RestartLocal> implements DebugI
|
||||
public byte getOpcode() {
|
||||
return 0x06;
|
||||
}
|
||||
|
||||
public int getRegisterNumber() {
|
||||
return registerNumber.getCachedValue();
|
||||
}
|
||||
}
|
||||
|
@ -51,4 +51,8 @@ public class SetFile extends CompositeField<SetFile> implements DebugInstruction
|
||||
public byte getOpcode() {
|
||||
return 0x09;
|
||||
}
|
||||
|
||||
public StringIdItem getFileName() {
|
||||
return fileName.getReference();
|
||||
}
|
||||
}
|
||||
|
@ -47,4 +47,13 @@ public class SpecialOpcode extends CompositeField<SpecialOpcode> implements Debu
|
||||
public byte getOpcode() {
|
||||
return opcode;
|
||||
}
|
||||
|
||||
public byte getLineDelta() {
|
||||
return (byte)((((opcode & 0xFF) - 0x0A) % 15) - 4);
|
||||
}
|
||||
|
||||
public byte getAddressDelta() {
|
||||
return (byte)(((opcode & 0xFF) - 0x0A) / 15);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -58,4 +58,16 @@ public class StartLocal extends CompositeField<StartLocal> implements DebugInstr
|
||||
public byte getOpcode() {
|
||||
return 0x03;
|
||||
}
|
||||
|
||||
public int getRegisterNumber() {
|
||||
return registerNumber.getCachedValue();
|
||||
}
|
||||
|
||||
public StringIdItem getName() {
|
||||
return localName.getReference();
|
||||
}
|
||||
|
||||
public TypeIdItem getType() {
|
||||
return localType.getReference();
|
||||
}
|
||||
}
|
||||
|
@ -63,4 +63,20 @@ public class StartLocalExtended extends CompositeField<StartLocalExtended> imple
|
||||
public byte getOpcode() {
|
||||
return 0x04;
|
||||
}
|
||||
|
||||
public int getRegisterNumber() {
|
||||
return registerNumber.getCachedValue();
|
||||
}
|
||||
|
||||
public StringIdItem getName() {
|
||||
return localName.getReference();
|
||||
}
|
||||
|
||||
public TypeIdItem getType() {
|
||||
return localType.getReference();
|
||||
}
|
||||
|
||||
public StringIdItem getSignature() {
|
||||
return signature.getReference();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user