]> Repositorios git - scryer-prolog.git/commitdiff
correct register overallocation
authorMark Thom <[email protected]>
Sat, 25 Mar 2017 18:26:06 +0000 (12:26 -0600)
committerMark Thom <[email protected]>
Sat, 25 Mar 2017 18:26:06 +0000 (12:26 -0600)
src/prolog/codegen.rs
src/prolog/io.rs

index 4c5592ae7135cb0721c67cccf1e6a4619c06fd3a..69c327f6a311efda3f186bf2a2e2ea7c7168c9b0 100644 (file)
@@ -234,12 +234,12 @@ impl<'a> TermMarker<'a> {
     }
 
     fn advance_at_head(&mut self, term: &'a Term) {
-        self.arg_c = 1;
-        self.temp_c = max(term.subterms(), self.temp_c) + 1;
+        self.arg_c  = 1;
+        self.temp_c = max(term.subterms() + 1, self.temp_c);
     }
 
     fn advance(&mut self, term: &'a Term) {
-        self.arg_c = 1;
+        self.arg_c  = 1;
         self.temp_c = term.subterms() + 1;
     }
 }
@@ -339,13 +339,9 @@ impl<'a> CodeGenerator<'a> {
         Target::to_list(lvl, cell.get())
     }
 
-    fn constant_subterm<Target>(&mut self,
-                                cell: &'a Cell<RegType>,
-                                constant: &'a Constant)
-                                -> Target
+    fn constant_subterm<Target>(&mut self, constant: &'a Constant) -> Target
         where Target: CompilationTarget<'a>
     {
-        self.marker.mark_non_var(Level::Deep, cell);
         Target::constant_subterm(constant.clone())
     }
 
@@ -407,8 +403,8 @@ impl<'a> CodeGenerator<'a> {
                 self.anon_var_term(Level::Deep),
             &Term::Cons(ref cell, _, _) | &Term::Clause(ref cell, _, _) =>
                 self.non_var_subterm(cell),
-            &Term::Constant(ref cell, ref constant) =>
-                self.constant_subterm(cell, constant),
+            &Term::Constant(_, ref constant) =>
+                self.constant_subterm(constant),
             &Term::Var(ref cell, ref var) =>
                 self.var_term(Level::Deep, cell, var)
         }
index 022c8471284268cc3476d2aabc95ac6194122e53..1ae4e1ee10d1a181d8e8f4afc08b6f667b4ed568 100644 (file)
@@ -241,7 +241,7 @@ Each predicate must have the same name and arity.";
             EvalResult::EntrySuccess
         },
         &Ok(TopLevel::Query(ref query)) => {
-            let compiled_query = cg.compile_query(&query);            
+            let compiled_query = cg.compile_query(&query);
             wam.run_query(compiled_query, &cg)
         },
         &Err(_) => {