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 #ifndef ES2PANDA_IR_TS_PARAMETER_PROPERTY_H 17 #define ES2PANDA_IR_TS_PARAMETER_PROPERTY_H 18 19 #include "ir/expression.h" 20 #include "lexer/token/tokenType.h" 21 22 namespace ark::es2panda::ir { 23 enum class AccessibilityOption { NO_OPTS, PUBLIC, PRIVATE, PROTECTED }; 24 25 class TSParameterProperty : public Expression { 26 public: TSParameterProperty(AccessibilityOption accessibility, Expression *parameter, bool readonly, bool isStatic, bool isExport)27 explicit TSParameterProperty(AccessibilityOption accessibility, Expression *parameter, bool readonly, bool isStatic, 28 bool isExport) 29 : Expression(AstNodeType::TS_PARAMETER_PROPERTY), 30 accessibility_(accessibility), 31 parameter_(parameter), 32 readonly_(readonly), 33 static_(isStatic), 34 export_(isExport) 35 { 36 } 37 Accessibility() const38 AccessibilityOption Accessibility() const 39 { 40 return accessibility_; 41 } 42 Readonly() const43 bool Readonly() const 44 { 45 return readonly_; 46 } 47 IsStatic() const48 bool IsStatic() const 49 { 50 return static_; 51 } 52 IsExport() const53 bool IsExport() const 54 { 55 return export_; 56 } 57 Parameter() const58 const Expression *Parameter() const 59 { 60 return parameter_; 61 } 62 63 void TransformChildren(const NodeTransformer &cb, std::string_view transformationName) override; 64 void Iterate(const NodeTraverser &cb) const override; 65 void Dump(ir::AstDumper *dumper) const override; 66 void Dump(ir::SrcDumper *dumper) const override; 67 void Compile([[maybe_unused]] compiler::PandaGen *pg) const override; 68 void Compile(compiler::ETSGen *etsg) const override; 69 checker::Type *Check([[maybe_unused]] checker::TSChecker *checker) override; 70 checker::Type *Check([[maybe_unused]] checker::ETSChecker *checker) override; 71 72 void Accept(ASTVisitorT *v) override 73 { 74 v->Accept(this); 75 } 76 77 private: 78 AccessibilityOption accessibility_; 79 Expression *parameter_; 80 bool readonly_; 81 bool static_; 82 bool export_; 83 }; 84 } // namespace ark::es2panda::ir 85 86 #endif 87