• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "ir/base/scriptFunctionSignature.h"
17 #include "ir/ts/tsTypeParameterDeclaration.h"
18 #include "ir/typeNode.h"
19 
20 namespace panda::es2panda::ir {
21 
Iterate(const NodeTraverser & cb) const22 void FunctionSignature::Iterate(const NodeTraverser &cb) const
23 {
24     if (typeParams_ != nullptr) {
25         cb(typeParams_);
26     }
27 
28     for (auto *it : Params()) {
29         cb(it);
30     }
31 
32     if (returnTypeAnnotation_ != nullptr) {
33         cb(returnTypeAnnotation_);
34     }
35 }
36 
TransformChildren(const NodeTransformer & cb)37 void FunctionSignature::TransformChildren(const NodeTransformer &cb)
38 {
39     if (typeParams_ != nullptr) {
40         typeParams_ = cb(typeParams_)->AsTSTypeParameterDeclaration();
41     }
42 
43     for (auto *&it : params_) {
44         it = cb(it)->AsExpression();
45     }
46 
47     if (returnTypeAnnotation_ != nullptr) {
48         returnTypeAnnotation_ = static_cast<TypeNode *>(cb(returnTypeAnnotation_));
49     }
50 }
51 }  // namespace panda::es2panda::ir
52