@@ -6,7 +6,7 @@ use crate::forest::Forest;
6
6
use crate :: hh:: HhGoal ;
7
7
use crate :: stack:: { Stack , StackIndex } ;
8
8
use crate :: strand:: { CanonicalStrand , SelectedSubgoal , Strand } ;
9
- use crate :: table:: AnswerIndex ;
9
+ use crate :: table:: { AnswerIndex , Table } ;
10
10
use crate :: {
11
11
Answer , CompleteAnswer , ExClause , FlounderedSubgoal , Literal , Minimums , TableIndex , TimeStamp ,
12
12
} ;
@@ -222,9 +222,9 @@ impl<C: Context> Forest<C> {
222
222
goal
223
223
) ;
224
224
let coinductive_goal = context. is_coinductive ( & goal) ;
225
- let table = self . tables . insert ( goal, coinductive_goal) ;
226
- self . push_initial_strands ( context, table) ;
227
- table
225
+ let mut table = Table :: new ( goal. clone ( ) , coinductive_goal) ;
226
+ Self :: push_initial_strands ( context, self . tables . next_index ( ) , & mut table) ;
227
+ self . tables . insert ( table)
228
228
}
229
229
230
230
/// When a table is first created, this function is invoked to
@@ -238,23 +238,22 @@ impl<C: Context> Forest<C> {
238
238
/// In terms of the NFTD paper, this corresponds to the *Program
239
239
/// Clause Resolution* step being applied eagerly, as many times
240
240
/// as possible.
241
- fn push_initial_strands ( & mut self , context : & impl ContextOps < C > , table : TableIndex ) {
241
+ fn push_initial_strands ( context : & impl ContextOps < C > , table_idx : TableIndex , table : & mut Table < C > ) {
242
242
// Instantiate the table goal with fresh inference variables.
243
- let table_goal = self . tables [ table] . table_goal . clone ( ) ;
243
+ let table_goal = table. table_goal . clone ( ) ;
244
244
let ( infer, subst, environment, goal) = context. instantiate_ucanonical_goal ( & table_goal) ;
245
- self . push_initial_strands_instantiated ( context, table, infer, subst, environment, goal) ;
245
+ Self :: push_initial_strands_instantiated ( context, table_idx , table, infer, subst, environment, goal) ;
246
246
}
247
247
248
248
fn push_initial_strands_instantiated (
249
- & mut self ,
250
249
context : & impl ContextOps < C > ,
251
- table : TableIndex ,
250
+ table_idx : TableIndex ,
251
+ table : & mut Table < C > ,
252
252
mut infer : C :: InferenceTable ,
253
253
subst : C :: Substitution ,
254
254
environment : C :: Environment ,
255
255
goal : C :: Goal ,
256
256
) {
257
- let table_ref = & mut self . tables [ table] ;
258
257
match context. into_hh_goal ( goal) {
259
258
HhGoal :: DomainGoal ( domain_goal) => {
260
259
match context. program_clauses ( & environment, & domain_goal, & mut infer) {
@@ -277,13 +276,13 @@ impl<C: Context> Forest<C> {
277
276
last_pursued_time : TimeStamp :: default ( ) ,
278
277
} ;
279
278
let canonical_strand = Self :: canonicalize_strand ( context, strand) ;
280
- table_ref . enqueue_strand ( canonical_strand) ;
279
+ table . enqueue_strand ( canonical_strand) ;
281
280
}
282
281
}
283
282
}
284
283
Err ( Floundered ) => {
285
- debug ! ( "Marking table {:?} as floundered!" , table ) ;
286
- table_ref . mark_floundered ( ) ;
284
+ debug ! ( "Marking table {:?} as floundered!" , table_idx ) ;
285
+ table . mark_floundered ( ) ;
287
286
}
288
287
}
289
288
}
@@ -311,7 +310,7 @@ impl<C: Context> Forest<C> {
311
310
last_pursued_time : TimeStamp :: default ( ) ,
312
311
} ;
313
312
let canonical_strand = Self :: canonicalize_strand ( context, strand) ;
314
- table_ref . enqueue_strand ( canonical_strand) ;
313
+ table . enqueue_strand ( canonical_strand) ;
315
314
}
316
315
}
317
316
}
0 commit comments