minor cleanup.
This commit is contained in:
@@ -155,7 +155,7 @@ impl RegType {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
#[derive(PartialEq, Eq, Clone, Copy)]
|
||||
pub enum VarReg {
|
||||
ArgAndNorm(RegType, usize),
|
||||
Norm(RegType)
|
||||
@@ -329,7 +329,7 @@ impl fmt::Display for Constant {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
#[derive(PartialEq, Eq, Clone)]
|
||||
pub enum Term {
|
||||
AnonVar,
|
||||
Clause(Cell<RegType>, TabledRc<Atom>, Vec<Box<Term>>, Option<Fixity>),
|
||||
@@ -376,6 +376,19 @@ pub enum CompareNumberQT {
|
||||
Equal
|
||||
}
|
||||
|
||||
impl CompareNumberQT {
|
||||
fn name<'a>(self) -> &'a str {
|
||||
match self {
|
||||
CompareNumberQT::GreaterThan => ">",
|
||||
CompareNumberQT::LessThan => "<",
|
||||
CompareNumberQT::GreaterThanOrEqual => ">=",
|
||||
CompareNumberQT::LessThanOrEqual => "=<",
|
||||
CompareNumberQT::NotEqual => "=\\=",
|
||||
CompareNumberQT::Equal => "=:="
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// vars of predicate, toplevel offset. Vec<Term> is always a vector
|
||||
// of vars (we get their adjoining cells this way).
|
||||
pub type JumpStub = Vec<Term>;
|
||||
@@ -421,13 +434,12 @@ pub struct Rule {
|
||||
pub clauses: Vec<QueryTerm>
|
||||
}
|
||||
|
||||
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
pub enum ClauseType<'a> {
|
||||
Arg,
|
||||
CallN,
|
||||
Catch,
|
||||
CompareNumber(CompareNumberQT),
|
||||
Deep(Level, &'a Cell<RegType>, &'a TabledRc<Atom>, Option<Fixity>),
|
||||
Display,
|
||||
DuplicateTerm,
|
||||
@@ -444,6 +456,7 @@ impl<'a> ClauseType<'a> {
|
||||
&ClauseType::Arg => "arg",
|
||||
&ClauseType::CallN => "call",
|
||||
&ClauseType::Catch => "catch",
|
||||
&ClauseType::CompareNumber(qt) => qt.name(),
|
||||
&ClauseType::Display => "display",
|
||||
&ClauseType::Deep(_, _, name, _) => name.as_str(),
|
||||
&ClauseType::DuplicateTerm => "duplicate_term",
|
||||
|
||||
@@ -100,23 +100,7 @@ impl<'a, TermMarker: Allocator<'a>> CodeGenerator<'a, TermMarker>
|
||||
{
|
||||
match self.marker.bindings().get(name) {
|
||||
Some(&VarData::Temp(_, t, _)) if t != 0 => RegType::Temp(t),
|
||||
Some(&VarData::Perm(p)) if p != 0 =>
|
||||
/* if let GenContext::Last(chunk_num) = term_loc {
|
||||
let mut target = Vec::new();
|
||||
|
||||
self.marker.evacuate_arg(chunk_num, &mut target);
|
||||
|
||||
self.marker.reset_arg(arity);
|
||||
self.marker.mark_var(name, Level::Shallow, vr, term_loc, &mut target);
|
||||
|
||||
if !target.is_empty() {
|
||||
code.push(Line::Query(target));
|
||||
}
|
||||
|
||||
vr.get().norm()
|
||||
} else { */
|
||||
RegType::Perm(p),
|
||||
//},
|
||||
Some(&VarData::Perm(p)) if p != 0 => RegType::Perm(p),
|
||||
_ => {
|
||||
let mut target = Vec::new();
|
||||
|
||||
|
||||
@@ -60,8 +60,11 @@ impl<'a> QueryIterator<'a> {
|
||||
let state = TermIterState::Clause(0, ClauseType::Display, terms);
|
||||
QueryIterator { state_stack: vec![state] }
|
||||
},
|
||||
&QueryTerm::Inlined(InlinedQueryTerm::CompareNumber(_, ref terms))
|
||||
| &QueryTerm::Is(ref terms) => {
|
||||
&QueryTerm::Inlined(InlinedQueryTerm::CompareNumber(qt, ref terms)) => {
|
||||
let state = TermIterState::Clause(0, ClauseType::CompareNumber(qt), terms);
|
||||
QueryIterator { state_stack: vec![state] }
|
||||
},
|
||||
&QueryTerm::Is(ref terms) => {
|
||||
let state = TermIterState::Clause(0, ClauseType::Is, terms);
|
||||
QueryIterator { state_stack: vec![state] }
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user