diff options
Diffstat (limited to 'Libraries/LibJS/AST.h')
-rw-r--r-- | Libraries/LibJS/AST.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/Libraries/LibJS/AST.h b/Libraries/LibJS/AST.h index 6c3f11b8f1..8821c5ceaf 100644 --- a/Libraries/LibJS/AST.h +++ b/Libraries/LibJS/AST.h @@ -211,6 +211,33 @@ private: NonnullOwnPtr<ScopeNode> m_body; }; +class ForStatement : public Statement { +public: + ForStatement(OwnPtr<Statement> init, OwnPtr<Expression> test, OwnPtr<Expression> update, NonnullOwnPtr<ScopeNode> body) + : m_init(move(init)) + , m_test(move(test)) + , m_update(move(update)) + , m_body(move(body)) + { + } + + const Statement* init() const { return m_init; } + const Expression* test() const { return m_test; } + const Expression* update() const { return m_update; } + const ScopeNode& body() const { return *m_body; } + + virtual Value execute(Interpreter&) const override; + virtual void dump(int indent) const override; + +private: + virtual const char* class_name() const override { return "ForStatement"; } + + OwnPtr<Statement> m_init; + OwnPtr<Expression> m_test; + OwnPtr<Expression> m_update; + NonnullOwnPtr<ScopeNode> m_body; +}; + enum class BinaryOp { Plus, Minus, |