new TermIterState variants

This commit is contained in:
Mark Thom
2022-12-05 20:49:23 -07:00
committed by Mark
parent a66d666bed
commit 063cf0c608
9 changed files with 141 additions and 148 deletions

View File

@@ -57,6 +57,7 @@ pub(super) fn compile_relation(
}
}
/*
pub(super) fn compile_appendix(
code: &mut Code,
mut queue: VecDeque<TopLevel>,
@@ -97,6 +98,7 @@ pub(super) fn compile_appendix(
Ok(())
}
*/
fn lower_bound_of_target_clause(skeleton: &PredicateSkeleton, target_pos: usize) -> usize {
if target_pos == 0 {
@@ -1342,7 +1344,7 @@ impl<'a, LS: LoadState<'a>> Loader<'a, LS> {
let mut preprocessor = Preprocessor::new(settings);
let clause = self.try_term_to_tl(term, &mut preprocessor)?;
let queue = preprocessor.parse_queue(self)?;
// let queue = preprocessor.parse_queue(self)?;
let mut cg = CodeGenerator::new(
&mut LS::machine_st(&mut self.payload).atom_tbl,
@@ -1351,6 +1353,7 @@ impl<'a, LS: LoadState<'a>> Loader<'a, LS> {
let mut clause_code = cg.compile_predicate(&vec![clause])?;
/*
compile_appendix(
&mut clause_code,
queue,
@@ -1358,6 +1361,7 @@ impl<'a, LS: LoadState<'a>> Loader<'a, LS> {
settings.non_counted_bt,
cg.atom_tbl,
)?;
*/
Ok(StandaloneCompileResult {
clause_code,
@@ -1385,7 +1389,7 @@ impl<'a, LS: LoadState<'a>> Loader<'a, LS> {
clauses.push(self.try_term_to_tl(term, &mut preprocessor)?);
}
let queue = preprocessor.parse_queue(self)?;
// let queue = preprocessor.parse_queue(self)?;
let mut cg = CodeGenerator::new(
&mut LS::machine_st(&mut self.payload).atom_tbl,
@@ -1394,6 +1398,7 @@ impl<'a, LS: LoadState<'a>> Loader<'a, LS> {
let mut code = cg.compile_predicate(&clauses)?;
/*
compile_appendix(
&mut code,
queue,
@@ -1401,6 +1406,7 @@ impl<'a, LS: LoadState<'a>> Loader<'a, LS> {
settings.non_counted_bt,
cg.atom_tbl,
)?;
*/
if settings.is_extensible {
let mut clause_clause_locs = VecDeque::new();

View File

@@ -487,6 +487,8 @@ impl VariableClassifier {
Ok(())
}
// TODO: maybe replace Vec<QueryTerm> with an iterator that has, in the stream,
// with a 'QueryTerm' that toggles the chunk num and type, like we do here.
fn classify_body_variables<'a, LS: LoadState<'a>>(
&mut self,
loader: &mut Loader<'a, LS>,
@@ -826,6 +828,7 @@ impl BranchMap {
debug_assert_eq!(var_data.records.len(), var_num);
var_data.fixtures.populate_restricting_sets();
var_data
}
}

View File

@@ -228,7 +228,7 @@ impl CodeIndex {
}
pub(crate) type HeapVarDict = IndexMap<Var, HeapCellValue, FxBuildHasher>;
pub(crate) type AllocVarDict = IndexMap<Var, VarData, FxBuildHasher>;
pub(crate) type AllocVarDict = IndexMap<Var, VarAlloc, FxBuildHasher>;
pub(crate) type GlobalVarDir = IndexMap<Atom, (Ball, Option<HeapCellValue>), FxBuildHasher>;

View File

@@ -553,9 +553,9 @@ impl Preprocessor {
self.settings.default_call_policy(),
);
let (head, var_records) = classifier.classify_fact(term)?;
let (head, var_data) = classifier.classify_fact(term)?;
Ok(Fact { head, var_records })
Ok(Fact { head, var_data })
}
_ => Err(CompilationError::InadmissibleFact),
}
@@ -571,7 +571,7 @@ impl Preprocessor {
self.settings.default_call_policy(),
);
let (head, mut query_terms, var_records) =
let (head, mut query_terms, var_data) =
classifier.classify_rule(loader, head, body)?;
let clauses = query_terms.drain(1..).collect();
@@ -581,12 +581,12 @@ impl Preprocessor {
Term::Clause(_, name, terms) => Ok(Rule {
head: (name, terms, qt),
clauses,
var_records,
var_data,
}),
Term::Literal(_, Literal::Atom(name)) => Ok(Rule {
head: (name, vec![], qt),
clauses,
var_records,
var_data,
}),
_ => Err(CompilationError::InvalidRuleHead),
}