pub struct Program {
pub name: Identifier,
pub constants: BTreeMap<QualifiedIdentifier, Constant>,
pub evaluators: BTreeMap<QualifiedIdentifier, EvaluatorFunction>,
pub functions: BTreeMap<QualifiedIdentifier, Function>,
pub buses: BTreeMap<QualifiedIdentifier, Bus>,
pub periodic_columns: BTreeMap<QualifiedIdentifier, PeriodicColumn>,
pub public_inputs: BTreeMap<Identifier, PublicInput>,
pub trace_columns: Vec<TraceSegment>,
pub boundary_constraints: Vec<Statement>,
pub integrity_constraints: Vec<Statement>,
}Expand description
This represents a fully parsed AirScript program, with all imports resolved/parsed/merged.
It has undergone initial semantic analysis, which guarantees that all names are resolved to their definitions. Semantic analysis also runs a variety of validation checks while performing name resolution, including basic type checking, constraint validation, and more.
Additionally, a Program has had most dead code eliminated. Specifically any items which are not referred to from the root module directly or transitively, are not present in the Program structure. Currently, analysis doesn’t check for dead code within functions or constraint blocks, so that is the only area in which dead code may still exist.
Fields§
§name: IdentifierThe name of an AirScript program is the name of its root module.
constants: BTreeMap<QualifiedIdentifier, Constant>The set of used constants referenced in this program.
evaluators: BTreeMap<QualifiedIdentifier, EvaluatorFunction>The set of used evaluator functions referenced in this program.
functions: BTreeMap<QualifiedIdentifier, Function>The set of used pure functions referenced in this program.
buses: BTreeMap<QualifiedIdentifier, Bus>The set of used buses referenced in this program.
periodic_columns: BTreeMap<QualifiedIdentifier, PeriodicColumn>The set of used periodic columns referenced in this program.
public_inputs: BTreeMap<Identifier, PublicInput>The set of public inputs defined in the root module
NOTE: Public inputs are only visible in the root module, so we do not use QualifiedIdentifier as a key into this collection.
trace_columns: Vec<TraceSegment>The set of trace columns of the main trace defined in the root module
boundary_constraints: Vec<Statement>The boundary_constraints block defined in the root module
It is guaranteed that this is non-empty
integrity_constraints: Vec<Statement>The integrity_constraints block in the root module
It is guaranteed that this is non-empty
Implementations§
Source§impl Program
impl Program
Sourcepub fn new(name: Identifier) -> Self
pub fn new(name: Identifier) -> Self
Creates a new, empty Program.
§SAFETY
This function technically violates the guarantees described above in the module docs, however it is useful for testing purposes to allow constructing a valid Program piece-by-piece. It is up to the caller to ensure that they construct a Program that adheres to all of the expected guarantees.
NOTE: It isn’t strictly unsafe in the Rust sense to fail to uphold
the guarantees described above; it will simply cause compilation to
fail unexpectedly with a panic at some point. As a result, this function
isn’t marked unsafe, but should be treated like it is anyway.
Sourcepub fn load(
diagnostics: &DiagnosticsHandler,
root: ModuleId,
library: Library,
) -> Result<Self, SemanticAnalysisError>
pub fn load( diagnostics: &DiagnosticsHandler, root: ModuleId, library: Library, ) -> Result<Self, SemanticAnalysisError>
Load a program from a library of modules, of which one should be a root module.
When called, it is expected that the library has had import resolution performed, and that the library contains a root module.
Trait Implementations§
Source§impl Parse for Program
impl Parse for Program
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 Program
Auto Trait Implementations§
impl Freeze for Program
impl RefUnwindSafe for Program
impl Send for Program
impl Sync for Program
impl Unpin for Program
impl UnwindSafe for Program
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