summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/bindings.rs2
-rw-r--r--core/lib.rs1
-rw-r--r--core/modules.rs2
-rw-r--r--core/runtime.rs20
4 files changed, 11 insertions, 14 deletions
diff --git a/core/bindings.rs b/core/bindings.rs
index 03212f356..782c98bd1 100644
--- a/core/bindings.rs
+++ b/core/bindings.rs
@@ -2,8 +2,8 @@
use crate::error::AnyError;
use crate::error::JsError;
+use crate::runtime::JsRuntimeState;
use crate::JsRuntime;
-use crate::JsRuntimeState;
use crate::Op;
use crate::OpId;
use crate::OpTable;
diff --git a/core/lib.rs b/core/lib.rs
index 73d0da071..0dca01691 100644
--- a/core/lib.rs
+++ b/core/lib.rs
@@ -45,7 +45,6 @@ pub use crate::runtime::js_check;
pub use crate::runtime::GetErrorClassFn;
pub use crate::runtime::HeapLimits;
pub use crate::runtime::JsRuntime;
-pub use crate::runtime::JsRuntimeState;
pub use crate::runtime::RuntimeOptions;
pub use crate::runtime::Snapshot;
pub use crate::zero_copy_buf::BufVec;
diff --git a/core/modules.rs b/core/modules.rs
index e02d5c52e..b35e691c5 100644
--- a/core/modules.rs
+++ b/core/modules.rs
@@ -363,6 +363,7 @@ impl ModuleNameMap {
}
/// Check if a name is an alias to another module.
+ #[cfg(test)]
pub fn is_alias(&self, name: &str) -> bool {
let cond = self.inner.get(name);
matches!(cond, Some(SymbolicModule::Alias(_)))
@@ -427,6 +428,7 @@ impl Modules {
self.by_name.alias(name.to_owned(), target.to_owned());
}
+ #[cfg(test)]
pub fn is_alias(&self, name: &str) -> bool {
self.by_name.is_alias(name)
}
diff --git a/core/runtime.rs b/core/runtime.rs
index 65ab50497..e0a840c1a 100644
--- a/core/runtime.rs
+++ b/core/runtime.rs
@@ -86,7 +86,7 @@ pub struct JsRuntime {
/// Internal state for JsRuntime which is stored in one of v8::Isolate's
/// embedder slots.
-pub struct JsRuntimeState {
+pub(crate) struct JsRuntimeState {
pub global_context: Option<v8::Global<v8::Context>>,
pub(crate) shared_ab: Option<v8::Global<v8::SharedArrayBuffer>>,
pub(crate) js_recv_cb: Option<v8::Global<v8::Function>>,
@@ -305,6 +305,12 @@ impl JsRuntime {
}
}
+ pub fn global_context(&self) -> v8::Global<v8::Context> {
+ let state = Self::state(self);
+ let state = state.borrow();
+ state.global_context.clone().unwrap()
+ }
+
fn setup_isolate(mut isolate: v8::OwnedIsolate) -> v8::OwnedIsolate {
isolate.set_capture_stack_trace_for_uncaught_exceptions(true, 10);
isolate.set_promise_reject_callback(bindings::promise_reject_callback);
@@ -317,7 +323,7 @@ impl JsRuntime {
isolate
}
- pub fn state(isolate: &v8::Isolate) -> Rc<RefCell<JsRuntimeState>> {
+ pub(crate) fn state(isolate: &v8::Isolate) -> Rc<RefCell<JsRuntimeState>> {
let s = isolate.get_slot::<Rc<RefCell<JsRuntimeState>>>().unwrap();
s.clone()
}
@@ -594,16 +600,6 @@ impl Future for JsRuntime {
}
impl JsRuntimeState {
- /// Allows a callback to be set whenever a V8 exception is made. This allows
- /// the caller to wrap the JsError into an error. By default this callback
- /// is set to JsError::create.
- pub fn set_js_error_create_fn(
- &mut self,
- f: impl Fn(JsError) -> AnyError + 'static,
- ) {
- self.js_error_create_fn = Box::new(f);
- }
-
// Called by V8 during `Isolate::mod_instantiate`.
pub fn module_resolve_cb(
&mut self,