Skip to content

Commit

Permalink
Format
Browse files Browse the repository at this point in the history
  • Loading branch information
JustusAdam committed Aug 11, 2023
1 parent 3845017 commit bf0a444
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 34 deletions.
5 changes: 2 additions & 3 deletions explorer/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ impl std::str::FromStr for PathMetric {
}

/// Unique name of a node that also lets us recover a [`dfpp::ir::GlobalLocation`].
///
///
/// Must be fully expanded basic block nodename, e.g. `bb39[2]@bb58[5]@bb0[4]`. You can find this in the
/// comments in analysis_result.frg.
#[derive(Eq, Ord, PartialEq, PartialOrd, Clone, Debug, Hash)]
Expand Down Expand Up @@ -280,7 +280,6 @@ impl std::str::FromStr for Direction {
}
}


#[derive(Debug)]
pub enum RunCommandErr<'g> {
NodeNotFound(NodeName),
Expand Down Expand Up @@ -334,4 +333,4 @@ impl<'g> std::fmt::Display for RunCommandErr<'g> {
}
}
}
}
}
10 changes: 4 additions & 6 deletions explorer/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,15 @@
//! which can change the behavior of a graph witout copies.

use dfpp::{
ir::GlobalLocation,
ana::inline::{Edge, EdgeType},
ir::GlobalLocation,
};

use petgraph::visit::{
Data, EdgeRef, GraphBase, GraphRef, IntoEdgeReferences, IntoEdges, IntoEdgesDirected,
IntoNeighbors, IntoNeighborsDirected, IntoNodeIdentifiers, NodeCount, NodeIndexable, Visitable,
};



/// The canonical representation fo a graph used by the explorer.
pub type Graph<'g> = petgraph::graphmap::GraphMap<Node<'g>, Edge, petgraph::Directed>;

Expand Down Expand Up @@ -149,7 +147,7 @@ impl<'f, G: IntoNodeIdentifiers + IntoEdgeReferences> IntoNodeIdentifiers
#[derive(Clone, Copy)]
pub struct IgnoreCtrlEdges<G>(G);

impl<G> From<G> for IgnoreCtrlEdges<G>{
impl<G> From<G> for IgnoreCtrlEdges<G> {
fn from(value: G) -> Self {
Self(value)
}
Expand Down Expand Up @@ -232,7 +230,7 @@ impl<E: EdgeRef<Weight = Edge>, I: Iterator<Item = E>> std::iter::Iterator

/// One of the iterators for [`IgnoreCtrlEdges`] that are needed to run the
/// algorithms in [`petgraph`].
///
///
/// This is confusingly named I know, but the actual graph is
/// [`IgnoreCtrlEdges`], wheras this is an iterator over edges with control
/// edges ignored.
Expand Down Expand Up @@ -326,4 +324,4 @@ impl<G: NodeIndexable> NodeIndexable for IgnoreCtrlEdges<G> {
fn to_index(&self, a: Self::NodeId) -> usize {
self.0.to_index(a)
}
}
}
11 changes: 3 additions & 8 deletions explorer/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,15 @@ extern crate serde_lexpr as sexpr;

use clap::Parser;

use dfpp::{
ir::global_location::*,
serializers::Bodies,
Either, HashMap,
};
use dfpp::{ir::global_location::*, serializers::Bodies, Either, HashMap};
use ringbuffer::RingBufferWrite;

mod graph;
mod command;
mod graph;
mod run;

use graph::*;
use command::*;

use graph::*;

/// Command line arguments for the explorer.
#[derive(Parser)]
Expand Down
22 changes: 5 additions & 17 deletions explorer/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,13 @@ use dfpp::{
Either, HashMap,
};

use petgraph::visit::{
EdgeRef, IntoEdgesDirected,
};
use petgraph::visit::{EdgeRef, IntoEdgesDirected};

use crate::graph::*;
use crate::command::*;
use crate::graph::*;

use crate::Repl;



impl<'g> Repl<'g> {
fn translate_node(&self, name: NodeName) -> Result<Node<'g>, RunCommandErr<'g>> {
let map = self
Expand Down Expand Up @@ -113,10 +109,7 @@ impl<'g> Repl<'g> {
Ok(Box::new(
[{
let paths = petgraph::algo::bellman_ford(
&WithWeightedEdges::new(
graph,
&|_| 1.0,
),
&WithWeightedEdges::new(graph, &|_| 1.0),
from,
)
.unwrap();
Expand All @@ -135,10 +128,7 @@ impl<'g> Repl<'g> {
Ok(Box::new(
[{
let paths = petgraph::algo::bellman_ford(
&WithWeightedEdges::new(
graph,
&|_| 1.0,
),
&WithWeightedEdges::new(graph, &|_| 1.0),
from,
)
.unwrap();
Expand Down Expand Up @@ -544,6 +534,4 @@ impl<'g> Repl<'g> {
self.graph = Some(g);
Ok(())
}


}
}

0 comments on commit bf0a444

Please sign in to comment.