mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-02 06:37:52 +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:
@@ -79,10 +79,20 @@ public:
|
||||
void enter_scope(const ScopeNode&, Vector<Argument>, ScopeType);
|
||||
void exit_scope(const ScopeNode&);
|
||||
|
||||
void push_this_value(Value value) { m_this_stack.append(move(value)); }
|
||||
void pop_this_value() { m_this_stack.take_last(); }
|
||||
Value this_value() const
|
||||
{
|
||||
if (m_this_stack.is_empty())
|
||||
return m_global_object;
|
||||
return m_this_stack.last();
|
||||
}
|
||||
|
||||
private:
|
||||
Heap m_heap;
|
||||
|
||||
Vector<ScopeFrame> m_scope_stack;
|
||||
Vector<Value> m_this_stack;
|
||||
|
||||
Object* m_global_object { nullptr };
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user