1 /**
2 * Copyright (c) 2021-2024 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 "superExpression.h"
17
18 #include "checker/ETSchecker.h"
19 #include "checker/TSchecker.h"
20 #include "compiler/core/ETSGen.h"
21 #include "compiler/core/pandagen.h"
22 #include "util/helpers.h"
23 #include "ir/astDump.h"
24 #include "ir/srcDump.h"
25
26 namespace ark::es2panda::ir {
TransformChildren([[maybe_unused]] const NodeTransformer &cb, [[maybe_unused]] std::string_view const transformationName)27 void SuperExpression::TransformChildren([[maybe_unused]] const NodeTransformer &cb,
28 [[maybe_unused]] std::string_view const transformationName)
29 {
30 }
31
Iterate([[maybe_unused]] const NodeTraverser &cb) const32 void SuperExpression::Iterate([[maybe_unused]] const NodeTraverser &cb) const {}
33
Dump(ir::AstDumper *dumper) const34 void SuperExpression::Dump(ir::AstDumper *dumper) const
35 {
36 dumper->Add({{"type", "Super"}});
37 }
38
Dump(ir::SrcDumper *dumper) const39 void SuperExpression::Dump(ir::SrcDumper *dumper) const
40 {
41 dumper->Add("super");
42 }
43
Compile(compiler::PandaGen *pg) const44 void SuperExpression::Compile(compiler::PandaGen *pg) const
45 {
46 pg->GetAstCompiler()->Compile(this);
47 }
48
Compile(compiler::ETSGen *etsg) const49 void SuperExpression::Compile(compiler::ETSGen *etsg) const
50 {
51 etsg->GetAstCompiler()->Compile(this);
52 }
53
Check(checker::TSChecker *checker)54 checker::Type *SuperExpression::Check(checker::TSChecker *checker)
55 {
56 return checker->GetAnalyzer()->Check(this);
57 }
58
Check([[maybe_unused]] checker::ETSChecker *checker)59 checker::Type *SuperExpression::Check([[maybe_unused]] checker::ETSChecker *checker)
60 {
61 return checker->GetAnalyzer()->Check(this);
62 }
63
Clone(ArenaAllocator *const allocator, AstNode *const parent)64 SuperExpression *SuperExpression::Clone(ArenaAllocator *const allocator, AstNode *const parent)
65 {
66 if (auto *const clone = allocator->New<SuperExpression>(); clone != nullptr) {
67 if (parent != nullptr) {
68 clone->SetParent(parent);
69 }
70 return clone;
71 }
72 throw Error(ErrorType::GENERIC, "", CLONE_ALLOCATION_ERROR);
73 }
74 } // namespace ark::es2panda::ir
75