mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 05:37:35 +00:00
LibJS: Implement the NewObjectEnvironment() abstract operation
This commit is contained in:
parent
d8e9a176cd
commit
395bee07e0
3 changed files with 14 additions and 1 deletions
|
@ -14,6 +14,7 @@
|
|||
#include <LibCrypto/BigInt/SignedBigInteger.h>
|
||||
#include <LibJS/AST.h>
|
||||
#include <LibJS/Interpreter.h>
|
||||
#include <LibJS/Runtime/AbstractOperations.h>
|
||||
#include <LibJS/Runtime/Accessor.h>
|
||||
#include <LibJS/Runtime/Array.h>
|
||||
#include <LibJS/Runtime/BigInt.h>
|
||||
|
@ -306,7 +307,7 @@ Value WithStatement::execute(Interpreter& interpreter, GlobalObject& global_obje
|
|||
|
||||
VERIFY(object);
|
||||
|
||||
auto* object_environment_record = interpreter.heap().allocate<ObjectEnvironmentRecord>(global_object, *object, interpreter.vm().call_frame().environment_record);
|
||||
auto* object_environment_record = new_object_environment(*object, true, interpreter.vm().call_frame().environment_record);
|
||||
TemporaryChange<EnvironmentRecord*> scope_change(interpreter.vm().call_frame().environment_record, object_environment_record);
|
||||
return interpreter.execute_statement(global_object, m_body).value_or(js_undefined());
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include <LibJS/Runtime/Function.h>
|
||||
#include <LibJS/Runtime/GlobalObject.h>
|
||||
#include <LibJS/Runtime/Object.h>
|
||||
#include <LibJS/Runtime/ObjectEnvironmentRecord.h>
|
||||
#include <LibJS/Runtime/PropertyName.h>
|
||||
#include <LibJS/Runtime/ProxyObject.h>
|
||||
|
||||
|
@ -165,4 +166,14 @@ DeclarativeEnvironmentRecord* new_declarative_environment(EnvironmentRecord& env
|
|||
return global_object.heap().allocate<DeclarativeEnvironmentRecord>(global_object, &environment_record);
|
||||
}
|
||||
|
||||
// 9.1.2.3 NewObjectEnvironment ( O, W, E ), https://tc39.es/ecma262/#sec-newobjectenvironment
|
||||
ObjectEnvironmentRecord* new_object_environment(Object& object, bool is_with_environment, EnvironmentRecord* environment_record)
|
||||
{
|
||||
auto& global_object = object.global_object();
|
||||
if (!is_with_environment) {
|
||||
TODO();
|
||||
}
|
||||
return global_object.heap().allocate<ObjectEnvironmentRecord>(global_object, object, environment_record);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
namespace JS {
|
||||
|
||||
DeclarativeEnvironmentRecord* new_declarative_environment(EnvironmentRecord&);
|
||||
ObjectEnvironmentRecord* new_object_environment(Object&, bool is_with_environment, EnvironmentRecord*);
|
||||
Value require_object_coercible(GlobalObject&, Value);
|
||||
Function* get_method(GlobalObject& global_object, Value, PropertyName const&);
|
||||
size_t length_of_array_like(GlobalObject&, Object const&);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue