blob: 0000f216b60b891df382928fd8d867339d772717 [file] [log] [blame]
Logan Chien4dd96f52012-02-29 01:26:58 +08001/*
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
Logan Chien4eb953f2012-03-01 13:16:52 +080017#ifndef ART_SRC_OAT_COMPILATION_UNIT_H_
18#define ART_SRC_OAT_COMPILATION_UNIT_H_
Logan Chien4dd96f52012-02-29 01:26:58 +080019
Logan Chien61c65dc2012-02-29 03:22:30 +080020#include "dex_file.h"
21
Logan Chien4dd96f52012-02-29 01:26:58 +080022#include <stdint.h>
23
24namespace art {
25
26class ClassLoader;
27class ClassLinker;
28class DexFile;
29class DexCache;
30
31class OatCompilationUnit {
32 public:
Logan Chienbfe4ea42012-03-01 13:24:17 +080033 OatCompilationUnit(const ClassLoader* class_loader, ClassLinker* class_linker,
34 const DexFile& dex_file, DexCache& dex_cache,
35 const DexFile::CodeItem* code_item,
Logan Chien4dd96f52012-02-29 01:26:58 +080036 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 Chien61c65dc2012-02-29 03:22:30 +080042 OatCompilationUnit* GetCallee(uint32_t callee_method_idx,
Logan Chienbfe4ea42012-03-01 13:24:17 +080043 uint32_t callee_access_flags) {
44 return new OatCompilationUnit(class_loader_, class_linker_, *dex_file_,
45 *dex_cache_, NULL, callee_method_idx,
46 callee_access_flags);
Logan Chien61c65dc2012-02-29 03:22:30 +080047 }
48
Logan Chiendd361c92012-04-10 23:40:37 +080049 const ClassLoader* GetClassLoader() const {
50 return class_loader_;
51 }
52
53 ClassLinker* GetClassLinker() const {
54 return class_linker_;
55 }
56
57 const DexFile* GetDexFile() const {
58 return dex_file_;
59 }
60
61 DexCache* GetDexCache() const {
62 return dex_cache_;
63 }
64
65 uint32_t GetDexMethodIndex() const {
66 return method_idx_;
67 }
68
69 const DexFile::CodeItem* GetCodeItem() const {
70 return code_item_;
71 }
72
Logan Chienbfe4ea42012-03-01 13:24:17 +080073 const char* GetShorty() const {
74 const DexFile::MethodId& method_id = dex_file_->GetMethodId(method_idx_);
Logan Chien61c65dc2012-02-29 03:22:30 +080075 return dex_file_->GetMethodShorty(method_id);
76 }
77
Logan Chienbfe4ea42012-03-01 13:24:17 +080078 const char* GetShorty(uint32_t* shorty_len) const {
79 const DexFile::MethodId& method_id = dex_file_->GetMethodId(method_idx_);
Logan Chien61c65dc2012-02-29 03:22:30 +080080 return dex_file_->GetMethodShorty(method_id, shorty_len);
81 }
82
Logan Chiendd361c92012-04-10 23:40:37 +080083 bool IsStatic() const {
84 return ((access_flags_ & kAccStatic) != 0);
85 }
86
Logan Chien4dd96f52012-02-29 01:26:58 +080087 public:
Logan Chienbfe4ea42012-03-01 13:24:17 +080088 const ClassLoader* class_loader_;
Logan Chien4dd96f52012-02-29 01:26:58 +080089 ClassLinker* class_linker_;
90
Logan Chienbfe4ea42012-03-01 13:24:17 +080091 const DexFile* dex_file_;
Logan Chien4dd96f52012-02-29 01:26:58 +080092 DexCache* dex_cache_;
93
Logan Chienbfe4ea42012-03-01 13:24:17 +080094 const DexFile::CodeItem* code_item_;
Logan Chien4dd96f52012-02-29 01:26:58 +080095 uint32_t method_idx_;
96 uint32_t access_flags_;
97};
98
99} // namespace art
100
Logan Chien4eb953f2012-03-01 13:16:52 +0800101#endif // ART_SRC_OAT_COMPILATION_UNIT_H_