Move JSON ops to deno_core (#7336)

This commit is contained in:
Bert Belder 2020-09-06 02:34:02 +02:00 committed by GitHub
parent 849431eb1d
commit c821e8f2f1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
78 changed files with 1492 additions and 2204 deletions

View file

@ -1,8 +1,11 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
mod op_fetch_asset;
use deno_core::js_check;
use deno_core::BasicState;
use deno_core::CoreIsolate;
use deno_core::OpRegistry;
use deno_core::StartupData;
use std::collections::HashMap;
use std::env;
@ -28,8 +31,9 @@ fn create_snapshot(
}
fn create_runtime_snapshot(snapshot_path: &Path, files: Vec<String>) {
let runtime_isolate = CoreIsolate::new(StartupData::None, true);
create_snapshot(runtime_isolate, snapshot_path, files);
let state = BasicState::new();
let isolate = CoreIsolate::new(state, StartupData::None, true);
create_snapshot(isolate, snapshot_path, files);
}
fn create_compiler_snapshot(
@ -37,7 +41,6 @@ fn create_compiler_snapshot(
files: Vec<String>,
cwd: &Path,
) {
let mut runtime_isolate = CoreIsolate::new(StartupData::None, true);
let mut custom_libs: HashMap<String, PathBuf> = HashMap::new();
custom_libs
.insert("lib.deno.web.d.ts".to_string(), deno_web::get_declaration());
@ -61,11 +64,15 @@ fn create_compiler_snapshot(
"lib.deno.unstable.d.ts".to_string(),
cwd.join("dts/lib.deno.unstable.d.ts"),
);
runtime_isolate.register_op(
let state = BasicState::new();
state.register_op(
"op_fetch_asset",
op_fetch_asset::op_fetch_asset(custom_libs),
);
create_snapshot(runtime_isolate, snapshot_path, files);
let isolate = CoreIsolate::new(state, StartupData::None, true);
create_snapshot(isolate, snapshot_path, files);
}
fn ts_version() -> String {