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_SIGNATURE_DECLARATION_H 17#define ES2PANDA_IR_TS_SIGNATURE_DECLARATION_H 18 19#include <ir/expression.h> 20 21namespace panda::es2panda::binder { 22class Scope; 23} // namespace panda::es2panda::binder 24 25namespace panda::es2panda::compiler { 26class PandaGen; 27} // namespace panda::es2panda::compiler 28 29namespace panda::es2panda::checker { 30class Checker; 31class Type; 32} // namespace panda::es2panda::checker 33 34namespace panda::es2panda::ir { 35 36class TSTypeParameterDeclaration; 37 38class TSSignatureDeclaration : public Expression { 39public: 40 enum class TSSignatureDeclarationKind { CALL_SIGNATURE, CONSTRUCT_SIGNATURE }; 41 42 explicit TSSignatureDeclaration(binder::Scope *scope, TSSignatureDeclarationKind kind, 43 TSTypeParameterDeclaration *typeParams, 44 ArenaVector<Expression *> &¶ms, Expression *returnTypeAnnotation) 45 : Expression(AstNodeType::TS_SIGNATURE_DECLARATION), 46 scope_(scope), 47 kind_(kind), 48 typeParams_(typeParams), 49 params_(std::move(params)), 50 returnTypeAnnotation_(returnTypeAnnotation) 51 { 52 } 53 binder::Scope *Scope() const 54 { 55 return scope_; 56 } 57 58 const TSTypeParameterDeclaration *TypeParams() const 59 { 60 return typeParams_; 61 } 62 63 const ArenaVector<Expression *> &Params() const 64 { 65 return params_; 66 } 67 68 const Expression *ReturnTypeAnnotation() const 69 { 70 return returnTypeAnnotation_; 71 } 72 73 TSSignatureDeclarationKind Kind() const 74 { 75 return kind_; 76 } 77 78 void Iterate(const NodeTraverser &cb) const override; 79 void Dump(ir::AstDumper *dumper) const override; 80 void Compile([[maybe_unused]] compiler::PandaGen *pg) const override; 81 checker::Type *Check(checker::Checker *checker) const override; 82 void UpdateSelf(const NodeUpdater &cb, binder::Binder *binder) override; 83 84private: 85 binder::Scope *scope_; 86 TSSignatureDeclarationKind kind_; 87 TSTypeParameterDeclaration *typeParams_; 88 ArenaVector<Expression *> params_; 89 Expression *returnTypeAnnotation_; 90}; 91 92} // namespace panda::es2panda::ir 93 94#endif 95