/* * Copyright (c) 2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ECMASCRIPT_CONTAINERS_CONTAINERS_PRIVATE_H #define ECMASCRIPT_CONTAINERS_CONTAINERS_PRIVATE_H #include "ecmascript/base/builtins_base.h" namespace panda::ecmascript::containers { using InitializeFunction = JSHandle (*)(JSThread *); enum FuncLength : uint8_t { ZERO = 0, ONE, TWO, THREE, FOUR }; enum ContainerTag : uint8_t { ArrayList = 0, Queue, Deque, Stack, Vector, List, LinkedList, TreeMap, TreeSet, HashMap, HashSet, LightWeightMap, LightWeightSet, PlainArray, END }; // Using Lazy-loading container, including ArrayList, Queue, Stack, Vector, List, LinkedList, Deque, // TreeMap, TreeSet, HashMap, HashSet, LightWeightMap, LightWeightSet, PlainArray. // Use through ArkPrivate.Load([ContainerTag]) in js, ContainTag was declaerd in ArkPrivate like ArkPrivate::ArrayList. class ContainersPrivate : public base::BuiltinsBase { public: static JSTaggedValue Load(EcmaRuntimeCallInfo *msg); private: static JSHandle NewContainerConstructor(JSThread *thread, const JSHandle &prototype, EcmaEntrypoint ctorFunc, const char *name, int length); static JSHandle NewFunction(JSThread *thread, const JSHandle &key, EcmaEntrypoint func, int length, kungfu::BuiltinsStubCSigns::ID builtinId = kungfu::BuiltinsStubCSigns::INVALID); static void SetFrozenFunction(JSThread *thread, const JSHandle &obj, const char *key, EcmaEntrypoint func, int length, kungfu::BuiltinsStubCSigns::ID builtinId = kungfu::BuiltinsStubCSigns::INVALID); static void SetFrozenConstructor(JSThread *thread, const JSHandle &obj, const char *keyChar, JSHandle &value); static JSHandle CreateGetter(JSThread *thread, EcmaEntrypoint func, const char *name, int length); static void SetGetter(JSThread *thread, const JSHandle &obj, const JSHandle &key, const JSHandle &getter); static void SetFunctionAtSymbol(JSThread *thread, const JSHandle &env, const JSHandle &obj, const JSHandle &symbol, const char *name, EcmaEntrypoint func, int length); static void SetStringTagSymbol(JSThread *thread, const JSHandle &env, const JSHandle &obj, const char *key); static JSTaggedValue InitializeContainer(JSThread *thread, const JSHandle &obj, InitializeFunction func, const char *name); static JSHandle InitializeArrayList(JSThread *thread); static void InitializeArrayListIterator(JSThread *thread, const JSHandle &env, GlobalEnvConstants *globalConst); static JSHandle InitializeHashMap(JSThread *thread); static void InitializeHashMapIterator(JSThread *thread); static JSHandle InitializeHashSet(JSThread *thread); static void InitializeHashSetIterator(JSThread *thread); static JSHandle InitializeLightWeightMap(JSThread *thread); static void InitializeLightWeightMapIterator(JSThread *thread); static JSHandle InitializeLightWeightSet(JSThread *thread); static void InitializeLightWeightSetIterator(JSThread *thread); static JSHandle InitializeTreeMap(JSThread *thread); static void InitializeTreeMapIterator(JSThread *thread); static JSHandle InitializeTreeSet(JSThread *thread); static void InitializeTreeSetIterator(JSThread *thread); static JSHandle InitializePlainArray(JSThread *thread); static void InitializePlainArrayIterator(JSThread *thread); static JSHandle InitializeVector(JSThread *thread); static void InitializeVectorIterator(JSThread *thread, const JSHandle &env, GlobalEnvConstants *globalConst); static JSHandle InitializeQueue(JSThread *thread); static void InitializeQueueIterator(JSThread *thread, const JSHandle &env, GlobalEnvConstants *globalConst); static JSHandle InitializeDeque(JSThread *thread); static void InitializeDequeIterator(JSThread *thread, const JSHandle &env, GlobalEnvConstants *globalConst); static JSHandle InitializeStack(JSThread *thread); static void InitializeStackIterator(JSThread *thread, GlobalEnvConstants *globalConst); static JSHandle InitializeList(JSThread *thread); static JSHandle InitializeLinkedList(JSThread *thread); static void InitializeLinkedListIterator(JSThread *thread, const JSHandle &env); static void InitializeListIterator(JSThread *thread, const JSHandle &env); }; } // namespace panda::ecmascript::containers #endif // ECMASCRIPT_CONTAINERS_CONTAINERS_PRIVATE_H