diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2020-09-20 01:17:35 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-20 01:17:35 +0200 |
commit | b657d743a22802b8232fbf558f2f00bf2942096f (patch) | |
tree | e3a3047e78b6bd9c9e3f551f99f5e80e32de079d /cli/ops/runtime_compiler.rs | |
parent | aaa5e6613a739f8e2ff7579b69c2504bcdc37d4f (diff) |
refactor: remove CliState, use OpState, add CliModuleLoader (#7588)
- remove "CliState.workers" and "CliState.next_worker_id", instead
store them on "OpState" using type aliases.
- remove "CliState.global_timer" and "CliState.start_time", instead
store them on "OpState" using type aliases.
- remove "CliState.is_internal", instead pass it to Worker::new
- move "CliState::permissions" to "OpState"
- move "CliState::main_module" to "OpState"
- move "CliState::global_state" to "OpState"
- move "CliState::check_unstable()" to "GlobalState"
- change "cli_state()" to "global_state()"
- change "deno_core::ModuleLoader" trait to pass "OpState" to callbacks
- rename "CliState" to "CliModuleLoader"
Diffstat (limited to 'cli/ops/runtime_compiler.rs')
-rw-r--r-- | cli/ops/runtime_compiler.rs | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/cli/ops/runtime_compiler.rs b/cli/ops/runtime_compiler.rs index 708a60cfa..f2839585c 100644 --- a/cli/ops/runtime_compiler.rs +++ b/cli/ops/runtime_compiler.rs @@ -1,5 +1,6 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. +use crate::permissions::Permissions; use crate::tsc::runtime_bundle; use crate::tsc::runtime_compile; use crate::tsc::runtime_transpile; @@ -32,11 +33,14 @@ async fn op_compile( args: Value, _data: BufVec, ) -> Result<Value, AnyError> { - let cli_state = super::cli_state2(&state); + let cli_state = super::global_state2(&state); cli_state.check_unstable("Deno.compile"); let args: CompileArgs = serde_json::from_value(args)?; - let global_state = cli_state.global_state.clone(); - let permissions = cli_state.permissions.borrow().clone(); + let global_state = cli_state.clone(); + let permissions = { + let state = state.borrow(); + state.borrow::<Permissions>().clone() + }; let fut = if args.bundle { runtime_bundle( &global_state, @@ -71,11 +75,14 @@ async fn op_transpile( args: Value, _data: BufVec, ) -> Result<Value, AnyError> { - let cli_state = super::cli_state2(&state); + let cli_state = super::global_state2(&state); cli_state.check_unstable("Deno.transpile"); let args: TranspileArgs = serde_json::from_value(args)?; - let global_state = cli_state.global_state.clone(); - let permissions = cli_state.permissions.borrow().clone(); + let global_state = cli_state.clone(); + let permissions = { + let state = state.borrow(); + state.borrow::<Permissions>().clone() + }; let result = runtime_transpile(&global_state, permissions, &args.sources, &args.options) .await?; |