Skip to content

Commit

Permalink
dunno
Browse files Browse the repository at this point in the history
  • Loading branch information
brockelmore committed Mar 18, 2024
1 parent d0bfb2e commit 7bf324c
Show file tree
Hide file tree
Showing 33 changed files with 1,676 additions and 882 deletions.
2 changes: 1 addition & 1 deletion crates/analyzers/src/func_analyzer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl<'a> FunctionVarsBoundAnalysis {
let deps = ctx.ctx_deps(analyzer).unwrap();
let deps = deps
.iter()
.map(|var| (var.display_name(analyzer).unwrap(), var))
.map(|var| (var.as_controllable_name(analyzer).unwrap(), var))
.collect::<BTreeMap<_, _>>();
// create the bound strings
// let atoms = ctx.dep_atoms(analyzer).unwrap();
Expand Down
4 changes: 2 additions & 2 deletions crates/analyzers/src/var_analyzer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ pub trait VarBoundAnalyzer: Search + AnalyzerBackend + Sized {
if let Some(next_range) = curr.ref_range(self).unwrap() {
let nr_min = next_range.evaled_range_min(self).unwrap();
let nr_max = next_range.evaled_range_max(self).unwrap();
let nr_excl = &next_range.exclusions;
let nr_excl = &next_range.range_exclusions();

// check if there was a bound change
if report_config.show_all_lines
Expand All @@ -266,7 +266,7 @@ pub trait VarBoundAnalyzer: Search + AnalyzerBackend + Sized {
if let Some(next_range) = next.ref_range(self).unwrap() {
let nr_min = next_range.evaled_range_min(self).unwrap();
let nr_max = next_range.evaled_range_max(self).unwrap();
let nr_excl = &next_range.exclusions;
let nr_excl = &next_range.range_exclusions();

// check if there was a bound change
if report_config.show_all_lines
Expand Down
13 changes: 8 additions & 5 deletions crates/graph/src/nodes/context/solving.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use crate::FlattenedRange;
use crate::elem::Elem;
use crate::SolcRange;
use crate::{
as_dot_str,
Expand Down Expand Up @@ -33,18 +35,18 @@ impl ContextNode {
let mut ranges = BTreeMap::default();
deps.iter().try_for_each(|dep| {
let mut range = dep.range(analyzer)?.unwrap();
let r: Cow<'_, SolcRange> = range.flattened_range(analyzer)?;
let r: Cow<'_, _> = range.flattened_range(analyzer)?;
ranges.insert(*dep, r.into_owned());
Ok(())
})?;

Ok(ranges
.iter()
.filter_map(|(_dep, range)| {
if let Some(atom) = range.min.atomize(analyzer) {
if let Some(atom) = Elem::Arena(range.min).atomize(analyzer) {
Some(atom)
} else {
range.max.atomize(analyzer)
Elem::Arena(range.max).atomize(analyzer)
}
})
.collect::<Vec<SolverAtom>>())
Expand Down Expand Up @@ -89,12 +91,13 @@ impl ContextNode {
// dep.cache_flattened_range(analyzer)?;
let mut range = dep.range(analyzer)?.unwrap();
let r = range.flattened_range(analyzer)?.into_owned();
tracing::trace!("flattened: {}", <FlattenedRange as Into<SolcRange>>::into(r.clone()).as_dot_str(analyzer));
// add the atomic constraint
if let Some(atom) = r.min.atomize(analyzer) {
if let Some(atom) = Elem::Arena(r.min).atomize(analyzer) {
let mut solver = std::mem::take(&mut self.underlying_mut(analyzer)?.dl_solver);
solver.add_constraints(vec![atom], analyzer);
self.underlying_mut(analyzer)?.dl_solver = solver;
} else if let Some(atom) = r.max.atomize(analyzer) {
} else if let Some(atom) = Elem::Arena(r.max).atomize(analyzer) {
let mut solver = std::mem::take(&mut self.underlying_mut(analyzer)?.dl_solver);
solver.add_constraints(vec![atom], analyzer);
self.underlying_mut(analyzer)?.dl_solver = solver;
Expand Down
20 changes: 12 additions & 8 deletions crates/graph/src/nodes/context/var/ranging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ impl ContextVarNode {

new_min.arenaize(analyzer)?;



// new_min.cache_flatten(analyzer)?;
// new_min.cache_minimize(analyzer)?;

Expand Down Expand Up @@ -279,7 +281,7 @@ impl ContextVarNode {
pub fn set_range_exclusions(
&self,
analyzer: &mut impl GraphBackend,
mut new_exclusions: Vec<Elem<Concrete>>,
mut new_exclusions: Vec<usize>,
) -> Result<(), GraphError> {
tracing::trace!(
"setting range exclusions for {}",
Expand All @@ -292,9 +294,10 @@ impl ContextVarNode {
None
};

new_exclusions
.iter_mut()
.try_for_each(|excl| excl.arenaize(analyzer))?;
// let new_exclusions = new_exclusions
// .into_iter()
// .map(|excl| analyzer.range_arena_idx_or_upsert(excl))
// .collect();

self.underlying_mut(analyzer)?
.set_range_exclusions(new_exclusions, fallback)?;
Expand Down Expand Up @@ -366,7 +369,7 @@ impl ContextVarNode {
pub fn try_set_range_exclusions(
&self,
analyzer: &mut impl GraphBackend,
mut new_exclusions: Vec<Elem<Concrete>>,
mut new_exclusions: Vec<usize>,
) -> Result<bool, GraphError> {
tracing::trace!(
"setting range exclusions for: {}",
Expand All @@ -379,9 +382,10 @@ impl ContextVarNode {
None
};

new_exclusions
.iter_mut()
.try_for_each(|excl| excl.arenaize(analyzer))?;
// let new_exclusions = new_exclusions
// .into_iter()
// .map(|excl| analyzer.range_arena_idx_or_upsert(excl))
// .collect();

Ok(self
.underlying_mut(analyzer)?
Expand Down
4 changes: 2 additions & 2 deletions crates/graph/src/nodes/context/var/underlying.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ impl ContextVar {

pub fn set_range_exclusions(
&mut self,
new_exclusions: Vec<Elem<Concrete>>,
new_exclusions: Vec<usize>,
fallback_range: Option<SolcRange>,
) -> Result<(), GraphError> {
match &mut self.ty {
Expand Down Expand Up @@ -414,7 +414,7 @@ impl ContextVar {

pub fn try_set_range_exclusions(
&mut self,
new_exclusions: Vec<Elem<Concrete>>,
new_exclusions: Vec<usize>,
fallback_range: Option<SolcRange>,
) -> bool {
match &mut self.ty {
Expand Down
12 changes: 11 additions & 1 deletion crates/graph/src/nodes/context/variables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ impl ContextNode {
underlying_mut
.expr_ret_stack
.iter()
.for_each(|elem| println!("{}", elem.debug_str(analyzer)));
.enumerate()
.for_each(|(i, elem)| println!("{i}. {}", elem.debug_str(analyzer)));
Ok(())
}

Expand Down Expand Up @@ -212,6 +213,10 @@ impl ContextNode {
loc: Loc,
analyzer: &mut (impl GraphBackend + AnalyzerBackend),
) -> Result<ExprRet, GraphError> {
tracing::trace!(
"moving expr to {}",
self.path(analyzer)
);
match expr {
ExprRet::SingleLiteral(var) => Ok(ExprRet::SingleLiteral(
self.maybe_move_var(var.into(), loc, analyzer)?.into(),
Expand Down Expand Up @@ -239,6 +244,11 @@ impl ContextNode {
let var = var.latest_version(analyzer);
if let Some(ctx) = var.maybe_ctx(analyzer) {
if ctx != *self {
tracing::trace!(
"moving var {} from {}",
ctx.path(analyzer),
self.path(analyzer)
);
let mut new_cvar = var.latest_version(analyzer).underlying(analyzer)?.clone();
new_cvar.loc = Some(loc);

Expand Down
9 changes: 9 additions & 0 deletions crates/graph/src/range/elem/concrete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@ impl RangeElem<Concrete> for RangeConcrete<Concrete> {
Ok(false)
}

fn depends_on(
&self,
var: ContextVarNode,
seen: &mut Vec<ContextVarNode>,
analyzer: &impl GraphBackend,
) -> Result<bool, Self::GraphError> {
Ok(false)
}

fn flatten(
&self,
_maximize: bool,
Expand Down
Loading

0 comments on commit 7bf324c

Please sign in to comment.