diff options
Diffstat (limited to 'ext/node/ops/vm_internal.rs')
-rw-r--r-- | ext/node/ops/vm_internal.rs | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/ext/node/ops/vm_internal.rs b/ext/node/ops/vm_internal.rs index a9c13a582..ca3cac41f 100644 --- a/ext/node/ops/vm_internal.rs +++ b/ext/node/ops/vm_internal.rs @@ -1,5 +1,6 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. +use crate::create_host_defined_options; use deno_core::error::type_error; use deno_core::error::AnyError; use deno_core::v8; @@ -19,7 +20,22 @@ impl ContextifyScript { scope: &mut v8::HandleScope, source_str: v8::Local<v8::String>, ) -> Result<Self, AnyError> { - let source = v8::script_compiler::Source::new(source_str, None); + let resource_name = v8::undefined(scope); + let host_defined_options = create_host_defined_options(scope); + let origin = v8::ScriptOrigin::new( + scope, + resource_name.into(), + 0, + 0, + false, + 0, + None, + false, + false, + false, + Some(host_defined_options), + ); + let source = v8::script_compiler::Source::new(source_str, Some(&origin)); let unbound_script = v8::script_compiler::compile_unbound_script( scope, @@ -260,7 +276,7 @@ pub fn init_global_template<'a>( thread_local! { pub static GETTER_MAP_FN: v8::NamedPropertyGetterCallback<'static> = property_getter.map_fn_to(); pub static SETTER_MAP_FN: v8::NamedPropertySetterCallback<'static> = property_setter.map_fn_to(); - pub static DELETER_MAP_FN: v8::NamedPropertyGetterCallback<'static> = property_deleter.map_fn_to(); + pub static DELETER_MAP_FN: v8::NamedPropertyDeleterCallback<'static> = property_deleter.map_fn_to(); pub static ENUMERATOR_MAP_FN: v8::NamedPropertyEnumeratorCallback<'static> = property_enumerator.map_fn_to(); pub static DEFINER_MAP_FN: v8::NamedPropertyDefinerCallback<'static> = property_definer.map_fn_to(); pub static DESCRIPTOR_MAP_FN: v8::NamedPropertyGetterCallback<'static> = property_descriptor.map_fn_to(); @@ -269,7 +285,7 @@ thread_local! { thread_local! { pub static INDEXED_GETTER_MAP_FN: v8::IndexedPropertyGetterCallback<'static> = indexed_property_getter.map_fn_to(); pub static INDEXED_SETTER_MAP_FN: v8::IndexedPropertySetterCallback<'static> = indexed_property_setter.map_fn_to(); - pub static INDEXED_DELETER_MAP_FN: v8::IndexedPropertyGetterCallback<'static> = indexed_property_deleter.map_fn_to(); + pub static INDEXED_DELETER_MAP_FN: v8::IndexedPropertyDeleterCallback<'static> = indexed_property_deleter.map_fn_to(); pub static INDEXED_DEFINER_MAP_FN: v8::IndexedPropertyDefinerCallback<'static> = indexed_property_definer.map_fn_to(); pub static INDEXED_DESCRIPTOR_MAP_FN: v8::IndexedPropertyGetterCallback<'static> = indexed_property_descriptor.map_fn_to(); } @@ -362,7 +378,7 @@ fn property_setter<'s>( key: v8::Local<'s, v8::Name>, value: v8::Local<'s, v8::Value>, args: v8::PropertyCallbackArguments<'s>, - mut rv: v8::ReturnValue, + mut rv: v8::ReturnValue<()>, ) -> v8::Intercepted { let Some(ctx) = ContextifyContext::get(scope, args.this()) else { return v8::Intercepted::No; @@ -441,7 +457,7 @@ fn property_setter<'s>( .has_own_property(scope, set_key.into()) .unwrap_or(false) { - rv.set(value); + rv.set_bool(true); return v8::Intercepted::Yes; } } @@ -455,7 +471,7 @@ fn property_deleter<'s>( scope: &mut v8::HandleScope<'s>, key: v8::Local<'s, v8::Name>, args: v8::PropertyCallbackArguments<'s>, - mut rv: v8::ReturnValue, + mut rv: v8::ReturnValue<v8::Boolean>, ) -> v8::Intercepted { let Some(ctx) = ContextifyContext::get(scope, args.this()) else { return v8::Intercepted::No; @@ -475,7 +491,7 @@ fn property_deleter<'s>( fn property_enumerator<'s>( scope: &mut v8::HandleScope<'s>, args: v8::PropertyCallbackArguments<'s>, - mut rv: v8::ReturnValue, + mut rv: v8::ReturnValue<v8::Array>, ) { let Some(ctx) = ContextifyContext::get(scope, args.this()) else { return; @@ -490,7 +506,7 @@ fn property_enumerator<'s>( return; }; - rv.set(properties.into()); + rv.set(properties); } fn property_definer<'s>( @@ -498,7 +514,7 @@ fn property_definer<'s>( key: v8::Local<'s, v8::Name>, desc: &v8::PropertyDescriptor, args: v8::PropertyCallbackArguments<'s>, - _: v8::ReturnValue, + _: v8::ReturnValue<()>, ) -> v8::Intercepted { let Some(ctx) = ContextifyContext::get(scope, args.this()) else { return v8::Intercepted::No; @@ -622,7 +638,7 @@ fn indexed_property_setter<'s>( index: u32, value: v8::Local<'s, v8::Value>, args: v8::PropertyCallbackArguments<'s>, - rv: v8::ReturnValue, + rv: v8::ReturnValue<()>, ) -> v8::Intercepted { let key = uint32_to_name(scope, index); property_setter(scope, key, value, args, rv) @@ -632,7 +648,7 @@ fn indexed_property_deleter<'s>( scope: &mut v8::HandleScope<'s>, index: u32, args: v8::PropertyCallbackArguments<'s>, - mut rv: v8::ReturnValue, + mut rv: v8::ReturnValue<v8::Boolean>, ) -> v8::Intercepted { let Some(ctx) = ContextifyContext::get(scope, args.this()) else { return v8::Intercepted::No; @@ -656,7 +672,7 @@ fn indexed_property_definer<'s>( index: u32, descriptor: &v8::PropertyDescriptor, args: v8::PropertyCallbackArguments<'s>, - rv: v8::ReturnValue, + rv: v8::ReturnValue<()>, ) -> v8::Intercepted { let key = uint32_to_name(scope, index); property_definer(scope, key, descriptor, args, rv) |