pub struct DominatedGraph<'tcx> {
pub tcx: TyCtxt<'tcx>,
pub def_id: DefId,
pub local_len: usize,
pub variables: HashMap<usize, VariableNode<'tcx>>,
}Expand description
A dominated graph.
Fields§
§tcx: TyCtxt<'tcx>The type context.
def_id: DefIdThe definition ID of the function.
local_len: usizeThe number of local variables.
variables: HashMap<usize, VariableNode<'tcx>>The variables in the graph. Map from local variable index to VariableNode.
Implementations§
Source§impl<'tcx> DominatedGraph<'tcx>
impl<'tcx> DominatedGraph<'tcx>
pub fn new(tcx: TyCtxt<'tcx>, def_id: DefId) -> Self
Sourcepub fn init_self_with_inter(&mut self, inter_result: InterResultNode<'tcx>)
pub fn init_self_with_inter(&mut self, inter_result: InterResultNode<'tcx>)
Initialize the self node with an intermediate result.
Sourcepub fn dfs_insert_inter_results(
&mut self,
inter_result: InterResultNode<'tcx>,
local: usize,
)
pub fn dfs_insert_inter_results( &mut self, inter_result: InterResultNode<'tcx>, local: usize, )
Insert intermediate results into the graph.
Sourcefn insert_cis_for_arg(&mut self, local: usize, contract: PropertyContract<'tcx>)
fn insert_cis_for_arg(&mut self, local: usize, contract: PropertyContract<'tcx>)
Insert a contract into the CIS of an argument.
Sourcepub fn generate_ptr_with_obj_node(
&mut self,
local_ty: Ty<'tcx>,
idx: usize,
) -> usize
pub fn generate_ptr_with_obj_node( &mut self, local_ty: Ty<'tcx>, idx: usize, ) -> usize
When generate obj node, this function will add InBound Sp automatically.
Sourcefn add_bound_for_obj(&mut self, new_id: usize, local_ty: Ty<'tcx>)
fn add_bound_for_obj(&mut self, new_id: usize, local_ty: Ty<'tcx>)
Add a bound for an object node.
Sourcepub fn check_ptr(&mut self, arg: usize) -> usize
pub fn check_ptr(&mut self, arg: usize) -> usize
if current node is ptr or ref, then return the new node pointed by it.
Sourcepub fn get_local_ty_by_place(&self, arg: usize) -> Option<Ty<'tcx>>
pub fn get_local_ty_by_place(&self, arg: usize) -> Option<Ty<'tcx>>
Get the type of a local variable by its place.
Sourcepub fn get_obj_ty_through_chain(&self, arg: usize) -> Option<Ty<'tcx>>
pub fn get_obj_ty_through_chain(&self, arg: usize) -> Option<Ty<'tcx>>
Get the type of an object through a chain of pointers.
Sourcepub fn get_point_to_id(&self, arg: usize) -> usize
pub fn get_point_to_id(&self, arg: usize) -> usize
Get the ID of the node pointed to by a pointer or reference.
Source§impl<'tcx> DominatedGraph<'tcx>
impl<'tcx> DominatedGraph<'tcx>
pub fn generate_node_id(&self) -> usize
pub fn get_field_node_id( &mut self, local: usize, field_idx: usize, ty: Option<Ty<'tcx>>, ) -> usize
pub fn insert_field_node( &mut self, local: usize, field_idx: usize, ty: Option<Ty<'tcx>>, ) -> usize
Sourcepub fn find_var_id_with_fields_seq(
&mut self,
local: usize,
fields: &Vec<usize>,
) -> usize
pub fn find_var_id_with_fields_seq( &mut self, local: usize, fields: &Vec<usize>, ) -> usize
Find the variable ID in DG corresponding to a sequence of fields.
Sourcepub fn point(&mut self, lv: usize, rv: usize)
pub fn point(&mut self, lv: usize, rv: usize)
Establishes a points-to relationship: lv -> rv.
- Updates graph topology.
- If
lvis a Reference type, marks it as Aligned (Trusted Source).
Sourcepub fn get_var_nod_id(&self, local_id: usize) -> usize
pub fn get_var_nod_id(&self, local_id: usize) -> usize
Get the ID of a variable node.
Sourcepub fn get_map_idx_node(&self, local_id: usize) -> &VariableNode<'tcx>
pub fn get_map_idx_node(&self, local_id: usize) -> &VariableNode<'tcx>
Get a variable node by its local ID.
Sourcepub fn get_var_node(&self, local_id: usize) -> Option<&VariableNode<'tcx>>
pub fn get_var_node(&self, local_id: usize) -> Option<&VariableNode<'tcx>>
Get a variable node by its local ID.
Sourcepub fn get_var_node_mut(
&mut self,
local_id: usize,
) -> Option<&mut VariableNode<'tcx>>
pub fn get_var_node_mut( &mut self, local_id: usize, ) -> Option<&mut VariableNode<'tcx>>
Get a mutable reference to a variable node by its local ID.
pub fn merge(&mut self, lv: usize, rv: usize)
pub fn copy_node(&mut self, lv: usize, rv: usize)
Sourcefn break_node_connection(&mut self, lv: usize, rv: usize)
fn break_node_connection(&mut self, lv: usize, rv: usize)
Break the connection between two nodes.
Sourcefn init_self_node(
&mut self,
self_id: usize,
ty: Option<Ty<'tcx>>,
state: States<'tcx>,
)
fn init_self_node( &mut self, self_id: usize, ty: Option<Ty<'tcx>>, state: States<'tcx>, )
Initialize the self node with an intermediate result.
Sourcefn insert_node(
&mut self,
dv: usize,
ty: Option<Ty<'tcx>>,
parent_id: usize,
child_id: Option<usize>,
state: States<'tcx>,
)
fn insert_node( &mut self, dv: usize, ty: Option<Ty<'tcx>>, parent_id: usize, child_id: Option<usize>, state: States<'tcx>, )
Insert intermediate results into the graph.
Sourcefn delete_node(&mut self, idx: usize)
fn delete_node(&mut self, idx: usize)
Delete a node from the graph.
Sourcepub fn update_value(&mut self, arg: usize, value: usize)
pub fn update_value(&mut self, arg: usize, value: usize)
Update the constant value of a node.
Sourcepub fn insert_patial_op(&mut self, p1: usize, p2: usize, op: &BinOp)
pub fn insert_patial_op(&mut self, p1: usize, p2: usize, op: &BinOp)
Insert a partial order constraint between two nodes.
Source§impl<'tcx> DominatedGraph<'tcx>
Debug implementation for DominatedGraph.
impl<'tcx> DominatedGraph<'tcx>
Debug implementation for DominatedGraph.
Sourcepub fn to_dot_graph(&self) -> String
pub fn to_dot_graph(&self) -> String
Generate a DOT graph representation of the dominated graph.
Sourcefn generate_node_label(&self, node: &VariableNode<'tcx>) -> String
fn generate_node_label(&self, node: &VariableNode<'tcx>) -> String
Generate a label for a node in the DOT graph.
Sourcepub fn display_dominated_graph(&self)
pub fn display_dominated_graph(&self)
Debug helper: Visualize the graph structure and states in a table format
fn safe_truncate_str(&self, s: &str, max_width: usize) -> String
Source§impl<'tcx> DominatedGraph<'tcx>
impl<'tcx> DominatedGraph<'tcx>
Sourcepub fn update_from_offset_def(
&mut self,
target_local: usize,
base_local: usize,
offset_def: SymbolicDef<'tcx>,
)
pub fn update_from_offset_def( &mut self, target_local: usize, base_local: usize, offset_def: SymbolicDef<'tcx>, )
Public method called by BodyVisitor to update graph topology when a PtrOffset definition is applied.
Trait Implementations§
Source§impl<'tcx> Clone for DominatedGraph<'tcx>
impl<'tcx> Clone for DominatedGraph<'tcx>
Source§fn clone(&self) -> DominatedGraph<'tcx>
fn clone(&self) -> DominatedGraph<'tcx>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more