1 /*
2  * Copyright (C) 2013 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 #include "dex_compilation_unit.h"
18 
19 #include "base/stringprintf.h"
20 #include "dex/compiler_ir.h"
21 #include "utils.h"
22 
23 namespace art {
24 
DexCompilationUnit(CompilationUnit * cu,jobject class_loader,ClassLinker * class_linker,const DexFile & dex_file,const DexFile::CodeItem * code_item,uint16_t class_def_idx,uint32_t method_idx,uint32_t access_flags,const VerifiedMethod * verified_method)25 DexCompilationUnit::DexCompilationUnit(CompilationUnit* cu,
26                                        jobject class_loader,
27                                        ClassLinker* class_linker,
28                                        const DexFile& dex_file,
29                                        const DexFile::CodeItem* code_item,
30                                        uint16_t class_def_idx,
31                                        uint32_t method_idx,
32                                        uint32_t access_flags,
33                                        const VerifiedMethod* verified_method)
34     : cu_(cu),
35       class_loader_(class_loader),
36       class_linker_(class_linker),
37       dex_file_(&dex_file),
38       code_item_(code_item),
39       class_def_idx_(class_def_idx),
40       dex_method_idx_(method_idx),
41       access_flags_(access_flags),
42       verified_method_(verified_method) {
43 }
44 
GetSymbol()45 const std::string& DexCompilationUnit::GetSymbol() {
46   if (symbol_.empty()) {
47     symbol_ = "dex_";
48     symbol_ += MangleForJni(PrettyMethod(dex_method_idx_, *dex_file_));
49   }
50   return symbol_;
51 }
52 
53 }  // namespace art
54