dex_compilation_unit.h revision 9fc16eb43fe938f0cddb13638bd7cbc2ea9534a2
1/*
2 * Copyright (C) 2012 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef ART_COMPILER_DRIVER_DEX_COMPILATION_UNIT_H_
18#define ART_COMPILER_DRIVER_DEX_COMPILATION_UNIT_H_
19
20#include <stdint.h>
21
22#include "dex_file.h"
23#include "jni.h"
24
25namespace art {
26namespace mirror {
27class ClassLoader;
28class DexCache;
29}  // namespace mirror
30class ClassLinker;
31struct CompilationUnit;
32
33class DexCompilationUnit {
34 public:
35  explicit DexCompilationUnit(CompilationUnit* cu);
36
37  DexCompilationUnit(CompilationUnit* cu, jobject class_loader, ClassLinker* class_linker,
38                     const DexFile& dex_file, const DexFile::CodeItem* code_item,
39                     uint32_t class_def_idx, uint32_t method_idx, uint32_t access_flags);
40
41  CompilationUnit* GetCompilationUnit() const {
42    return cu_;
43  }
44
45  jobject GetClassLoader() const {
46    return class_loader_;
47  }
48
49  ClassLinker* GetClassLinker() const {
50    return class_linker_;
51  }
52
53  const DexFile* GetDexFile() const {
54    return dex_file_;
55  }
56
57  uint32_t GetClassDefIndex() const {
58    return class_def_idx_;
59  }
60
61  uint32_t GetDexMethodIndex() const {
62    return dex_method_idx_;
63  }
64
65  const DexFile::CodeItem* GetCodeItem() const {
66    return code_item_;
67  }
68
69  const char* GetShorty() const {
70    const DexFile::MethodId& method_id = dex_file_->GetMethodId(dex_method_idx_);
71    return dex_file_->GetMethodShorty(method_id);
72  }
73
74  const char* GetShorty(uint32_t* shorty_len) const {
75    const DexFile::MethodId& method_id = dex_file_->GetMethodId(dex_method_idx_);
76    return dex_file_->GetMethodShorty(method_id, shorty_len);
77  }
78
79  uint32_t GetAccessFlags() const {
80    return access_flags_;
81  }
82
83  bool IsConstructor() const {
84    return ((access_flags_ & kAccConstructor) != 0);
85  }
86
87  bool IsNative() const {
88    return ((access_flags_ & kAccNative) != 0);
89  }
90
91  bool IsStatic() const {
92    return ((access_flags_ & kAccStatic) != 0);
93  }
94
95  bool IsSynchronized() const {
96    return ((access_flags_ & kAccSynchronized) != 0);
97  }
98
99  const std::string& GetSymbol();
100
101 private:
102  CompilationUnit* const cu_;
103
104  const jobject class_loader_;
105
106  ClassLinker* const class_linker_;
107
108  const DexFile* const dex_file_;
109
110  const DexFile::CodeItem* const code_item_;
111  const uint32_t class_def_idx_;
112  const uint32_t dex_method_idx_;
113  const uint32_t access_flags_;
114
115  std::string symbol_;
116};
117
118}  // namespace art
119
120#endif  // ART_COMPILER_DRIVER_DEX_COMPILATION_UNIT_H_
121