pub struct Module {Show 13 fields
    pub span: SourceSpan,
    pub name: ModuleId,
    pub ty: ModuleType,
    pub imports: BTreeMap<ModuleId, Import>,
    pub constants: BTreeMap<Identifier, Constant>,
    pub evaluators: BTreeMap<Identifier, EvaluatorFunction>,
    pub functions: BTreeMap<Identifier, Function>,
    pub periodic_columns: BTreeMap<Identifier, PeriodicColumn>,
    pub public_inputs: BTreeMap<Identifier, PublicInput>,
    pub trace_columns: Vec<TraceSegment>,
    pub buses: BTreeMap<Identifier, Bus>,
    pub boundary_constraints: Option<Span<Vec<Statement>>>,
    pub integrity_constraints: Option<Span<Vec<Statement>>>,
}Expand description
This represents the parsed contents of a single AirScript module
When parsing successfully produces a Module, it is guaranteed that:
- Fields which are only allowed in root modules are empty/unset in library modules
 - Fields which must be present in root modules are guaranteed to be present in a root module
 - It is guaranteed that at least one boundary constraint and one integrity constraint are present in a root module
 - No duplicate module-level declarations were present
 - All globally-visible declarations are unique
 
However, most validation is not run at this stage, but rather later when producing a Program. In particular, variable declarations are not checked, and imports are only partially validated here, in that we check for obviously overlapping imports, but cannot fully validate them until later. Likewise we do not validate constraints, look for invalid variable usages, etc.
Fields§
§span: SourceSpan§name: ModuleId§ty: ModuleType§imports: BTreeMap<ModuleId, Import>§constants: BTreeMap<Identifier, Constant>§evaluators: BTreeMap<Identifier, EvaluatorFunction>§functions: BTreeMap<Identifier, Function>§periodic_columns: BTreeMap<Identifier, PeriodicColumn>§public_inputs: BTreeMap<Identifier, PublicInput>§trace_columns: Vec<TraceSegment>§buses: BTreeMap<Identifier, Bus>§boundary_constraints: Option<Span<Vec<Statement>>>§integrity_constraints: Option<Span<Vec<Statement>>>Implementations§
Source§impl Module
 
impl Module
Sourcepub fn new(ty: ModuleType, span: SourceSpan, name: ModuleId) -> Self
 
pub fn new(ty: ModuleType, span: SourceSpan, name: ModuleId) -> Self
Constructs an empty module of the specified type, with the given span and name.
§SAFETY
Similar to Program::new, this function simply constructs an empty Module, and so it does not uphold any guarantees described in it’s documentation. It is up to the caller to guarantee that they construct a valid module that upholds those guarantees, otherwise it is expected that compilation will panic at some point down the line.
Sourcepub fn from_declarations(
    diagnostics: &DiagnosticsHandler,
    ty: ModuleType,
    span: SourceSpan,
    name: Identifier,
    declarations: Vec<Declaration>,
) -> Result<Self, SemanticAnalysisError>
 
pub fn from_declarations( diagnostics: &DiagnosticsHandler, ty: ModuleType, span: SourceSpan, name: Identifier, declarations: Vec<Declaration>, ) -> Result<Self, SemanticAnalysisError>
Constructs a module of the specified type, with the given span and name, using the provided declarations.
The resulting module has had some initial semantic analysis performed as described in the module docs. It is expected that this module will be added to a Library and used to construct a Program before it is considered fully validated.
pub fn is_root(&self) -> bool
pub fn is_library(&self) -> bool
Sourcepub fn exports(&self) -> impl Iterator<Item = Export<'_>> + '_
 
pub fn exports(&self) -> impl Iterator<Item = Export<'_>> + '_
Traverse all of the items exported from this module
Sourcepub fn get(&self, id: &Identifier) -> Option<Export<'_>>
 
pub fn get(&self, id: &Identifier) -> Option<Export<'_>>
Get the export with the given identifier, if it can be found
Trait Implementations§
Source§impl Parse for Module
 
impl Parse for Module
Source§type Error = ParseError
 
type Error = ParseError
Source§type Token = Result<(SourceIndex, Token, SourceIndex), ParseError>
 
type Token = Result<(SourceIndex, Token, SourceIndex), ParseError>
Source§fn root_file_error(source: Error, path: PathBuf) -> Self::Error
 
fn root_file_error(source: Error, path: PathBuf) -> Self::Error
Source§fn parse<S>(
    parser: &Parser,
    diagnostics: &DiagnosticsHandler,
    source: S,
) -> Result<Self, Self::Error>where
    S: Source,
 
fn parse<S>(
    parser: &Parser,
    diagnostics: &DiagnosticsHandler,
    source: S,
) -> Result<Self, Self::Error>where
    S: Source,
Source§fn parse_tokens<S: IntoIterator<Item = Result<(SourceIndex, Token, SourceIndex), ParseError>>>(
    diagnostics: &DiagnosticsHandler,
    codemap: Arc<CodeMap>,
    tokens: S,
) -> Result<Self, Self::Error>
 
fn parse_tokens<S: IntoIterator<Item = Result<(SourceIndex, Token, SourceIndex), ParseError>>>( diagnostics: &DiagnosticsHandler, codemap: Arc<CodeMap>, tokens: S, ) -> Result<Self, Self::Error>
impl Eq for Module
Auto Trait Implementations§
impl Freeze for Module
impl RefUnwindSafe for Module
impl Send for Module
impl Sync for Module
impl Unpin for Module
impl UnwindSafe for Module
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<Q, K> Equivalent<K> for Q
 
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
 
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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