diff options
author | Matt Mastracci <matthew@mastracci.com> | 2023-06-13 20:03:10 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-14 02:03:10 +0000 |
commit | ec8e9d4f5bd2c8eed5f086356c1c6dd7c8b40b7f (patch) | |
tree | 2ffda9204901bfb757e8ce6359d1fc6aa2f9964b /core/modules/map.rs | |
parent | fd9d6baea311d9b227b130749647a86838ba2ccc (diff) |
chore(core): Refactor runtime and split out tests (#19491)
This is a quick first refactoring to split the tests out of runtime and
move runtime-related code to a top-level runtime module.
There will be a followup to refactor imports a bit, but this is the
major change that will most likely conflict with other work and I want
to merge it early.
Diffstat (limited to 'core/modules/map.rs')
-rw-r--r-- | core/modules/map.rs | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/core/modules/map.rs b/core/modules/map.rs index 4ab146659..828d5888b 100644 --- a/core/modules/map.rs +++ b/core/modules/map.rs @@ -1,6 +1,4 @@ -use crate::JsRuntime; // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. -use crate::bindings; use crate::error::generic_error; use crate::fast_string::FastString; use crate::modules::get_asserted_module_type_from_assertions; @@ -20,7 +18,8 @@ use crate::modules::NoopModuleLoader; use crate::modules::PrepareLoadFuture; use crate::modules::RecursiveModuleLoad; use crate::modules::ResolutionKind; -use crate::snapshot_util::SnapshottedData; +use crate::runtime::JsRuntime; +use crate::runtime::SnapshottedData; use anyhow::Error; use futures::future::FutureExt; use futures::stream::FuturesUnordered; @@ -467,7 +466,7 @@ impl ModuleMap { let name_str = name.v8(scope); let source_str = source.v8(scope); - let origin = bindings::module_origin(scope, name_str); + let origin = module_origin(scope, name_str); let source = v8::script_compiler::Source::new(source_str, Some(&origin)); let tc_scope = &mut v8::TryCatch::new(scope); @@ -820,3 +819,22 @@ fn json_module_evaluation_steps<'a>( resolver.resolve(tc_scope, undefined.into()); Some(resolver.get_promise(tc_scope).into()) } + +pub fn module_origin<'a>( + s: &mut v8::HandleScope<'a>, + resource_name: v8::Local<'a, v8::String>, +) -> v8::ScriptOrigin<'a> { + let source_map_url = v8::String::empty(s); + v8::ScriptOrigin::new( + s, + resource_name.into(), + 0, + 0, + false, + 123, + source_map_url.into(), + true, + false, + true, + ) +} |