pub struct FlatGraphBuilder { /* private fields */ }Expand description
Wraper around DfirGraph to build a flat graph from AST code.
Implementations§
Source§impl FlatGraphBuilder
impl FlatGraphBuilder
Sourcepub fn build(self) -> Result<FlatGraphBuilderOutput, Diagnostics>
pub fn build(self) -> Result<FlatGraphBuilderOutput, Diagnostics>
Build into an unpartitioned DfirGraph, returning a struct containing the flat graph, any diagnostics, and
other outputs.
If any diagnostics are errors, Err is returned and the underlying graph is lost.
Sourcepub fn add_dfir(
&mut self,
dfir: DfirCode,
current_loop: Option<GraphLoopId>,
operator_tag: Option<&str>,
)
pub fn add_dfir( &mut self, dfir: DfirCode, current_loop: Option<GraphLoopId>, operator_tag: Option<&str>, )
Adds all DfirStatements within the DfirCode to this DfirGraph.
Optional configuration:
- In the given loop context
current_loop. - With the given operator tag
operator_tag.
Sourcepub fn add_statement(&mut self, stmt: DfirStatement)
pub fn add_statement(&mut self, stmt: DfirStatement)
Add a single DfirStatement line to this DfirGraph in the root context.
Sourcepub fn insert_loop(&mut self, parent_loop: Option<GraphLoopId>) -> GraphLoopId
pub fn insert_loop(&mut self, parent_loop: Option<GraphLoopId>) -> GraphLoopId
Programmatically create a new loop { ... } context, with the given parent loop context
(or None for a root-level loop).
The returned GraphLoopId can be passed as the current_loop argument of
Self::add_dfir / Self::append_assign_pipeline to place statements inside the loop,
§Panics
Panics if parent_loop is a loop not belonging to this instance.
across multiple calls. This is the programmatic equivalent of a
DfirStatement::Loop block in the surface syntax, but allows the loop body to be built
up incrementally.
Sourcepub fn append_assign_pipeline(
&mut self,
asgn_name: Option<&Ident>,
pred_name: Option<&Ident>,
pipeline: Pipeline,
current_loop: Option<GraphLoopId>,
operator_tag: Option<&str>,
)
pub fn append_assign_pipeline( &mut self, asgn_name: Option<&Ident>, pred_name: Option<&Ident>, pipeline: Pipeline, current_loop: Option<GraphLoopId>, operator_tag: Option<&str>, )
Programatically add an pipeline, optionally adding pred_name as a single predecessor and
assigning it all to asgn_name.
In DFIR syntax, equivalent to Self::add_statement of (if all names are supplied):
#asgn_name = #pred_name -> #pipeline;But with, optionally:
- A
current_loopto put the operator in. - An
operator_tagto tag the operator with, for debugging/tracing.
Trait Implementations§
Source§impl Debug for FlatGraphBuilder
impl Debug for FlatGraphBuilder
Source§impl Default for FlatGraphBuilder
impl Default for FlatGraphBuilder
Source§fn default() -> FlatGraphBuilder
fn default() -> FlatGraphBuilder
Auto Trait Implementations§
impl !RefUnwindSafe for FlatGraphBuilder
impl !Send for FlatGraphBuilder
impl !Sync for FlatGraphBuilder
impl !UnwindSafe for FlatGraphBuilder
impl Freeze for FlatGraphBuilder
impl Unpin for FlatGraphBuilder
impl UnsafeUnpin for FlatGraphBuilder
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<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