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 | |
| 17 | #ifndef ART_SRC_METHOD_UNIT_H_ |
| 18 | #define ART_SRC_METHOD_UNIT_H_ |
| 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 { |
| 25 | |
| 26 | class ClassLoader; |
| 27 | class ClassLinker; |
| 28 | class DexFile; |
| 29 | class DexCache; |
| 30 | |
| 31 | class OatCompilationUnit { |
| 32 | public: |
| 33 | OatCompilationUnit(ClassLoader const* class_loader, ClassLinker* class_linker, |
| 34 | DexFile const& dex_file, DexCache& dex_cache, |
| 35 | DexFile::CodeItem const* code_item, |
| 36 | uint32_t method_idx, uint32_t access_flags) |
| 37 | : class_loader_(class_loader), class_linker_(class_linker), |
| 38 | dex_file_(&dex_file), dex_cache_(&dex_cache), code_item_(code_item), |
| 39 | method_idx_(method_idx), access_flags_(access_flags) { |
| 40 | } |
| 41 | |
Logan Chien | 61c65dc | 2012-02-29 03:22:30 +0800 | [diff] [blame^] | 42 | OatCompilationUnit* GetCallee(uint32_t callee_method_idx, |
| 43 | uint32_t callee_access_flags) { |
| 44 | return new OatCompilationUnit(class_loader_, class_linker_, *dex_file_, *dex_cache_, |
| 45 | NULL, callee_method_idx, callee_access_flags); |
| 46 | } |
| 47 | |
| 48 | char const* GetShorty() const { |
| 49 | DexFile::MethodId const& method_id = dex_file_->GetMethodId(method_idx_); |
| 50 | return dex_file_->GetMethodShorty(method_id); |
| 51 | } |
| 52 | |
| 53 | char const* GetShorty(uint32_t* shorty_len) const { |
| 54 | DexFile::MethodId const& method_id = dex_file_->GetMethodId(method_idx_); |
| 55 | return dex_file_->GetMethodShorty(method_id, shorty_len); |
| 56 | } |
| 57 | |
Logan Chien | 4dd96f5 | 2012-02-29 01:26:58 +0800 | [diff] [blame] | 58 | public: |
| 59 | ClassLoader const* class_loader_; |
| 60 | ClassLinker* class_linker_; |
| 61 | |
| 62 | DexFile const* dex_file_; |
| 63 | DexCache* dex_cache_; |
| 64 | |
| 65 | DexFile::CodeItem const* code_item_; |
| 66 | uint32_t method_idx_; |
| 67 | uint32_t access_flags_; |
| 68 | }; |
| 69 | |
| 70 | } // namespace art |
| 71 | |
| 72 | #endif // ART_SRC_METHOD_UNIT_H_ |