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_BUILTINS_BUILTINS_LAZY_CALLBACK_H 17 #define ECMASCRIPT_BUILTINS_BUILTINS_LAZY_CALLBACK_H 18 19 #include "ecmascript/global_env.h" 20 #include "ecmascript/js_function.h" 21 #include "ecmascript/js_handle.h" 22 #include "ecmascript/js_tagged_value.h" 23 #include "ecmascript/js_thread.h" 24 #include "ecmascript/object_factory.h" 25 26 // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) 27 #define ITERATE_TYPED_ARRAY(V) \ 28 V(Int8Array) \ 29 V(Uint8Array) \ 30 V(Uint8ClampedArray) \ 31 V(Int16Array) \ 32 V(Uint16Array) \ 33 V(Int32Array) \ 34 V(Uint32Array) \ 35 V(Float32Array) \ 36 V(Float64Array) \ 37 V(BigInt64Array) \ 38 V(BigUint64Array) 39 40 #define ITERATE_INTL(V) \ 41 V(Locale) \ 42 V(DateTimeFormat) \ 43 V(NumberFormat) \ 44 V(RelativeTimeFormat) \ 45 V(Collator) \ 46 V(PluralRules) \ 47 V(DisplayNames) \ 48 V(ListFormat) \ 49 50 namespace panda::ecmascript::builtins { 51 class BuiltinsLazyCallback { 52 public: 53 static JSTaggedValue Date(JSThread *thread, const JSHandle<JSObject> &obj); 54 static JSTaggedValue Set(JSThread *thread, const JSHandle<JSObject> &obj); 55 static JSTaggedValue Map(JSThread *thread, const JSHandle<JSObject> &obj); 56 static JSTaggedValue WeakMap(JSThread *thread, const JSHandle<JSObject> &obj); 57 static JSTaggedValue WeakSet(JSThread *thread, const JSHandle<JSObject> &obj); 58 static JSTaggedValue WeakRef(JSThread *thread, const JSHandle<JSObject> &obj); 59 static JSTaggedValue FinalizationRegistry(JSThread *thread, const JSHandle<JSObject> &obj); 60 static JSTaggedValue TypedArray(JSThread *thread, const JSHandle<JSObject> &obj); 61 static JSTaggedValue Int8Array(JSThread *thread, const JSHandle<JSObject> &obj); 62 static JSTaggedValue Uint8Array(JSThread *thread, const JSHandle<JSObject> &obj); 63 static JSTaggedValue Uint8ClampedArray(JSThread *thread, const JSHandle<JSObject> &obj); 64 static JSTaggedValue Int16Array(JSThread *thread, const JSHandle<JSObject> &obj); 65 static JSTaggedValue Uint16Array(JSThread *thread, const JSHandle<JSObject> &obj); 66 static JSTaggedValue Int32Array(JSThread *thread, const JSHandle<JSObject> &obj); 67 static JSTaggedValue Uint32Array(JSThread *thread, const JSHandle<JSObject> &obj); 68 static JSTaggedValue Float32Array(JSThread *thread, const JSHandle<JSObject> &obj); 69 static JSTaggedValue Float64Array(JSThread *thread, const JSHandle<JSObject> &obj); 70 static JSTaggedValue BigInt64Array(JSThread *thread, const JSHandle<JSObject> &obj); 71 static JSTaggedValue BigUint64Array(JSThread *thread, const JSHandle<JSObject> &obj); 72 static JSTaggedValue ArrayBuffer(JSThread *thread, const JSHandle<JSObject> &obj); 73 static JSTaggedValue DataView(JSThread *thread, const JSHandle<JSObject> &obj); 74 static JSTaggedValue SharedArrayBuffer(JSThread *thread, const JSHandle<JSObject> &obj); 75 #ifdef ARK_SUPPORT_INTL 76 static JSTaggedValue Locale(JSThread *thread, const JSHandle<JSObject> &obj); 77 static JSTaggedValue DateTimeFormat(JSThread *thread, const JSHandle<JSObject> &obj); 78 static JSTaggedValue NumberFormat(JSThread *thread, const JSHandle<JSObject> &obj); 79 static JSTaggedValue RelativeTimeFormat(JSThread *thread, const JSHandle<JSObject> &obj); 80 static JSTaggedValue Collator(JSThread *thread, const JSHandle<JSObject> &obj); 81 static JSTaggedValue PluralRules(JSThread *thread, const JSHandle<JSObject> &obj); 82 static JSTaggedValue DisplayNames(JSThread *thread, const JSHandle<JSObject> &obj); 83 static JSTaggedValue ListFormat(JSThread *thread, const JSHandle<JSObject> &obj); 84 #endif 85 86 private: 87 static void ResetLazyInternalAttr(JSThread *thread, const JSHandle<JSObject> &object, const char *key); 88 }; 89 } // namespace panda::ecmascript::builtins 90 #endif // ECMASCRIPT_BUILTINS_BUILTINS_LAZY_CALLBACK_H