]> Repositorios git - scryer-prolog.git/commitdiff
update token type
authorMark Thom <[email protected]>
Sat, 13 Jan 2018 05:26:57 +0000 (22:26 -0700)
committerMark Thom <[email protected]>
Sat, 13 Jan 2018 05:26:57 +0000 (22:26 -0700)
src/prolog/ast.rs
src/prolog/machine/machine_state.rs
src/prolog/machine/mod.rs
src/prolog/parser

index a53f40e24ce07121366ba0d2b5c4ed5fc7e5c141..474bfc7257bdcd3a45ae9bdd3338bfaded4aaa94 100644 (file)
@@ -862,17 +862,7 @@ impl Addr {
             _ => false
         }
     }
-   
-    pub fn as_ref(&self) -> Option<Ref> {
-        match self {
-            &Addr::HeapCell(hc) => Some(Ref::HeapCell(hc)),
-            &Addr::StackCell(fr, sc) => Some(Ref::StackCell(fr, sc)),
-            &Addr::Lis(hc) => Some(Ref::HeapCell(hc)),
-            &Addr::Str(hc) => Some(Ref::HeapCell(hc)),
-            _ => None
-        }
-    }
-    
+       
     pub fn as_var(&self) -> Option<Ref> {
         match self {
             &Addr::HeapCell(hc) => Some(Ref::HeapCell(hc)),
@@ -892,7 +882,7 @@ impl Addr {
 impl From<Ref> for Addr {
     fn from(r: Ref) -> Self {
         match r {
-            Ref::HeapCell(hc) => Addr::HeapCell(hc),
+            Ref::HeapCell(hc)      => Addr::HeapCell(hc),
             Ref::StackCell(fr, sc) => Addr::StackCell(fr, sc)
         }
     }
index f5ee483faf4bd8988957da9e465db497246146a7..b1e08e8702fbfb9a697f35ed67eb311ff309bf61 100644 (file)
@@ -179,9 +179,9 @@ pub struct MachineState {
     pub(super) num_of_args: usize,
     pub(super) cp: CodePtr,
     pub(super) fail: bool,
-    pub(super) heap: Heap,
+    pub(crate) heap: Heap,
     pub(super) mode: MachineMode,
-    pub(super) and_stack: AndStack,
+    pub(crate) and_stack: AndStack,
     pub(super) or_stack: OrStack,
     pub(super) registers: Registers,
     pub(super) trail: Vec<Ref>,
@@ -221,7 +221,7 @@ impl MachineState {
             if self.b > 0 { self.or_stack[self.b - 1].global_index } else { 0 }) + 1
     }
 
-    pub fn store(&self, a: Addr) -> Addr {
+    pub(super) fn store(&self, a: Addr) -> Addr {
         match a {
             Addr::HeapCell(r)       => self.heap[r].as_addr(r),
             Addr::StackCell(fr, sc) => self.and_stack[fr][sc].clone(),
@@ -229,9 +229,7 @@ impl MachineState {
         }
     }
 
-    pub fn deref(&self, a: Addr) -> Addr {
-        let mut a = a;
-
+    pub(crate) fn deref(&self, mut a: Addr) -> Addr {        
         loop {
             let value = self.store(a.clone());
 
@@ -1134,11 +1132,14 @@ impl MachineState {
 
         for heap_value in self.ball.1.iter().cloned() {
             self.heap.push(match heap_value {
-                HeapCellValue::Addr(Addr::Con(c)) => HeapCellValue::Addr(Addr::Con(c)),
-                HeapCellValue::Addr(Addr::Lis(a)) => HeapCellValue::Addr(Addr::Lis(a - diff)),
+                HeapCellValue::Addr(Addr::Con(c)) =>
+                    HeapCellValue::Addr(Addr::Con(c)),
+                HeapCellValue::Addr(Addr::Lis(a)) =>
+                    HeapCellValue::Addr(Addr::Lis(a - diff)),
                 HeapCellValue::Addr(Addr::HeapCell(hc)) =>
                     HeapCellValue::Addr(Addr::HeapCell(hc - diff)),
-                HeapCellValue::Addr(Addr::Str(s)) => HeapCellValue::Addr(Addr::Str(s - diff)),
+                HeapCellValue::Addr(Addr::Str(s)) =>
+                    HeapCellValue::Addr(Addr::Str(s - diff)),
                 _ => heap_value
             });
         }
index 19ed0cb0acb08a403f730d67eb5d2fbd6b3092e5..259c06d9b578a3a3ceea3b9bae37f97564b4998c 100644 (file)
@@ -4,7 +4,7 @@ use prolog::codegen::*;
 use prolog::heapview::*;
 use prolog::fixtures::*;
 
-mod machine_state;
+pub(crate) mod machine_state;
 
 use std::collections::HashMap;
 use std::ops::Index;
index 57001ad9911a4a973fae5cf16e4be1273e3ad55f..96f4b3e33cc0cfabfbb9cb31fcb22012182653d2 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 57001ad9911a4a973fae5cf16e4be1273e3ad55f
+Subproject commit 96f4b3e33cc0cfabfbb9cb31fcb22012182653d2