refactor: tidy
This commit is contained in:
@@ -57,7 +57,7 @@ pub(crate) fn compile_scoped(expr: &Ir, ctx: &impl CodegenContext) -> String {
|
|||||||
buf.into_string()
|
buf.into_string()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) struct CodeBuffer {
|
struct CodeBuffer {
|
||||||
buf: String,
|
buf: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -182,7 +182,7 @@ impl Context {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) struct Ctx {
|
struct Ctx {
|
||||||
symbols: DefaultStringInterner,
|
symbols: DefaultStringInterner,
|
||||||
global: HashMap<SymId, Ir<'static>>,
|
global: HashMap<SymId, Ir<'static>>,
|
||||||
sources: Vec<Source>,
|
sources: Vec<Source>,
|
||||||
@@ -307,7 +307,7 @@ impl Ctx {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn get_current_dir(&self) -> &Path {
|
fn get_current_dir(&self) -> &Path {
|
||||||
self.sources
|
self.sources
|
||||||
.last()
|
.last()
|
||||||
.as_ref()
|
.as_ref()
|
||||||
@@ -315,17 +315,13 @@ impl Ctx {
|
|||||||
.get_dir()
|
.get_dir()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn get_current_source(&self) -> Source {
|
fn get_current_source(&self) -> Source {
|
||||||
self.sources
|
self.sources
|
||||||
.last()
|
.last()
|
||||||
.expect("current_source is not set")
|
.expect("current_source is not set")
|
||||||
.clone()
|
.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn get_source(&self, id: usize) -> Source {
|
|
||||||
self.sources.get(id).expect("source not found").clone()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn downgrade<'ctx>(
|
fn downgrade<'ctx>(
|
||||||
&'ctx mut self,
|
&'ctx mut self,
|
||||||
source: Source,
|
source: Source,
|
||||||
@@ -363,7 +359,7 @@ impl Ctx {
|
|||||||
Ok(code)
|
Ok(code)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn compile_scoped(&mut self, source: Source, scope: Vec<String>) -> Result<String> {
|
fn compile_scoped(&mut self, source: Source, scope: Vec<String>) -> Result<String> {
|
||||||
let scope = Scope::ScopedImport(
|
let scope = Scope::ScopedImport(
|
||||||
scope
|
scope
|
||||||
.into_iter()
|
.into_iter()
|
||||||
@@ -419,7 +415,7 @@ impl RuntimeContext for Ctx {
|
|||||||
self.compile_scoped(source, scope)
|
self.compile_scoped(source, scope)
|
||||||
}
|
}
|
||||||
fn get_source(&self, id: usize) -> Source {
|
fn get_source(&self, id: usize) -> Source {
|
||||||
self.get_source(id)
|
self.sources.get(id).expect("source not found").clone()
|
||||||
}
|
}
|
||||||
fn get_store(&self) -> &DaemonStore {
|
fn get_store(&self) -> &DaemonStore {
|
||||||
&self.store
|
&self.store
|
||||||
@@ -454,7 +450,7 @@ impl<'ir, 'ctx> ScopeGuard<'_, 'ctx, 'ir> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct DowngradeCtx<'ctx, 'ir> {
|
struct DowngradeCtx<'ctx, 'ir> {
|
||||||
bump: &'ir Bump,
|
bump: &'ir Bump,
|
||||||
symbols: &'ctx mut DefaultStringInterner,
|
symbols: &'ctx mut DefaultStringInterner,
|
||||||
source: Source,
|
source: Source,
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ fn runtime_extension<Ctx: RuntimeContext>() -> Extension {
|
|||||||
mod private {
|
mod private {
|
||||||
use deno_error::js_error_wrapper;
|
use deno_error::js_error_wrapper;
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct SimpleErrorWrapper(pub(crate) String);
|
pub struct SimpleErrorWrapper(String);
|
||||||
impl std::fmt::Display for SimpleErrorWrapper {
|
impl std::fmt::Display for SimpleErrorWrapper {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
std::fmt::Display::fmt(&self.0, f)
|
std::fmt::Display::fmt(&self.0, f)
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ where
|
|||||||
|
|
||||||
#[derive(Embed)]
|
#[derive(Embed)]
|
||||||
#[folder = "src/runtime/corepkgs"]
|
#[folder = "src/runtime/corepkgs"]
|
||||||
pub(crate) struct CorePkgs;
|
struct CorePkgs;
|
||||||
|
|
||||||
fn new_simple_jserror(msg: String) -> Box<JsError> {
|
fn new_simple_jserror(msg: String) -> Box<JsError> {
|
||||||
JsError {
|
JsError {
|
||||||
|
|||||||
Reference in New Issue
Block a user