]> Repositorios git - scryer-prolog.git/commitdiff
remove Div for ast.rs
authorMark Thom <[email protected]>
Thu, 9 Nov 2017 05:57:40 +0000 (22:57 -0700)
committerMark Thom <[email protected]>
Thu, 9 Nov 2017 05:57:40 +0000 (22:57 -0700)
src/prolog/and_stack.rs
src/prolog/ast.rs
src/prolog/machine.rs

index c1294be58a3aab57190e7aed4dd911cae0c4d146..77a729f93567b546934fbf7f888fff28362f3bf7 100644 (file)
@@ -3,6 +3,7 @@ use prolog::ast::*;
 use std::ops::{Index, IndexMut};
 use std::vec::Vec;
 
+#[derive(Clone)]
 pub struct Frame {
     pub global_index: usize,
     pub b0: usize,
@@ -12,13 +13,13 @@ pub struct Frame {
 }
 
 impl Frame {
-    fn new(global_index: usize, sz: usize, e: usize, cp: CodePtr, n: usize) -> Self {
+    fn new(global_index: usize, fr: usize, e: usize, cp: CodePtr, n: usize) -> Self {
         Frame {
-            global_index: global_index,
+            global_index,
             b0: 0,
             e: e,
             cp: cp,
-            perms: (1 .. n+1).map(|i| Addr::StackCell(sz, i)).collect()
+            perms: (1 .. n+1).map(|i| Addr::StackCell(fr, i)).collect()
         }
     }
 }
@@ -47,6 +48,10 @@ impl AndStack {
     pub fn clear(&mut self) {
         self.0.clear()
     }
+
+    pub fn pop(&mut self) {
+        self.0.pop();
+    }
 }
 
 impl Index<usize> for AndStack {
index 05fc31b531e535b7fdb9da336f0a65f98510e81a..9e6b493ef5c2688b8f8a3bdb2e1c7fbf2df192b4 100644 (file)
@@ -9,7 +9,7 @@ use std::collections::{HashMap, VecDeque};
 use std::fmt;
 use std::io::Error as IOError;
 use std::num::{ParseFloatError};
-use std::ops::{Add, AddAssign, Sub, Mul, Div, Neg};
+use std::ops::{Add, AddAssign, Sub, Mul, Neg};
 use std::str::Utf8Error;
 use std::vec::Vec;
 
index 68374c929e4827749ebc696aca22eb58842972b0..0d9246188bacac02248c644e1e19fccab2031a44 100644 (file)
@@ -1511,9 +1511,10 @@ impl MachineState {
         match instr {
             &ControlInstruction::Allocate(num_cells) => {
                 let num_frames = self.num_frames();
-                self.and_stack.push(num_frames + 1, self.e, self.cp, num_cells);
 
+                self.and_stack.push(num_frames + 1, self.e, self.cp, num_cells);
                 self.e = self.and_stack.len() - 1;
+                
                 self.p += 1;
             },
             &ControlInstruction::Call(ref name, arity, _) =>
@@ -1538,7 +1539,7 @@ impl MachineState {
 
                 self.cp = self.and_stack[e].cp;
                 self.e  = self.and_stack[e].e;
-
+                
                 self.p += 1;
             },
             &ControlInstruction::Execute(ref name, arity) =>