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 * > && params,Expression * returnTypeAnnotation,bool computed,bool optional)40 explicit TSMethodSignature(binder::Scope *scope, Expression *key, TSTypeParameterDeclaration *typeParams, 41 ArenaVector<Expression *> &¶ms, Expression *returnTypeAnnotation, bool computed, 42 bool optional) 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 { 52 } 53 Scope()54 binder::Scope *Scope() const 55 { 56 return scope_; 57 } 58 Key()59 const Expression *Key() const 60 { 61 return key_; 62 } 63 Key()64 Expression *Key() 65 { 66 return key_; 67 } 68 TypeParams()69 const TSTypeParameterDeclaration *TypeParams() const 70 { 71 return typeParams_; 72 } 73 Params()74 const ArenaVector<Expression *> &Params() const 75 { 76 return params_; 77 } 78 ReturnTypeAnnotation()79 const Expression *ReturnTypeAnnotation() const 80 { 81 return returnTypeAnnotation_; 82 } 83 Computed()84 bool Computed() const 85 { 86 return computed_; 87 } 88 Optional()89 bool Optional() const 90 { 91 return optional_; 92 } 93 94 void Iterate(const NodeTraverser &cb) const override; 95 void Dump(ir::AstDumper *dumper) const override; 96 void Compile([[maybe_unused]] compiler::PandaGen *pg) const override; 97 checker::Type *Check(checker::Checker *checker) const override; 98 void UpdateSelf(const NodeUpdater &cb, binder::Binder *binder) override; 99 100 private: 101 binder::Scope *scope_; 102 Expression *key_; 103 TSTypeParameterDeclaration *typeParams_; 104 ArenaVector<Expression *> params_; 105 Expression *returnTypeAnnotation_; 106 bool computed_; 107 bool optional_; 108 }; 109 110 } // namespace panda::es2panda::ir 111 112 #endif 113