summaryrefslogtreecommitdiff
path: root/core/runtime.rs
diff options
context:
space:
mode:
Diffstat (limited to 'core/runtime.rs')
-rw-r--r--core/runtime.rs35
1 files changed, 30 insertions, 5 deletions
diff --git a/core/runtime.rs b/core/runtime.rs
index 9c6b7afea..c028d97c2 100644
--- a/core/runtime.rs
+++ b/core/runtime.rs
@@ -985,11 +985,36 @@ impl JsRuntime {
fn init_cbs(&mut self, realm: &JsRealm) {
let (recv_cb, build_custom_error_cb) = {
let scope = &mut realm.handle_scope(self.v8_isolate());
- let recv_cb =
- Self::eval::<v8::Function>(scope, "Deno.core.opresolve").unwrap();
- let build_custom_error_cb =
- Self::eval::<v8::Function>(scope, "Deno.core.buildCustomError")
- .expect("Deno.core.buildCustomError is undefined in the realm");
+ let context = realm.context();
+ let context_local = v8::Local::new(scope, context);
+ let global = context_local.global(scope);
+ let deno_str = v8::String::new(scope, "Deno").unwrap();
+ let core_str = v8::String::new(scope, "core").unwrap();
+ let opresolve_str = v8::String::new(scope, "opresolve").unwrap();
+ let build_custom_error_str =
+ v8::String::new(scope, "buildCustomError").unwrap();
+
+ let deno_obj: v8::Local<v8::Object> = global
+ .get(scope, deno_str.into())
+ .unwrap()
+ .try_into()
+ .unwrap();
+ let core_obj: v8::Local<v8::Object> = deno_obj
+ .get(scope, core_str.into())
+ .unwrap()
+ .try_into()
+ .unwrap();
+
+ let recv_cb: v8::Local<v8::Function> = core_obj
+ .get(scope, opresolve_str.into())
+ .unwrap()
+ .try_into()
+ .unwrap();
+ let build_custom_error_cb: v8::Local<v8::Function> = core_obj
+ .get(scope, build_custom_error_str.into())
+ .unwrap()
+ .try_into()
+ .unwrap();
(
v8::Global::new(scope, recv_cb),
v8::Global::new(scope, build_custom_error_cb),