• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "method_data_accessor.h"
17 
18 namespace panda::panda_file {
19 
MethodDataAccessor(const File & panda_file,File::EntityId method_id)20 MethodDataAccessor::MethodDataAccessor(const File &panda_file, File::EntityId method_id)
21     : panda_file_(panda_file), method_id_(method_id)
22 {
23     auto sp = panda_file_.GetSpanFromId(method_id);
24 
25     class_idx_ = helpers::Read<IDX_SIZE>(&sp);
26     proto_idx_ = helpers::Read<IDX_SIZE>(&sp);
27 
28     class_off_ = panda_file.ResolveClassIndex(method_id, class_idx_).GetOffset();
29     proto_off_ = panda_file.ResolveProtoIndex(method_id, proto_idx_).GetOffset();
30 
31     name_off_ = helpers::Read<ID_SIZE>(&sp);
32     access_flags_ = helpers::ReadULeb128(&sp);
33 
34     is_external_ = panda_file_.IsExternal(method_id);
35 
36     if (!is_external_) {
37         tagged_values_sp_ = sp;
38         size_ = 0;
39     } else {
40         size_ = panda_file_.GetIdFromPointer(sp.data()).GetOffset() - method_id_.GetOffset();
41     }
42 }
43 
44 }  // namespace panda::panda_file
45