blob: 94ba33d6a8b8a4f3c07547750bdfcc1f9932f72d [file] [log] [blame]
Carl Shapiro1fb86202011-06-27 17:43:13 -07001// Copyright 2011 Google Inc. All Rights Reserved.
2
3#ifndef ART_SRC_DEX_FILE_H_
4#define ART_SRC_DEX_FILE_H_
5
6#include "src/globals.h"
7#include "src/macros.h"
8#include "src/object.h"
9#include "src/raw_dex_file.h"
10
11namespace art {
12
13class DexFile {
14 public:
15 // Opens a dex file. Returns NULL on failure.
16 static DexFile* Open(const char* filename);
17
18 // Close and deallocate.
19 ~DexFile();
20
21 size_t NumTypes() {
22 return num_classes_;
23 }
24
25 size_t NumMethods() {
26 return num_methods_;
27 }
28
29 Class* LoadClass(const char* descriptor);
30
31 Class* LoadClass(const RawDexFile::ClassDef& class_def);
32
33 private:
34 DexFile(RawDexFile* raw) : raw_(raw) {};
35
36 void Init();
37
Carl Shapiro3ee755d2011-06-28 12:11:04 -070038 void LoadInterfaces(const RawDexFile::ClassDef& class_def, Class *klass);
Carl Shapiro1fb86202011-06-27 17:43:13 -070039
Carl Shapiro3ee755d2011-06-28 12:11:04 -070040 void LoadField(Class* klass, const RawDexFile::Field& src, Field* dst);
Carl Shapiro1fb86202011-06-27 17:43:13 -070041
Carl Shapiro3ee755d2011-06-28 12:11:04 -070042 void LoadMethod(Class* klass, const RawDexFile::Method& src, Method* dst);
Carl Shapiro1fb86202011-06-27 17:43:13 -070043
44 // Table of contents for interned String objects.
45 String** strings_;
46 size_t num_strings_;
47
48 // Table of contents for Class objects.
49 Class** classes_;
50 size_t num_classes_;
51
52 // Table of contents for methods.
53 Method** methods_;
54 size_t num_methods_;
55
56 // Table of contents for fields.
57 Field** fields_;
58 size_t num_fields_;
59
60 // The size of the DEX file, in bytes.
61 size_t length_;
62
63 // The underlying dex file.
64 RawDexFile* raw_;
65
66 DISALLOW_COPY_AND_ASSIGN(DexFile);
67};
68
69} // namespace art
70
71#endif // ART_SRC_DEX_FILE_H_