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 21namespace panda::es2panda::binder { 22class LocalScope; 23class Variable; 24} // namespace panda::es2panda::binder 25 26namespace panda::es2panda::compiler { 27class PandaGen; 28} // namespace panda::es2panda::compiler 29 30namespace panda::es2panda::checker { 31class Checker; 32class Type; 33} // namespace panda::es2panda::checker 34 35namespace panda::es2panda::ir { 36 37class Identifier; 38class TSInterfaceBody; 39class TSInterfaceHeritage; 40class TSTypeParameterDeclaration; 41 42class TSInterfaceDeclaration : public Statement { 43public: 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 55 binder::LocalScope *Scope() const 56 { 57 return scope_; 58 } 59 60 const TSInterfaceBody *Body() const 61 { 62 return body_; 63 } 64 65 const Identifier *Id() const 66 { 67 return id_; 68 } 69 70 const TSTypeParameterDeclaration *TypeParams() const 71 { 72 return typeParams_; 73 } 74 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 87private: 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