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 #ifndef ES2PANDA_IR_EXPRESSION_CHAIN_EXPRESSION_H 17 #define ES2PANDA_IR_EXPRESSION_CHAIN_EXPRESSION_H 18 19 #include "ir/expression.h" 20 #include "ir/irnode.h" 21 22 namespace panda::es2panda::checker { 23 class TSAnalyzer; 24 } // namespace panda::es2panda::checker 25 26 namespace panda::es2panda::ir { 27 class ChainExpression : public Expression { 28 public: 29 ChainExpression() = delete; 30 ~ChainExpression() override = default; 31 32 NO_COPY_SEMANTIC(ChainExpression); 33 NO_MOVE_SEMANTIC(ChainExpression); 34 ChainExpression(Expression * expression)35 explicit ChainExpression(Expression *expression) 36 : Expression(AstNodeType::CHAIN_EXPRESSION), expression_(expression) 37 { 38 } 39 40 // NOTE (csabahurton): friend relationship can be removed once there are getters for private fields 41 friend class checker::TSAnalyzer; 42 GetExpression()43 const Expression *GetExpression() const noexcept 44 { 45 return expression_; 46 } 47 48 // NOLINTNEXTLINE(google-default-arguments) 49 [[nodiscard]] ChainExpression *Clone(ArenaAllocator *allocator, AstNode *parent = nullptr) override; 50 51 void TransformChildren(const NodeTransformer &cb) override; 52 void Iterate(const NodeTraverser &cb) const override; 53 void Dump(ir::AstDumper *dumper) const override; 54 void Dump(ir::SrcDumper *dumper) const override; 55 void Compile(compiler::PandaGen *pg) const override; 56 void Compile(compiler::ETSGen *etsg) const override; 57 void CompileToReg(compiler::PandaGen *pg, compiler::VReg &objReg) const; 58 checker::Type *Check(checker::TSChecker *checker) override; 59 checker::Type *Check(checker::ETSChecker *checker) override; 60 Accept(ASTVisitorT * v)61 void Accept(ASTVisitorT *v) override 62 { 63 v->Accept(this); 64 } 65 66 private: 67 Expression *expression_; 68 }; 69 } // namespace panda::es2panda::ir 70 71 #endif 72