mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-07 00:56:14 +00:00
LibJS: Keep PrivateEnvironment through NativeFunction calls
Previously the variable and lexical environments were already kept in a NativeFunction call. However when we (try to) call a private method from within an async function we go through async_block_start which sets up a NativeFunction to call. This is technically not exactly as the spec describes it, as that requires you to actually "continue" the context. Since we don't have that concept (yet) we use this as an implementation detail to access the private environment from within a native function. Note that this not allow general private environment access since most things get blocked by the parser already.
This commit is contained in:
@@ -139,6 +139,9 @@ ThrowCompletionOr<Value> NativeFunction::internal_call(Value this_argument, Mark
|
||||
|
||||
callee_context.lexical_environment = caller_context.lexical_environment;
|
||||
callee_context.variable_environment = caller_context.variable_environment;
|
||||
// Note: Keeping the private environment is probably only needed because of async methods in classes
|
||||
// calling async_block_start which goes through a NativeFunction here.
|
||||
callee_context.private_environment = caller_context.private_environment;
|
||||
|
||||
// NOTE: This is a LibJS specific hack for NativeFunction to inherit the strictness of its caller.
|
||||
callee_context.is_strict_mode = vm.in_strict_mode();
|
||||
|
||||
Reference in New Issue
Block a user