Struct dialectic_compiler::cfg::Cfg [−][src]
A cfg of CFG nodes acting as a context for a single compilation unit.
Implementations
impl Cfg
[src]
pub fn new() -> Self
[src]
Construct an empty control flow graph.
pub fn insert(&mut self, node: CfgNode) -> Index
[src]
Insert a constructed CfgNode
into the CFG, and get back its newly minted index.
pub fn insert_error_at(&mut self, node: Index, kind: CompileError)
[src]
Insert an Error
node as a shim.
pub fn create_error(&mut self, kind: CompileError, span: Span) -> Index
[src]
Create a dummy Error
node, as a stand-in for a node which should have been generated but
for some reason cannot be.
pub fn singleton(&mut self, expr: Ir) -> Index
[src]
Create a new node containing only this expression with no next-node link.
pub fn spanned(&mut self, expr: Ir, span: Span) -> Index
[src]
Create a new node w/ an assigned span containing only this expression with no next-node link.
pub fn resolve_scopes(&mut self, node: Option<Index>)
[src]
The purpose of the scope resolution pass is to transform “implicit” continuations into
“explicit” continuations. For example, consider the session type choose { ... }; send ()
.
In this type, the first parsing of the block will result in a Choose
node with its
continuation/“next” pointer set to point to a Send(())
node. However, in order to ensure
that the arms of the choose construct don’t have to worry about the continuation that comes
“after” in a higher/parent scope, we have the resolve_scopes pass to “lower” this
continuation which implicitly follows every arm of the Choose
, into becoming the
continuation of every relevant arm of the Choose
. This does have some special cases, for
example we don’t want to change or set a next continuation for a Break
node or Continue
node.
pub fn report_dead_code(&mut self, node: Option<Index>)
[src]
Attach errors to all dead code and code that leads to dead code, based on an internal call to the flow analysis and reachability analysis on the graph.
pub fn generate_target(
&mut self,
node: Option<Index>
) -> Result<Spanned<Target>, Error>
[src]
&mut self,
node: Option<Index>
) -> Result<Spanned<Target>, Error>
Traverse a Cfg
rooted at the specified index to produce either a valid Target
corresponding to it, or a syn::Error
corresponding to one or more compiler errors.
Important: This function must be called after the scope resolution pass, or else the resultant code may omit sections of the input control flow graph due to implicit continuations which have not yet been resolved.
pub fn iter(&self) -> impl Iterator<Item = (Index, &CfgNode)> + '_
[src]
Iterate over all nodes in the CFG. The order is not defined.
Trait Implementations
impl Debug for Cfg
[src]
impl Default for Cfg
[src]
impl Index<Index> for Cfg
[src]
type Output = CfgNode
The returned type after indexing.
fn index(&self, index: Index) -> &Self::Output
[src]
impl IndexMut<Index> for Cfg
[src]
Auto Trait Implementations
impl RefUnwindSafe for Cfg
impl !Send for Cfg
impl !Sync for Cfg
impl Unpin for Cfg
impl UnwindSafe for Cfg
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,