major refactor.

This commit is contained in:
Mark Thom
2018-02-25 12:13:07 -07:00
parent 05c1275acf
commit cf9db43d5b
20 changed files with 735 additions and 813 deletions

View File

@@ -1,6 +1,5 @@
use prolog::ast::*;
use prolog::iterators::*;
use prolog::tabled_rc::*;
pub trait CompilationTarget<'a> {
type Iterator : Iterator<Item=TermRef<'a>>;
@@ -9,7 +8,7 @@ pub trait CompilationTarget<'a> {
fn to_constant(Level, Constant, RegType) -> Self;
fn to_list(Level, RegType) -> Self;
fn to_structure(Level, TabledRc<Atom>, usize, RegType, Option<Fixity>) -> Self;
fn to_structure(ClauseType, usize, RegType) -> Self;
fn to_void(usize) -> Self;
fn is_void_instr(&self) -> bool;
@@ -40,11 +39,9 @@ impl<'a> CompilationTarget<'a> for FactInstruction {
FactInstruction::GetConstant(lvl, constant, reg)
}
fn to_structure(lvl: Level, atom: TabledRc<Atom>, arity: usize,
reg: RegType, fixity: Option<Fixity>)
-> Self
fn to_structure(ct: ClauseType, arity: usize, reg: RegType) -> Self
{
FactInstruction::GetStructure(lvl, atom, arity, reg, fixity)
FactInstruction::GetStructure(ct, arity, reg)
}
fn to_list(lvl: Level, reg: RegType) -> Self {
@@ -105,11 +102,9 @@ impl<'a> CompilationTarget<'a> for QueryInstruction {
term.post_order_iter()
}
fn to_structure(lvl: Level, atom: TabledRc<Atom>, arity: usize,
reg: RegType, fixity: Option<Fixity>)
-> Self
fn to_structure(ct: ClauseType, arity: usize, r: RegType) -> Self
{
QueryInstruction::PutStructure(lvl, atom, arity, reg, fixity)
QueryInstruction::PutStructure(ct, arity, r)
}
fn to_constant(lvl: Level, constant: Constant, reg: RegType) -> Self {