1 /** 2 * Copyright (c) 2021-2025 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_IR_TYPE_NODE_H 17 #define ES2PANDA_IR_TYPE_NODE_H 18 19 #include "ir/expression.h" 20 #include "ir/annotationAllowed.h" 21 22 namespace ark::es2panda::checker { 23 class TSChecker; 24 class Type; 25 } // namespace ark::es2panda::checker 26 27 namespace ark::es2panda::ir { 28 class TypeNode : public AnnotationAllowed<Expression> { 29 public: 30 TypeNode() = delete; 31 ~TypeNode() override = default; 32 33 NO_COPY_SEMANTIC(TypeNode); 34 NO_MOVE_SEMANTIC(TypeNode); 35 IsTypeNode()36 [[nodiscard]] bool IsTypeNode() const noexcept override 37 { 38 return true; 39 } 40 GetType(checker::TSChecker * checker)41 [[nodiscard]] virtual checker::Type *GetType([[maybe_unused]] checker::TSChecker *checker) 42 { 43 return nullptr; 44 } 45 GetType(checker::ETSChecker * checker)46 [[nodiscard]] virtual checker::Type *GetType([[maybe_unused]] checker::ETSChecker *checker) 47 { 48 return nullptr; 49 } 50 51 [[nodiscard]] TypeNode *Clone(ArenaAllocator *allocator, AstNode *parent) override; 52 53 void CopyTo(AstNode *other) const override; 54 55 protected: TypeNode(AstNodeType const type,ArenaAllocator * const allocator)56 explicit TypeNode(AstNodeType const type, ArenaAllocator *const allocator) 57 : AnnotationAllowed<Expression>(type, allocator) 58 { 59 } 60 TypeNode(AstNodeType const type,ModifierFlags const flags,ArenaAllocator * const allocator)61 explicit TypeNode(AstNodeType const type, ModifierFlags const flags, ArenaAllocator *const allocator) 62 : AnnotationAllowed<Expression>(type, flags, allocator) 63 { 64 } 65 }; 66 } // namespace ark::es2panda::ir 67 68 #endif /* ES2PANDA_IR_TYPE_NODE_H */ 69