1
2/**
3 * Copyright (c) 2021-2024 Huawei Device Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef ES2PANDA_COMPILER_CHECKER_ETS_PRIMITIVE_WRAPPERS_H
18#define ES2PANDA_COMPILER_CHECKER_ETS_PRIMITIVE_WRAPPERS_H
19
20#include "checker/types/ets/etsObjectType.h"
21
22namespace ark::es2panda::checker {
23class ETSObjectType;
24
25using WrapperDesc = ArenaUnorderedMap<util::StringView, std::pair<ETSObjectType *, ETSObjectFlags>>;
26
27class PrimitiveWrappers {
28public:
29    explicit PrimitiveWrappers(ArenaAllocator *allocator) : wrappers_(allocator->Adapter())
30    {
31        wrappers_.insert({"Boolean", {nullptr, ETSObjectFlags::BUILTIN_BOOLEAN}});
32        wrappers_.insert({"Byte", {nullptr, ETSObjectFlags::BUILTIN_BYTE}});
33        wrappers_.insert({"Char", {nullptr, ETSObjectFlags::BUILTIN_CHAR}});
34        wrappers_.insert({"Short", {nullptr, ETSObjectFlags::BUILTIN_SHORT}});
35        wrappers_.insert({"Int", {nullptr, ETSObjectFlags::BUILTIN_INT}});
36        wrappers_.insert({"Long", {nullptr, ETSObjectFlags::BUILTIN_LONG}});
37        wrappers_.insert({"Float", {nullptr, ETSObjectFlags::BUILTIN_FLOAT}});
38        wrappers_.insert({"Double", {nullptr, ETSObjectFlags::BUILTIN_DOUBLE}});
39    }
40    NO_COPY_SEMANTIC(PrimitiveWrappers);
41    NO_MOVE_SEMANTIC(PrimitiveWrappers);
42    ~PrimitiveWrappers() = default;
43
44    WrapperDesc &Wrappers()
45    {
46        return wrappers_;
47    }
48
49    const WrapperDesc &Wrappers() const
50    {
51        return wrappers_;
52    }
53
54private:
55    WrapperDesc wrappers_;
56};
57}  // namespace ark::es2panda::checker
58#endif
59