1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 06:37:43 +00:00

LibJS: Parse "with" statements :^)

This commit is contained in:
Andreas Kling 2020-11-28 15:05:57 +01:00
parent 98f2da9834
commit d617120499
4 changed files with 55 additions and 0 deletions

View file

@ -351,6 +351,27 @@ private:
NonnullRefPtr<Statement> m_body;
};
class WithStatement final : public Statement {
public:
WithStatement(NonnullRefPtr<Expression> object, NonnullRefPtr<Statement> body)
: m_object(move(object))
, m_body(move(body))
{
}
const Expression& object() const { return *m_object; }
const Statement& body() const { return *m_body; }
virtual Value execute(Interpreter&, GlobalObject&) const override;
virtual void dump(int indent) const override;
private:
virtual const char* class_name() const override { return "WithStatement"; }
NonnullRefPtr<Expression> m_object;
NonnullRefPtr<Statement> m_body;
};
class ForStatement final : public Statement {
public:
ForStatement(RefPtr<ASTNode> init, RefPtr<Expression> test, RefPtr<Expression> update, NonnullRefPtr<Statement> body)