• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2023-2025 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 "plugins/ets/runtime/ets_annotation.h"
17 
18 #include "libpandafile/annotation_data_accessor.h"
19 #include "libpandafile/method_data_accessor-inl.h"
20 #include "plugins/ets/runtime/ets_panda_file_items.h"
21 #include "runtime/include/method.h"
22 
23 namespace ark::ets {
24 
25 /*static*/
FindAsyncAnnotation(const Method * method)26 panda_file::File::EntityId EtsAnnotation::FindAsyncAnnotation(const Method *method)
27 {
28     panda_file::File::EntityId asyncAnnId;
29     const panda_file::File &pf = *method->GetPandaFile();
30     panda_file::MethodDataAccessor mda(pf, method->GetFileId());
31     mda.EnumerateAnnotations([&pf, &asyncAnnId](panda_file::File::EntityId annId) {
32         panda_file::AnnotationDataAccessor ada(pf, annId);
33         const char *className = utf::Mutf8AsCString(pf.GetStringData(ada.GetClassId()).data);
34         if (className == panda_file_items::class_descriptors::ASYNC) {
35             asyncAnnId = annId;
36         }
37     });
38     return asyncAnnId;
39 }
40 
41 }  // namespace ark::ets
42