blob: ec7c9a30e84cda20679474ef1609b7f4c1c06aa1 [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:
Ian Rogers00f7d0e2012-07-19 15:28:27 -070033 OatCompilationUnit(jobject class_loader, ClassLinker* class_linker, const DexFile& dex_file,
TDYa127dc5daa02013-01-09 21:31:37 +080034 const DexFile::CodeItem* code_item, uint32_t class_def_idx,
35 uint32_t method_idx, uint32_t access_flags)
Ian Rogers00f7d0e2012-07-19 15:28:27 -070036 : class_loader_(class_loader), class_linker_(class_linker), dex_file_(&dex_file),
TDYa127dc5daa02013-01-09 21:31:37 +080037 code_item_(code_item), class_def_idx_(class_def_idx), method_idx_(method_idx),
38 access_flags_(access_flags) {
Logan Chien4dd96f52012-02-29 01:26:58 +080039 }
40
Logan Chien61c65dc2012-02-29 03:22:30 +080041 OatCompilationUnit* GetCallee(uint32_t callee_method_idx,
Logan Chienbfe4ea42012-03-01 13:24:17 +080042 uint32_t callee_access_flags) {
Ian Rogers00f7d0e2012-07-19 15:28:27 -070043 return new OatCompilationUnit(class_loader_, class_linker_, *dex_file_, NULL,
TDYa127dc5daa02013-01-09 21:31:37 +080044 0, callee_method_idx, callee_access_flags);
Logan Chien61c65dc2012-02-29 03:22:30 +080045 }
46
Ian Rogers00f7d0e2012-07-19 15:28:27 -070047 jobject GetClassLoader() const {
Logan Chiendd361c92012-04-10 23:40:37 +080048 return class_loader_;
49 }
50
51 ClassLinker* GetClassLinker() const {
52 return class_linker_;
53 }
54
55 const DexFile* GetDexFile() const {
56 return dex_file_;
57 }
58
TDYa127dc5daa02013-01-09 21:31:37 +080059 uint32_t GetClassDefIndex() const {
60 return class_def_idx_;
61 }
62
Logan Chiendd361c92012-04-10 23:40:37 +080063 uint32_t GetDexMethodIndex() const {
64 return method_idx_;
65 }
66
67 const DexFile::CodeItem* GetCodeItem() const {
68 return code_item_;
69 }
70
Logan Chienbfe4ea42012-03-01 13:24:17 +080071 const char* GetShorty() const {
72 const DexFile::MethodId& method_id = dex_file_->GetMethodId(method_idx_);
Logan Chien61c65dc2012-02-29 03:22:30 +080073 return dex_file_->GetMethodShorty(method_id);
74 }
75
Logan Chienbfe4ea42012-03-01 13:24:17 +080076 const char* GetShorty(uint32_t* shorty_len) const {
77 const DexFile::MethodId& method_id = dex_file_->GetMethodId(method_idx_);
Logan Chien61c65dc2012-02-29 03:22:30 +080078 return dex_file_->GetMethodShorty(method_id, shorty_len);
79 }
80
Logan Chiendd361c92012-04-10 23:40:37 +080081 bool IsStatic() const {
82 return ((access_flags_ & kAccStatic) != 0);
83 }
84
Logan Chien4dd96f52012-02-29 01:26:58 +080085 public:
Ian Rogers00f7d0e2012-07-19 15:28:27 -070086 jobject class_loader_;
87 ClassLinker* const class_linker_;
Logan Chien4dd96f52012-02-29 01:26:58 +080088
Ian Rogers00f7d0e2012-07-19 15:28:27 -070089 const DexFile* const dex_file_;
Logan Chien4dd96f52012-02-29 01:26:58 +080090
Ian Rogers00f7d0e2012-07-19 15:28:27 -070091 const DexFile::CodeItem* const code_item_;
TDYa127dc5daa02013-01-09 21:31:37 +080092 const uint32_t class_def_idx_;
Ian Rogers00f7d0e2012-07-19 15:28:27 -070093 const uint32_t method_idx_;
94 const uint32_t access_flags_;
Logan Chien4dd96f52012-02-29 01:26:58 +080095};
96
97} // namespace art
98
Logan Chien4eb953f2012-03-01 13:16:52 +080099#endif // ART_SRC_OAT_COMPILATION_UNIT_H_