• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2021-2022 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 ES2PANDA_COMPILER_TYPESCRIPT_TYPES_GLOBAL_TYPES_HOLDER_H
17 #define ES2PANDA_COMPILER_TYPESCRIPT_TYPES_GLOBAL_TYPES_HOLDER_H
18 
19 #include "type.h"
20 
21 namespace panda::es2panda::checker {
22 
23 enum class GlobalTypeId {
24     NUMBER,
25     ANY,
26     STRING,
27     SYMBOL,
28     BOOLEAN,
29     VOID,
30     NULL_ID,
31     UNDEFINED,
32     UNKNOWN,
33     NEVER,
34     NON_PRIMITIVE,
35     BIGINT,
36     FALSE_ID,
37     TRUE_ID,
38     NUMBER_OR_BIGINT,
39     STRING_OR_NUMBER,
40     ZERO,
41     EMPTY_STRING,
42     ZERO_BIGINT,
43     PRIMITIVE,
44     EMPTY_TUPLE,
45     EMPTY_OBJECT,
46     RESOLVING_RETURN_TYPE,
47     ERROR_TYPE,
48     COUNT
49 };
50 
51 class GlobalTypesHolder {
52 public:
53     explicit GlobalTypesHolder(ArenaAllocator *allocator);
54     ~GlobalTypesHolder() = default;
55     NO_COPY_SEMANTIC(GlobalTypesHolder);
56     NO_MOVE_SEMANTIC(GlobalTypesHolder);
57 
58     Type *GlobalNumberType();
59     Type *GlobalAnyType();
60     Type *GlobalStringType();
61     Type *GlobalSymbolType();
62     Type *GlobalBooleanType();
63     Type *GlobalVoidType();
64     Type *GlobalNullType();
65     Type *GlobalUndefinedType();
66     Type *GlobalUnknownType();
67     Type *GlobalNeverType();
68     Type *GlobalNonPrimitiveType();
69     Type *GlobalBigintType();
70     Type *GlobalFalseType();
71     Type *GlobalTrueType();
72     Type *GlobalNumberOrBigintType();
73     Type *GlobalStringOrNumberType();
74     Type *GlobalZeroType();
75     Type *GlobalEmptyStringType();
76     Type *GlobalZeroBigintType();
77     Type *GlobalPrimitiveType();
78     Type *GlobalEmptyTupleType();
79     Type *GlobalEmptyObjectType();
80     Type *GlobalResolvingReturnType();
81     Type *GlobalErrorType();
82 
83 private:
84     std::array<Type *, static_cast<size_t>(GlobalTypeId::COUNT)> globalTypes_ {};
85 };
86 
87 }  // namespace panda::es2panda::checker
88 
89 #endif /* ES2PANDA_COMPILER_TYPESCRIPT_TYPES_GLOBAL_TYPES_HOLDER_H */
90