• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2011 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_RUNTIME_DEX_FILE_INL_H_
18 #define ART_RUNTIME_DEX_FILE_INL_H_
19 
20 #include "base/logging.h"
21 #include "dex_file.h"
22 #include "leb128.h"
23 #include "utils.h"
24 
25 namespace art {
26 
GetStringLength(const StringId & string_id)27 inline int32_t DexFile::GetStringLength(const StringId& string_id) const {
28   const byte* ptr = begin_ + string_id.string_data_off_;
29   return DecodeUnsignedLeb128(&ptr);
30 }
31 
GetStringDataAndLength(const StringId & string_id,uint32_t * length)32 inline const char* DexFile::GetStringDataAndLength(const StringId& string_id, uint32_t* length) const {
33   DCHECK(length != NULL) << GetLocation();
34   const byte* ptr = begin_ + string_id.string_data_off_;
35   *length = DecodeUnsignedLeb128(&ptr);
36   return reinterpret_cast<const char*>(ptr);
37 }
38 
GetTryItems(const CodeItem & code_item,uint32_t offset)39 inline const DexFile::TryItem* DexFile::GetTryItems(const CodeItem& code_item, uint32_t offset) {
40   const uint16_t* insns_end_ = &code_item.insns_[code_item.insns_size_in_code_units_];
41   return reinterpret_cast<const TryItem*>
42       (RoundUp(reinterpret_cast<uint32_t>(insns_end_), 4)) + offset;
43 }
44 
45 }  // namespace art
46 
47 #endif  // ART_RUNTIME_DEX_FILE_INL_H_
48