pub struct ParseBook {
pub fun_defs: IndexMap<Name, Definition>,
pub imp_defs: IndexMap<Name, Definition>,
pub hvm_defs: HvmDefinitions,
pub adts: Adts,
pub ctrs: Constructors,
pub import_ctx: ImportCtx,
pub source: Name,
}
Expand description
Intermediate representation of a program.
Fields§
§fun_defs: IndexMap<Name, Definition>
The functional
function definitions.
imp_defs: IndexMap<Name, Definition>
The imperative
function definitions.
hvm_defs: HvmDefinitions
HVM native function definitions.
adts: Adts
The algebraic datatypes defined by the program
ctrs: Constructors
To which type does each constructor belong to.
import_ctx: ImportCtx
Imported packages to be loaded in the program
source: Name
File path that the book was loaded from.
Implementations§
Source§impl ParseBook
impl ParseBook
pub fn contains_def(&self, name: &Name) -> bool
pub fn contains_builtin_def(&self, name: &Name) -> Option<bool>
Source§impl ParseBook
impl ParseBook
Sourcepub fn load_imports(
self,
loader: impl PackageLoader,
diag_config: DiagnosticsConfig,
) -> Result<Book, Diagnostics>
pub fn load_imports( self, loader: impl PackageLoader, diag_config: DiagnosticsConfig, ) -> Result<Book, Diagnostics>
Loads and applies imports recursively to a ParseBook,
transforming definitions and ADTs to a canonical name,
and adding use
binds so that names are accessible by their alias.
§Details
The process involves:
- Loading imports recursively using the provided
loader
. - Transforming definitions and ADTs with naming transformations.
- Adding binds for aliases and old names in their respective definitions.
- Converting the ParseBook into its functional form.
- Perform any necessary post-processing.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ParseBook
impl RefUnwindSafe for ParseBook
impl Send for ParseBook
impl Sync for ParseBook
impl Unpin for ParseBook
impl UnwindSafe for ParseBook
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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 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>
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