// 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>, Rc<Cell<usize>>);
+pub type JumpStub = Vec<Term>;
pub enum QueryTerm {
Arg(Vec<Box<Term>>),
&QueryTerm::Functor(_) => 3,
&QueryTerm::Inlined(ref term) => term.arity(),
&QueryTerm::Is(_) => 2,
- &QueryTerm::Jump((ref vars, _)) => vars.len(),
+ &QueryTerm::Jump(ref vars) => vars.len(),
&QueryTerm::CallN(ref terms) => terms.len(),
&QueryTerm::Cut => 0,
&QueryTerm::Term(ref term) => term.arity(),
ExecuteN(usize),
FunctorCall,
FunctorExecute,
- JmpByCall(usize, Rc<Cell<usize>>), // arity, global_offset.
- JmpByExecute(usize, Rc<Cell<usize>>),
+ JmpByCall(usize, usize), // arity, global_offset.
+ JmpByExecute(usize, usize),
// GotoCall(usize, usize), // p, arity.
GotoExecute(usize, usize), // p, arity.
IsCall(RegType, ArithmeticTerm),
code.push(Line::Control(ControlInstruction::FunctorCall)),
&QueryTerm::Inlined(_) =>
code.push(proceed!()),
- &QueryTerm::Jump((ref vars, ref offset)) => {
- code.push(jmp_call!(vars.len(), offset.clone()));
+ &QueryTerm::Jump(ref vars) => {
+ code.push(jmp_call!(vars.len(), 0));
},
&QueryTerm::Term(Term::Constant(_, Constant::Atom(ref atom))) => {
let call = ControlInstruction::Call(atom.clone(), 0, pvs);
write!(f, "is_call {}, {}", r, at),
&ControlInstruction::IsExecute(r, ref at) =>
write!(f, "is_execute {}, {}", r, at),
- &ControlInstruction::JmpByCall(arity, ref offset) =>
- write!(f, "jmp_by_call {}/{}", offset.get(), arity),
- &ControlInstruction::JmpByExecute(arity, ref offset) =>
- write!(f, "jmp_by_execute {}/{}", offset.get(), arity),
+ &ControlInstruction::JmpByCall(arity, offset) =>
+ write!(f, "jmp_by_call {}/{}", offset, arity),
+ &ControlInstruction::JmpByExecute(arity, offset) =>
+ write!(f, "jmp_by_execute {}/{}", offset, arity),
&ControlInstruction::Proceed =>
write!(f, "proceed"),
&ControlInstruction::ThrowCall =>
// set first jmp_by_call or jmp_by_index instruction to code.len() - idx,
// where idx is the place it occurs. It only does this to the *first* uninitialized
// jmp index it encounters, then returns.
-fn set_first_index(code: &Code)
+fn set_first_index(code: &mut Code)
{
- for (idx, line) in code.iter().enumerate() {
+ let code_len = code.len();
+
+ for (idx, line) in code.iter_mut().enumerate() {
match line {
- &Line::Control(ControlInstruction::JmpByExecute(_, ref offset))
- | &Line::Control(ControlInstruction::JmpByCall(_, ref offset)) if offset.get() == 0 => {
- offset.set(code.len() - idx);
+ &mut Line::Control(ControlInstruction::JmpByExecute(_, ref mut offset))
+ | &mut Line::Control(ControlInstruction::JmpByCall(_, ref mut offset)) if *offset == 0 => {
+ *offset = code_len - idx;
break;
},
_ => {}
QueryIterator { state_stack: vec![state] }
},
&QueryTerm::Cut => QueryIterator { state_stack: vec![] },
- &QueryTerm::Jump((ref vars, _)) => {
+ &QueryTerm::Jump(ref vars) => {
let state_stack = vars.iter().rev().map(|t| {
TermIterState::to_state(Level::Shallow, t)
}).collect();
while let Some(term) = item {
match term {
- &QueryTerm::Jump((ref vars, _)) => {
+ &QueryTerm::Jump(ref vars) => {
result.push(term);
arity = vars.len();
break;
self.unify(a1, Addr::Con(Constant::Number(a2)));
self.p = self.cp;
},
- &ControlInstruction::JmpByCall(arity, ref offset) => {
+ &ControlInstruction::JmpByCall(arity, offset) => {
self.cp = self.p + 1;
self.num_of_args = arity;
self.b0 = self.b;
- self.p += offset.get();
+ self.p += offset;
},
- &ControlInstruction::JmpByExecute(arity, ref offset) => {
+ &ControlInstruction::JmpByExecute(arity, offset) => {
self.num_of_args = arity;
self.b0 = self.b;
- self.p += offset.get();
+ self.p += offset;
},
&ControlInstruction::Proceed =>
self.p = self.cp,
-Subproject commit 9e80f2bd8268425c2128772b336f616be8d2c5d8
+Subproject commit e15eb2d27bb866d7a94fe47a829f5c51893bede3