mirror of
https://github.com/denoland/rusty_v8.git
synced 2024-12-26 09:13:46 -05:00
feat: add Module::is_graph_async (#1607)
This commit is contained in:
parent
9f37bb80df
commit
a97d89614e
3 changed files with 16 additions and 0 deletions
|
@ -3223,6 +3223,10 @@ const v8::Value* v8__Module__Evaluate(const v8::Module& self,
|
|||
ptr_to_local(&self)->Evaluate(ptr_to_local(&context)));
|
||||
}
|
||||
|
||||
bool v8__Module__IsGraphAsync(const v8::Module& self) {
|
||||
return ptr_to_local(&self)->IsGraphAsync();
|
||||
}
|
||||
|
||||
bool v8__Module__IsSourceTextModule(const v8::Module& self) {
|
||||
return ptr_to_local(&self)->IsSourceTextModule();
|
||||
}
|
||||
|
|
|
@ -169,6 +169,7 @@ extern "C" {
|
|||
this: *const Module,
|
||||
context: *const Context,
|
||||
) -> *const Value;
|
||||
fn v8__Module__IsGraphAsync(this: *const Module) -> bool;
|
||||
fn v8__Module__IsSourceTextModule(this: *const Module) -> bool;
|
||||
fn v8__Module__IsSyntheticModule(this: *const Module) -> bool;
|
||||
fn v8__Module__CreateSyntheticModule(
|
||||
|
@ -349,6 +350,15 @@ impl Module {
|
|||
}
|
||||
}
|
||||
|
||||
/// Returns whether this module or any of its requested modules is async,
|
||||
/// i.e. contains top-level await.
|
||||
///
|
||||
/// The module's status must be at least kInstantiated.
|
||||
#[inline(always)]
|
||||
pub fn is_graph_async(&self) -> bool {
|
||||
unsafe { v8__Module__IsGraphAsync(self) }
|
||||
}
|
||||
|
||||
/// Returns whether the module is a SourceTextModule.
|
||||
#[inline(always)]
|
||||
pub fn is_source_text_module(&self) -> bool {
|
||||
|
|
|
@ -4989,6 +4989,7 @@ fn module_stalled_top_level_await() {
|
|||
.instantiate_module(scope, compile_specifier_as_module_resolve_callback);
|
||||
assert!(result.unwrap());
|
||||
assert_eq!(v8::ModuleStatus::Instantiated, module.get_status());
|
||||
assert!(module.is_graph_async());
|
||||
|
||||
let result = module.evaluate(scope);
|
||||
assert!(result.is_some());
|
||||
|
@ -7756,6 +7757,7 @@ fn synthetic_module() {
|
|||
.instantiate_module(scope, unexpected_module_resolve_callback)
|
||||
.unwrap();
|
||||
assert_eq!(module.get_status(), v8::ModuleStatus::Instantiated);
|
||||
assert!(!module.is_graph_async());
|
||||
|
||||
module.evaluate(scope).unwrap();
|
||||
assert_eq!(module.get_status(), v8::ModuleStatus::Evaluated);
|
||||
|
|
Loading…
Reference in a new issue