Struct calyx_frontend::Workspace
source · pub struct Workspace {
pub components: Vec<ComponentDef>,
pub declarations: Vec<ComponentDef>,
pub externs: LinkedHashMap<Option<PathBuf>, Vec<Primitive>>,
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.
externs: LinkedHashMap<Option<PathBuf>, Vec<Primitive>>
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§
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.