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 "tsParameterProperty.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/expression.h"
24
25namespace ark::es2panda::ir {
26void TSParameterProperty::TransformChildren(const NodeTransformer &cb, std::string_view transformationName)
27{
28    if (auto *transformedNode = cb(parameter_); parameter_ != transformedNode) {
29        parameter_->SetTransformedNode(transformationName, transformedNode);
30        parameter_ = transformedNode->AsExpression();
31    }
32}
33
34void TSParameterProperty::Iterate(const NodeTraverser &cb) const
35{
36    cb(parameter_);
37}
38
39void TSParameterProperty::Dump(ir::AstDumper *dumper) const
40{
41    dumper->Add({{"type", "TSParameterProperty"},
42                 {"accessibility", accessibility_ == AccessibilityOption::PUBLIC      ? "public"
43                                   : accessibility_ == AccessibilityOption::PRIVATE   ? "private"
44                                   : accessibility_ == AccessibilityOption::PROTECTED ? "protected"
45                                                                                      : "undefined"},
46                 {"readonly", readonly_},
47                 {"static", static_},
48                 {"export", export_},
49                 {"parameter", parameter_}});
50}
51
52void TSParameterProperty::Dump(ir::SrcDumper *dumper) const
53{
54    dumper->Add("TSParameterProperty");
55}
56
57void TSParameterProperty::Compile([[maybe_unused]] compiler::PandaGen *pg) const
58{
59    pg->GetAstCompiler()->Compile(this);
60}
61void TSParameterProperty::Compile(compiler::ETSGen *etsg) const
62{
63    etsg->GetAstCompiler()->Compile(this);
64}
65
66checker::Type *TSParameterProperty::Check([[maybe_unused]] checker::TSChecker *checker)
67{
68    return checker->GetAnalyzer()->Check(this);
69}
70
71checker::Type *TSParameterProperty::Check([[maybe_unused]] checker::ETSChecker *checker)
72{
73    return checker->GetAnalyzer()->Check(this);
74}
75}  // namespace ark::es2panda::ir
76