mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 10:38:11 +00:00
LibJS: Make AsyncFunctionStart and AsyncBlockStart templates
This will allow implementing a version of these functions that accepts a JS::SafeFunction, which is needed for the implementation of Array.fromAsync.
This commit is contained in:
parent
7b5362fea6
commit
930dd2948f
3 changed files with 13 additions and 5 deletions
|
@ -754,7 +754,8 @@ void ECMAScriptFunctionObject::ordinary_call_bind_this(ExecutionContext& callee_
|
|||
}
|
||||
|
||||
// 27.7.5.1 AsyncFunctionStart ( promiseCapability, asyncFunctionBody ), https://tc39.es/ecma262/#sec-async-functions-abstract-operations-async-function-start
|
||||
void async_function_start(VM& vm, PromiseCapability const& promise_capability, NonnullRefPtr<Statement const> const& async_function_body)
|
||||
template<typename T>
|
||||
void async_function_start(VM& vm, PromiseCapability const& promise_capability, T const& async_function_body)
|
||||
{
|
||||
// 1. Let runningContext be the running execution context.
|
||||
auto& running_context = vm.running_execution_context();
|
||||
|
@ -771,7 +772,8 @@ void async_function_start(VM& vm, PromiseCapability const& promise_capability, N
|
|||
}
|
||||
|
||||
// 27.7.5.2 AsyncBlockStart ( promiseCapability, asyncBody, asyncContext ), https://tc39.es/ecma262/#sec-asyncblockstart
|
||||
void async_block_start(VM& vm, NonnullRefPtr<Statement const> const& async_body, PromiseCapability const& promise_capability, ExecutionContext& async_context)
|
||||
template<typename T>
|
||||
void async_block_start(VM& vm, T const& async_body, PromiseCapability const& promise_capability, ExecutionContext& async_context)
|
||||
{
|
||||
auto& realm = *vm.current_realm();
|
||||
|
||||
|
@ -847,6 +849,9 @@ void async_block_start(VM& vm, NonnullRefPtr<Statement const> const& async_body,
|
|||
// 8. Return unused.
|
||||
}
|
||||
|
||||
template void async_block_start(VM&, NonnullGCPtr<Statement const> const& async_body, PromiseCapability const&, ExecutionContext&);
|
||||
template void async_function_start(VM&, PromiseCapability const&, NonnullGCPtr<Statement const> const& async_function_body);
|
||||
|
||||
// 10.2.1.4 OrdinaryCallEvaluateBody ( F, argumentsList ), https://tc39.es/ecma262/#sec-ordinarycallevaluatebody
|
||||
// 15.8.4 Runtime Semantics: EvaluateAsyncFunctionBody, https://tc39.es/ecma262/#sec-runtime-semantics-evaluatefunctionbody
|
||||
Completion ECMAScriptFunctionObject::ordinary_call_evaluate_body()
|
||||
|
|
|
@ -15,8 +15,11 @@
|
|||
|
||||
namespace JS {
|
||||
|
||||
void async_block_start(VM&, NonnullRefPtr<Statement const> const& parse_node, PromiseCapability const&, ExecutionContext&);
|
||||
void async_function_start(VM&, PromiseCapability const&, NonnullRefPtr<Statement const> const& async_function_body);
|
||||
template<typename T>
|
||||
void async_block_start(VM&, T const& async_body, PromiseCapability const&, ExecutionContext&);
|
||||
|
||||
template<typename T>
|
||||
void async_function_start(VM&, PromiseCapability const&, T const& async_function_body);
|
||||
|
||||
// 10.2 ECMAScript Function Objects, https://tc39.es/ecma262/#sec-ecmascript-function-objects
|
||||
class ECMAScriptFunctionObject final : public FunctionObject {
|
||||
|
|
|
@ -737,7 +737,7 @@ ThrowCompletionOr<void> SourceTextModule::execute_module(VM& vm, GCPtr<PromiseCa
|
|||
VERIFY(capability != nullptr);
|
||||
|
||||
// b. Perform AsyncBlockStart(capability, module.[[ECMAScriptCode]], moduleContext).
|
||||
async_block_start(vm, m_ecmascript_code, *capability, module_context);
|
||||
async_block_start<NonnullRefPtr<Statement const>>(vm, m_ecmascript_code, *capability, module_context);
|
||||
}
|
||||
|
||||
// 11. Return unused.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue