• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2021-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 "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 
25 namespace panda::es2panda::ir {
TransformChildren(const NodeTransformer & cb)26 void TSParameterProperty::TransformChildren(const NodeTransformer &cb)
27 {
28     parameter_ = cb(parameter_)->AsExpression();
29 }
30 
Iterate(const NodeTraverser & cb) const31 void TSParameterProperty::Iterate(const NodeTraverser &cb) const
32 {
33     cb(parameter_);
34 }
35 
Dump(ir::AstDumper * dumper) const36 void TSParameterProperty::Dump(ir::AstDumper *dumper) const
37 {
38     dumper->Add({{"type", "TSParameterProperty"},
39                  {"accessibility", accessibility_ == AccessibilityOption::PUBLIC      ? "public"
40                                    : accessibility_ == AccessibilityOption::PRIVATE   ? "private"
41                                    : accessibility_ == AccessibilityOption::PROTECTED ? "protected"
42                                                                                       : "undefined"},
43                  {"readonly", readonly_},
44                  {"static", static_},
45                  {"export", export_},
46                  {"parameter", parameter_}});
47 }
48 
Dump(ir::SrcDumper * dumper) const49 void TSParameterProperty::Dump(ir::SrcDumper *dumper) const
50 {
51     dumper->Add("TSParameterProperty");
52 }
53 
Compile(compiler::PandaGen * pg) const54 void TSParameterProperty::Compile([[maybe_unused]] compiler::PandaGen *pg) const
55 {
56     pg->GetAstCompiler()->Compile(this);
57 }
Compile(compiler::ETSGen * etsg) const58 void TSParameterProperty::Compile(compiler::ETSGen *etsg) const
59 {
60     etsg->GetAstCompiler()->Compile(this);
61 }
62 
Check(checker::TSChecker * checker)63 checker::Type *TSParameterProperty::Check([[maybe_unused]] checker::TSChecker *checker)
64 {
65     return checker->GetAnalyzer()->Check(this);
66 }
67 
Check(checker::ETSChecker * checker)68 checker::Type *TSParameterProperty::Check([[maybe_unused]] checker::ETSChecker *checker)
69 {
70     return checker->GetAnalyzer()->Check(this);
71 }
72 }  // namespace panda::es2panda::ir
73