]> Repositorios git - scryer-prolog.git/commitdiff
fix toplevel heap view
authorMark Thom <[email protected]>
Sun, 24 Mar 2019 16:10:43 +0000 (10:10 -0600)
committerMark Thom <[email protected]>
Sun, 24 Mar 2019 16:10:43 +0000 (10:10 -0600)
Cargo.toml
src/prolog/write.rs

index 3e537a6b2f80b51a7333d9437506b20ee874b865..e113c926be70ad08ac616ab6c6c38e726f126f31 100644 (file)
@@ -1,6 +1,6 @@
 [package]
 name = "scryer-prolog"
-version = "0.8.16"
+version = "0.8.17"
 authors = ["Mark Thom <[email protected]>"]
 repository = "https://github.com/mthom/scryer-prolog"
 description = "A modern Prolog implementation written mostly in Rust."
index 721394d9f1a0b36a47643a6f61dae5cd0ad105b6..c667c0f90fe2362e88d1884bdd24ce4132794aef 100644 (file)
@@ -373,10 +373,15 @@ pub fn print(wam: &mut Machine, result: EvalSession) {
     match result {
         EvalSession::InitialQuerySuccess(alloc_locs, mut heap_locs) =>
             loop {
-                if wam.or_stack_is_empty() {
-                    if heap_locs.is_empty() {
-                        let attr_goals = wam.attribute_goals(&heap_locs);
+                let bindings = {
+                    let mut output = PrinterOutputter::new();
+                    wam.toplevel_heap_view(&heap_locs, output).result()
+                };
 
+                let attr_goals = wam.attribute_goals(&heap_locs);
+
+                if wam.or_stack_is_empty() {
+                    if bindings.is_empty() {
                         if !attr_goals.is_empty() {
                             println!("{}.", attr_goals);
                         } else {
@@ -385,29 +390,20 @@ pub fn print(wam: &mut Machine, result: EvalSession) {
 
                         return;
                     }
-                } else if heap_locs.is_empty() {
+                } else if bindings.is_empty() && attr_goals.is_empty() {
                     print!("true");
                     stdout().flush().unwrap();
                 }
 
                 let mut raw_stdout = stdout().into_raw_mode().unwrap();
 
-                let bindings = if !heap_locs.is_empty() {
-                    let mut output = PrinterOutputter::new();
-                    wam.toplevel_heap_view(&heap_locs, output).result()
-                } else {
-                    "".to_string()
-                };
-
-                let attr_goals = wam.attribute_goals(&heap_locs);
-
                 if !attr_goals.is_empty() {
                     if bindings.is_empty() {
                         write!(raw_stdout, "{}", attr_goals).unwrap();
                     } else {
                         write!(raw_stdout, "{}, {}", bindings, attr_goals).unwrap();
                     }
-                } else {
+                } else if !bindings.is_empty() {
                     write!(raw_stdout, "{}", bindings).unwrap();
                 }
 
@@ -445,7 +441,7 @@ pub fn print(wam: &mut Machine, result: EvalSession) {
 
                     break;
                 }
-            },        
+            },
         EvalSession::Error(e) => println!("{}", e),
         _ => {}
     };