mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 04:18:12 +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:
parent
d02c37f3e3
commit
f7c15d00c9
5 changed files with 42 additions and 2 deletions
|
@ -45,12 +45,18 @@ public:
|
|||
|
||||
virtual bool is_function() const { return false; }
|
||||
virtual bool is_native_function() const { return false; }
|
||||
virtual bool is_string_object() const { return false; }
|
||||
|
||||
virtual const char* class_name() const override { return "Object"; }
|
||||
virtual void visit_children(Cell::Visitor&) override;
|
||||
|
||||
Object* prototype() { return m_prototype; }
|
||||
const Object* prototype() const { return m_prototype; }
|
||||
void set_prototype(Object* prototype) { m_prototype = prototype; }
|
||||
|
||||
private:
|
||||
HashMap<String, Value> m_properties;
|
||||
Object* m_prototype { nullptr };
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue