1 /** 2 * Copyright (c) 2021 - 2023 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_COMPILER_CORE_SCRIPT_FUNCTION_SIGNATURE_H 17 #define ES2PANDA_COMPILER_CORE_SCRIPT_FUNCTION_SIGNATURE_H 18 19 #include "ir/astNode.h" 20 21 namespace panda::es2panda::ir { 22 class TSTypeParameterDeclaration; 23 class TypeNode; 24 25 class FunctionSignature { 26 public: 27 using FunctionParams = ArenaVector<Expression *>; 28 FunctionSignature(TSTypeParameterDeclaration * typeParams,FunctionParams && params,TypeNode * returnTypeAnnotation)29 FunctionSignature(TSTypeParameterDeclaration *typeParams, FunctionParams &¶ms, TypeNode *returnTypeAnnotation) 30 : typeParams_(typeParams), params_(std::move(params)), returnTypeAnnotation_(returnTypeAnnotation) 31 { 32 } 33 Params()34 const FunctionParams &Params() const 35 { 36 return params_; 37 } 38 Params()39 FunctionParams &Params() 40 { 41 return params_; 42 } 43 TypeParams()44 TSTypeParameterDeclaration *TypeParams() 45 { 46 return typeParams_; 47 } 48 TypeParams()49 const TSTypeParameterDeclaration *TypeParams() const 50 { 51 return typeParams_; 52 } 53 ReturnType()54 TypeNode *ReturnType() 55 { 56 return returnTypeAnnotation_; 57 } 58 SetReturnType(TypeNode * type)59 void SetReturnType(TypeNode *type) 60 { 61 returnTypeAnnotation_ = type; 62 } 63 ReturnType()64 const TypeNode *ReturnType() const 65 { 66 return returnTypeAnnotation_; 67 } 68 69 void Iterate(const NodeTraverser &cb) const; 70 71 void TransformChildren(const NodeTransformer &cb); 72 73 private: 74 TSTypeParameterDeclaration *typeParams_; 75 ArenaVector<Expression *> params_; 76 TypeNode *returnTypeAnnotation_; 77 }; 78 79 } // namespace panda::es2panda::ir 80 81 #endif 82