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 23 namespace panda { 24 namespace ecmascript { 25 class GlobalEnv; 26 class PropertyDetector { 27 public: 28 #define GLOBAL_ENV_DETECTOR_FIELDS(V) \ 29 V(JSTaggedValue, RegExpReplaceDetector, REGEXP_REPLACE_DETECTOR_INDEX) \ 30 V(JSTaggedValue, RegExpSplitDetector, REGEXP_SPLIT_DETECTOR_INDEX) \ 31 V(JSTaggedValue, MapIteratorDetector, MAP_ITERATOR_DETECTOR_INDEX) \ 32 V(JSTaggedValue, SetIteratorDetector, SET_ITERATOR_DETECTOR_INDEX) \ 33 V(JSTaggedValue, StringIteratorDetector, STRING_ITERATOR_DETECTOR_INDEX) \ 34 V(JSTaggedValue, ArrayIteratorDetector, ARRAY_ITERATOR_DETECTOR_INDEX) \ 35 V(JSTaggedValue, TypedArrayIteratorDetector, TYPED_ARRAY_ITERATOR_DETECTOR_INDEX) \ 36 V(JSTaggedValue, TypedArraySpeciesProtectDetector, TYPED_ARRAY_SPECIES_PROTECT_DETECTOR_INDEX) 37 38 #define DECLARE_DETECTOR(type, name, index) \ 39 static inline bool Is##name##Valid(JSHandle<GlobalEnv> env); \ 40 static inline void Invalidate##name(JSHandle<GlobalEnv> env); 41 GLOBAL_ENV_DETECTOR_FIELDS(DECLARE_DETECTOR) 42 #undef DECLARE_DETECTOR 43 44 #define DETECTOR_SYMBOL_LIST(V) \ 45 V(ReplaceSymbol, "Symbol.replace", replace ) \ 46 V(SplitSymbol, "Symbol.split", split ) \ 47 V(IteratorSymbol, "Symbol.iterator", iterator) \ 48 V(SpeciesSymbol, "Symbol.species", species) 49 }; 50 51 } // namespace ecmascript 52 } // namespace panda 53 54 #endif // ECMASCRIPT_PROPERTY_DETECTOR_H 55