mirror of
https://github.com/RGBCube/serenity
synced 2025-07-23 20:27:35 +00:00
LibJS: Move async_block_start out of ECMAScriptFunctionObject
This commit is contained in:
parent
cd83325c7c
commit
39b134e8c1
2 changed files with 7 additions and 7 deletions
|
@ -693,21 +693,20 @@ void ECMAScriptFunctionObject::async_function_start(PromiseCapability const& pro
|
||||||
// 3. NOTE: Copying the execution state is required for AsyncBlockStart to resume its execution. It is ill-defined to resume a currently executing context.
|
// 3. NOTE: Copying the execution state is required for AsyncBlockStart to resume its execution. It is ill-defined to resume a currently executing context.
|
||||||
|
|
||||||
// 4. Perform ! AsyncBlockStart(promiseCapability, asyncFunctionBody, asyncContext).
|
// 4. Perform ! AsyncBlockStart(promiseCapability, asyncFunctionBody, asyncContext).
|
||||||
async_block_start(promise_capability, async_context);
|
async_block_start(vm, m_ecmascript_code, promise_capability, async_context);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 27.7.5.2 AsyncBlockStart ( promiseCapability, asyncBody, asyncContext ), https://tc39.es/ecma262/#sec-asyncblockstart
|
// 27.7.5.2 AsyncBlockStart ( promiseCapability, asyncBody, asyncContext ), https://tc39.es/ecma262/#sec-asyncblockstart
|
||||||
void ECMAScriptFunctionObject::async_block_start(PromiseCapability const& promise_capability, ExecutionContext& async_context)
|
void async_block_start(VM& vm, NonnullRefPtr<Statement> const& async_body, PromiseCapability const& promise_capability, ExecutionContext& async_context)
|
||||||
{
|
{
|
||||||
auto& vm = this->vm();
|
auto& global_object = vm.current_realm()->global_object();
|
||||||
|
|
||||||
// 1. Assert: promiseCapability is a PromiseCapability Record.
|
// 1. Assert: promiseCapability is a PromiseCapability Record.
|
||||||
|
|
||||||
// 2. Let runningContext be the running execution context.
|
// 2. Let runningContext be the running execution context.
|
||||||
auto& running_context = vm.running_execution_context();
|
auto& running_context = vm.running_execution_context();
|
||||||
|
|
||||||
// 3. Set the code evaluation state of asyncContext such that when evaluation is resumed for that execution context the following steps will be performed:
|
// 3. Set the code evaluation state of asyncContext such that when evaluation is resumed for that execution context the following steps will be performed:
|
||||||
auto* execution_steps = NativeFunction::create(global_object(), "", [async_body = m_ecmascript_code, &promise_capability](auto& vm, auto& global_object) -> ThrowCompletionOr<Value> {
|
auto* execution_steps = NativeFunction::create(global_object, "", [&async_body, &promise_capability](auto& vm, auto& global_object) -> ThrowCompletionOr<Value> {
|
||||||
// a. Let result be the result of evaluating asyncBody.
|
// a. Let result be the result of evaluating asyncBody.
|
||||||
auto result = async_body->execute(vm.interpreter(), global_object);
|
auto result = async_body->execute(vm.interpreter(), global_object);
|
||||||
|
|
||||||
|
@ -740,7 +739,7 @@ void ECMAScriptFunctionObject::async_block_start(PromiseCapability const& promis
|
||||||
});
|
});
|
||||||
|
|
||||||
// 4. Push asyncContext onto the execution context stack; asyncContext is now the running execution context.
|
// 4. Push asyncContext onto the execution context stack; asyncContext is now the running execution context.
|
||||||
auto push_result = vm.push_execution_context(async_context, global_object());
|
auto push_result = vm.push_execution_context(async_context, global_object);
|
||||||
if (push_result.is_error())
|
if (push_result.is_error())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,8 @@
|
||||||
|
|
||||||
namespace JS {
|
namespace JS {
|
||||||
|
|
||||||
|
void async_block_start(VM&, NonnullRefPtr<Statement> const& parse_node, PromiseCapability const&, ExecutionContext&);
|
||||||
|
|
||||||
// 10.2 ECMAScript Function Objects, https://tc39.es/ecma262/#sec-ecmascript-function-objects
|
// 10.2 ECMAScript Function Objects, https://tc39.es/ecma262/#sec-ecmascript-function-objects
|
||||||
class ECMAScriptFunctionObject final : public FunctionObject {
|
class ECMAScriptFunctionObject final : public FunctionObject {
|
||||||
JS_OBJECT(ECMAScriptFunctionObject, FunctionObject);
|
JS_OBJECT(ECMAScriptFunctionObject, FunctionObject);
|
||||||
|
@ -97,7 +99,6 @@ private:
|
||||||
void ordinary_call_bind_this(ExecutionContext&, Value this_argument);
|
void ordinary_call_bind_this(ExecutionContext&, Value this_argument);
|
||||||
|
|
||||||
void async_function_start(PromiseCapability const&);
|
void async_function_start(PromiseCapability const&);
|
||||||
void async_block_start(PromiseCapability const&, ExecutionContext&);
|
|
||||||
|
|
||||||
ThrowCompletionOr<void> function_declaration_instantiation(Interpreter*);
|
ThrowCompletionOr<void> function_declaration_instantiation(Interpreter*);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue