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 21 namespace panda::es2panda::binder { 22 class Scope; 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 TSTypeParameterDeclaration; 37 38 class TSMethodSignature : public Expression { 39 public: TSMethodSignature(binder::Scope *scope, Expression *key, TSTypeParameterDeclaration *typeParams, ArenaVector<Expression *> &¶ms, Expression *returnTypeAnnotation, bool computed, bool optional, bool isGetAccessor, bool isSetAccessor)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 Scope() const56 binder::Scope *Scope() const 57 { 58 return scope_; 59 } 60 Key() const61 const Expression *Key() const 62 { 63 return key_; 64 } 65 Key()66 Expression *Key() 67 { 68 return key_; 69 } 70 TypeParams() const71 const TSTypeParameterDeclaration *TypeParams() const 72 { 73 return typeParams_; 74 } 75 Params() const76 const ArenaVector<Expression *> &Params() const 77 { 78 return params_; 79 } 80 ReturnTypeAnnotation() const81 const Expression *ReturnTypeAnnotation() const 82 { 83 return returnTypeAnnotation_; 84 } 85 Computed() const86 bool Computed() const 87 { 88 return computed_; 89 } 90 Optional() const91 bool Optional() const 92 { 93 return optional_; 94 } 95 IsGetAccessor() const96 bool IsGetAccessor() const 97 { 98 return isGetAccessor_; 99 } 100 IsSetAccessor() const101 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 112 private: 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