]> Repositorios git - scryer-prolog.git/commitdiff
fix bug with mark_non_var
authorMark Thom <[email protected]>
Mon, 8 Oct 2018 06:34:08 +0000 (00:34 -0600)
committerMark Thom <[email protected]>
Mon, 8 Oct 2018 06:34:08 +0000 (00:34 -0600)
README.md
src/prolog/compile.rs
src/prolog/debray_allocator.rs
src/prolog/lib/dcgs.pl
src/prolog/machine/mod.rs

index 60591bc810313600bda0461eec52254745ecd8cb..7fb1e25e8faf9483e1d56eedb4ad16bdf1fd755f 100644 (file)
--- a/README.md
+++ b/README.md
@@ -35,7 +35,7 @@ Extend rusty-wam to include the following, among other features:
     - A representation of 'partial strings' as difference lists
       of characters (_done_).
 * `term_expansion/2` and `goal_expansion/2` (_in progress_).
-* Definite Clause Grammars.
+* Definite Clause Grammars (_in progress_).
 * Attributed variables using the SICStus Prolog interface and
   semantics. Adding coroutines like `dif/2`, `freeze/2`, etc.
   is straightforward with attributed variables.
index f45cbdc81f69147dd384a1b3c62caa1279650c6c..8ef35af2834b66dfa5c6c0e70118fc7cbe665501 100644 (file)
@@ -220,7 +220,7 @@ impl ListingCompiler {
                                                  wam.machine_flags())?;
 
             compile_appendix(&mut decl_code, &queue, non_counted_bt, wam.machine_flags())?;
-
+            
             let idx = code_dir.entry((name, arity)).or_insert(CodeIndex::default());
             set_code_index!(idx, IndexPtr::Index(p), self.get_module_name());
 
@@ -271,7 +271,7 @@ impl ListingCompiler {
                 let mut code = cg.compile_predicate(&(preds.0).0)?;
 
                 compile_appendix(&mut code, &preds.1, false, flags)?;
-
+                
                 Ok(code_repo.term_expanders = code)
             },
             Declaration::NonCountedBacktracking(name, arity) =>
@@ -351,7 +351,7 @@ fn compile_listing<R: Read>(wam: &mut Machine, src: R, mut indices: IndexStore)
 
     try_eval_session!(compiler.add_code(wam, module_code, indices));
     try_eval_session!(compiler.add_code(wam, toplvl_code, results.toplevel_indices));
-
+  
     EvalSession::EntrySuccess
 }
 
index 549cbb335b2a4e4eed46b440f05902f279c75367..e94b8fc66080a321bf02af81b2192f18cbdd6bdc 100644 (file)
@@ -231,24 +231,23 @@ impl<'a> Allocator<'a> for DebrayAllocator
         where Target: CompilationTarget<'a>
     {
         let r = cell.get();
+        
+        let r = match lvl {
+            Level::Shallow => {
+                let k = self.arg_c;
+                
+                if let GenContext::Last(chunk_num) = term_loc {
+                    self.evacuate_arg(chunk_num, target);
+                }
+                
+                self.arg_c += 1;
+                RegType::Temp(k)
+            },
+            _ if r.reg_num() == 0 => RegType::Temp(self.alloc_reg_to_non_var()),
+            _ => r
+        };
 
-        if r.reg_num() == 0 {
-            let r = match lvl {
-                Level::Shallow => {
-                    let k = self.arg_c;
-
-                    if let GenContext::Last(chunk_num) = term_loc {
-                        self.evacuate_arg(chunk_num, target);
-                    }
-
-                    self.arg_c += 1;
-                    RegType::Temp(k)
-                },
-                _ => RegType::Temp(self.alloc_reg_to_non_var())
-            };
-
-            cell.set(r);
-        }
+        cell.set(r);        
     }
 
     fn mark_var<Target>(&mut self, var: Rc<Var>, lvl: Level, cell: &'a Cell<VarReg>,
index f2640a282f320f659b2ebba9cdb6c278d43acbe3..7bad699732d87d7f9e05ddff88dc03f2347abec7 100644 (file)
@@ -25,7 +25,7 @@ term_expansion(Term0, (ModHead :- ModBody)) :-
     !,
     nonvar(Head),
     Head =.. [RuleName | Args],
-    append(Args, ['$VAR'(0), '$VAR'(N)], ModArgs),
+    append(Args, ['$VAR'(0), '$VAR'(N)], ModArgs), %% problematic line.
     ModHead =.. [RuleName | ModArgs],
     nonvar(Body),
     expand_body(Body, ModBody1, 0, N1),
index b4c21f1158ab0dfee0c30709143cf768edade895..0370a58be6aadf75ed140843898df1b4caba5bb9 100644 (file)
@@ -317,7 +317,7 @@ impl Machine {
 
                 continue;
             }
-
+                        
             self.indices.code_dir.insert(key.clone(), idx.clone());
         }
 
@@ -347,9 +347,9 @@ impl Machine {
             self.machine_st.copy_and_align_ball_to_heap();
 
             let error_str = self.machine_st.print_exception(Addr::HeapCell(h),
-                                                    &heap_locs,
-                                                    TermFormatter {},
-                                                    PrinterOutputter::new())
+                                                            &heap_locs,
+                                                            TermFormatter {},
+                                                            PrinterOutputter::new())
                                 .result();
 
             EvalSession::from(SessionError::QueryFailureWithException(error_str))