Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debuggable lattices #53

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ascent_base/src/lattice/bounded_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::Lattice;
/// `BoundedSet` is a generalization of the flat lattice.
///
/// A `BoundedSet` stores at most `BOUND` items, and if asked to store more, will go to `TOP`.
#[derive(Clone, PartialEq, Eq, Hash)]
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
pub struct BoundedSet<const BOUND: usize, T: PartialEq + Eq + Hash + Ord>(Option<Set<T>>);

impl<const BOUND: usize, T: PartialEq + Eq + Hash + Ord> Default for BoundedSet<BOUND, T> {
Expand Down
2 changes: 1 addition & 1 deletion ascent_base/src/lattice/constant_propagation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::cmp::Ordering;
use super::{BoundedLattice, Lattice};

/// A flat `Lattice`: `Bottom` <= everything <= `Top`, and `Constant(x) == Constant(y)` iff `x == y`
#[derive(PartialEq, Eq, Clone, Copy, Debug, Hash)]
#[derive(PartialEq, Eq, Clone, Copy, Hash, Debug)]
#[allow(dead_code)]
pub enum ConstPropagation<T> {
Bottom,
Expand Down
12 changes: 11 additions & 1 deletion ascent_base/src/lattice/ord_lattice.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
use std::fmt::{Debug, Display, Formatter};

use crate::Lattice;

#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct OrdLattice<T>(pub T);

impl<T: Debug> Debug for OrdLattice<T> {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { self.0.fmt(f) }
}

impl<T: Debug> Display for OrdLattice<T> {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { self.0.fmt(f) }
}

impl<T: Ord> Lattice for OrdLattice<T> {
#[inline(always)]
fn meet(self, other: Self) -> Self { self.min(other) }
Expand Down
5 changes: 5 additions & 0 deletions ascent_base/src/lattice/set.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::cmp::Ordering;
use std::collections::BTreeSet;
use std::fmt::{Debug, Formatter};
use std::hash::Hash;
use std::ops::Deref;

Expand All @@ -22,6 +23,10 @@ impl<T: PartialEq + Eq + Hash + Ord> Default for Set<T> {
fn default() -> Self { Self(Default::default()) }
}

impl<T: PartialEq + Eq + Hash + Ord + Debug> Debug for Set<T> {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { self.0.fmt(f) }
}

impl<T: PartialEq + Eq + Hash + Ord> Deref for Set<T> {
type Target = BTreeSet<T>;

Expand Down
Loading