• 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 "tsClassImplements.h"
17 
18 #include "checker/TSchecker.h"
19 #include "compiler/core/ETSGen.h"
20 #include "compiler/core/pandagen.h"
21 #include "ir/astDump.h"
22 #include "ir/srcDump.h"
23 #include "ir/ts/tsTypeParameter.h"
24 #include "ir/ts/tsTypeParameterInstantiation.h"
25 
26 namespace panda::es2panda::ir {
TransformChildren(const NodeTransformer & cb)27 void TSClassImplements::TransformChildren(const NodeTransformer &cb)
28 {
29     expression_ = cb(expression_)->AsExpression();
30 }
31 
Iterate(const NodeTraverser & cb) const32 void TSClassImplements::Iterate(const NodeTraverser &cb) const
33 {
34     cb(expression_);
35 
36     if (typeParameters_ != nullptr) {
37         cb(typeParameters_);
38     }
39 }
40 
Dump(ir::AstDumper * dumper) const41 void TSClassImplements::Dump(ir::AstDumper *dumper) const
42 {
43     dumper->Add({{"type", "TSClassImplements"},
44                  {"expression", expression_},
45                  {"typeParameters", AstDumper::Optional(typeParameters_)}});
46 }
47 
Dump(ir::SrcDumper * dumper) const48 void TSClassImplements::Dump(ir::SrcDumper *dumper) const
49 {
50     expression_->Dump(dumper);
51     ASSERT(typeParameters_ == nullptr);
52 }
53 
Compile(compiler::PandaGen * pg) const54 void TSClassImplements::Compile([[maybe_unused]] compiler::PandaGen *pg) const
55 {
56     pg->GetAstCompiler()->Compile(this);
57 }
58 
Compile(compiler::ETSGen * etsg) const59 void TSClassImplements::Compile(compiler::ETSGen *etsg) const
60 {
61     etsg->GetAstCompiler()->Compile(this);
62 }
63 
Check(checker::TSChecker * checker)64 checker::Type *TSClassImplements::Check([[maybe_unused]] checker::TSChecker *checker)
65 {
66     return checker->GetAnalyzer()->Check(this);
67 }
68 
Check(checker::ETSChecker * checker)69 checker::Type *TSClassImplements::Check([[maybe_unused]] checker::ETSChecker *checker)
70 {
71     return checker->GetAnalyzer()->Check(this);
72 }
73 }  // namespace panda::es2panda::ir
74