aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-09-12 15:16:58 +0100
committerAleksey Kladov <[email protected]>2018-09-15 22:00:05 +0100
commit0e493160c0cdbaa71f61af64fd7c439410e8c8b1 (patch)
tree91e07c84f547f91cd4ccdd60cf3c5605ee77834e /crates
parent907d44a75113d318102ff05a66b4dcdafa1b5e7f (diff)
store params in the graph
Diffstat (limited to 'crates')
-rw-r--r--crates/libanalysis/src/db.rs12
1 files changed, 7 insertions, 5 deletions
diff --git a/crates/libanalysis/src/db.rs b/crates/libanalysis/src/db.rs
index d67cc189c..d30e75fe2 100644
--- a/crates/libanalysis/src/db.rs
+++ b/crates/libanalysis/src/db.rs
@@ -91,12 +91,13 @@ impl Clone for Db {
91 } 91 }
92} 92}
93 93
94type QueryDeps = Vec<(QueryInvocationId, Arc<Any>, OutputHash)>;
94 95
95#[derive(Default, Debug)] 96#[derive(Default, Debug)]
96pub(crate) struct Cache { 97pub(crate) struct Cache {
97 gen: Gen, 98 gen: Gen,
98 green: im::HashMap<QueryInvocationId, (Gen, OutputHash)>, 99 green: im::HashMap<QueryInvocationId, (Gen, OutputHash)>,
99 deps: im::HashMap<QueryInvocationId, Vec<(QueryInvocationId, OutputHash)>>, 100 deps: im::HashMap<QueryInvocationId, QueryDeps>,
100 results: im::HashMap<QueryInvocationId, Arc<Any>>, 101 results: im::HashMap<QueryInvocationId, Arc<Any>>,
101} 102}
102 103
@@ -124,7 +125,7 @@ impl Cache {
124 125
125pub(crate) struct QueryCtx { 126pub(crate) struct QueryCtx {
126 db: Arc<Db>, 127 db: Arc<Db>,
127 stack: RefCell<Vec<(QueryInvocationId, Vec<(QueryInvocationId, OutputHash)>)>>, 128 stack: RefCell<Vec<(QueryInvocationId, QueryDeps)>>,
128 pub(crate) trace: RefCell<Vec<TraceEvent>>, 129 pub(crate) trace: RefCell<Vec<TraceEvent>>,
129} 130}
130 131
@@ -148,7 +149,8 @@ impl QueryCtx {
148 { 149 {
149 let mut stack = self.stack.borrow_mut(); 150 let mut stack = self.stack.borrow_mut();
150 if let Some((_, ref mut deps)) = stack.last_mut() { 151 if let Some((_, ref mut deps)) = stack.last_mut() {
151 deps.push((me, output_hash::<Q>(&res))); 152 let params = Arc::new(params.clone());
153 deps.push((me, params, output_hash::<Q>(&res)));
152 } 154 }
153 } 155 }
154 156
@@ -161,7 +163,7 @@ impl QueryCtx {
161 163
162pub(crate) trait Query { 164pub(crate) trait Query {
163 const ID: u32; 165 const ID: u32;
164 type Params: Hash + Eq + Debug + Any + 'static; 166 type Params: Hash + Eq + Debug + Clone + Any + 'static;
165 type Output: Hash + Debug + Any + 'static; 167 type Output: Hash + Debug + Any + 'static;
166} 168}
167 169
@@ -212,7 +214,7 @@ where
212 }; 214 };
213 let deps_are_fresh = cache.deps[&id] 215 let deps_are_fresh = cache.deps[&id]
214 .iter() 216 .iter()
215 .all(|&(dep_id, dep_hash)| { 217 .all(|&(dep_id, _, dep_hash)| {
216 match cache.green.get(&dep_id) { 218 match cache.green.get(&dep_id) {
217 //TODO: store the value of parameters, and re-execute the query 219 //TODO: store the value of parameters, and re-execute the query
218 Some((gen, hash)) if gen == &curr_gen && hash == &dep_hash => true, 220 Some((gen, hash)) if gen == &curr_gen && hash == &dep_hash => true,