mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-04 15:45:25 +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:
@@ -9,7 +9,7 @@
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <LibJS/AST.h>
|
||||
#include <LibJS/Interpreter.h>
|
||||
#include <LibJS/Runtime/DeclarativeEnvironmentRecord.h>
|
||||
#include <LibJS/Runtime/FunctionEnvironmentRecord.h>
|
||||
#include <LibJS/Runtime/GlobalObject.h>
|
||||
#include <LibJS/Runtime/Object.h>
|
||||
#include <LibJS/Runtime/Reference.h>
|
||||
@@ -193,10 +193,10 @@ Value Interpreter::execute_statement(GlobalObject& global_object, const Statemen
|
||||
return last_value;
|
||||
}
|
||||
|
||||
DeclarativeEnvironmentRecord* Interpreter::current_declarative_environment_record()
|
||||
FunctionEnvironmentRecord* Interpreter::current_function_environment_record()
|
||||
{
|
||||
VERIFY(is<DeclarativeEnvironmentRecord>(vm().call_frame().environment_record));
|
||||
return static_cast<DeclarativeEnvironmentRecord*>(vm().call_frame().environment_record);
|
||||
VERIFY(is<FunctionEnvironmentRecord>(vm().call_frame().environment_record));
|
||||
return static_cast<FunctionEnvironmentRecord*>(vm().call_frame().environment_record);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user