clean up codegen.rs

This commit is contained in:
Mark Thom
2018-01-31 19:49:48 -07:00
parent b761575f7f
commit d1c281ac0a

View File

@@ -8,7 +8,6 @@ use prolog::targets::*;
use std::cell::Cell; use std::cell::Cell;
use std::collections::HashMap; use std::collections::HashMap;
use std::mem::swap;
use std::vec::Vec; use std::vec::Vec;
pub struct CodeGenerator<'a, TermMarker> { pub struct CodeGenerator<'a, TermMarker> {
@@ -286,11 +285,8 @@ impl<'a, TermMarker: Allocator<'a>> CodeGenerator<'a, 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 mut instr = ControlInstruction::Proceed; match ctrl.clone() {
swap(ctrl, &mut instr);
match instr {
ControlInstruction::ArgCall => ControlInstruction::ArgCall =>
*ctrl = ControlInstruction::ArgExecute, *ctrl = ControlInstruction::ArgExecute,
ControlInstruction::Call(name, arity, _) => ControlInstruction::Call(name, arity, _) =>
@@ -313,8 +309,7 @@ impl<'a, TermMarker: Allocator<'a>> CodeGenerator<'a, TermMarker>
*ctrl = ControlInstruction::IsExecute(r, at), *ctrl = ControlInstruction::IsExecute(r, at),
ControlInstruction::Proceed => {}, ControlInstruction::Proceed => {},
_ => dealloc_index += 1 // = code.len() _ => dealloc_index += 1 // = code.len()
} },
},
Some(&mut Line::Cut(CutInstruction::Cut)) => Some(&mut Line::Cut(CutInstruction::Cut)) =>
dealloc_index += 1, dealloc_index += 1,
_ => {} _ => {}