mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-28 10:37:17 +02:00
LibJS: Add basic support for module code with top-level await
For now, we handle this by creating a synthetic async function to wrap the top-level module code. This allows us to piggyback on the async function driver wrapper mechanism.
This commit is contained in:
Notes:
sideshowbarker
2024-07-17 21:11:12 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/a2c3db8367 Pull-request: https://github.com/SerenityOS/serenity/pull/22183 Reviewed-by: https://github.com/trflynn89 ✅
@@ -1192,7 +1192,11 @@ Completion ECMAScriptFunctionObject::ordinary_call_evaluate_body()
|
||||
}
|
||||
}
|
||||
|
||||
auto declaration_result = function_declaration_instantiation();
|
||||
auto declaration_result = [&]() -> ThrowCompletionOr<void> {
|
||||
if (is_module_wrapper())
|
||||
return {};
|
||||
return function_declaration_instantiation();
|
||||
}();
|
||||
|
||||
if (m_kind == FunctionKind::Normal || m_kind == FunctionKind::Generator || m_kind == FunctionKind::AsyncGenerator) {
|
||||
if (declaration_result.is_error())
|
||||
|
||||
Reference in New Issue
Block a user