Merge branch 'main' into pylyzer-mode

This commit is contained in:
Shunsuke Shibayama 2022-12-14 09:23:47 +09:00
commit 3d69353bf6
9 changed files with 36 additions and 0 deletions

View file

@ -386,6 +386,7 @@ pub trait Runnable: Sized + Default {
const NAME: &'static str;
fn new(cfg: ErgConfig) -> Self;
fn cfg(&self) -> &ErgConfig;
fn cfg_mut(&mut self) -> &mut ErgConfig;
fn finish(&mut self); // called when the :exit command is received.
/// Erase all but immutable information.
fn initialize(&mut self);
@ -397,6 +398,9 @@ pub trait Runnable: Sized + Default {
fn input(&self) -> &Input {
&self.cfg().input
}
fn set_input(&mut self, input: Input) {
self.cfg_mut().input = input;
}
fn start_message(&self) -> String {
format!(
"{} {SEMVER} (tags/?:{GIT_HASH_SHORT}, {BUILD_DATE}) on {ARCH}/{OS}\n",

View file

@ -40,6 +40,10 @@ impl Runnable for HIRBuilder {
fn cfg(&self) -> &ErgConfig {
self.lowerer.cfg()
}
#[inline]
fn cfg_mut(&mut self) -> &mut ErgConfig {
self.lowerer.cfg_mut()
}
#[inline]
fn finish(&mut self) {}

View file

@ -127,6 +127,10 @@ impl Runnable for Compiler {
fn cfg(&self) -> &ErgConfig {
&self.cfg
}
#[inline]
fn cfg_mut(&mut self) -> &mut ErgConfig {
&mut self.cfg
}
#[inline]
fn finish(&mut self) {}

View file

@ -71,6 +71,10 @@ impl Runnable for ASTLowerer {
fn cfg(&self) -> &ErgConfig {
&self.cfg
}
#[inline]
fn cfg_mut(&mut self) -> &mut ErgConfig {
&mut self.cfg
}
fn new(cfg: ErgConfig) -> Self {
Self::new_with_cache(

View file

@ -124,6 +124,10 @@ impl Runnable for Transpiler {
fn cfg(&self) -> &ErgConfig {
&self.cfg
}
#[inline]
fn cfg_mut(&mut self) -> &mut ErgConfig {
&mut self.cfg
}
#[inline]
fn finish(&mut self) {}

View file

@ -29,6 +29,10 @@ impl Runnable for ASTBuilder {
fn cfg(&self) -> &ErgConfig {
self.runner.cfg()
}
#[inline]
fn cfg_mut(&mut self) -> &mut ErgConfig {
self.runner.cfg_mut()
}
#[inline]
fn finish(&mut self) {}

View file

@ -33,6 +33,10 @@ impl Runnable for LexerRunner {
fn cfg(&self) -> &ErgConfig {
&self.cfg
}
#[inline]
fn cfg_mut(&mut self) -> &mut ErgConfig {
&mut self.cfg
}
#[inline]
fn finish(&mut self) {}

View file

@ -183,6 +183,10 @@ impl Runnable for ParserRunner {
fn cfg(&self) -> &ErgConfig {
&self.cfg
}
#[inline]
fn cfg_mut(&mut self) -> &mut ErgConfig {
&mut self.cfg
}
#[inline]
fn finish(&mut self) {}

View file

@ -48,6 +48,10 @@ impl Runnable for DummyVM {
fn cfg(&self) -> &ErgConfig {
&self.compiler.cfg
}
#[inline]
fn cfg_mut(&mut self) -> &mut ErgConfig {
&mut self.compiler.cfg
}
fn new(cfg: ErgConfig) -> Self {
let stream = if cfg.input.is_repl() {