1 /**
2  * Copyright (c) 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_STATEMENT_FOR_IN_STATEMENT_H
17 #define ES2PANDA_IR_STATEMENT_FOR_IN_STATEMENT_H
18 
19 #include "ir/statements/loopStatement.h"
20 
21 namespace ark::es2panda::varbinder {
22 class LoopScope;
23 }  // namespace ark::es2panda::varbinder
24 
25 namespace ark::es2panda::ir {
26 class Expression;
27 
28 class ForInStatement : public LoopStatement {
29 public:
ForInStatement(AstNode *left, Expression *right, Statement *body)30     explicit ForInStatement(AstNode *left, Expression *right, Statement *body)
31         : LoopStatement(AstNodeType::FOR_IN_STATEMENT), left_(left), right_(right), body_(body)
32     {
33     }
34 
Left()35     AstNode *Left()
36     {
37         return left_;
38     }
39 
Left() const40     const AstNode *Left() const
41     {
42         return left_;
43     }
44 
Right()45     Expression *Right()
46     {
47         return right_;
48     }
49 
Right() const50     const Expression *Right() const
51     {
52         return right_;
53     }
54 
Body()55     Statement *Body()
56     {
57         return body_;
58     }
59 
Body() const60     const Statement *Body() const
61     {
62         return body_;
63     }
64 
65     void TransformChildren(const NodeTransformer &cb, std::string_view transformationName) override;
66 
67     void Iterate(const NodeTraverser &cb) const override;
68     void Dump(ir::AstDumper *dumper) const override;
69     void Dump(ir::SrcDumper *dumper) const override;
70     void Compile(compiler::PandaGen *pg) const override;
71     void Compile(compiler::ETSGen *etsg) const override;
72     checker::Type *Check(checker::TSChecker *checker) override;
73     checker::Type *Check(checker::ETSChecker *checker) override;
74 
75     void Accept(ASTVisitorT *v) override
76     {
77         v->Accept(this);
78     }
79 
80 private:
81     AstNode *left_;
82     Expression *right_;
83     Statement *body_;
84 };
85 }  // namespace ark::es2panda::ir
86 
87 #endif
88