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
This commit is contained in:
Ryan Dahl 2020-09-10 09:57:45 -04:00 committed by GitHub
parent 6f70e6e72b
commit 7c2e7c6608
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
44 changed files with 1576 additions and 1348 deletions

View file

@ -3,9 +3,7 @@
mod op_fetch_asset;
use deno_core::js_check;
use deno_core::BasicState;
use deno_core::JsRuntime;
use deno_core::OpRegistry;
use deno_core::StartupData;
use std::collections::HashMap;
use std::env;
@ -39,8 +37,7 @@ fn create_snapshot(
}
fn create_runtime_snapshot(snapshot_path: &Path, files: Vec<PathBuf>) {
let state = BasicState::new();
let isolate = JsRuntime::new(state, StartupData::None, true);
let isolate = JsRuntime::new(StartupData::None, true);
create_snapshot(isolate, snapshot_path, files);
}
@ -73,13 +70,11 @@ fn create_compiler_snapshot(
cwd.join("dts/lib.deno.unstable.d.ts"),
);
let state = BasicState::new();
state.register_op(
let mut isolate = JsRuntime::new(StartupData::None, true);
isolate.register_op(
"op_fetch_asset",
op_fetch_asset::op_fetch_asset(custom_libs),
);
let isolate = JsRuntime::new(state, StartupData::None, true);
create_snapshot(isolate, snapshot_path, files);
}