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_TYPE_FLAG_H 17 #define ES2PANDA_COMPILER_TYPESCRIPT_TYPES_TYPE_FLAG_H 18 19 #include <util/enumbitops.h> 20 21 #include <cinttypes> 22 23 namespace panda::es2panda::checker { 24 25 enum class TypeFlag : uint64_t { 26 NONE = 0, 27 NUMBER = 1ULL << 0, // x: number 28 STRING = 1ULL << 1, // x: string 29 BOOLEAN = 1ULL << 2, // x: boolean 30 VOID = 1ULL << 3, // x: void 31 NULL_TYPE = 1ULL << 4, // x: null 32 UNDEFINED = 1ULL << 5, // x: undefined 33 UNKNOWN = 1ULL << 6, // x: unknown 34 NEVER = 1ULL << 7, // x: never 35 UNION = 1ULL << 8, // x: a | b 36 OBJECT = 1ULL << 9, // x: object 37 BIGINT = 1ULL << 10, // x: bigint 38 BOOLEAN_LITERAL = 1ULL << 11, // x: true 39 NUMBER_LITERAL = 1ULL << 12, // x: 10 40 STRING_LITERAL = 1ULL << 13, // x: "foo" 41 BIGINT_LITERAL = 1ULL << 14, // x: 10n 42 ENUM = 1ULL << 15, // enum x 43 ENUM_LITERAL = 1ULL << 16, // member of enum 44 SYMBOL = 1ULL << 17, // x: symbol 45 UNIQUE_SYMBOL = 1ULL << 18, // one of JS unique symbols 46 TYPE_PARAMETER = 1ULL << 19, // function<x> 47 INTERSECTION = 1ULL << 20, // x: a & b 48 INDEX = 1ULL << 21, // keyof x 49 INDEX_ACCESS = 1ULL << 22, // x[a] 50 CONDITIONAL = 1ULL << 23, // x extends a ? b : c 51 SUBSTITUTION = 1ULL << 24, // type parameter substitution 52 TEMPLATE_LITERAL = 1ULL << 25, // x: `hello ${World}` 53 STRING_MAPPING = 1ULL << 27, // Uppercase/Lowercase type 54 ANY = 1ULL << 28, // x: any 55 ARRAY = 1ULL << 29, // x: number[] 56 FUNCTION = 1ULL << 30, // x: (a) => b 57 NON_PRIMITIVE = 1ULL << 31, // x: object 58 TYPE_REFERENCE = 1ULL << 32, 59 READONLY = 1ULL << 33, 60 COMPUTED_TYPE_LITERAL_NAME = STRING_LITERAL | NUMBER_LITERAL | ENUM, 61 COMPUTED_NAME = COMPUTED_TYPE_LITERAL_NAME | STRING | NUMBER | ANY | SYMBOL, 62 ANY_OR_UNKNOWN = ANY | UNKNOWN, 63 ANY_OR_VOID = ANY | VOID, 64 NULLABLE = UNDEFINED | NULL_TYPE, 65 ANY_OR_NULLABLE = ANY | NULLABLE, 66 LITERAL = NUMBER_LITERAL | BOOLEAN_LITERAL | STRING_LITERAL | BIGINT_LITERAL, 67 NUMBER_LIKE = NUMBER | NUMBER_LITERAL, 68 NUMBER_LIKE_ENUM = NUMBER_LIKE | ENUM, 69 STRING_LIKE = STRING | STRING_LITERAL, 70 BOOLEAN_LIKE = BOOLEAN | BOOLEAN_LITERAL, 71 BIGINT_LIKE = BIGINT | BIGINT_LITERAL, 72 VOID_LIKE = VOID | UNDEFINED, 73 NUMBER_OR_ANY = NUMBER | ANY, 74 PRIMITIVE = STRING | NUMBER | BIGINT | BOOLEAN | ENUM | ENUM_LITERAL | SYMBOL | VOID | UNDEFINED | NULL_TYPE | 75 LITERAL | UNIQUE_SYMBOL, 76 PRIMITIVE_OR_ANY = PRIMITIVE | ANY, 77 UNION_OR_INTERSECTION = UNION | INTERSECTION, 78 DEFINITELY_FALSY = 79 STRING_LITERAL | NUMBER_LITERAL | BOOLEAN_LITERAL | BIGINT_LITERAL | VOID | UNDEFINED | NULL_TYPE, 80 POSSIBLY_FALSY = DEFINITELY_FALSY | STRING | NUMBER | BOOLEAN | BIGINT, 81 VALID_ARITHMETIC_TYPE = ANY | NUMBER_LIKE | BIGINT_LIKE | ENUM, 82 UNIT = LITERAL | UNIQUE_SYMBOL | NULLABLE, 83 }; 84 85 DEFINE_BITOPS(TypeFlag) 86 87 } // namespace panda::es2panda::checker 88 89 #endif /* TYPESCRIPT_TYPES_TYPE_FLAG_H */ 90