mirror of
https://github.com/revanced/smali.git
synced 2025-05-04 08:34:25 +02:00
Rename DexFile to DexFileBuffer
This commit is contained in:
parent
a88239d92d
commit
dc9e5455bc
@ -39,13 +39,13 @@ import javax.annotation.Nonnull;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class DexBackedAnnotation implements Annotation {
|
public class DexBackedAnnotation implements Annotation {
|
||||||
@Nonnull public final DexFile dexFile;
|
@Nonnull public final DexFileBuffer dexFile;
|
||||||
|
|
||||||
public final int visibility;
|
public final int visibility;
|
||||||
@Nonnull public final String type;
|
@Nonnull public final String type;
|
||||||
private final int elementsOffset;
|
private final int elementsOffset;
|
||||||
|
|
||||||
public DexBackedAnnotation(@Nonnull DexFile dexFile,
|
public DexBackedAnnotation(@Nonnull DexFileBuffer dexFile,
|
||||||
int annotationOffset) {
|
int annotationOffset) {
|
||||||
this.dexFile = dexFile;
|
this.dexFile = dexFile;
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ import javax.annotation.Nullable;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class DexBackedClassDef implements ClassDef {
|
public class DexBackedClassDef implements ClassDef {
|
||||||
@Nonnull public final DexFile dexFile;
|
@Nonnull public final DexFileBuffer dexFile;
|
||||||
|
|
||||||
@Nonnull public final String name;
|
@Nonnull public final String name;
|
||||||
public final int accessFlags;
|
public final int accessFlags;
|
||||||
@ -63,7 +63,7 @@ public class DexBackedClassDef implements ClassDef {
|
|||||||
private static final int CLASS_DATA_OFFSET = 24;
|
private static final int CLASS_DATA_OFFSET = 24;
|
||||||
private static final int STATIC_INITIAL_VALUES_OFFSET = 28;
|
private static final int STATIC_INITIAL_VALUES_OFFSET = 28;
|
||||||
|
|
||||||
public DexBackedClassDef(@Nonnull DexFile dexFile,
|
public DexBackedClassDef(@Nonnull DexFileBuffer dexFile,
|
||||||
int classDefOffset) {
|
int classDefOffset) {
|
||||||
this.dexFile = dexFile;
|
this.dexFile = dexFile;
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ import javax.annotation.Nullable;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class DexBackedField implements Field {
|
public class DexBackedField implements Field {
|
||||||
@Nonnull public final DexFile dexFile;
|
@Nonnull public final DexFileBuffer dexFile;
|
||||||
|
|
||||||
@Nonnull public final String name;
|
@Nonnull public final String name;
|
||||||
@Nonnull public final String type;
|
@Nonnull public final String type;
|
||||||
|
@ -44,7 +44,7 @@ import javax.annotation.Nullable;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class DexBackedMethod implements Method {
|
public class DexBackedMethod implements Method {
|
||||||
@Nonnull public final DexFile dexFile;
|
@Nonnull public final DexFileBuffer dexFile;
|
||||||
|
|
||||||
@Nonnull public final String name;
|
@Nonnull public final String name;
|
||||||
public final int accessFlags;
|
public final int accessFlags;
|
||||||
|
@ -45,7 +45,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class DexBackedMethodImplementation implements MethodImplementation {
|
public class DexBackedMethodImplementation implements MethodImplementation {
|
||||||
@Nonnull public final DexFile dexFile;
|
@Nonnull public final DexFileBuffer dexFile;
|
||||||
private final int codeOffset;
|
private final int codeOffset;
|
||||||
|
|
||||||
public final int registerCount;
|
public final int registerCount;
|
||||||
@ -59,7 +59,7 @@ public class DexBackedMethodImplementation implements MethodImplementation {
|
|||||||
|
|
||||||
private static final int TRY_ITEM_SIZE = 8;
|
private static final int TRY_ITEM_SIZE = 8;
|
||||||
|
|
||||||
public DexBackedMethodImplementation(@Nonnull DexFile dexFile,
|
public DexBackedMethodImplementation(@Nonnull DexFileBuffer dexFile,
|
||||||
int codeOffset) {
|
int codeOffset) {
|
||||||
this.dexFile = dexFile;
|
this.dexFile = dexFile;
|
||||||
this.codeOffset = codeOffset;
|
this.codeOffset = codeOffset;
|
||||||
|
@ -40,7 +40,7 @@ import javax.annotation.Nonnull;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class DexBackedTryBlock implements TryBlock {
|
public class DexBackedTryBlock implements TryBlock {
|
||||||
public final DexFile dexFile;
|
public final DexFileBuffer dexFile;
|
||||||
private final InstructionOffsetMap instructionOffsetMap;
|
private final InstructionOffsetMap instructionOffsetMap;
|
||||||
|
|
||||||
public final int startIndex;
|
public final int startIndex;
|
||||||
@ -52,7 +52,7 @@ public class DexBackedTryBlock implements TryBlock {
|
|||||||
private static final int CODE_UNIT_COUNT_OFFSET = 4;
|
private static final int CODE_UNIT_COUNT_OFFSET = 4;
|
||||||
private static final int HANDLER_OFFSET_OFFSET = 6;
|
private static final int HANDLER_OFFSET_OFFSET = 6;
|
||||||
|
|
||||||
public DexBackedTryBlock(DexFile dexFile,
|
public DexBackedTryBlock(DexFileBuffer dexFile,
|
||||||
int tryItemOffset,
|
int tryItemOffset,
|
||||||
int handlersStartOffset,
|
int handlersStartOffset,
|
||||||
InstructionOffsetMap instructionOffsetMap) {
|
InstructionOffsetMap instructionOffsetMap) {
|
||||||
|
@ -35,11 +35,11 @@ import org.jf.util.ExceptionWithContext;
|
|||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public class DexFile {
|
public class DexFileBuffer {
|
||||||
// TODO: consider using a direct ByteBuffer instead
|
// TODO: consider using a direct ByteBuffer instead
|
||||||
protected final byte[] buf;
|
protected final byte[] buf;
|
||||||
|
|
||||||
public DexFile(byte[] buf) {
|
public DexFileBuffer(byte[] buf) {
|
||||||
this.buf = buf;
|
this.buf = buf;
|
||||||
}
|
}
|
||||||
|
|
@ -36,15 +36,15 @@ import org.jf.util.ExceptionWithContext;
|
|||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
public class DexFileReader {
|
public class DexFileReader {
|
||||||
@Nonnull private final DexFile dexFile;
|
@Nonnull private final DexFileBuffer dexFile;
|
||||||
private int offset;
|
private int offset;
|
||||||
|
|
||||||
public DexFileReader(@Nonnull DexFile dexFile, int offset) {
|
public DexFileReader(@Nonnull DexFileBuffer dexFile, int offset) {
|
||||||
this.dexFile = dexFile;
|
this.dexFile = dexFile;
|
||||||
this.offset = offset;
|
this.offset = offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull public DexFile getDexFile() { return dexFile; }
|
@Nonnull public DexFileBuffer getDexFile() { return dexFile; }
|
||||||
public int getOffset() { return offset; }
|
public int getOffset() { return offset; }
|
||||||
|
|
||||||
public String getString(int stringIndex) { return dexFile.getString(stringIndex); }
|
public String getString(int stringIndex) { return dexFile.getString(stringIndex); }
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
package org.jf.dexlib2.dexbacked.util;
|
package org.jf.dexlib2.dexbacked.util;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import org.jf.dexlib2.dexbacked.DexFile;
|
import org.jf.dexlib2.dexbacked.DexFileBuffer;
|
||||||
import org.jf.dexlib2.dexbacked.DexBackedAnnotation;
|
import org.jf.dexlib2.dexbacked.DexBackedAnnotation;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
@ -53,7 +53,7 @@ public abstract class AnnotationsDirectory {
|
|||||||
@Nonnull public abstract AnnotationIterator getMethodAnnotationIterator();
|
@Nonnull public abstract AnnotationIterator getMethodAnnotationIterator();
|
||||||
@Nonnull public abstract AnnotationIterator getParameterAnnotationIterator();
|
@Nonnull public abstract AnnotationIterator getParameterAnnotationIterator();
|
||||||
|
|
||||||
public static AnnotationsDirectory newOrEmpty(@Nonnull DexFile dexFile,
|
public static AnnotationsDirectory newOrEmpty(@Nonnull DexFileBuffer dexFile,
|
||||||
int directoryAnnotationsOffset) {
|
int directoryAnnotationsOffset) {
|
||||||
if (directoryAnnotationsOffset == 0) {
|
if (directoryAnnotationsOffset == 0) {
|
||||||
return EMPTY;
|
return EMPTY;
|
||||||
@ -71,7 +71,7 @@ public abstract class AnnotationsDirectory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public static List<? extends DexBackedAnnotation> getAnnotations(@Nonnull final DexFile dexFile,
|
public static List<? extends DexBackedAnnotation> getAnnotations(@Nonnull final DexFileBuffer dexFile,
|
||||||
final int annotationSetOffset) {
|
final int annotationSetOffset) {
|
||||||
if (annotationSetOffset != 0) {
|
if (annotationSetOffset != 0) {
|
||||||
final int size = dexFile.readSmallUint(annotationSetOffset);
|
final int size = dexFile.readSmallUint(annotationSetOffset);
|
||||||
@ -89,7 +89,7 @@ public abstract class AnnotationsDirectory {
|
|||||||
return ImmutableList.of();
|
return ImmutableList.of();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<List<? extends DexBackedAnnotation>> getParameterAnnotations(@Nonnull final DexFile dexFile,
|
public static List<List<? extends DexBackedAnnotation>> getParameterAnnotations(@Nonnull final DexFileBuffer dexFile,
|
||||||
final int annotationSetListOffset) {
|
final int annotationSetListOffset) {
|
||||||
if (annotationSetListOffset > 0) {
|
if (annotationSetListOffset > 0) {
|
||||||
final int size = dexFile.readSmallUint(annotationSetListOffset);
|
final int size = dexFile.readSmallUint(annotationSetListOffset);
|
||||||
@ -108,7 +108,7 @@ public abstract class AnnotationsDirectory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static class AnnotationsDirectoryImpl extends AnnotationsDirectory {
|
private static class AnnotationsDirectoryImpl extends AnnotationsDirectory {
|
||||||
@Nonnull public final DexFile dexFile;
|
@Nonnull public final DexFileBuffer dexFile;
|
||||||
private final int directoryOffset;
|
private final int directoryOffset;
|
||||||
|
|
||||||
private static final int FIELD_COUNT_OFFSET = 4;
|
private static final int FIELD_COUNT_OFFSET = 4;
|
||||||
@ -121,7 +121,7 @@ public abstract class AnnotationsDirectory {
|
|||||||
/** The size of a method_annotation structure */
|
/** The size of a method_annotation structure */
|
||||||
private static final int METHOD_ANNOTATION_SIZE = 8;
|
private static final int METHOD_ANNOTATION_SIZE = 8;
|
||||||
|
|
||||||
public AnnotationsDirectoryImpl(@Nonnull DexFile dexFile,
|
public AnnotationsDirectoryImpl(@Nonnull DexFileBuffer dexFile,
|
||||||
int directoryOffset) {
|
int directoryOffset) {
|
||||||
this.dexFile = dexFile;
|
this.dexFile = dexFile;
|
||||||
this.directoryOffset = directoryOffset;
|
this.directoryOffset = directoryOffset;
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
package org.jf.dexlib2.dexbacked.util;
|
package org.jf.dexlib2.dexbacked.util;
|
||||||
|
|
||||||
import org.jf.dexlib2.dexbacked.DexFile;
|
import org.jf.dexlib2.dexbacked.DexFileBuffer;
|
||||||
import org.jf.dexlib2.dexbacked.DexFileReader;
|
import org.jf.dexlib2.dexbacked.DexFileReader;
|
||||||
import org.jf.dexlib2.dexbacked.value.DexBackedEncodedValue;
|
import org.jf.dexlib2.dexbacked.value.DexBackedEncodedValue;
|
||||||
import org.jf.dexlib2.iface.value.EncodedValue;
|
import org.jf.dexlib2.iface.value.EncodedValue;
|
||||||
@ -49,7 +49,7 @@ public abstract class StaticInitialValueIterator {
|
|||||||
public abstract void skipNext();
|
public abstract void skipNext();
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public static StaticInitialValueIterator newOrEmpty(@Nonnull DexFile dexFile, int offset) {
|
public static StaticInitialValueIterator newOrEmpty(@Nonnull DexFileBuffer dexFile, int offset) {
|
||||||
if (offset == 0) {
|
if (offset == 0) {
|
||||||
return EMPTY;
|
return EMPTY;
|
||||||
}
|
}
|
||||||
@ -61,7 +61,7 @@ public abstract class StaticInitialValueIterator {
|
|||||||
private final int size;
|
private final int size;
|
||||||
private int index = 0;
|
private int index = 0;
|
||||||
|
|
||||||
public StaticInitialValueIteratorImpl(@Nonnull DexFile dexFile, int offset) {
|
public StaticInitialValueIteratorImpl(@Nonnull DexFileBuffer dexFile, int offset) {
|
||||||
this.reader = dexFile.readerAt(offset);
|
this.reader = dexFile.readerAt(offset);
|
||||||
this.size = reader.readSmallUleb128();
|
this.size = reader.readSmallUleb128();
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
package org.jf.dexlib2.dexbacked.util;
|
package org.jf.dexlib2.dexbacked.util;
|
||||||
|
|
||||||
import org.jf.dexlib2.dexbacked.DexFile;
|
import org.jf.dexlib2.dexbacked.DexFileBuffer;
|
||||||
import org.jf.dexlib2.dexbacked.DexFileReader;
|
import org.jf.dexlib2.dexbacked.DexFileReader;
|
||||||
import org.jf.util.AbstractListIterator;
|
import org.jf.util.AbstractListIterator;
|
||||||
|
|
||||||
@ -44,10 +44,10 @@ import java.util.NoSuchElementException;
|
|||||||
* @param <T> The type of the item that this list contains
|
* @param <T> The type of the item that this list contains
|
||||||
*/
|
*/
|
||||||
public abstract class VariableSizeList<T> extends AbstractSequentialList<T> {
|
public abstract class VariableSizeList<T> extends AbstractSequentialList<T> {
|
||||||
@Nonnull private final DexFile dexFile;
|
@Nonnull private final DexFileBuffer dexFile;
|
||||||
private final int offset;
|
private final int offset;
|
||||||
|
|
||||||
public VariableSizeList(@Nonnull DexFile dexFile, int offset) {
|
public VariableSizeList(@Nonnull DexFileBuffer dexFile, int offset) {
|
||||||
this.dexFile = dexFile;
|
this.dexFile = dexFile;
|
||||||
this.offset = offset;
|
this.offset = offset;
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
package org.jf.dexlib2.dexbacked.util;
|
package org.jf.dexlib2.dexbacked.util;
|
||||||
|
|
||||||
import org.jf.dexlib2.dexbacked.DexFile;
|
import org.jf.dexlib2.dexbacked.DexFileBuffer;
|
||||||
import org.jf.dexlib2.dexbacked.DexFileReader;
|
import org.jf.dexlib2.dexbacked.DexFileReader;
|
||||||
import org.jf.util.AbstractListIterator;
|
import org.jf.util.AbstractListIterator;
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ public abstract class VariableSizeListWithContext<T> extends AbstractSequentialL
|
|||||||
private int index = 0;
|
private int index = 0;
|
||||||
@Nonnull private final DexFileReader reader;
|
@Nonnull private final DexFileReader reader;
|
||||||
|
|
||||||
public Iterator(DexFile dexFile, int offset) {
|
public Iterator(DexFileBuffer dexFile, int offset) {
|
||||||
this.reader = dexFile.readerAt(offset);
|
this.reader = dexFile.readerAt(offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
package org.jf.dexlib2.dexbacked.value;
|
package org.jf.dexlib2.dexbacked.value;
|
||||||
|
|
||||||
import org.jf.dexlib2.dexbacked.DexFile;
|
import org.jf.dexlib2.dexbacked.DexFileBuffer;
|
||||||
import org.jf.dexlib2.dexbacked.DexFileReader;
|
import org.jf.dexlib2.dexbacked.DexFileReader;
|
||||||
import org.jf.dexlib2.ValueType;
|
import org.jf.dexlib2.ValueType;
|
||||||
import org.jf.dexlib2.dexbacked.DexBackedAnnotationElement;
|
import org.jf.dexlib2.dexbacked.DexBackedAnnotationElement;
|
||||||
@ -43,7 +43,7 @@ import javax.annotation.Nonnull;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class DexBackedAnnotationEncodedValue implements AnnotationEncodedValue {
|
public class DexBackedAnnotationEncodedValue implements AnnotationEncodedValue {
|
||||||
@Nonnull public final DexFile dexFile;
|
@Nonnull public final DexFileBuffer dexFile;
|
||||||
public final String type;
|
public final String type;
|
||||||
private final int elementsOffset;
|
private final int elementsOffset;
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
package org.jf.dexlib2.dexbacked.value;
|
package org.jf.dexlib2.dexbacked.value;
|
||||||
|
|
||||||
import org.jf.dexlib2.dexbacked.DexFile;
|
import org.jf.dexlib2.dexbacked.DexFileBuffer;
|
||||||
import org.jf.dexlib2.dexbacked.DexFileReader;
|
import org.jf.dexlib2.dexbacked.DexFileReader;
|
||||||
import org.jf.dexlib2.ValueType;
|
import org.jf.dexlib2.ValueType;
|
||||||
import org.jf.dexlib2.dexbacked.util.VariableSizeList;
|
import org.jf.dexlib2.dexbacked.util.VariableSizeList;
|
||||||
@ -42,7 +42,7 @@ import javax.annotation.Nonnull;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class DexBackedArrayEncodedValue implements ArrayEncodedValue {
|
public class DexBackedArrayEncodedValue implements ArrayEncodedValue {
|
||||||
@Nonnull public final DexFile dexFile;
|
@Nonnull public final DexFileBuffer dexFile;
|
||||||
private final int encodedArrayOffset;
|
private final int encodedArrayOffset;
|
||||||
|
|
||||||
public DexBackedArrayEncodedValue(@Nonnull DexFileReader dexFileReader) {
|
public DexBackedArrayEncodedValue(@Nonnull DexFileReader dexFileReader) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user