mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 03:27:34 +00:00
LibJS: Bring function environment records closer to the spec
This patch adds FunctionEnvironmentRecord as a subclass of the existing DeclarativeEnvironmentRecord. Things that are specific to function environment records move into there, simplifying the base. Most of the abstract operations related to function environment records are rewritten to match the spec exactly. I also had to implement GetThisEnvironment() and GetSuperConstructor() to keep tests working after the changes, so that's nice as well. :^)
This commit is contained in:
parent
6ed6434bab
commit
aabd82d508
28 changed files with 228 additions and 159 deletions
|
@ -26,7 +26,7 @@ public:
|
|||
virtual Value call() = 0;
|
||||
virtual Value construct(Function& new_target) = 0;
|
||||
virtual const FlyString& name() const = 0;
|
||||
virtual DeclarativeEnvironmentRecord* create_environment_record() = 0;
|
||||
virtual FunctionEnvironmentRecord* create_environment_record() = 0;
|
||||
|
||||
BoundFunction* bind(Value bound_this_value, Vector<Value> arguments);
|
||||
|
||||
|
@ -42,6 +42,11 @@ public:
|
|||
|
||||
virtual bool is_strict_mode() const { return false; }
|
||||
|
||||
// [[Environment]]
|
||||
// The Environment Record that the function was closed over.
|
||||
// Used as the outer environment when evaluating the code of the function.
|
||||
virtual EnvironmentRecord* environment() { return nullptr; }
|
||||
|
||||
protected:
|
||||
virtual void visit_edges(Visitor&) override;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue