implement new disjunction compilation

This commit is contained in:
Mark
2023-06-17 16:28:56 -06:00
parent b205abe949
commit 0e583d620a
32 changed files with 2877 additions and 2980 deletions

View File

@@ -29,11 +29,13 @@ pub(crate) trait CompilationTarget<'a> {
fn argument_to_variable(r: RegType, r: usize) -> Instruction;
fn argument_to_value(r: RegType, val: usize) -> Instruction;
fn unsafe_argument_to_value(r: RegType, val: usize) -> Instruction;
fn move_to_register(r: RegType, val: usize) -> Instruction;
fn subterm_to_variable(r: RegType) -> Instruction;
fn subterm_to_value(r: RegType) -> Instruction;
fn unsafe_subterm_to_value(r: RegType) -> Instruction;
fn clause_arg_to_instr(r: RegType) -> Instruction;
}
@@ -42,7 +44,7 @@ impl<'a> CompilationTarget<'a> for FactInstruction {
type Iterator = FactIterator<'a>;
fn iter(term: &'a Term) -> Self::Iterator {
breadth_first_iter(term, false) // do not iterate over the root clause if one exists.
breadth_first_iter(term, RootIterationPolicy::NotIterated)
}
fn to_constant(lvl: Level, constant: Literal, reg: RegType) -> Instruction {
@@ -95,6 +97,10 @@ impl<'a> CompilationTarget<'a> for FactInstruction {
Instruction::GetValue(arg, val)
}
fn unsafe_argument_to_value(arg: RegType, val: usize) -> Instruction {
Instruction::GetValue(arg, val)
}
fn subterm_to_variable(val: RegType) -> Instruction {
Instruction::UnifyVariable(val)
}
@@ -103,6 +109,10 @@ impl<'a> CompilationTarget<'a> for FactInstruction {
Instruction::UnifyValue(val)
}
fn unsafe_subterm_to_value(val: RegType) -> Instruction {
Instruction::UnifyLocalValue(val)
}
fn clause_arg_to_instr(val: RegType) -> Instruction {
Instruction::UnifyVariable(val)
}
@@ -165,6 +175,13 @@ impl<'a> CompilationTarget<'a> for QueryInstruction {
Instruction::PutValue(arg, val)
}
fn unsafe_argument_to_value(arg: RegType, val: usize) -> Instruction {
match arg {
RegType::Perm(p) => Instruction::PutUnsafeValue(p, val),
RegType::Temp(_) => Instruction::PutValue(arg, val),
}
}
fn subterm_to_variable(val: RegType) -> Instruction {
Instruction::SetVariable(val)
}
@@ -173,6 +190,10 @@ impl<'a> CompilationTarget<'a> for QueryInstruction {
Instruction::SetValue(val)
}
fn unsafe_subterm_to_value(val: RegType) -> Instruction {
Instruction::SetLocalValue(val)
}
fn clause_arg_to_instr(val: RegType) -> Instruction {
Instruction::SetValue(val)
}