]> Repositorios git - scryer-prolog.git/commitdiff
minor modification to lco in codegen
authorMark Thom <[email protected]>
Fri, 5 Oct 2018 04:28:42 +0000 (22:28 -0600)
committerMark Thom <[email protected]>
Fri, 5 Oct 2018 04:28:42 +0000 (22:28 -0600)
src/prolog/codegen.rs

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