1 /* 2 * Copyright (c) 2024 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_CHECKER_TYPES_ETS_OBJECT_TYPE_CONSTANTS_H 17 #define ES2PANDA_COMPILER_CHECKER_TYPES_ETS_OBJECT_TYPE_CONSTANTS_H 18 19 #include "checker/types/type.h" 20 21 namespace ark::es2panda::checker { 22 23 using ENUMBITOPS_OPERATORS; 24 25 enum class ETSObjectFlags : std::uint64_t { 26 NO_OPTS = 0U, 27 CLASS = 1U << 0U, 28 INTERFACE = 1U << 1U, 29 INSTANCE = 1U << 2U, 30 ABSTRACT = 1U << 3U, 31 GLOBAL = 1U << 4U, 32 ENUM = 1U << 5U, 33 FUNCTIONAL = 1U << 6U, 34 RESOLVED_INTERFACES = 1U << 7U, 35 RESOLVED_SUPER = 1U << 8U, 36 RESOLVED_TYPE_PARAMS = 1U << 9U, 37 CHECKED_COMPATIBLE_ABSTRACTS = 1U << 10U, 38 STRING = 1U << 11U, 39 INCOMPLETE_INSTANTIATION = 1U << 12U, 40 INNER = 1U << 13U, 41 DYNAMIC = 1U << 14U, 42 ASYNC_FUNC_RETURN_TYPE = 1U << 15U, 43 CHECKED_INVOKE_LEGITIMACY = 1U << 16U, 44 REQUIRED = 1U << 17U, 45 READONLY = 1U << 18U, 46 47 BUILTIN_BIGINT = 1U << 22U, 48 BUILTIN_STRING = 1U << 23U, 49 BUILTIN_BOOLEAN = 1U << 24U, 50 BUILTIN_BYTE = 1U << 25U, 51 BUILTIN_CHAR = 1U << 26U, 52 BUILTIN_SHORT = 1U << 27U, 53 BUILTIN_INT = 1U << 28U, 54 BUILTIN_LONG = 1U << 29U, 55 BUILTIN_FLOAT = 1U << 30U, 56 BUILTIN_DOUBLE = 1U << 31U, 57 58 BOXED_ENUM = 1ULL << 32U, 59 60 BUILTIN_NUMERIC = BUILTIN_BYTE | BUILTIN_SHORT | BUILTIN_INT | BUILTIN_LONG | BUILTIN_FLOAT | BUILTIN_DOUBLE, 61 // Complete set includes null|undefined|Object 62 VALUE_TYPED = BUILTIN_BOOLEAN | BUILTIN_CHAR | BUILTIN_NUMERIC | BUILTIN_BIGINT | STRING, 63 UNBOXABLE_TYPE = BUILTIN_BOOLEAN | BUILTIN_CHAR | BUILTIN_NUMERIC | BOXED_ENUM, 64 BUILTIN_TYPE = BUILTIN_STRING | BUILTIN_BIGINT | UNBOXABLE_TYPE, 65 66 GLOBAL_CLASS = CLASS | GLOBAL, 67 FUNCTIONAL_INTERFACE = INTERFACE | ABSTRACT | FUNCTIONAL, 68 RESOLVED_HEADER = RESOLVED_INTERFACES | RESOLVED_SUPER | RESOLVED_TYPE_PARAMS, 69 }; 70 71 // NOTE: Do not change the order of the first 7 flags (including NO_OPTS)! 72 // Because ETSChecker::ValidateResolvedProperty relies on the order of the flags. 73 enum class PropertySearchFlags : std::uint32_t { 74 NO_OPTS = 0, 75 SEARCH_INSTANCE_METHOD = 1U << 0U, 76 SEARCH_INSTANCE_FIELD = 1U << 1U, 77 SEARCH_INSTANCE_DECL = 1U << 2U, 78 SEARCH_STATIC_METHOD = 1U << 3U, 79 SEARCH_STATIC_FIELD = 1U << 4U, 80 SEARCH_STATIC_DECL = 1U << 5U, 81 82 SEARCH_IN_BASE = 1U << 6U, 83 SEARCH_IN_INTERFACES = 1U << 7U, 84 IGNORE_ABSTRACT = 1U << 8U, 85 ALLOW_FUNCTIONAL_INTERFACE = 1U << 9U, 86 DISALLOW_SYNTHETIC_METHOD_CREATION = 1U << 10U, 87 IS_FUNCTIONAL = 1U << 11U, 88 IS_SETTER = 1U << 12U, 89 IS_GETTER = 1U << 13U, 90 91 SEARCH_INSTANCE = SEARCH_INSTANCE_FIELD | SEARCH_INSTANCE_METHOD | SEARCH_INSTANCE_DECL, 92 SEARCH_STATIC = SEARCH_STATIC_FIELD | SEARCH_STATIC_METHOD | SEARCH_STATIC_DECL, 93 94 SEARCH_METHOD = SEARCH_INSTANCE_METHOD | SEARCH_STATIC_METHOD, 95 SEARCH_FIELD = SEARCH_INSTANCE_FIELD | SEARCH_STATIC_FIELD, 96 SEARCH_DECL = SEARCH_INSTANCE_DECL | SEARCH_STATIC_DECL, 97 SEARCH_ALL = SEARCH_METHOD | SEARCH_FIELD | SEARCH_DECL, 98 }; 99 100 enum class PropertyType { 101 INSTANCE_METHOD, 102 INSTANCE_FIELD, 103 INSTANCE_DECL, 104 STATIC_METHOD, 105 STATIC_FIELD, 106 STATIC_DECL, 107 COUNT, 108 }; 109 110 /* Invoke method name in functional interfaces */ 111 constexpr char const *FUNCTIONAL_INTERFACE_INVOKE_METHOD_NAME = "invoke0"; 112 constexpr char const *FUNCTIONAL_INTERFACE_SUBSTITUTED_INVOKE_METHOD_NAME = "invoke"; 113 114 } // namespace ark::es2panda::checker 115 116 namespace enumbitops { 117 118 template <> 119 struct IsAllowedType<ark::es2panda::checker::ETSObjectFlags> : std::true_type { 120 }; 121 122 template <> 123 struct IsAllowedType<ark::es2panda::checker::PropertySearchFlags> : std::true_type { 124 }; 125 126 } // namespace enumbitops 127 128 #endif /* ES2PANDA_COMPILER_CHECKER_TYPES_ETS_OBJECT_TYPE_CONSTANTS_H */ 129