adjust for nested throws.

This commit is contained in:
Mark Thom
2017-08-14 22:49:41 -06:00
parent aa3bee5db9
commit 1d2c02e9af
9 changed files with 362 additions and 174 deletions

View File

@@ -212,7 +212,7 @@ impl<'a, TermMarker: Allocator<'a>> CodeGenerator<'a, TermMarker>
compiled_query.push(Line::Control(call));
},
QueryTermRef::Catch(_) =>
compiled_query.push(Line::Control(ControlInstruction::Catch)),
compiled_query.push(Line::Control(ControlInstruction::CatchCall)),
QueryTermRef::Term(&Term::Constant(_, Constant::Atom(ref atom))) => {
let call = ControlInstruction::Call(atom.clone(), 0, pvs);
compiled_query.push(Line::Control(call));
@@ -222,7 +222,7 @@ impl<'a, TermMarker: Allocator<'a>> CodeGenerator<'a, TermMarker>
compiled_query.push(Line::Control(call));
},
QueryTermRef::Throw(_) =>
compiled_query.push(Line::Control(ControlInstruction::Throw)),
compiled_query.push(Line::Control(ControlInstruction::ThrowCall)),
_ => {}
}
}
@@ -242,6 +242,14 @@ impl<'a, TermMarker: Allocator<'a>> CodeGenerator<'a, TermMarker>
if let &mut Line::Control(ref mut ctrl) = body.last_mut().unwrap() {
*ctrl = ControlInstruction::ExecuteN(terms.len());
},
QueryTermRef::Catch(_) =>
if let &mut Line::Control(ref mut ctrl) = body.last_mut().unwrap() {
*ctrl = ControlInstruction::CatchExecute;
},
QueryTermRef::Throw(_) =>
if let &mut Line::Control(ref mut ctrl) = body.last_mut().unwrap() {
*ctrl = ControlInstruction::ThrowExecute;
},
_ => dealloc_index = body.len()
};