1/*
2 * Copyright (c) 2023 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#ifndef ECMASCRIPT_PROPERTY_DETECTOR_H
17#define ECMASCRIPT_PROPERTY_DETECTOR_H
18
19#include "ecmascript/ecma_macros.h"
20#include "ecmascript/js_handle.h"
21#include "ecmascript/js_tagged_value.h"
22
23namespace panda {
24namespace ecmascript {
25class GlobalEnv;
26class PropertyDetector {
27public:
28#define GLOBAL_ENV_DETECTOR_FIELDS(V)                                                   \
29    V(JSTaggedValue, RegExpReplaceDetector, REGEXP_REPLACE_DETECTOR_INDEX)              \
30    V(JSTaggedValue, MapIteratorDetector, MAP_ITERATOR_DETECTOR_INDEX)                  \
31    V(JSTaggedValue, SetIteratorDetector, SET_ITERATOR_DETECTOR_INDEX)                  \
32    V(JSTaggedValue, StringIteratorDetector, STRING_ITERATOR_DETECTOR_INDEX)            \
33    V(JSTaggedValue, ArrayIteratorDetector, ARRAY_ITERATOR_DETECTOR_INDEX)              \
34    V(JSTaggedValue, TypedArrayIteratorDetector, TYPED_ARRAY_ITERATOR_DETECTOR_INDEX)   \
35    V(JSTaggedValue, TypedArraySpeciesProtectDetector, TYPED_ARRAY_SPECIES_PROTECT_DETECTOR_INDEX)    \
36    V(JSTaggedValue, NumberStringNotRegexpLikeDetector, NUMBER_STRING_NOT_REGEXP_LIKE_DETECTOR_INDEX) \
37    V(JSTaggedValue, RegExpFlagsDetector, REGEXP_FLAGS_DETECTOR_INDEX)                                \
38    V(JSTaggedValue, RegExpSpeciesDetector, REGEXP_SPECIES_DETECTOR_INDEX)
39
40#define DECLARE_DETECTOR(type, name, index)                        \
41    static inline bool Is##name##Valid(JSHandle<GlobalEnv> env);   \
42    static inline void Invalidate##name(JSHandle<GlobalEnv> env);
43    GLOBAL_ENV_DETECTOR_FIELDS(DECLARE_DETECTOR)
44#undef DECLARE_DETECTOR
45
46#define DETECTOR_SYMBOL_LIST(V)                      \
47    V(ReplaceSymbol,  "Symbol.replace",   replace )  \
48    V(SplitSymbol,    "Symbol.split",     split   )  \
49    V(MatchAllSymbol, "Symbol.matchAll",  matchAll)  \
50    V(IteratorSymbol, "Symbol.iterator",  iterator)  \
51    V(SpeciesSymbol,  "Symbol.species",   species)
52};
53
54}  // namespace ecmascript
55}  // namespace panda
56
57#endif  // ECMASCRIPT_PROPERTY_DETECTOR_H
58