• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "tsConditionalType.h"
17 
18 #include <ir/astDump.h>
19 
20 namespace panda::es2panda::ir {
21 
Iterate(const NodeTraverser & cb) const22 void TSConditionalType::Iterate(const NodeTraverser &cb) const
23 {
24     cb(checkType_);
25     cb(extendsType_);
26     cb(trueType_);
27     cb(falseType_);
28 }
29 
Dump(ir::AstDumper * dumper) const30 void TSConditionalType::Dump(ir::AstDumper *dumper) const
31 {
32     dumper->Add({{"type", "TSConditionalType"},
33                  {"checkType", checkType_},
34                  {"extendsType", extendsType_},
35                  {"trueType", trueType_},
36                  {"falseType", falseType_}});
37 }
38 
Compile(compiler::PandaGen * pg) const39 void TSConditionalType::Compile([[maybe_unused]] compiler::PandaGen *pg) const {}
40 
Check(checker::Checker * checker) const41 checker::Type *TSConditionalType::Check([[maybe_unused]] checker::Checker *checker) const
42 {
43     return nullptr;
44 }
45 
GetType(checker::Checker * checker) const46 checker::Type *TSConditionalType::GetType([[maybe_unused]] checker::Checker *checker) const
47 {
48     return nullptr;
49 }
50 
UpdateSelf(const NodeUpdater & cb,binder::Binder * binder)51 void TSConditionalType::UpdateSelf(const NodeUpdater &cb, [[maybe_unused]] binder::Binder *binder)
52 {
53     checkType_ = std::get<ir::AstNode *>(cb(checkType_))->AsExpression();
54     extendsType_ = std::get<ir::AstNode *>(cb(extendsType_))->AsExpression();
55     trueType_ = std::get<ir::AstNode *>(cb(trueType_))->AsExpression();
56     falseType_ = std::get<ir::AstNode *>(cb(falseType_))->AsExpression();
57 }
58 
59 }  // namespace panda::es2panda::ir
60