codegen bug fix.
This commit is contained in:
@@ -137,6 +137,8 @@ trait CompilationTarget<'a> {
|
|||||||
fn argument_to_value(usize, usize) -> Self;
|
fn argument_to_value(usize, usize) -> Self;
|
||||||
fn subterm_to_variable(usize) -> Self;
|
fn subterm_to_variable(usize) -> Self;
|
||||||
fn subterm_to_value(usize) -> Self;
|
fn subterm_to_value(usize) -> Self;
|
||||||
|
|
||||||
|
fn clause_arg_to_instr(usize) -> Self;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> CompilationTarget<'a> for FactInstruction {
|
impl<'a> CompilationTarget<'a> for FactInstruction {
|
||||||
@@ -165,6 +167,10 @@ impl<'a> CompilationTarget<'a> for FactInstruction {
|
|||||||
fn subterm_to_value(val: usize) -> Self {
|
fn subterm_to_value(val: usize) -> Self {
|
||||||
FactInstruction::UnifyValue(val)
|
FactInstruction::UnifyValue(val)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn clause_arg_to_instr(val: usize) -> Self {
|
||||||
|
FactInstruction::UnifyVariable(val)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> CompilationTarget<'a> for QueryInstruction {
|
impl<'a> CompilationTarget<'a> for QueryInstruction {
|
||||||
@@ -193,6 +199,10 @@ impl<'a> CompilationTarget<'a> for QueryInstruction {
|
|||||||
fn subterm_to_value(val: usize) -> Self {
|
fn subterm_to_value(val: usize) -> Self {
|
||||||
QueryInstruction::SetValue(val)
|
QueryInstruction::SetValue(val)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn clause_arg_to_instr(val: usize) -> Self {
|
||||||
|
QueryInstruction::SetValue(val)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn to_structure<'a, Target>(tm: &mut TermMarker<'a>,
|
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>
|
where Target: CompilationTarget<'a>
|
||||||
{
|
{
|
||||||
tm.mark_non_var(Level::Deep, cell);
|
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>,
|
fn var_term<'a, Target>(tm: &mut TermMarker<'a>,
|
||||||
|
|||||||
@@ -29,13 +29,13 @@ fn l1_repl() {
|
|||||||
Ok(TopLevel::Fact(fact)) => {
|
Ok(TopLevel::Fact(fact)) => {
|
||||||
let mut compiled_fact = compile_fact(&fact);
|
let mut compiled_fact = compile_fact(&fact);
|
||||||
let index = ms.code.len();
|
let index = ms.code.len();
|
||||||
|
|
||||||
ms.code.append(&mut compiled_fact);
|
ms.code.append(&mut compiled_fact);
|
||||||
ms.code_dir.insert((fact.name().clone(), fact.arity()), index);
|
ms.code_dir.insert((fact.name().clone(), fact.arity()), index);
|
||||||
},
|
},
|
||||||
Ok(TopLevel::Query(query)) => {
|
Ok(TopLevel::Query(query)) => {
|
||||||
let compiled_query = compile_query(&query);
|
let compiled_query = compile_query(&query);
|
||||||
|
|
||||||
for instruction in &compiled_query {
|
for instruction in &compiled_query {
|
||||||
ms.execute_query_instr(instruction);
|
ms.execute_query_instr(instruction);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user