Struct calyx_frontend::Workspace
source · [−]pub struct Workspace {
pub components: Vec<ComponentDef>,
pub declarations: Vec<ComponentDef>,
pub lib: LibrarySignatures,
pub original_imports: Vec<String>,
pub metadata: Option<String>,
}
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
Implementations
sourceimpl 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.