summaryrefslogtreecommitdiff
path: root/cli/ops/compiler.rs
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2020-09-10 09:57:45 -0400
committerGitHub <noreply@github.com>2020-09-10 09:57:45 -0400
commit7c2e7c660804afca823d60e6496aa853f75db16c (patch)
treeb7746b181c1564c6b1abd2e906662f9e6b008417 /cli/ops/compiler.rs
parent6f70e6e72ba2d5c1de7495adac37c1e4f4e86b24 (diff)
Use gotham-like state for ops (#7385)
Provides a concrete state type that can be dynamically added. This is necessary for op crates. * renames BasicState to OpState * async ops take `Rc<RefCell<OpState>>` * sync ops take `&mut OpState` * removes `OpRegistry`, `OpRouter` traits * `get_error_class_fn` moved to OpState * ResourceTable moved to OpState
Diffstat (limited to 'cli/ops/compiler.rs')
-rw-r--r--cli/ops/compiler.rs32
1 files changed, 18 insertions, 14 deletions
diff --git a/cli/ops/compiler.rs b/cli/ops/compiler.rs
index 0b8379fa3..618851daa 100644
--- a/cli/ops/compiler.rs
+++ b/cli/ops/compiler.rs
@@ -1,27 +1,31 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-use crate::state::State;
-use deno_core::OpRegistry;
-use std::rc::Rc;
use std::sync::Arc;
use std::sync::Mutex;
-pub fn init(s: &Rc<State>, response: Arc<Mutex<Option<String>>>) {
+pub fn init(
+ rt: &mut deno_core::JsRuntime,
+ response: Arc<Mutex<Option<String>>>,
+) {
let custom_assets = std::collections::HashMap::new();
// TODO(ry) use None.
// TODO(bartlomieju): is this op even required?
- s.register_op(
+ rt.register_op(
"op_fetch_asset",
crate::op_fetch_asset::op_fetch_asset(custom_assets),
);
- s.register_op_json_sync("op_compiler_respond", move |_state, args, _bufs| {
- let mut response_slot = response.lock().unwrap();
- let replaced_value = response_slot.replace(args.to_string());
- assert!(
- replaced_value.is_none(),
- "op_compiler_respond found unexpected existing compiler output",
- );
- Ok(json!({}))
- });
+ super::reg_json_sync(
+ rt,
+ "op_compiler_respond",
+ move |_state, args, _bufs| {
+ let mut response_slot = response.lock().unwrap();
+ let replaced_value = response_slot.replace(args.to_string());
+ assert!(
+ replaced_value.is_none(),
+ "op_compiler_respond found unexpected existing compiler output",
+ );
+ Ok(json!({}))
+ },
+ );
}