Logan Chien | 4dd96f5 | 2012-02-29 01:26:58 +0800 | [diff] [blame] | 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 | |
Ian Rogers | 89756f2 | 2013-03-04 16:40:02 -0800 | [diff] [blame] | 17 | #ifndef ART_SRC_COMPILER_DEX_DEX_COMPILATION_UNIT_H_ |
| 18 | #define ART_SRC_COMPILER_DEX_DEX_COMPILATION_UNIT_H_ |
Logan Chien | 4dd96f5 | 2012-02-29 01:26:58 +0800 | [diff] [blame] | 19 | |
Logan Chien | 61c65dc | 2012-02-29 03:22:30 +0800 | [diff] [blame] | 20 | #include "dex_file.h" |
| 21 | |
Logan Chien | 4dd96f5 | 2012-02-29 01:26:58 +0800 | [diff] [blame] | 22 | #include <stdint.h> |
| 23 | |
| 24 | namespace art { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 25 | namespace mirror { |
Logan Chien | 4dd96f5 | 2012-02-29 01:26:58 +0800 | [diff] [blame] | 26 | class ClassLoader; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 27 | class DexCache; |
| 28 | } // namespace mirror |
Logan Chien | 4dd96f5 | 2012-02-29 01:26:58 +0800 | [diff] [blame] | 29 | class ClassLinker; |
| 30 | class DexFile; |
Logan Chien | 4dd96f5 | 2012-02-29 01:26:58 +0800 | [diff] [blame] | 31 | |
Ian Rogers | 89756f2 | 2013-03-04 16:40:02 -0800 | [diff] [blame] | 32 | class DexCompilationUnit { |
Logan Chien | 4dd96f5 | 2012-02-29 01:26:58 +0800 | [diff] [blame] | 33 | public: |
Ian Rogers | 89756f2 | 2013-03-04 16:40:02 -0800 | [diff] [blame] | 34 | DexCompilationUnit(jobject class_loader, ClassLinker* class_linker, const DexFile& dex_file, |
TDYa127 | dc5daa0 | 2013-01-09 21:31:37 +0800 | [diff] [blame] | 35 | const DexFile::CodeItem* code_item, uint32_t class_def_idx, |
| 36 | uint32_t method_idx, uint32_t access_flags) |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 37 | : class_loader_(class_loader), class_linker_(class_linker), dex_file_(&dex_file), |
Ian Rogers | 89756f2 | 2013-03-04 16:40:02 -0800 | [diff] [blame] | 38 | code_item_(code_item), class_def_idx_(class_def_idx), dex_method_idx_(method_idx), |
TDYa127 | dc5daa0 | 2013-01-09 21:31:37 +0800 | [diff] [blame] | 39 | access_flags_(access_flags) { |
Logan Chien | 4dd96f5 | 2012-02-29 01:26:58 +0800 | [diff] [blame] | 40 | } |
| 41 | |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 42 | jobject GetClassLoader() const { |
Logan Chien | dd361c9 | 2012-04-10 23:40:37 +0800 | [diff] [blame] | 43 | return class_loader_; |
| 44 | } |
| 45 | |
| 46 | ClassLinker* GetClassLinker() const { |
| 47 | return class_linker_; |
| 48 | } |
| 49 | |
| 50 | const DexFile* GetDexFile() const { |
| 51 | return dex_file_; |
| 52 | } |
| 53 | |
TDYa127 | dc5daa0 | 2013-01-09 21:31:37 +0800 | [diff] [blame] | 54 | uint32_t GetClassDefIndex() const { |
| 55 | return class_def_idx_; |
| 56 | } |
| 57 | |
Logan Chien | dd361c9 | 2012-04-10 23:40:37 +0800 | [diff] [blame] | 58 | uint32_t GetDexMethodIndex() const { |
Ian Rogers | 89756f2 | 2013-03-04 16:40:02 -0800 | [diff] [blame] | 59 | return dex_method_idx_; |
Logan Chien | dd361c9 | 2012-04-10 23:40:37 +0800 | [diff] [blame] | 60 | } |
| 61 | |
| 62 | const DexFile::CodeItem* GetCodeItem() const { |
| 63 | return code_item_; |
| 64 | } |
| 65 | |
Logan Chien | bfe4ea4 | 2012-03-01 13:24:17 +0800 | [diff] [blame] | 66 | const char* GetShorty() const { |
Ian Rogers | 89756f2 | 2013-03-04 16:40:02 -0800 | [diff] [blame] | 67 | const DexFile::MethodId& method_id = dex_file_->GetMethodId(dex_method_idx_); |
Logan Chien | 61c65dc | 2012-02-29 03:22:30 +0800 | [diff] [blame] | 68 | return dex_file_->GetMethodShorty(method_id); |
| 69 | } |
| 70 | |
Logan Chien | bfe4ea4 | 2012-03-01 13:24:17 +0800 | [diff] [blame] | 71 | const char* GetShorty(uint32_t* shorty_len) const { |
Ian Rogers | 89756f2 | 2013-03-04 16:40:02 -0800 | [diff] [blame] | 72 | const DexFile::MethodId& method_id = dex_file_->GetMethodId(dex_method_idx_); |
Logan Chien | 61c65dc | 2012-02-29 03:22:30 +0800 | [diff] [blame] | 73 | return dex_file_->GetMethodShorty(method_id, shorty_len); |
| 74 | } |
| 75 | |
Ian Rogers | 89756f2 | 2013-03-04 16:40:02 -0800 | [diff] [blame] | 76 | uint32_t GetAccessFlags() const { |
| 77 | return access_flags_; |
| 78 | } |
| 79 | |
| 80 | bool IsNative() const { |
| 81 | return ((access_flags_ & kAccNative) != 0); |
| 82 | } |
| 83 | |
Logan Chien | dd361c9 | 2012-04-10 23:40:37 +0800 | [diff] [blame] | 84 | bool IsStatic() const { |
| 85 | return ((access_flags_ & kAccStatic) != 0); |
| 86 | } |
| 87 | |
Ian Rogers | 89756f2 | 2013-03-04 16:40:02 -0800 | [diff] [blame] | 88 | bool IsSynchronized() const { |
| 89 | return ((access_flags_ & kAccSynchronized) != 0); |
| 90 | } |
| 91 | |
| 92 | private: |
| 93 | const jobject class_loader_; |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 94 | ClassLinker* const class_linker_; |
Logan Chien | 4dd96f5 | 2012-02-29 01:26:58 +0800 | [diff] [blame] | 95 | |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 96 | const DexFile* const dex_file_; |
Logan Chien | 4dd96f5 | 2012-02-29 01:26:58 +0800 | [diff] [blame] | 97 | |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 98 | const DexFile::CodeItem* const code_item_; |
TDYa127 | dc5daa0 | 2013-01-09 21:31:37 +0800 | [diff] [blame] | 99 | const uint32_t class_def_idx_; |
Ian Rogers | 89756f2 | 2013-03-04 16:40:02 -0800 | [diff] [blame] | 100 | const uint32_t dex_method_idx_; |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 101 | const uint32_t access_flags_; |
Logan Chien | 4dd96f5 | 2012-02-29 01:26:58 +0800 | [diff] [blame] | 102 | }; |
| 103 | |
| 104 | } // namespace art |
| 105 | |
Ian Rogers | 89756f2 | 2013-03-04 16:40:02 -0800 | [diff] [blame] | 106 | #endif // ART_SRC_COMPILER_DEX_DEX_COMPILATION_UNIT_H_ |