calyx_frontend

Struct 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>,
    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

Source

pub fn from_compile_lib() -> CalyxResult<Self>

Construct a new workspace using the compile.futil library which contains the core primitives needed for compilation.

Source

pub fn construct(file: &Option<PathBuf>, lib_path: &Path) -> CalyxResult<Self>

Construct a new workspace from an input stream representing a Calyx program.

Source

pub fn construct_shallow( file: &Option<PathBuf>, lib_path: &Path, ) -> CalyxResult<Self>

Construct the Workspace using the given NamespaceDef and ignore all imported dependencies.

Source

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.

Source

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§

Source§

impl Default for Workspace

Source§

fn default() -> Workspace

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.