1 /*
2 * Copyright (c) 2022 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 "tsTemplateLiteralType.h"
17
18 #include <ir/astDump.h>
19
20 namespace panda::es2panda::ir {
21
Iterate(const NodeTraverser & cb) const22 void TSTemplateLiteralType::Iterate(const NodeTraverser &cb) const
23 {
24 for (auto *it : references_) {
25 cb(it);
26 }
27
28 for (auto *it : quasis_) {
29 cb(it);
30 }
31 }
32
Dump(ir::AstDumper * dumper) const33 void TSTemplateLiteralType::Dump(ir::AstDumper *dumper) const
34 {
35 dumper->Add({{"type", "TSTemplateLiteralType"}, {"references", references_}, {"quasis", quasis_}});
36 }
37
Compile(compiler::PandaGen * pg) const38 void TSTemplateLiteralType::Compile([[maybe_unused]] compiler::PandaGen *pg) const {}
39
Check(checker::Checker * checker) const40 checker::Type *TSTemplateLiteralType::Check([[maybe_unused]] checker::Checker *checker) const
41 {
42 // TODO(huangyu): Implement checker for template literal type
43 return nullptr;
44 }
45
GetType(checker::Checker * checker) const46 checker::Type *TSTemplateLiteralType::GetType(checker::Checker *checker) const
47 {
48 // TODO(huangyu): Implement GetType for template literal type
49 return nullptr;
50 }
51
UpdateSelf(const NodeUpdater & cb,binder::Binder * binder)52 void TSTemplateLiteralType::UpdateSelf(const NodeUpdater &cb, [[maybe_unused]] binder::Binder *binder)
53 {
54 for (auto iter = references_.begin(); iter != references_.end(); iter++) {
55 *iter = std::get<ir::AstNode *>(cb(*iter))->AsExpression();
56 }
57
58 for (auto iter = quasis_.begin(); iter != quasis_.end(); iter++) {
59 *iter = std::get<ir::AstNode *>(cb(*iter))->AsTemplateElement();
60 }
61 }
62
63 } // namespace panda::es2panda::ir
64