pub struct Cfg { /* private fields */ }
Expand description
A cfg of CFG nodes acting as a context for a single compilation unit.
Implementations§
Source§impl Cfg
impl Cfg
Sourcepub fn insert(&mut self, node: CfgNode) -> Index
pub fn insert(&mut self, node: CfgNode) -> Index
Insert a constructed CfgNode
into the CFG, and get back its newly minted index.
Sourcepub fn insert_error_at(&mut self, node: Index, kind: CompileError)
pub fn insert_error_at(&mut self, node: Index, kind: CompileError)
Insert an Error
node as a shim.
Sourcepub fn create_error(&mut self, kind: CompileError, span: Span) -> Index
pub fn create_error(&mut self, kind: CompileError, span: Span) -> Index
Create a dummy Error
node, as a stand-in for a node which should have been generated but
for some reason cannot be.
Sourcepub fn singleton(&mut self, expr: Ir) -> Index
pub fn singleton(&mut self, expr: Ir) -> Index
Create a new node containing only this expression with no next-node link.
Sourcepub fn spanned(&mut self, expr: Ir, span: Span) -> Index
pub fn spanned(&mut self, expr: Ir, span: Span) -> Index
Create a new node w/ an assigned span containing only this expression with no next-node link.
Sourcepub fn resolve_scopes(&mut self, node: Option<Index>)
pub fn resolve_scopes(&mut self, node: Option<Index>)
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.
Sourcepub fn report_dead_code(&mut self, node: Option<Index>)
pub fn report_dead_code(&mut self, node: Option<Index>)
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.
Sourcepub fn generate_target(
&mut self,
node: Option<Index>,
) -> Result<Spanned<Target>, Error>
pub fn generate_target( &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.