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_METHOD_SIGNATURE_H 17#define ES2PANDA_IR_TS_METHOD_SIGNATURE_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 TSMethodSignature : public Expression { 39public: 40 explicit TSMethodSignature(binder::Scope *scope, Expression *key, TSTypeParameterDeclaration *typeParams, 41 ArenaVector<Expression *> &¶ms, Expression *returnTypeAnnotation, bool computed, 42 bool optional, bool isGetAccessor, bool isSetAccessor) 43 : Expression(AstNodeType::TS_METHOD_SIGNATURE), 44 scope_(scope), 45 key_(key), 46 typeParams_(typeParams), 47 params_(std::move(params)), 48 returnTypeAnnotation_(returnTypeAnnotation), 49 computed_(computed), 50 optional_(optional), 51 isGetAccessor_(isGetAccessor), 52 isSetAccessor_(isSetAccessor) 53 { 54 } 55 56 binder::Scope *Scope() const 57 { 58 return scope_; 59 } 60 61 const Expression *Key() const 62 { 63 return key_; 64 } 65 66 Expression *Key() 67 { 68 return key_; 69 } 70 71 const TSTypeParameterDeclaration *TypeParams() const 72 { 73 return typeParams_; 74 } 75 76 const ArenaVector<Expression *> &Params() const 77 { 78 return params_; 79 } 80 81 const Expression *ReturnTypeAnnotation() const 82 { 83 return returnTypeAnnotation_; 84 } 85 86 bool Computed() const 87 { 88 return computed_; 89 } 90 91 bool Optional() const 92 { 93 return optional_; 94 } 95 96 bool IsGetAccessor() const 97 { 98 return isGetAccessor_; 99 } 100 101 bool IsSetAccessor() const 102 { 103 return isSetAccessor_; 104 } 105 106 void Iterate(const NodeTraverser &cb) const override; 107 void Dump(ir::AstDumper *dumper) const override; 108 void Compile([[maybe_unused]] compiler::PandaGen *pg) const override; 109 checker::Type *Check(checker::Checker *checker) const override; 110 void UpdateSelf(const NodeUpdater &cb, binder::Binder *binder) override; 111 112private: 113 binder::Scope *scope_; 114 Expression *key_; 115 TSTypeParameterDeclaration *typeParams_; 116 ArenaVector<Expression *> params_; 117 Expression *returnTypeAnnotation_; 118 bool computed_; 119 bool optional_; 120 bool isGetAccessor_; 121 bool isSetAccessor_; 122}; 123 124} // namespace panda::es2panda::ir 125 126#endif 127