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 #include "tsImportType.h"
17
18 #include <ir/astDump.h>
19 #include <ir/ts/tsTypeParameter.h>
20 #include <ir/ts/tsTypeParameterInstantiation.h>
21
22 namespace panda::es2panda::ir {
23
Iterate(const NodeTraverser & cb) const24 void TSImportType::Iterate(const NodeTraverser &cb) const
25 {
26 cb(param_);
27
28 if (typeParams_) {
29 cb(typeParams_);
30 }
31
32 if (qualifier_) {
33 cb(qualifier_);
34 }
35 }
36
Dump(ir::AstDumper * dumper) const37 void TSImportType::Dump(ir::AstDumper *dumper) const
38 {
39 dumper->Add({{"type", "TSImportType"},
40 {"parameter", param_},
41 {"qualifier", AstDumper::Optional(qualifier_)},
42 {"typeParameters", AstDumper::Optional(typeParams_)},
43 {"isTypeOf", isTypeof_}});
44 }
45
Compile(compiler::PandaGen * pg) const46 void TSImportType::Compile([[maybe_unused]] compiler::PandaGen *pg) const {}
47
Check(checker::Checker * checker) const48 checker::Type *TSImportType::Check([[maybe_unused]] checker::Checker *checker) const
49 {
50 return nullptr;
51 }
52
GetType(checker::Checker * checker) const53 checker::Type *TSImportType::GetType([[maybe_unused]] checker::Checker *checker) const
54 {
55 return nullptr;
56 }
57
UpdateSelf(const NodeUpdater & cb,binder::Binder * binder)58 void TSImportType::UpdateSelf(const NodeUpdater &cb, [[maybe_unused]] binder::Binder *binder)
59 {
60 param_ = std::get<ir::AstNode *>(cb(param_))->AsExpression();
61
62 if (typeParams_) {
63 typeParams_ = std::get<ir::AstNode *>(cb(typeParams_))->AsTSTypeParameterInstantiation();
64 }
65
66 if (qualifier_) {
67 qualifier_ = std::get<ir::AstNode *>(cb(qualifier_))->AsExpression();
68 }
69 }
70
71 } // namespace panda::es2panda::ir
72