pub struct Workspace {
pub components: Vec<ComponentDef>,
pub declarations: Vec<ComponentDef>,
pub lib: LibrarySignatures,
pub original_imports: Vec<String>,
pub metadata: Option<String>,
pub source_info_table: Option<SourceInfoTable>,
}
Expand description
A Workspace represents all Calyx files transitively discovered while trying to compile a top-level file.
§Example
When parsing a file foo.futil
:
import "core.futil";
component main() -> () { ... }
The workspace gets the absolute path for core.futil
and adds main
to the set of defined
components. core.futil
is searched both relative to the current file and the library path.
Next core.futil
is parsed:
extern "core.sv" {
primitive std_add[width](left: width, right: width) -> (out: width);
}
The workspace adds std_add
to the currently defined primitives and looks for core.sv
in a
relative path to this file. It does not look for core.sv
on the library path.
Finally, since core.futil
does not import
any file, the parsing process is completed.
Fields§
§components: Vec<ComponentDef>
List of component definitions that need to be compiled.
declarations: Vec<ComponentDef>
List of component definitions that should be used as declarations and not compiled. This is used when the compiler is invoked with File compilation mode.
lib: LibrarySignatures
Absolute path to extern definitions and primitives defined by them.
original_imports: Vec<String>
Original import statements present in the top-level file.
metadata: Option<String>
Optional opaque metadata attached to the top-level file.
source_info_table: Option<SourceInfoTable>
Optional source info table attached to the top-level file
Implementations§
Source§impl Workspace
impl Workspace
Sourcepub fn from_compile_lib() -> CalyxResult<Self>
pub fn from_compile_lib() -> CalyxResult<Self>
Construct a new workspace using the compile.futil
library which
contains the core primitives needed for compilation.
Sourcepub fn construct(file: &Option<PathBuf>, lib_path: &Path) -> CalyxResult<Self>
pub fn construct(file: &Option<PathBuf>, lib_path: &Path) -> CalyxResult<Self>
Construct a new workspace from an input stream representing a Calyx program.
Sourcepub fn construct_shallow(
file: &Option<PathBuf>,
lib_path: &Path,
) -> CalyxResult<Self>
pub fn construct_shallow( file: &Option<PathBuf>, lib_path: &Path, ) -> CalyxResult<Self>
Construct the Workspace using the given NamespaceDef and ignore all imported dependencies.
Sourcepub fn merge_namespace(
&mut self,
ns: NamespaceDef,
is_source: bool,
parent: &Path,
shallow: bool,
lib_path: &Path,
) -> CalyxResult<Vec<(PathBuf, bool)>>
pub fn merge_namespace( &mut self, ns: NamespaceDef, is_source: bool, parent: &Path, shallow: bool, lib_path: &Path, ) -> CalyxResult<Vec<(PathBuf, bool)>>
Merge the contents of a namespace into this workspace.
is_source
identifies this namespace as a source file.
The output is a list of files that need to be parsed next and whether they are source files.
Sourcepub fn construct_with_all_deps<const SHALLOW: bool>(
files: Vec<PathBuf>,
lib_path: &Path,
) -> CalyxResult<Self>
pub fn construct_with_all_deps<const SHALLOW: bool>( files: Vec<PathBuf>, lib_path: &Path, ) -> CalyxResult<Self>
Construct the Workspace using the given files and all their dependencies. If SHALLOW is true, then parse imported components as declarations and not added to the workspace components. If in doubt, set SHALLOW to false.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Workspace
impl RefUnwindSafe for Workspace
impl Send for Workspace
impl Sync for Workspace
impl Unpin for Workspace
impl UnwindSafe for Workspace
Blanket Implementations§
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> 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