pub struct Compiler {
pub(crate) storage: Storage<Self>,
pub(crate) inputs: Arc<Mutex<Inputs>>,
pub(crate) vfs: Arc<dyn VirtualFileSystem>,
pub(crate) debug_tx: Option<Sender<DebugEvent>>,
}Fields§
§storage: Storage<Self>§inputs: Arc<Mutex<Inputs>>Extra information about our inputs that the rest of Dada compiler doesn’t have to know (e.g., they’re URL etc).
This is behind a mutex but we have an invariant that we only modify things in the mutex
if we have &mut access to the compiler.
vfs: Arc<dyn VirtualFileSystem>Mediates all access to the file system.
debug_tx: Option<Sender<DebugEvent>>Directory where debug logs are written.
Implementations§
Source§impl Compiler
impl Compiler
pub fn new( vfs: impl VirtualFileSystem, debug_tx: Option<Sender<DebugEvent>>, ) -> Self
Sourcepub fn fork(&self) -> Fork<Self>
pub fn fork(&self) -> Fork<Self>
Create a “fork” of the compiler that has only &self access.
This is meant to be used from another thread.
Sourcepub fn load_source_file(
&mut self,
source_url: &(impl ToUrl + ?Sized),
) -> Fallible<SourceFile>
pub fn load_source_file( &mut self, source_url: &(impl ToUrl + ?Sized), ) -> Fallible<SourceFile>
Load the contents of source_url and then open it with those contents.
Sourcepub fn open_source_file(
&mut self,
source_url: &(impl ToUrl + ?Sized),
contents: Result<String, String>,
) -> Fallible<SourceFile>
pub fn open_source_file( &mut self, source_url: &(impl ToUrl + ?Sized), contents: Result<String, String>, ) -> Fallible<SourceFile>
“Open” a source file with the given contents.
This will find an existing SourceFile if one exists and update its content.
If none exists, a new SourceFile will be created and the containing crate will be added.
Sourcepub fn get_previously_opened_source_file(
&mut self,
source_url: &(impl ToUrl + ?Sized),
) -> Fallible<SourceFile>
pub fn get_previously_opened_source_file( &mut self, source_url: &(impl ToUrl + ?Sized), ) -> Fallible<SourceFile>
Get the SourceFile for the given path.
Errors if no source file was opened yet.
Sourcepub fn add_crate_containing_source_file(
&mut self,
source_url: &Url,
) -> Fallible<Krate>
pub fn add_crate_containing_source_file( &mut self, source_url: &Url, ) -> Fallible<Krate>
Given a .dada file, finds the enclosing crate and adds it into the list of crates.
Given some path a/b/c.dada, we decide that c is a submodule of a/b if there exists
a a/b.dada; otherwise, c is considered a crate of its own.
Sourcepub fn add_crate_with_root_path(&mut self, root_url: &Url) -> Fallible<Krate>
pub fn add_crate_with_root_path(&mut self, root_url: &Url) -> Fallible<Krate>
Add a crate that is rooted in the given dada file.
The crate is named after the file name.
Sourcepub fn codegen_main_fn(&self, source_file: SourceFile) -> &Option<Vec<u8>>
pub fn codegen_main_fn(&self, source_file: SourceFile) -> &Option<Vec<u8>>
Codegen the main function of a source file.
Sourcepub fn check_all(&self, source_file: SourceFile) -> Vec<&Diagnostic>
pub fn check_all(&self, source_file: SourceFile) -> Vec<&Diagnostic>
Compute all diagnostics for a source file.
Sourcepub fn probe_variable_type(&self, span: AbsoluteSpan) -> Option<String>
pub fn probe_variable_type(&self, span: AbsoluteSpan) -> Option<String>
Return type of the variable found at the given span or None if there is no variable there.
Sourcepub fn probe_expression_type(&self, span: AbsoluteSpan) -> Option<String>
pub fn probe_expression_type(&self, span: AbsoluteSpan) -> Option<String>
Return type of the variable found at the given span or None if there is no variable there.
Sourcepub fn probe_ast(&self, span: AbsoluteSpan) -> Option<String>
pub fn probe_ast(&self, span: AbsoluteSpan) -> Option<String>
Return compact AST representation of the expression at the given span.
pub(crate) fn deduplicated(diagnostics: Vec<&Diagnostic>) -> Vec<&Diagnostic>
pub fn fn_asts(&self, source_file: SourceFile) -> String
Sourcepub fn root(&self) -> CompilationRoot
pub fn root(&self) -> CompilationRoot
Access the [CompilationRoot], from which all crates and sources can be reached.
Sourcepub(crate) fn add_crate(
&mut self,
crate_name: String,
new_source: impl Into<KrateSource>,
) -> Fallible<Krate>
pub(crate) fn add_crate( &mut self, crate_name: String, new_source: impl Into<KrateSource>, ) -> Fallible<Krate>
Add a crate named crate_name sourced at source into our list.
We can never have two crates with the same name.
If a crate k named crate_name already exists, we check if k has the same source.
If so, the existing crate is returned. Otherwise, an error results.
Sourcepub(crate) fn get_source_file(&self, url: &Url) -> Option<SourceFile>
pub(crate) fn get_source_file(&self, url: &Url) -> Option<SourceFile>
If there is a source file registered at path, return it.
Else return None.
Sourcepub(crate) fn get_or_create_source_file(&self, url: &Url) -> SourceFile
pub(crate) fn get_or_create_source_file(&self, url: &Url) -> SourceFile
Get or create a source-file at a given path.
Trait Implementations§
Source§impl Database for Compiler
impl Database for Compiler
Source§fn salsa_event(&self, event: &dyn Fn() -> Event)
fn salsa_event(&self, event: &dyn Fn() -> Event)
UserData][] trait.
By default, the event is logged at level debug using tracing facade. Read more§fn trigger_lru_eviction(&mut self)
fn trigger_lru_eviction(&mut self)
§fn synthetic_write(&mut self, durability: Durability)
fn synthetic_write(&mut self, durability: Durability)
durability has changed, triggering a new revision.
This is mostly useful for profiling scenarios. Read more§fn report_untracked_read(&self)
fn report_untracked_read(&self)
§fn ingredient_debug_name(
&self,
ingredient_index: IngredientIndex,
) -> Cow<'_, str>
fn ingredient_debug_name( &self, ingredient_index: IngredientIndex, ) -> Cow<'_, str>
§fn unwind_if_revision_cancelled(&self)
fn unwind_if_revision_cancelled(&self)
Source§impl Db for Compiler
impl Db for Compiler
Source§fn url_display(&self, url: &Url) -> String
fn url_display(&self, url: &Url) -> String
Source§fn root(&self) -> CompilationRoot
fn root(&self) -> CompilationRoot
CompilationRoot], from which all crates and sources can be reached.Source§fn source_file<'db>(
&'db self,
krate: Krate,
modules: &[Identifier<'db>],
) -> SourceFile
fn source_file<'db>( &'db self, krate: Krate, modules: &[Identifier<'db>], ) -> SourceFile
Source§fn debug_tx(&self) -> Option<Sender<DebugEvent>>
fn debug_tx(&self) -> Option<Sender<DebugEvent>>
None is returned, no debugging output is emitted.
If Some is returned, it should supply a directory where .json files will be created.
The dada_debug crate will monitor this directory
and serve up the information for use in debugging.impl Db for Compiler
Auto Trait Implementations§
impl !Freeze for Compiler
impl !RefUnwindSafe for Compiler
impl Send for Compiler
impl !Sync for Compiler
impl Unpin for Compiler
impl UnsafeUnpin for Compiler
impl !UnwindSafe for Compiler
Blanket Implementations§
§impl<T> AsDynDatabase for Twhere
T: Database,
impl<T> AsDynDatabase for Twhere
T: Database,
fn as_dyn_database(&self) -> &(dyn Database + 'static)
fn as_dyn_database_mut(&mut self) -> &mut (dyn Database + 'static)
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more