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_INTERFACE_DECLARATION_H 17 #define ES2PANDA_IR_TS_INTERFACE_DECLARATION_H 18 19 #include <ir/statement.h> 20 21 namespace panda::es2panda::binder { 22 class LocalScope; 23 class Variable; 24 } // namespace panda::es2panda::binder 25 26 namespace panda::es2panda::compiler { 27 class PandaGen; 28 } // namespace panda::es2panda::compiler 29 30 namespace panda::es2panda::checker { 31 class Checker; 32 class Type; 33 } // namespace panda::es2panda::checker 34 35 namespace panda::es2panda::ir { 36 37 class Identifier; 38 class TSInterfaceBody; 39 class TSInterfaceHeritage; 40 class TSTypeParameterDeclaration; 41 42 class TSInterfaceDeclaration : public Statement { 43 public: TSInterfaceDeclaration(binder::LocalScope * scope,Identifier * id,TSTypeParameterDeclaration * typeParams,TSInterfaceBody * body,ArenaVector<TSInterfaceHeritage * > && extends)44 explicit TSInterfaceDeclaration(binder::LocalScope *scope, Identifier *id, TSTypeParameterDeclaration *typeParams, 45 TSInterfaceBody *body, ArenaVector<TSInterfaceHeritage *> &&extends) 46 : Statement(AstNodeType::TS_INTERFACE_DECLARATION), 47 scope_(scope), 48 id_(id), 49 typeParams_(typeParams), 50 body_(body), 51 extends_(std::move(extends)) 52 { 53 } 54 Scope()55 binder::LocalScope *Scope() const 56 { 57 return scope_; 58 } 59 Body()60 const TSInterfaceBody *Body() const 61 { 62 return body_; 63 } 64 Id()65 const Identifier *Id() const 66 { 67 return id_; 68 } 69 TypeParams()70 const TSTypeParameterDeclaration *TypeParams() const 71 { 72 return typeParams_; 73 } 74 Extends()75 const ArenaVector<TSInterfaceHeritage *> &Extends() const 76 { 77 return extends_; 78 } 79 80 void Iterate(const NodeTraverser &cb) const override; 81 void Dump(ir::AstDumper *dumper) const override; 82 void Compile([[maybe_unused]] compiler::PandaGen *pg) const override; 83 checker::Type *Check(checker::Checker *checker) const override; 84 checker::Type *InferType(checker::Checker *checker, binder::Variable *bindingVar) const; 85 void UpdateSelf(const NodeUpdater &cb, [[maybe_unused]] binder::Binder *binder) override; 86 87 private: 88 binder::LocalScope *scope_; 89 Identifier *id_; 90 TSTypeParameterDeclaration *typeParams_; 91 TSInterfaceBody *body_; 92 ArenaVector<TSInterfaceHeritage *> extends_; 93 }; 94 } // namespace panda::es2panda::ir 95 96 #endif 97