1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 04:37:34 +00:00

LibJS: Split out NewExpression evaluation from CallExpression

This patch adds an override for NewExpression::execute() in the AST
interpreter to separate the logic from CallExpression. As a result,
both evaluation functions are simplified.

Both expressions are still largely non-conforming, but this makes
it easier to work on improving that since we can now deal with them
separately. :^)
This commit is contained in:
Andreas Kling 2021-07-02 18:25:32 +02:00
parent bad1acf137
commit 814549b846
2 changed files with 66 additions and 44 deletions

View file

@ -922,11 +922,16 @@ public:
virtual void dump(int indent) const override;
virtual void generate_bytecode(Bytecode::Generator&) const override;
private:
Expression const& callee() const { return m_callee; }
protected:
void throw_type_error_for_callee(Interpreter&, GlobalObject&, Value callee_value, StringView call_type) const;
struct ThisAndCallee {
Value this_value;
Value callee;
};
ThisAndCallee compute_this_and_callee(Interpreter&, GlobalObject&) const;
NonnullRefPtr<Expression> m_callee;
@ -940,6 +945,8 @@ public:
{
}
virtual Value execute(Interpreter&, GlobalObject&) const override;
virtual bool is_new_expression() const override { return true; }
};