compile special instructions for partial strings when recognized

This commit is contained in:
Mark Thom
2020-04-11 21:53:28 -06:00
parent 92d8642133
commit 6e4b76a3b4
16 changed files with 737 additions and 302 deletions

View File

@@ -17,6 +17,8 @@ pub trait CompilationTarget<'a> {
fn to_void(_: usize) -> Self;
fn is_void_instr(&self) -> bool;
fn to_pstr(lvl: Level, string: String, r: RegType, has_tail: bool) -> Self;
fn incr_void_instr(&mut self);
fn constant_subterm(_: Constant) -> Self;
@@ -62,6 +64,10 @@ impl<'a> CompilationTarget<'a> for FactInstruction {
}
}
fn to_pstr(lvl: Level, string: String, r: RegType, has_tail: bool) -> Self {
FactInstruction::GetPartialString(lvl, string, r, has_tail)
}
fn incr_void_instr(&mut self) {
match self {
&mut FactInstruction::UnifyVoid(ref mut incr) => *incr += 1,
@@ -117,6 +123,10 @@ impl<'a> CompilationTarget<'a> for QueryInstruction {
QueryInstruction::PutList(lvl, reg)
}
fn to_pstr(lvl: Level, string: String, r: RegType, has_tail: bool) -> Self {
QueryInstruction::PutPartialString(lvl, string, r, has_tail)
}
fn to_void(subterms: usize) -> Self {
QueryInstruction::SetVoid(subterms)
}