get rid of chunked iterators for facts.
This commit is contained in:
@@ -194,7 +194,6 @@ impl<'a, TermMarker: Allocator<'a>> CodeGenerator<'a, TermMarker>
|
|||||||
self.update_var_count(term_or_cut_ref.post_order_iter());
|
self.update_var_count(term_or_cut_ref.post_order_iter());
|
||||||
vs.mark_vars_in_chunk(term_or_cut_ref.post_order_iter(),
|
vs.mark_vars_in_chunk(term_or_cut_ref.post_order_iter(),
|
||||||
last_term_arity,
|
last_term_arity,
|
||||||
chunk_num,
|
|
||||||
term_loc);
|
term_loc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -242,7 +241,7 @@ impl<'a, TermMarker: Allocator<'a>> CodeGenerator<'a, TermMarker>
|
|||||||
if let Some(&mut Line::Control(ref mut ctrl)) = code.last_mut() {
|
if let Some(&mut Line::Control(ref mut ctrl)) = code.last_mut() {
|
||||||
let mut instr = ControlInstruction::Proceed;
|
let mut instr = ControlInstruction::Proceed;
|
||||||
swap(ctrl, &mut instr);
|
swap(ctrl, &mut instr);
|
||||||
|
|
||||||
match instr {
|
match instr {
|
||||||
ControlInstruction::Call(name, arity, _) =>
|
ControlInstruction::Call(name, arity, _) =>
|
||||||
*ctrl = ControlInstruction::Execute(name, arity),
|
*ctrl = ControlInstruction::Execute(name, arity),
|
||||||
@@ -257,7 +256,7 @@ impl<'a, TermMarker: Allocator<'a>> CodeGenerator<'a, TermMarker>
|
|||||||
_ => dealloc_index += 1 // = code.len()
|
_ => dealloc_index += 1 // = code.len()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dealloc_index
|
dealloc_index
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -429,7 +428,7 @@ impl<'a, TermMarker: Allocator<'a>> CodeGenerator<'a, TermMarker>
|
|||||||
code.push(proceed!()),
|
code.push(proceed!()),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
let dealloc_index = Self::lco(code);
|
let dealloc_index = Self::lco(code);
|
||||||
|
|
||||||
if conjunct_info.allocates() {
|
if conjunct_info.allocates() {
|
||||||
@@ -501,9 +500,14 @@ impl<'a, TermMarker: Allocator<'a>> CodeGenerator<'a, TermMarker>
|
|||||||
|
|
||||||
pub fn compile_fact<'b: 'a>(&mut self, term: &'b Term) -> Code
|
pub fn compile_fact<'b: 'a>(&mut self, term: &'b Term) -> Code
|
||||||
{
|
{
|
||||||
let iter = ChunkedIterator::from_fact(term);
|
self.update_var_count(term.post_order_iter());
|
||||||
|
|
||||||
self.collect_var_data(iter);
|
let mut vs = VariableFixtures::new();
|
||||||
|
vs.mark_vars_in_chunk(term.post_order_iter(), term.arity(), GenContext::Head);
|
||||||
|
|
||||||
|
vs.populate_restricting_sets();
|
||||||
|
|
||||||
|
self.marker.drain_var_data(vs);
|
||||||
self.marker.advance(GenContext::Head, term.arity());
|
self.marker.advance(GenContext::Head, term.arity());
|
||||||
|
|
||||||
let mut code = Vec::new();
|
let mut code = Vec::new();
|
||||||
|
|||||||
@@ -173,11 +173,11 @@ impl<'a> VariableFixtures<'a>
|
|||||||
|
|
||||||
pub fn mark_vars_in_chunk<Iter>(&mut self,
|
pub fn mark_vars_in_chunk<Iter>(&mut self,
|
||||||
iter: Iter,
|
iter: Iter,
|
||||||
last_term_arity: usize,
|
last_term_arity: usize,
|
||||||
chunk_num: usize,
|
|
||||||
term_loc: GenContext)
|
term_loc: GenContext)
|
||||||
where Iter: Iterator<Item=TermRef<'a>>
|
where Iter: Iterator<Item=TermRef<'a>>
|
||||||
{
|
{
|
||||||
|
let chunk_num = term_loc.chunk_num();
|
||||||
let mut arg_c = 1;
|
let mut arg_c = 1;
|
||||||
|
|
||||||
for term_ref in iter {
|
for term_ref in iter {
|
||||||
|
|||||||
@@ -200,18 +200,6 @@ pub struct ChunkedIterator<'a>
|
|||||||
|
|
||||||
impl<'a> ChunkedIterator<'a>
|
impl<'a> ChunkedIterator<'a>
|
||||||
{
|
{
|
||||||
pub fn from_fact(term: &'a Term) -> Self
|
|
||||||
{
|
|
||||||
let inner_iter: Box<Iterator<Item=QueryTermRef<'a>>> =
|
|
||||||
Box::new(once(QueryTermRef::Term(term)));
|
|
||||||
|
|
||||||
ChunkedIterator {
|
|
||||||
term_loc: GenContext::Head,
|
|
||||||
iter: inner_iter,
|
|
||||||
deep_cut_encountered: false,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn from_term_sequence(terms: &'a [QueryTerm]) -> Self
|
pub fn from_term_sequence(terms: &'a [QueryTerm]) -> Self
|
||||||
{
|
{
|
||||||
let iter = terms.iter().map(|c| c.to_ref());
|
let iter = terms.iter().map(|c| c.to_ref());
|
||||||
|
|||||||
Reference in New Issue
Block a user