Skip to content

Commit

Permalink
Create UnionsAnd struct
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex-Fischman committed May 29, 2024
1 parent 2ec47de commit 2a9125a
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions dag_in_context/src/add_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use crate::{
struct ContextCache {
with_ctx: HashMap<(*const Expr, AssumptionRef), RcExpr>,
symbol_gen: HashMap<(*const Expr, AssumptionRef), String>,
unions: Vec<(String, String)>,
/// When true, don't add context- instead, make fresh query variables
/// and put these in place of context
symbolic_ctx: bool,
Expand All @@ -33,6 +34,20 @@ impl ContextCache {
}
}

pub struct UnionsAnd<T> {
unions: Vec<(String, String)>,
pub value: T,
}

impl<T> UnionsAnd<T> {
fn get_unions(&self) -> String {
self.unions
.iter()
.map(|(a, b)| format!("(union {a} {b})\n"))
.collect()
}
}

impl TreeProgram {
pub fn add_context(&self) -> TreeProgram {
TreeProgram {
Expand Down Expand Up @@ -89,6 +104,7 @@ impl Expr {
let mut cache = ContextCache {
with_ctx: HashMap::new(),
symbol_gen: HashMap::new(),
unions: Vec::new(),
symbolic_ctx: false,
dummy_ctx: true,
};
Expand All @@ -99,6 +115,7 @@ impl Expr {
let mut cache = ContextCache {
with_ctx: HashMap::new(),
symbol_gen: HashMap::new(),
unions: Vec::new(),
symbolic_ctx: true,
dummy_ctx: false,
};
Expand All @@ -109,6 +126,7 @@ impl Expr {
let mut cache = ContextCache {
with_ctx: HashMap::new(),
symbol_gen: HashMap::new(),
unions: Vec::new(),
symbolic_ctx: false,
dummy_ctx: false,
};
Expand Down

0 comments on commit 2a9125a

Please sign in to comment.