diff options
Diffstat (limited to 'crates/libanalysis/src/db.rs')
-rw-r--r-- | crates/libanalysis/src/db.rs | 12 |
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 | ||
94 | type QueryDeps = Vec<(QueryInvocationId, Arc<Any>, OutputHash)>; | ||
94 | 95 | ||
95 | #[derive(Default, Debug)] | 96 | #[derive(Default, Debug)] |
96 | pub(crate) struct Cache { | 97 | pub(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 | ||
125 | pub(crate) struct QueryCtx { | 126 | pub(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 | ||
162 | pub(crate) trait Query { | 164 | pub(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, |