• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
25 namespace art {
26 namespace mirror {
27 class ClassLoader;
28 class DexCache;
29 }  // namespace mirror
30 class ClassLinker;
31 struct CompilationUnit;
32 
33 class 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                      uint16_t class_def_idx, uint32_t method_idx, uint32_t access_flags);
40 
GetCompilationUnit()41   CompilationUnit* GetCompilationUnit() const {
42     return cu_;
43   }
44 
GetClassLoader()45   jobject GetClassLoader() const {
46     return class_loader_;
47   }
48 
GetClassLinker()49   ClassLinker* GetClassLinker() const {
50     return class_linker_;
51   }
52 
GetDexFile()53   const DexFile* GetDexFile() const {
54     return dex_file_;
55   }
56 
GetClassDefIndex()57   uint16_t GetClassDefIndex() const {
58     return class_def_idx_;
59   }
60 
GetDexMethodIndex()61   uint32_t GetDexMethodIndex() const {
62     return dex_method_idx_;
63   }
64 
GetCodeItem()65   const DexFile::CodeItem* GetCodeItem() const {
66     return code_item_;
67   }
68 
GetShorty()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 
GetShorty(uint32_t * shorty_len)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 
GetAccessFlags()79   uint32_t GetAccessFlags() const {
80     return access_flags_;
81   }
82 
IsConstructor()83   bool IsConstructor() const {
84     return ((access_flags_ & kAccConstructor) != 0);
85   }
86 
IsNative()87   bool IsNative() const {
88     return ((access_flags_ & kAccNative) != 0);
89   }
90 
IsStatic()91   bool IsStatic() const {
92     return ((access_flags_ & kAccStatic) != 0);
93   }
94 
IsSynchronized()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 uint16_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