minor modification to lco in codegen

This commit is contained in:
Mark Thom
2018-10-04 22:28:42 -06:00
parent 054def4cc7
commit d7e8da8324

View File

@@ -10,7 +10,6 @@ use prolog::targets::*;
use std::cell::Cell; use std::cell::Cell;
use std::collections::{HashMap}; use std::collections::{HashMap};
use std::mem;
use std::rc::Rc; use std::rc::Rc;
use std::vec::Vec; use std::vec::Vec;
@@ -236,17 +235,14 @@ impl<'a, TermMarker: Allocator<'a>> CodeGenerator<TermMarker>
let mut dealloc_index = code.len() - 1; let mut dealloc_index = code.len() - 1;
match code.last_mut() { match code.last_mut() {
Some(&mut Line::Control(ref mut ctrl)) => { Some(&mut Line::Control(ref mut ctrl)) =>
let old_ctrl = mem::replace(ctrl, ControlInstruction::Proceed); match ctrl {
&mut ControlInstruction::CallClause(_, _, _, ref mut last_call, _) =>
match old_ctrl { *last_call = true,
ControlInstruction::CallClause(ct, arity, pvs, false, use_default_cp) => &mut ControlInstruction::JmpBy(_, _, _, ref mut last_call) =>
*ctrl = ControlInstruction::CallClause(ct, arity, pvs, true, use_default_cp), *last_call = true,
ControlInstruction::JmpBy(arity, offset, pvs, false) => &mut ControlInstruction::Proceed => {},
*ctrl = ControlInstruction::JmpBy(arity, offset, pvs, true),
ControlInstruction::Proceed => {},
_ => dealloc_index += 1 _ => dealloc_index += 1
}
}, },
Some(&mut Line::Cut(CutInstruction::Cut(_))) => Some(&mut Line::Cut(CutInstruction::Cut(_))) =>
dealloc_index += 1, dealloc_index += 1,