Skip to content

Commit

Permalink
fix: merge conflict resolutions
Browse files Browse the repository at this point in the history
  • Loading branch information
plotchy committed Jun 26, 2024
1 parent d82e21a commit 79fc49f
Show file tree
Hide file tree
Showing 6 changed files with 119 additions and 185 deletions.
10 changes: 8 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

55 changes: 31 additions & 24 deletions crates/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use graph::{
};
use pyrometer::{Analyzer, Root, SourcePath};
use reqwest::Client;
use shared::Search;
use shared::{post_to_site, Search};
use shared::{GraphDot, USE_DEBUG_SITE};

use ariadne::sources;
Expand Down Expand Up @@ -235,27 +235,7 @@ fn main() {
},
};

if args.debug_site {
unsafe {
USE_DEBUG_SITE = true;
}

let rt = Runtime::new().unwrap();
rt.block_on(async {
let client = Client::new();
let res = client
.post("http://127.0.0.1:8545/clear")
.send()
.await
.expect("Failed to send request");

if res.status().is_success() {
trace!("Successfully cleared history of site");
} else {
error!("Failed to clear history of site: {:?}", res.status());
}
});
}

let mut analyzer = Analyzer {
max_depth: args.max_stack_depth,
Expand Down Expand Up @@ -288,6 +268,30 @@ fn main() {

let mut arena_base = Default::default();
let arena = &mut arena_base;

if args.debug_site {
unsafe {
USE_DEBUG_SITE = true;
}

let rt = Runtime::new().unwrap();
rt.block_on(async {
let client = Client::new();
let res = client
.post("http://127.0.0.1:8545/clear")
.send()
.await
.expect("Failed to send request");

if res.status().is_success() {
trace!("Successfully cleared history of site");
} else {
error!("Failed to clear history of site: {:?}", res.status());
}
});
post_to_site(&analyzer, arena);
}

let t0 = std::time::Instant::now();
let maybe_entry = analyzer.parse(arena, &sol, &current_path, true);
let t_end = t0.elapsed();
Expand All @@ -297,20 +301,23 @@ fn main() {

// println!("Arena: {:#?}", analyzer.range_arena);
if unsafe { USE_DEBUG_SITE } {
use shared::GraphLike;
use pyrometer::graph_backend::mermaid_str;
use pyrometer::graph_backend::post_to_site_arena;
use pyrometer::graph_backend::Elems;
match Elems::try_from(analyzer.range_arena()) {
let elems = Elems::try_from(&*arena);
match elems {
Ok(elems) => {
let elems_graph = elems.to_graph(&analyzer);
let elems_graph = elems.to_graph(&analyzer, arena);
let elems_graph_mermaid_str = mermaid_str(&elems_graph);
post_to_site_arena(elems_graph_mermaid_str);
}
Err(e) => {
eprintln!("Can't post arena, error creating Elems: {:?}", e);
}
};

// post the graph to the site
post_to_site(&analyzer, arena);
}

if args.stats {
Expand Down
48 changes: 39 additions & 9 deletions crates/graph/src/graph_elements.rs
Original file line number Diff line number Diff line change
Expand Up @@ -402,9 +402,7 @@ pub enum ContextEdge {
}

#[derive(Default)]
pub(crate) struct DummyGraph {
pub range_arena: RangeArena<Elem<Concrete>>,
}
pub(crate) struct DummyGraph {}

impl GraphLike for DummyGraph {
type Node = Node;
Expand All @@ -417,12 +415,44 @@ impl GraphLike for DummyGraph {
fn graph(&self) -> &Graph<Node, Edge, Directed, usize> {
panic!("Dummy Graph")
}
fn range_arena(&self) -> &RangeArena<Elem<Concrete>> {
&self.range_arena
}
fn range_arena_mut(&mut self) -> &mut RangeArena<Elem<Concrete>> {
&mut self.range_arena
}
}

impl GraphBackend for DummyGraph {}
impl GraphDot for DummyGraph {
type T = Elem<Concrete>;

fn dot_str(&self, _arena: &mut RangeArena<<Self as GraphDot>::T>) -> String {
// Provide a basic implementation or a placeholder
"digraph DummyGraph {}".to_string()
}

fn cluster_str(
&self,
_arena: &mut RangeArena<Self::T>,
_node: NodeIdx,
_cluster_num: &mut usize,
_is_killed: bool,
_handled_nodes: std::sync::Arc<std::sync::Mutex<std::collections::BTreeSet<NodeIdx>>>,
_handled_edges: std::sync::Arc<std::sync::Mutex<std::collections::BTreeSet<petgraph::prelude::EdgeIndex<usize>>>>,
_depth: usize,
_as_mermaid: bool,
) -> Option<String>
where
Self: std::marker::Sized {
todo!()
}

fn dot_str_no_tmps(&self, _arena: &mut RangeArena<Self::T>) -> String
where
Self: std::marker::Sized,
{
todo!()
}

fn mermaid_str(&self, _arena: &mut RangeArena<Self::T>) -> String
where
Self: std::marker::Sized,
{
todo!()
}
}
3 changes: 1 addition & 2 deletions crates/pyrometer/src/analyzer_backend.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use crate::Analyzer;
use shared::GraphDot;
use graph::{
elem::Elem,
nodes::{
Expand All @@ -18,7 +17,7 @@ use solang_parser::{
pt::{Expression, Loc},
};

use std::{collections::BTreeMap, path::PathBuf};
use std::collections::BTreeMap;

impl AnalyzerBackend for Analyzer {
fn add_concrete_var(
Expand Down
Loading

0 comments on commit 79fc49f

Please sign in to comment.