blob: 3cd1a5705384d24f0ea6d7d6cc19d9377756e18e [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
38 void LoadClassInterfaces(const RawDexFile::ClassDef& class_def,
39 Class *klass);
40
41 void LoadSFields(Class* klass, const RawDexFile::Field* src,
42 Field* dst);
43
44 void LoadIFields(Class* klass, const RawDexFile::Field* src,
45 Field* dst);
46
47 void LoadMethod(Class* klass, const RawDexFile::Method* src,
48 Method* dst);
49
50 // Table of contents for interned String objects.
51 String** strings_;
52 size_t num_strings_;
53
54 // Table of contents for Class objects.
55 Class** classes_;
56 size_t num_classes_;
57
58 // Table of contents for methods.
59 Method** methods_;
60 size_t num_methods_;
61
62 // Table of contents for fields.
63 Field** fields_;
64 size_t num_fields_;
65
66 // The size of the DEX file, in bytes.
67 size_t length_;
68
69 // The underlying dex file.
70 RawDexFile* raw_;
71
72 DISALLOW_COPY_AND_ASSIGN(DexFile);
73};
74
75} // namespace art
76
77#endif // ART_SRC_DEX_FILE_H_