]> Repositorios git - scryer-prolog.git/commitdiff
codegen bug fix.
authorMark Thom <[email protected]>
Sat, 28 Jan 2017 06:26:25 +0000 (23:26 -0700)
committerMark Thom <[email protected]>
Sat, 28 Jan 2017 06:26:25 +0000 (23:26 -0700)
src/l1/codegen.rs
src/main.rs

index b0027d9e159b3df422a00b4c93055313c9ce5006..6579ef0b95d0c1c28ce355ebb49038146705aadb 100644 (file)
@@ -137,6 +137,8 @@ trait CompilationTarget<'a> {
     fn argument_to_value(usize, usize) -> Self;
     fn subterm_to_variable(usize) -> Self;
     fn subterm_to_value(usize) -> Self;
+
+    fn clause_arg_to_instr(usize) -> Self;
 }
 
 impl<'a> CompilationTarget<'a> for FactInstruction {
@@ -165,6 +167,10 @@ impl<'a> CompilationTarget<'a> for FactInstruction {
     fn subterm_to_value(val: usize) -> Self {
         FactInstruction::UnifyValue(val)
     }
+
+    fn clause_arg_to_instr(val: usize) -> Self {
+        FactInstruction::UnifyVariable(val)
+    }
 }
 
 impl<'a> CompilationTarget<'a> for QueryInstruction {
@@ -193,6 +199,10 @@ impl<'a> CompilationTarget<'a> for QueryInstruction {
     fn subterm_to_value(val: usize) -> Self {
         QueryInstruction::SetValue(val)
     }
+    
+    fn clause_arg_to_instr(val: usize) -> Self {
+        QueryInstruction::SetValue(val)
+    }
 }
 
 fn to_structure<'a, Target>(tm: &mut TermMarker<'a>,
@@ -212,7 +222,7 @@ fn non_var_subterm<'a, Target>(tm: &mut TermMarker<'a>, cell: &'a Cell<usize>)
     where Target: CompilationTarget<'a>
 {
     tm.mark_non_var(Level::Deep, cell);
-    Target::subterm_to_value(cell.get()) // should be to_value??
+    Target::clause_arg_to_instr(cell.get())
 }
 
 fn var_term<'a, Target>(tm: &mut TermMarker<'a>,
index f221409da17694fcbbae04b63d2e99980b2983ad..00878d92f12feb9f9dc0a0b3a21c7df7138ba484 100644 (file)
@@ -29,13 +29,13 @@ fn l1_repl() {
             Ok(TopLevel::Fact(fact)) => {
                 let mut compiled_fact = compile_fact(&fact);
                 let index = ms.code.len();
-                
+
                 ms.code.append(&mut compiled_fact);
                 ms.code_dir.insert((fact.name().clone(), fact.arity()), index);
             },
             Ok(TopLevel::Query(query)) => {
                 let compiled_query = compile_query(&query);
-
+                
                 for instruction in &compiled_query {
                     ms.execute_query_instr(instruction);