namespace DexFormat { export enum AccessFlags { ACC_PUBLIC = 0x1 , ACC_PRIVATE = 0x2 , ACC_PROTECTED = 0x4 , ACC_STATIC = 0x8 , ACC_FINAL = 0x10 , ACC_SYNCHRONIZED = 0x20 , ACC_VOLATILE = 0x40 , ACC_BRIDGE = 0x40 , ACC_TRANSIENT = 0x80 , ACC_VARARGS = 0x80 , ACC_NATIVE = 0x100 , ACC_INTERFACE = 0x200 , ACC_ABSTRACT = 0x400 , ACC_STRICT = 0x800 , ACC_SYNTHETIC = 0x1000 , ACC_ANNOTATION = 0x2000 , ACC_ENUM = 0x4000 , ACC_CONSTRUCTOR = 0x10000 , ACC_DECLARED_SYNCHRONIZED = 0x20000 } abstract class BaseDef { protected static NO_INDEX : number = 0xffffffff ; protected reader : DexFileReader ; constructor ( reader ) { this . reader = reader ; } } abstract class ClassBaseDef extends BaseDef { protected classIdx : number ; public getClassData ( ) { return this . reader . getClass ( this . classIdx ) ; } public getClassType ( ) { return this . reader . getType ( this . classIdx ) ; } public getClassIdx ( ) { return this . classIdx ; } } export class TypeDef extends BaseDef { private descriptorIdx : number ; private internal : boolean ; constructor ( reader , descriptorIdx ) { super ( reader ) ; this . descriptorIdx = descriptorIdx ; } public getDescriptor ( ) { return this . reader . getString ( this . descriptorIdx ) ; } public setInternal ( internal ) { this . internal = internal ; } public isInternal ( ) { return this . internal ; } } export class ProtoDef extends BaseDef { private shortyIdx : number ; private returnTypeIdx : number ; private parametersOff : number ; constructor ( reader , shortyIdx , returnTypeIdx , parametersOff ) { super ( reader ) ; this . shortyIdx = shortyIdx ; this . returnTypeIdx = returnTypeIdx ; this . parametersOff = parametersOff ; } public getShorty ( ) { return this . reader . getString ( this . shortyIdx ) ; } public getParametersOff ( ) { return this . parametersOff ; } public getReturnType ( ) { return this . reader . getType ( this . returnTypeIdx ) ; } } export class FieldDef extends ClassBaseDef { private typeIdx : number ; private nameIdx : number ; constructor ( reader , classIdx , typeIdx , nameIdx ) { super ( reader ) ; this . classIdx = classIdx ; this . typeIdx = typeIdx ; this . nameIdx = nameIdx ; } public getName ( ) { return this . reader . getString ( this . nameIdx ) ; } public getType ( ) { return this . reader . getType ( this . typeIdx ) ; } } export class MethodDef extends ClassBaseDef { private protoIdx : number ; private nameIdx : number ; constructor ( reader , classIdx , protoIdx , nameIdx ) { super ( reader ) ; this . classIdx = classIdx ; this . protoIdx = protoIdx ; this . nameIdx = nameIdx ; } public getName ( ) { return this . reader . getString ( this . nameIdx ) ; } public getProto ( ) { return this . reader . getProto ( this . protoIdx ) ; } } export class ClassDef extends BaseDef { private classIdx : number ; private accessFlags : number ; private superclassIdx : number ; private interfacesOff : number ; private sourceFileIdx : number ; private annotationsOff : number ; private classDataOff : number ; private staticValuesOff : number ; constructor ( reader , classIdx , accessFlags , superclassIdx , interfacesOff , sourceFileIdx , annotationsOff , classDataOff , staticValuesOff ) { super ( reader ) ; this . classIdx = classIdx ; this . accessFlags = accessFlags ; this . superclassIdx = superclassIdx ; this . interfacesOff = interfacesOff ; this . sourceFileIdx = sourceFileIdx ; this . annotationsOff = annotationsOff ; this . classDataOff = classDataOff ; this . staticValuesOff = staticValuesOff ; } public getClassIdx ( ) { return this . classIdx ; } public isAccessFlag ( flag ) { return ( this . accessFlags & flag ) == flag ; } public getSourceFileName ( ) { return this . reader . getString ( this . sourceFileIdx ) ; } public getClassType ( ) { return this . reader . getType ( this . classIdx ) ; } public getSuperclassType ( ) { if ( this . superclassIdx == BaseDef . NO_INDEX ) { return null ; } else { return this . reader . getType ( this . superclassIdx ) ; } } public getInterfacesOff ( ) { return this . interfacesOff ; } public getAnnotationsOff ( ) { return this . annotationsOff ; } public getClassDataOff ( ) { return this . classDataOff ; } public getStaticValuesOff ( ) { return this . staticValuesOff ; } } }