clean up atomic and var code.
@@ -349,16 +349,24 @@ fn compile_seq(&mut self,
&Term::Constant(_, _) => {
code.push(succeed!());
},
- &Term::Var(ref vr, ref name) => {
+ &Term::Var(ref vr, ref name) =>
+ match self.marker.bindings().get(name) {
+ Some(&VarData::Temp(_, t, _)) if t != 0 =>
+ code.push(is_atomic!(RegType::Temp(t))),
+ Some(&VarData::Perm(p)) if p != 0 =>
+ code.push(is_atomic!(RegType::Perm(p))),
+ _ => {
let mut target = Vec::new();
- self.marker.advance(term_loc, *term); // reset self.marker.arg_c to 1.
+ // reset self.marker.arg_c to 1.
+ self.marker.advance(term_loc, *term);
self.marker.mark_var(name, Level::Shallow, vr, term_loc, &mut target);
code.push(Line::Query(target));
code.push(is_atomic!(vr.get().norm()));
}
},
+ },
&QueryTermRef::IsVar(inner_term) =>
match inner_term {
&Term::Constant(_, _) | &Term::Clause(_, _, _) | &Term::Cons(_, _, _) => {
@@ -367,15 +375,23 @@ fn compile_seq(&mut self,
&Term::AnonVar => {
code.push(succeed!());
},
- &Term::Var(ref vr, ref name) => {
+ &Term::Var(ref vr, ref name) =>
+ match self.marker.bindings().get(name) {
+ Some(&VarData::Temp(_, t, _)) if t != 0 =>
+ code.push(is_var!(RegType::Temp(t))),
+ Some(&VarData::Perm(p)) if p != 0 =>
+ code.push(is_var!(RegType::Perm(p))),
+ _ => {
let mut target = Vec::new();
- self.marker.advance(term_loc, *term); // reset self.marker.arg_c to 1.
+ // reset self.marker.arg_c to 1.
+ self.marker.advance(term_loc, *term);
self.marker.mark_var(name, Level::Shallow, vr, term_loc, &mut target);
code.push(Line::Query(target));
code.push(is_var!(vr.get().norm()));
}
+ }
},
_ if chunk_num == 0 => {
self.marker.advance(GenContext::Head, *term);
