1 /** 2 * Copyright (c) 2021 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_TS_TYPE_ALIAS_DECLARATION_H 17 #define ES2PANDA_IR_TS_TYPE_ALIAS_DECLARATION_H 18 19 #include <ir/statement.h> 20 21 namespace panda::es2panda::binder { 22 class Variable; 23 } // namespace panda::es2panda::binder 24 25 namespace panda::es2panda::compiler { 26 class PandaGen; 27 } // namespace panda::es2panda::compiler 28 29 namespace panda::es2panda::checker { 30 class Checker; 31 class Type; 32 } // namespace panda::es2panda::checker 33 34 namespace panda::es2panda::ir { 35 36 class Identifier; 37 class TSTypeParameterDeclaration; 38 39 class TSTypeAliasDeclaration : public Statement { 40 public: TSTypeAliasDeclaration(Identifier * id,TSTypeParameterDeclaration * typeParams,Expression * typeAnnotation,bool declare)41 explicit TSTypeAliasDeclaration(Identifier *id, TSTypeParameterDeclaration *typeParams, Expression *typeAnnotation, 42 bool declare) 43 : Statement(AstNodeType::TS_TYPE_ALIAS_DECLARATION), 44 id_(id), 45 typeParams_(typeParams), 46 typeAnnotation_(typeAnnotation), 47 declare_(declare) 48 { 49 } 50 Id()51 const Identifier *Id() const 52 { 53 return id_; 54 } 55 TypeParams()56 const TSTypeParameterDeclaration *TypeParams() const 57 { 58 return typeParams_; 59 } 60 TypeAnnotation()61 const Expression *TypeAnnotation() const 62 { 63 return typeAnnotation_; 64 } 65 Declare()66 bool Declare() const 67 { 68 return declare_; 69 } 70 71 void Iterate(const NodeTraverser &cb) const override; 72 void Dump(ir::AstDumper *dumper) const override; 73 void Compile([[maybe_unused]] compiler::PandaGen *pg) const override; 74 checker::Type *Check(checker::Checker *checker) const override; 75 void UpdateSelf(const NodeUpdater &cb, [[maybe_unused]] binder::Binder *binder) override; 76 77 private: 78 Identifier *id_; 79 TSTypeParameterDeclaration *typeParams_; 80 Expression *typeAnnotation_; 81 bool declare_; 82 }; 83 } // namespace panda::es2panda::ir 84 85 #endif 86