add an atom table.

This commit is contained in:
Mark Thom
2018-01-16 23:26:59 -07:00
parent 38cd9e5db7
commit d8be7b5b49
14 changed files with 276 additions and 181 deletions

View File

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