pub struct StructureAnalysis { /* private fields */ }
Expand description
This module is responsible for control flow analysis.
Implementations§
Source§impl StructureAnalysis
impl StructureAnalysis
Sourcepub fn new(debug_mode: bool, structure_max_iterations: usize) -> Self
pub fn new(debug_mode: bool, structure_max_iterations: usize) -> Self
Creates a new StructureAnalysis
instance.
Sourcepub fn add_region(&mut self, region_type: RegionType) -> RegionId
pub fn add_region(&mut self, region_type: RegionType) -> RegionId
Adds a new region to the control flow graph.
Sourcepub fn connect_regions(
&mut self,
from: RegionId,
to: RegionId,
edge_type: ControlFlowEdgeType,
) -> Result<(), StructureAnalysisError>
pub fn connect_regions( &mut self, from: RegionId, to: RegionId, edge_type: ControlFlowEdgeType, ) -> Result<(), StructureAnalysisError>
Connect two regions in the control flow graph.
Sourcepub fn get_region(
&self,
region_id: RegionId,
) -> Result<&Region, StructureAnalysisError>
pub fn get_region( &self, region_id: RegionId, ) -> Result<&Region, StructureAnalysisError>
Gets a region by its ID.
Sourcepub fn get_region_mut(
&mut self,
region_id: RegionId,
) -> Result<&mut Region, StructureAnalysisError>
pub fn get_region_mut( &mut self, region_id: RegionId, ) -> Result<&mut Region, StructureAnalysisError>
Gets a mutable region by its ID.
Sourcepub fn get_entry_region(&self) -> RegionId
pub fn get_entry_region(&self) -> RegionId
Gets the entry region id
Sourcepub fn get_node_index(
&self,
region_id: RegionId,
) -> Result<NodeIndex, StructureAnalysisError>
pub fn get_node_index( &self, region_id: RegionId, ) -> Result<NodeIndex, StructureAnalysisError>
Gets the node index of a region.
Sourcepub fn get_region_type(
&self,
region_id: RegionId,
) -> Result<RegionType, StructureAnalysisError>
pub fn get_region_type( &self, region_id: RegionId, ) -> Result<RegionType, StructureAnalysisError>
Gets the region type of a region ID.
Sourcepub fn get_branch_opcode(
&self,
region_id: RegionId,
) -> Result<Option<Opcode>, StructureAnalysisError>
pub fn get_branch_opcode( &self, region_id: RegionId, ) -> Result<Option<Opcode>, StructureAnalysisError>
Gets the opcode of a region ID.
Sourcepub fn get_region_id(
&self,
node_index: NodeIndex,
) -> Result<RegionId, StructureAnalysisError>
pub fn get_region_id( &self, node_index: NodeIndex, ) -> Result<RegionId, StructureAnalysisError>
Gets the region ID of a node index.
Sourcepub fn execute(&mut self) -> Result<(), StructureAnalysisError>
pub fn execute(&mut self) -> Result<(), StructureAnalysisError>
Executes the control flow analysis.
Sourcepub fn push_to_region<T>(&mut self, region_id: RegionId, node: T)
pub fn push_to_region<T>(&mut self, region_id: RegionId, node: T)
Push a node to a region.
Sourcepub fn push_unresolved_to_region(&mut self, region_id: RegionId, node: AstKind)
pub fn push_unresolved_to_region(&mut self, region_id: RegionId, node: AstKind)
Push an unresolved node to a region.
Sourcepub fn get_single_successor(
&self,
region_id: RegionId,
) -> Result<Option<RegionId>, StructureAnalysisError>
pub fn get_single_successor( &self, region_id: RegionId, ) -> Result<Option<RegionId>, StructureAnalysisError>
Sourcepub fn get_single_predecessor(
&self,
region_id: RegionId,
) -> Result<Option<RegionId>, StructureAnalysisError>
pub fn get_single_predecessor( &self, region_id: RegionId, ) -> Result<Option<RegionId>, StructureAnalysisError>
Sourcepub fn is_back_edge(
&self,
region: RegionId,
successor: RegionId,
) -> Result<bool, StructureAnalysisError>
pub fn is_back_edge( &self, region: RegionId, successor: RegionId, ) -> Result<bool, StructureAnalysisError>
If a node is a back edge. Basically calls dominates_strictly
with the arguments reversed.
§Arguments
region
: The region ID of the source region.successor
: The region ID of the destination region.
§Returns
true
if the edge is a back edge,false
otherwise.Err(StructureAnalysisError)
if an error occurred.
Sourcepub fn dominates_strictly(
&self,
dominator: RegionId,
dominatee: RegionId,
) -> Result<bool, StructureAnalysisError>
pub fn dominates_strictly( &self, dominator: RegionId, dominatee: RegionId, ) -> Result<bool, StructureAnalysisError>
Sourcepub fn get_single_linear_successor(
&self,
region_id: RegionId,
) -> Result<Option<RegionId>, StructureAnalysisError>
pub fn get_single_linear_successor( &self, region_id: RegionId, ) -> Result<Option<RegionId>, StructureAnalysisError>
Sourcepub fn has_single_predecessor(
&self,
id: RegionId,
) -> Result<bool, StructureAnalysisError>
pub fn has_single_predecessor( &self, id: RegionId, ) -> Result<bool, StructureAnalysisError>
Sourcepub fn remove_edge(
&mut self,
from_region_id: RegionId,
to_region_id: RegionId,
) -> Result<(), StructureAnalysisError>
pub fn remove_edge( &mut self, from_region_id: RegionId, to_region_id: RegionId, ) -> Result<(), StructureAnalysisError>
Sourcepub fn get_successors(
&self,
region_id: RegionId,
) -> Result<Vec<(RegionId, ControlFlowEdgeType)>, StructureAnalysisError>
pub fn get_successors( &self, region_id: RegionId, ) -> Result<Vec<(RegionId, ControlFlowEdgeType)>, StructureAnalysisError>
Sourcepub fn get_predecessors(
&self,
region_id: RegionId,
) -> Result<Vec<RegionId>, StructureAnalysisError>
pub fn get_predecessors( &self, region_id: RegionId, ) -> Result<Vec<RegionId>, StructureAnalysisError>
Sourcepub fn remove_node(
&mut self,
region_id: RegionId,
) -> Result<(), StructureAnalysisError>
pub fn remove_node( &mut self, region_id: RegionId, ) -> Result<(), StructureAnalysisError>
Sourcepub fn get_snapshots(&self) -> Result<&Vec<String>, StructureAnalysisError>
pub fn get_snapshots(&self) -> Result<&Vec<String>, StructureAnalysisError>
Gets the debug snapshots, where each snapshot is a Graphviz representation of the CFG.
Sourcepub fn before_reduce(&mut self, region_id: RegionId)
pub fn before_reduce(&mut self, region_id: RegionId)
This function should always be called before reducing a region.
Sourcepub fn after_reduce(&mut self, region_id: RegionId)
pub fn after_reduce(&mut self, region_id: RegionId)
This function should always be called after reducing a region.
Sourcepub fn capture_snapshot(&mut self, region_to_highlight: Option<RegionId>)
pub fn capture_snapshot(&mut self, region_to_highlight: Option<RegionId>)
Capture a snapshot of the CFG.
Sourcepub fn capture_region_snapshot(&mut self, region_to_highlight: RegionId)
pub fn capture_region_snapshot(&mut self, region_to_highlight: RegionId)
Capture a snapshot of the CFG.
§Arguments
region_to_highlight
: The region to highlight in the snapshot (e.g. region being manipulated)