1 /*
2 * Copyright (c) 2024 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 "runtime_adapter_static.h"
17 #include "static_core/runtime/include/method.h"
18
19 namespace libabckit {
20
21 // CC-OFFNXT(WordsTool.95) sensitive word conflict
22 // NOLINTNEXTLINE(google-build-using-namespace)
23 using namespace ark;
24
IsEqual(panda_file::MethodDataAccessor mda,std::initializer_list<panda_file::Type::TypeId> shorties,std::initializer_list<std::string_view> refTypes)25 bool AbckitRuntimeAdapterStatic::IsEqual(panda_file::MethodDataAccessor mda,
26 std::initializer_list<panda_file::Type::TypeId> shorties,
27 std::initializer_list<std::string_view> refTypes)
28 {
29 bool equal = true;
30 auto shortyIt = shorties.begin();
31 auto refTypeIt = refTypes.begin();
32 auto &pf = mda.GetPandaFile();
33
34 auto visitType = [&equal, &shorties, &shortyIt, &refTypes, &refTypeIt, &pf](panda_file::Type type,
35 panda_file::File::EntityId classId) {
36 if (!equal) {
37 return;
38 }
39 if (shortyIt == shorties.end() || *shortyIt++ != type.GetId()) {
40 equal = false;
41 return;
42 }
43 if (type.IsReference() &&
44 (refTypeIt == refTypes.end() || *refTypeIt++ != utf::Mutf8AsCString(pf.GetStringData(classId).data))) {
45 equal = false;
46 }
47 };
48 mda.EnumerateTypesInProto(visitType, true); // true for skipThis
49 return equal && shortyIt == shorties.end() && refTypeIt == refTypes.end();
50 }
51
52 #include "generated/get_intrinsic_id_static.inc"
53
54 } // namespace libabckit
55