1b1994897Sopenharmony_ci/**
2b1994897Sopenharmony_ci * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
3b1994897Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4b1994897Sopenharmony_ci * you may not use this file except in compliance with the License.
5b1994897Sopenharmony_ci * You may obtain a copy of the License at
6b1994897Sopenharmony_ci *
7b1994897Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0
8b1994897Sopenharmony_ci *
9b1994897Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10b1994897Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11b1994897Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12b1994897Sopenharmony_ci * See the License for the specific language governing permissions and
13b1994897Sopenharmony_ci * limitations under the License.
14b1994897Sopenharmony_ci */
15b1994897Sopenharmony_ci
16b1994897Sopenharmony_ci#ifndef ASSEMBLER_EXTENSIONS_ECMASCRIPT_META_H
17b1994897Sopenharmony_ci#define ASSEMBLER_EXTENSIONS_ECMASCRIPT_META_H
18b1994897Sopenharmony_ci
19b1994897Sopenharmony_ci#include "meta.h"
20b1994897Sopenharmony_ci
21b1994897Sopenharmony_cinamespace panda::pandasm::extensions::ecmascript {
22b1994897Sopenharmony_ci
23b1994897Sopenharmony_ciclass RecordMetadata : public pandasm::RecordMetadata {
24b1994897Sopenharmony_cipublic:
25b1994897Sopenharmony_ci    std::string GetBase() const override
26b1994897Sopenharmony_ci    {
27b1994897Sopenharmony_ci        auto base = GetAttributeValue("ecmascript.extends");
28b1994897Sopenharmony_ci        if (base) {
29b1994897Sopenharmony_ci            return base.value();
30b1994897Sopenharmony_ci        }
31b1994897Sopenharmony_ci
32b1994897Sopenharmony_ci        return "";
33b1994897Sopenharmony_ci    }
34b1994897Sopenharmony_ci
35b1994897Sopenharmony_ci    std::vector<std::string> GetInterfaces() const override
36b1994897Sopenharmony_ci    {
37b1994897Sopenharmony_ci        return {};
38b1994897Sopenharmony_ci    }
39b1994897Sopenharmony_ci
40b1994897Sopenharmony_ci    bool IsAnnotation() const override
41b1994897Sopenharmony_ci    {
42b1994897Sopenharmony_ci        return (GetAccessFlags() & ACC_ANNOTATION) != 0;
43b1994897Sopenharmony_ci    }
44b1994897Sopenharmony_ci
45b1994897Sopenharmony_ci    bool IsRuntimeAnnotation() const override
46b1994897Sopenharmony_ci    {
47b1994897Sopenharmony_ci        return false;
48b1994897Sopenharmony_ci    }
49b1994897Sopenharmony_ci
50b1994897Sopenharmony_ciprotected:
51b1994897Sopenharmony_ci    bool IsAnnotationRecordAttribute([[maybe_unused]] const std::string_view &attribute) const override
52b1994897Sopenharmony_ci    {
53b1994897Sopenharmony_ci        return false;
54b1994897Sopenharmony_ci    }
55b1994897Sopenharmony_ci
56b1994897Sopenharmony_ci    bool IsAnnotationIdAttribute([[maybe_unused]] const std::string_view &attribute) const override
57b1994897Sopenharmony_ci    {
58b1994897Sopenharmony_ci        return false;
59b1994897Sopenharmony_ci    }
60b1994897Sopenharmony_ci
61b1994897Sopenharmony_ci    bool IsAnnotationElementNameAttribute([[maybe_unused]] const std::string_view &attribute) const override
62b1994897Sopenharmony_ci    {
63b1994897Sopenharmony_ci        return false;
64b1994897Sopenharmony_ci    }
65b1994897Sopenharmony_ci
66b1994897Sopenharmony_ci    bool IsAnnotationElementTypeAttribute([[maybe_unused]] const std::string_view &attribute) const override
67b1994897Sopenharmony_ci    {
68b1994897Sopenharmony_ci        return false;
69b1994897Sopenharmony_ci    }
70b1994897Sopenharmony_ci
71b1994897Sopenharmony_ci    bool IsAnnotationElementArrayComponentTypeAttribute(
72b1994897Sopenharmony_ci        [[maybe_unused]] const std::string_view &attribute) const override
73b1994897Sopenharmony_ci    {
74b1994897Sopenharmony_ci        return false;
75b1994897Sopenharmony_ci    }
76b1994897Sopenharmony_ci
77b1994897Sopenharmony_ci    bool IsAnnotationElementValueAttribute([[maybe_unused]] const std::string_view &attribute) const override
78b1994897Sopenharmony_ci    {
79b1994897Sopenharmony_ci        return false;
80b1994897Sopenharmony_ci    }
81b1994897Sopenharmony_ci
82b1994897Sopenharmony_ci    std::optional<Error> Validate(const std::string_view &attribute) const override;
83b1994897Sopenharmony_ci
84b1994897Sopenharmony_ci    std::optional<Error> Validate(const std::string_view &attribute, const std::string_view &value) const override;
85b1994897Sopenharmony_ci
86b1994897Sopenharmony_ci    void SetFlags(const std::string_view &attribute) override;
87b1994897Sopenharmony_ci
88b1994897Sopenharmony_ci    void SetFlags(const std::string_view &attribute, const std::string_view &value) override;
89b1994897Sopenharmony_ci
90b1994897Sopenharmony_ci    void RemoveFlags(const std::string_view &attribute) override;
91b1994897Sopenharmony_ci
92b1994897Sopenharmony_ci    void RemoveFlags(const std::string_view &attribute, const std::string_view &value) override;
93b1994897Sopenharmony_ci};
94b1994897Sopenharmony_ci
95b1994897Sopenharmony_ciclass FieldMetadata : public pandasm::FieldMetadata {
96b1994897Sopenharmony_ciprotected:
97b1994897Sopenharmony_ci    bool IsAnnotationRecordAttribute([[maybe_unused]] const std::string_view &attribute) const override
98b1994897Sopenharmony_ci    {
99b1994897Sopenharmony_ci        return false;
100b1994897Sopenharmony_ci    }
101b1994897Sopenharmony_ci
102b1994897Sopenharmony_ci    bool IsAnnotationIdAttribute([[maybe_unused]] const std::string_view &attribute) const override
103b1994897Sopenharmony_ci    {
104b1994897Sopenharmony_ci        return false;
105b1994897Sopenharmony_ci    }
106b1994897Sopenharmony_ci
107b1994897Sopenharmony_ci    bool IsAnnotationElementNameAttribute([[maybe_unused]] const std::string_view &attribute) const override
108b1994897Sopenharmony_ci    {
109b1994897Sopenharmony_ci        return false;
110b1994897Sopenharmony_ci    }
111b1994897Sopenharmony_ci
112b1994897Sopenharmony_ci    bool IsAnnotationElementTypeAttribute([[maybe_unused]] const std::string_view &attribute) const override
113b1994897Sopenharmony_ci    {
114b1994897Sopenharmony_ci        return false;
115b1994897Sopenharmony_ci    }
116b1994897Sopenharmony_ci
117b1994897Sopenharmony_ci    bool IsAnnotationElementArrayComponentTypeAttribute(
118b1994897Sopenharmony_ci        [[maybe_unused]] const std::string_view &attribute) const override
119b1994897Sopenharmony_ci    {
120b1994897Sopenharmony_ci        return false;
121b1994897Sopenharmony_ci    }
122b1994897Sopenharmony_ci
123b1994897Sopenharmony_ci    bool IsAnnotationElementValueAttribute([[maybe_unused]] const std::string_view &attribute) const override
124b1994897Sopenharmony_ci    {
125b1994897Sopenharmony_ci        return false;
126b1994897Sopenharmony_ci    }
127b1994897Sopenharmony_ci
128b1994897Sopenharmony_ci    std::optional<Error> Validate(const std::string_view &attribute) const override;
129b1994897Sopenharmony_ci
130b1994897Sopenharmony_ci    std::optional<Error> Validate(const std::string_view &attribute, const std::string_view &value) const override;
131b1994897Sopenharmony_ci
132b1994897Sopenharmony_ci    void SetFlags(const std::string_view &attribute) override;
133b1994897Sopenharmony_ci
134b1994897Sopenharmony_ci    void SetFlags(const std::string_view &attribute, const std::string_view &value) override;
135b1994897Sopenharmony_ci
136b1994897Sopenharmony_ci    void RemoveFlags(const std::string_view &attribute) override;
137b1994897Sopenharmony_ci
138b1994897Sopenharmony_ci    void RemoveFlags(const std::string_view &attribute, const std::string_view &value) override;
139b1994897Sopenharmony_ci};
140b1994897Sopenharmony_ci
141b1994897Sopenharmony_ciclass FunctionMetadata : public pandasm::FunctionMetadata {
142b1994897Sopenharmony_ciprotected:
143b1994897Sopenharmony_ci    bool IsAnnotationRecordAttribute([[maybe_unused]] const std::string_view &attribute) const override
144b1994897Sopenharmony_ci    {
145b1994897Sopenharmony_ci        return false;
146b1994897Sopenharmony_ci    }
147b1994897Sopenharmony_ci
148b1994897Sopenharmony_ci    bool IsAnnotationIdAttribute([[maybe_unused]] const std::string_view &attribute) const override
149b1994897Sopenharmony_ci    {
150b1994897Sopenharmony_ci        return false;
151b1994897Sopenharmony_ci    }
152b1994897Sopenharmony_ci
153b1994897Sopenharmony_ci    bool IsAnnotationElementNameAttribute([[maybe_unused]] const std::string_view &attribute) const override
154b1994897Sopenharmony_ci    {
155b1994897Sopenharmony_ci        return false;
156b1994897Sopenharmony_ci    }
157b1994897Sopenharmony_ci
158b1994897Sopenharmony_ci    bool IsAnnotationElementTypeAttribute([[maybe_unused]] const std::string_view &attribute) const override
159b1994897Sopenharmony_ci    {
160b1994897Sopenharmony_ci        return false;
161b1994897Sopenharmony_ci    }
162b1994897Sopenharmony_ci
163b1994897Sopenharmony_ci    bool IsAnnotationElementArrayComponentTypeAttribute(
164b1994897Sopenharmony_ci        [[maybe_unused]] const std::string_view &attribute) const override
165b1994897Sopenharmony_ci    {
166b1994897Sopenharmony_ci        return false;
167b1994897Sopenharmony_ci    }
168b1994897Sopenharmony_ci
169b1994897Sopenharmony_ci    bool IsAnnotationElementValueAttribute([[maybe_unused]] const std::string_view &attribute) const override
170b1994897Sopenharmony_ci    {
171b1994897Sopenharmony_ci        return false;
172b1994897Sopenharmony_ci    }
173b1994897Sopenharmony_ci
174b1994897Sopenharmony_ci    std::optional<Error> Validate(const std::string_view &attribute) const override;
175b1994897Sopenharmony_ci
176b1994897Sopenharmony_ci    std::optional<Error> Validate(const std::string_view &attribute, const std::string_view &value) const override;
177b1994897Sopenharmony_ci
178b1994897Sopenharmony_ci    void SetFlags(const std::string_view &attribute) override;
179b1994897Sopenharmony_ci
180b1994897Sopenharmony_ci    void SetFlags(const std::string_view &attribute, const std::string_view &value) override;
181b1994897Sopenharmony_ci
182b1994897Sopenharmony_ci    void RemoveFlags(const std::string_view &attribute) override;
183b1994897Sopenharmony_ci
184b1994897Sopenharmony_ci    void RemoveFlags(const std::string_view &attribute, const std::string_view &value) override;
185b1994897Sopenharmony_ci};
186b1994897Sopenharmony_ci
187b1994897Sopenharmony_ciclass ParamMetadata : public pandasm::ParamMetadata {
188b1994897Sopenharmony_ciprotected:
189b1994897Sopenharmony_ci    bool IsAnnotationRecordAttribute([[maybe_unused]] const std::string_view &attribute) const override
190b1994897Sopenharmony_ci    {
191b1994897Sopenharmony_ci        return false;
192b1994897Sopenharmony_ci    }
193b1994897Sopenharmony_ci
194b1994897Sopenharmony_ci    bool IsAnnotationIdAttribute([[maybe_unused]] const std::string_view &attribute) const override
195b1994897Sopenharmony_ci    {
196b1994897Sopenharmony_ci        return false;
197b1994897Sopenharmony_ci    }
198b1994897Sopenharmony_ci
199b1994897Sopenharmony_ci    bool IsAnnotationElementNameAttribute([[maybe_unused]] const std::string_view &attribute) const override
200b1994897Sopenharmony_ci    {
201b1994897Sopenharmony_ci        return false;
202b1994897Sopenharmony_ci    }
203b1994897Sopenharmony_ci
204b1994897Sopenharmony_ci    bool IsAnnotationElementTypeAttribute([[maybe_unused]] const std::string_view &attribute) const override
205b1994897Sopenharmony_ci    {
206b1994897Sopenharmony_ci        return false;
207b1994897Sopenharmony_ci    }
208b1994897Sopenharmony_ci
209b1994897Sopenharmony_ci    bool IsAnnotationElementArrayComponentTypeAttribute(
210b1994897Sopenharmony_ci        [[maybe_unused]] const std::string_view &attribute) const override
211b1994897Sopenharmony_ci    {
212b1994897Sopenharmony_ci        return false;
213b1994897Sopenharmony_ci    }
214b1994897Sopenharmony_ci
215b1994897Sopenharmony_ci    bool IsAnnotationElementValueAttribute([[maybe_unused]] const std::string_view &attribute) const override
216b1994897Sopenharmony_ci    {
217b1994897Sopenharmony_ci        return false;
218b1994897Sopenharmony_ci    }
219b1994897Sopenharmony_ci
220b1994897Sopenharmony_ci    std::optional<Error> Validate(const std::string_view &attribute) const override;
221b1994897Sopenharmony_ci
222b1994897Sopenharmony_ci    std::optional<Error> Validate(const std::string_view &attribute, const std::string_view &value) const override;
223b1994897Sopenharmony_ci
224b1994897Sopenharmony_ci    void SetFlags(const std::string_view &attribute) override;
225b1994897Sopenharmony_ci
226b1994897Sopenharmony_ci    void SetFlags(const std::string_view &attribute, const std::string_view &value) override;
227b1994897Sopenharmony_ci
228b1994897Sopenharmony_ci    void RemoveFlags(const std::string_view &attribute) override;
229b1994897Sopenharmony_ci
230b1994897Sopenharmony_ci    void RemoveFlags(const std::string_view &attribute, const std::string_view &value) override;
231b1994897Sopenharmony_ci};
232b1994897Sopenharmony_ci
233b1994897Sopenharmony_ci}  // namespace panda::pandasm::extensions::ecmascript
234b1994897Sopenharmony_ci
235b1994897Sopenharmony_ci#endif  // ASSEMBLER_EXTENSIONS_ECMASCRIPT_META_H
236