1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 13:38:11 +00:00

LibJS: Add basic prototype support

Object will now traverse up the prototype chain when doing a get().
When a function is called on an object, that object will now also be
the "this" value inside the function. This stuff is probably not very
correct, but we will improve things as we go! :^)
This commit is contained in:
Andreas Kling 2020-03-15 15:01:10 +01:00
parent d02c37f3e3
commit f7c15d00c9
5 changed files with 42 additions and 2 deletions

View file

@ -142,6 +142,7 @@ private:
class Expression : public ASTNode {
public:
virtual bool is_member_expression() const { return false; }
};
class ErrorExpression final : public Expression {
@ -521,7 +522,10 @@ public:
virtual Value execute(Interpreter&) const override;
virtual void dump(int indent) const override;
const Expression& object() const { return *m_object; }
private:
virtual bool is_member_expression() const override { return true; }
virtual const char* class_name() const override { return "MemberExpression"; }
NonnullOwnPtr<Expression> m_object;