forked from denoland/deno
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separate behavior for the compiler isolate (denoland#1973)
- Loading branch information
Showing
9 changed files
with
450 additions
and
293 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. | ||
use crate::isolate_state::*; | ||
use crate::ops; | ||
use deno_core::deno_buf; | ||
use deno_core::deno_mod; | ||
use deno_core::Behavior; | ||
use deno_core::Op; | ||
use deno_core::StartupData; | ||
use std::sync::Arc; | ||
|
||
/// Implements deno_core::Behavior for the main Deno command-line. | ||
pub struct CliBehavior { | ||
startup_data: Option<StartupData>, | ||
pub state: Arc<IsolateState>, | ||
} | ||
|
||
impl CliBehavior { | ||
pub fn new( | ||
startup_data: Option<StartupData>, | ||
state: Arc<IsolateState>, | ||
) -> Self { | ||
Self { | ||
startup_data, | ||
state, | ||
} | ||
} | ||
} | ||
|
||
impl IsolateStateContainer for &CliBehavior { | ||
fn state(&self) -> Arc<IsolateState> { | ||
self.state.clone() | ||
} | ||
} | ||
|
||
impl IsolateStateContainer for CliBehavior { | ||
fn state(&self) -> Arc<IsolateState> { | ||
self.state.clone() | ||
} | ||
} | ||
|
||
impl Behavior for CliBehavior { | ||
fn startup_data(&mut self) -> Option<StartupData> { | ||
self.startup_data.take() | ||
} | ||
|
||
fn resolve(&mut self, specifier: &str, referrer: deno_mod) -> deno_mod { | ||
self.state_resolve(specifier, referrer) | ||
} | ||
|
||
fn dispatch( | ||
&mut self, | ||
control: &[u8], | ||
zero_copy: deno_buf, | ||
) -> (bool, Box<Op>) { | ||
ops::dispatch_all(Box::new(self), control, zero_copy, ops::op_selector_std) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.