nix = "0.15.0"
num-rug-adapter = { optional = true, version = "0.1.3" }
ordered-float = "0.5.0"
-prolog_parser = { version = "0.8.53", default-features = false }
+prolog_parser = { version = "0.8.54", default-features = false }
ref_thread_local = "0.0.0"
rug = { version = "1.4.0", optional = true }
rustyline = "6.0.0"
use std::rc::Rc;
use std::vec::Vec;
+#[derive(Debug)]
pub struct ArithInstructionIterator<'a> {
state_stack: Vec<TermIterState<'a>>,
}
}
}
+#[derive(Debug)]
pub enum ArithTermRef<'a> {
Constant(&'a Constant),
Op(ClauseName, usize), // name, arity.
}
}
+#[derive(Debug)]
pub struct ArithmeticEvaluator<'a> {
bindings: &'a AllocVarDict,
interm: Vec<ArithmeticTerm>,
use std::collections::BTreeMap;
-#[derive(Clone, Copy, Eq, PartialEq)]
+#[derive(Debug, Clone, Copy, Eq, PartialEq)]
pub enum CompareNumberQT {
GreaterThan,
LessThan,
}
}
-#[derive(Clone, Copy, PartialEq, Eq)]
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum CompareTermQT {
LessThan,
LessThanOrEqual,
}
}
-#[derive(Clone, PartialEq, Eq)]
+#[derive(Debug, Clone, PartialEq, Eq)]
pub enum ArithmeticTerm {
Reg(RegType),
Interm(usize),
}
}
-#[derive(Clone, Eq, PartialEq)]
+#[derive(Debug, Clone, Eq, PartialEq)]
pub enum InlinedClauseType {
CompareNumber(CompareNumberQT, ArithmeticTerm, ArithmeticTerm),
IsAtom(RegType),
}
}
-#[derive(Copy, Clone, Eq, PartialEq)]
+#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub enum SystemClauseType {
AbolishClause,
AbolishModuleClause,
}
}
-#[derive(Clone, Eq, PartialEq)]
+#[derive(Debug, Clone, Eq, PartialEq)]
pub enum BuiltInClauseType {
AcyclicTerm,
Arg,
Sort,
}
-#[derive(Clone, PartialEq, Eq)]
+#[derive(Debug, Clone, PartialEq, Eq)]
pub enum ClauseType {
BuiltIn(BuiltInClauseType),
CallN,
use std::rc::Rc;
use std::vec::Vec;
+#[derive(Debug)]
pub struct CodeGenerator<TermMarker> {
marker: TermMarker,
pub var_count: IndexMap<Rc<Var>, usize>,
non_counted_bt: bool,
}
+#[derive(Debug)]
pub struct ConjunctInfo<'a> {
pub perm_vs: VariableFixtures<'a>,
pub num_of_chunks: usize,
use std::collections::BTreeSet;
use std::rc::Rc;
+#[derive(Debug)]
pub struct DebrayAllocator {
bindings: IndexMap<Rc<Var>, VarData>,
arg_c: usize,
memberd_t(H2, [0,1,2,3,4,5,6,7,8,9], TH2),
memberd_t(M1, [0,1,2,3,4,5], TM1),
memberd_t(M2, [0,1,2,3,4,5,6,7,8,9], TM2),
- ( maplist(=(true), [TH1, TH2, TM1, TM2]) ->
+ ( maplist(=(true), [TH1, TH2, TM1, TM2]) ->
( H1 =:= 2 ->
( H2 =< 3 ->
T = true
use std::vec::Vec;
// labeled with chunk numbers.
+#[derive(Debug)]
pub enum VarStatus {
Perm(usize),
Temp(usize, TempVarData), // Perm(chunk_num) | Temp(chunk_num, _)
// Perm: 0 initially, a stack register once processed.
// Temp: labeled with chunk_num and temp offset (unassigned if 0).
+#[derive(Debug)]
pub enum VarData {
Perm(usize),
Temp(usize, usize, TempVarData),
}
}
+#[derive(Debug)]
pub struct TempVarData {
pub last_term_arity: usize,
pub use_set: OccurrenceSet,
type VariableFixture<'a> = (VarStatus, Vec<&'a Cell<VarReg>>);
+#[derive(Debug)]
pub struct VariableFixtures<'a>{
perm_vars: IndexMap<Rc<Var>, VariableFixture<'a>>,
last_chunk_temp_vars: IndexSet<Rc<Var>>
}
}
+#[derive(Debug)]
pub struct UnsafeVarMarker {
pub unsafe_vars: IndexMap<RegType, usize>,
pub safe_vars: IndexSet<RegType>,
// of vars (we get their adjoining cells this way).
pub type JumpStub = Vec<Term>;
-#[derive(Clone)]
+#[derive(Debug, Clone)]
pub enum TopLevel {
Declaration(Declaration),
Fact(Term, usize, usize), // Term, line_num, col_num
}
}
-#[derive(Clone, Copy)]
+#[derive(Debug, Clone, Copy)]
pub enum Level {
Deep,
Root,
}
}
-#[derive(Clone)]
+#[derive(Debug, Clone)]
pub enum QueryTerm {
// register, clause type, subterms, use default call policy.
Clause(Cell<RegType>, ClauseType, Vec<Box<Term>>, bool),
}
}
-#[derive(Clone)]
+#[derive(Debug, Clone)]
pub struct Rule {
pub head: (ClauseName, Vec<Box<Term>>, QueryTerm),
pub clauses: Vec<QueryTerm>,
}
-#[derive(Clone)]
+#[derive(Debug, Clone)]
pub struct Predicate(pub Vec<PredicateClause>);
impl Predicate {
}
}
-#[derive(Clone)]
+#[derive(Debug, Clone)]
pub enum ListingSource {
File(ClauseName, PathBuf), // filename, path
User,
pub type CompiledResult = (Predicate, VecDeque<TopLevel>);
-#[derive(Clone)]
+#[derive(Debug, Clone)]
pub enum PredicateClause {
Fact(Term, usize, usize), // Term, line number, column number.
Rule(Rule, usize, usize), // Term, line number, column number.
}
}
-#[derive(Clone)]
+#[derive(Debug, Clone)]
pub enum ModuleSource {
Library(ClauseName),
File(ClauseName),
pub type ScopedPredicateKey = (ClauseName, PredicateKey); // module name, predicate indicator.
-#[derive(Clone)]
+#[derive(Debug, Clone)]
pub enum MultiFileIndicator {
LocalScoped(ClauseName, usize), // name, arity
ModuleScoped(ScopedPredicateKey),
}
-#[derive(Clone)]
+#[derive(Debug, Clone)]
pub enum Declaration {
Dynamic(ClauseName, usize), // name, arity
EndOfFile,
}
}
-#[derive(Clone, PartialEq, Eq, PartialOrd, Ord)]
+#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
pub struct OpDecl(pub usize, pub Specifier, pub ClauseName);
impl OpDecl {
pub type ModuleDir = IndexMap<ClauseName, Module>;
-#[derive(Clone, PartialEq)]
+#[derive(Debug, Clone, PartialEq)]
pub enum ModuleExport {
OpDecl(OpDecl),
PredicateKey(PredicateKey),
}
-#[derive(Clone)]
+#[derive(Debug, Clone)]
pub struct ModuleDecl {
pub name: ClauseName,
pub exports: Vec<ModuleExport>,
}
+#[derive(Debug)]
pub struct Module {
pub atom_tbl: TabledData<Atom>,
pub module_decl: ModuleDecl,
pub listing_src: ListingSource,
}
-#[derive(Clone)]
+#[derive(Debug, Clone)]
pub enum Number {
Float(OrderedFloat<f64>),
Integer(Rc<Integer>),
use std::ops::Deref;
use std::vec::Vec;
+#[derive(Debug)]
pub struct HCPreOrderIterator<'a> {
pub machine_st: &'a MachineState,
pub state_stack: Vec<Addr>,
fn stack(&'b mut self) -> Self::MutStack;
}
+#[derive(Debug)]
pub struct HCPostOrderIterator<'a> {
base_iter: HCPreOrderIterator<'a>,
parent_stack: Vec<(usize, Addr)>, // number of children, parent node.
}
}
+#[derive(Debug)]
pub struct HCAcyclicIterator<'a> {
iter: HCPreOrderIterator<'a>,
seen: IndexSet<Addr>,
}
}
+#[derive(Debug)]
pub struct HCZippedAcyclicIterator<'a> {
i1: HCPreOrderIterator<'a>,
i2: HCPreOrderIterator<'a>,
use std::rc::Rc;
/* contains the location, name, precision and Specifier of the parent op. */
-#[derive(Clone)]
+#[derive(Debug, Clone)]
pub enum DirectedOp {
Left(ClauseName, SharedOpDesc),
Right(ClauseName, SharedOpDesc),
}
}
-#[derive(Clone)]
+#[derive(Debug, Clone)]
enum TokenOrRedirect {
Atom(ClauseName),
BarAsOp,
fn range_from(&self, range: RangeFrom<usize>) -> &str;
}
+#[derive(Debug)]
pub struct PrinterOutputter {
contents: String,
}
type ReverseHeapVarDict = IndexMap<Addr, Rc<Var>>;
+#[derive(Debug)]
pub struct HCPrinter<'a, Outputter> {
outputter: Outputter,
machine_st: &'a MachineState,
}
}
+#[derive(Debug)]
pub enum ChoiceInstruction {
DefaultRetryMeElse(usize),
DefaultTrustMe,
}
}
+#[derive(Debug)]
pub enum CutInstruction {
Cut(RegType),
GetLevel(RegType),
}
}
+#[derive(Debug)]
pub enum IndexedChoiceInstruction {
Retry(usize),
Trust(usize),
}
}
+#[derive(Debug)]
pub enum Line {
Arithmetic(ArithmeticInstruction),
Choice(ChoiceInstruction),
}
}
-#[derive(Clone)]
+#[derive(Debug, Clone)]
pub enum ArithmeticInstruction {
Add(ArithmeticTerm, ArithmeticTerm, usize),
Sub(ArithmeticTerm, ArithmeticTerm, usize),
}
}
+#[derive(Debug)]
pub enum ControlInstruction {
Allocate(usize), // num_frames.
// name, arity, perm_vars after threshold, last call, use default call policy.
}
}
+#[derive(Debug)]
pub enum IndexingInstruction {
SwitchOnTerm(usize, usize, usize, usize),
SwitchOnConstant(usize, IndexMap<Constant, usize>),
}
}
-#[derive(Clone)]
+#[derive(Debug, Clone)]
pub enum FactInstruction {
GetConstant(Level, Constant, RegType),
GetList(Level, RegType),
}
}
-#[derive(Clone)]
+#[derive(Debug, Clone)]
pub enum QueryInstruction {
GetVariable(RegType, usize),
PutConstant(Level, Constant, RegType),
use std::cell::Cell;
use std::collections::VecDeque;
+use std::fmt;
use std::iter::*;
use std::rc::Rc;
use std::vec::Vec;
-#[derive(Clone)]
+#[derive(Debug, Clone)]
pub enum TermRef<'a> {
AnonVar(Level),
Cons(Level, &'a Cell<RegType>, &'a Term, &'a Term),
}
}
+#[derive(Debug)]
pub enum TermIterState<'a> {
AnonVar(Level),
Constant(Level, &'a Cell<RegType>, &'a Constant),
}
}
+#[derive(Debug)]
pub struct QueryIterator<'a> {
state_stack: Vec<TermIterState<'a>>,
}
}
}
+#[derive(Debug)]
pub struct FactIterator<'a> {
state_queue: VecDeque<TermIterState<'a>>,
iterable_root: bool,
FactIterator::new(term, iterable_root)
}
+#[derive(Debug)]
pub enum ChunkedTerm<'a> {
HeadClause(ClauseName, &'a Vec<Box<Term>>),
BodyTerm(&'a QueryTerm),
cut_var_in_head: bool,
}
+impl<'a> fmt::Debug for ChunkedIterator<'a> {
+ fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
+ fmt.debug_struct("ChunkedIterator")
+ .field("chunk_num", &self.chunk_num)
+ // Hacky solution.
+ .field("iter", &"Box<dyn Iterator<Item = ChunkedTerm<'a>> + 'a>")
+ .field("deep_cut_encountered", &self.deep_cut_encountered)
+ .field("cut_var_in_head", &self.cut_var_in_head)
+ .finish()
+ }
+}
+
type ChunkedIteratorItem<'a> = (usize, usize, Vec<ChunkedTerm<'a>>);
type RuleBodyIteratorItem<'a> = (usize, usize, Vec<&'a QueryTerm>);
must_be(integer, Lower),
must_be(integer, Upper),
can_be(integer, X),
- between_(Lower, Upper, X).
+ between_(Lower, Upper, X).
between_(Lower, Upper, Lower) :-
Lower =< Upper.
wkl_add_to_new_answer_cluster(
wkl_worklist(Dll,_Ria,_FlagExecutingWork,_AlreadyInMetaworklist,_TableIdentifier),
Answer,AnswerClusterPointer
-) :-
+) :-
dll_append_left(Dll,wkl_answer_cluster(AnswerFlag),AnswerClusterPointer),
put_atts(AnswerFlag, wkl_answer_cluster([Answer])).
pub(super) type Bindings = Vec<(usize, Addr)>;
+#[derive(Debug)]
pub(super) struct AttrVarInitializer {
pub(super) attribute_goals: Vec<Addr>,
pub(super) attr_var_queue: Vec<usize>,
use std::collections::VecDeque;
use std::mem;
+#[derive(Debug)]
pub struct CodeRepo {
pub(super) cached_query: Code,
pub(super) goal_expanders: Code,
Ok(compiler.drop_expansions(&mut wam.code_repo))
}
+#[derive(Debug)]
pub struct GatherResult {
dynamic_clause_map: DynamicClauseMap,
pub(crate) worker_results: Vec<PredicateCompileQueue>,
in_situ_module_dir: ModuleStubDir,
}
+#[derive(Debug)]
pub struct ClauseCodeGenerator {
len_offset: usize,
code: Code,
}
}
+#[derive(Debug)]
pub struct ListingCompiler {
module: Option<Module>,
user_term_dir: TermDir,
type Trail = Vec<(Ref, HeapCellValue)>;
-#[derive(Clone, Copy)]
+#[derive(Debug, Clone, Copy)]
pub enum AttrVarPolicy {
DeepCopy,
StripAttributes
copy_term_state.copy_term_impl(addr);
}
+#[derive(Debug)]
struct CopyTermState<T: CopierTarget> {
trail: Trail,
scan: usize,
use std::ops::{Index, IndexMut};
use std::ptr;
+#[derive(Debug)]
pub(crate) struct StandardHeapTraits {}
impl RawBlockTraits for StandardHeapTraits {
}
}
+#[derive(Debug)]
pub(crate) struct HeapTemplate<T: RawBlockTraits> {
buf: RawBlock<T>,
_marker: PhantomData<HeapCellValue>,
}
}
+#[derive(Debug)]
pub(crate)
struct HeapIntoIter<T: RawBlockTraits> {
offset: usize,
}
}
+#[derive(Debug)]
pub(crate)
struct HeapIter<'a, T: RawBlockTraits> {
offset: usize,
}
}
+#[derive(Debug)]
pub(crate)
struct HeapIterMut<'a, T: RawBlockTraits> {
offset: usize,
pub(crate) type MachineStub = Vec<HeapCellValue>;
-#[derive(Clone, Copy)]
+#[derive(Debug, Clone, Copy)]
enum ErrorProvenance {
Constructed, // if constructed, offset the addresses.
Received, // otherwise, preserve the addresses.
}
+#[derive(Debug)]
pub(super) struct MachineError {
stub: MachineStub,
location: Option<(usize, usize)>, // line_num, col_num
}
}
-#[derive(Clone, Copy)]
+#[derive(Debug, Clone, Copy)]
pub enum Permission {
Access,
Create,
}
// from 7.12.2 b) of 13211-1:1995
-#[derive(Clone, Copy)]
+#[derive(Debug, Clone, Copy)]
pub enum ValidType {
Atom,
Atomic,
}
}
-#[derive(Clone, Copy)]
+#[derive(Debug, Clone, Copy)]
pub enum DomainErrorType {
NotLessThanZero,
Order,
}
// from 7.12.2 f) of 13211-1:1995
-#[derive(Clone, Copy)]
+#[derive(Debug, Clone, Copy)]
pub enum RepFlag {
Character,
CharacterCode,
}
// from 7.12.2 g) of 13211-1:1995
-#[derive(Clone, Copy)]
+#[derive(Debug, Clone, Copy)]
pub enum EvalError {
FloatOverflow,
Undefined,
}
// used by '$skip_max_list'.
-#[derive(Clone, Copy)]
+#[derive(Debug, Clone, Copy)]
pub(super) enum CycleSearchResult {
EmptyList,
NotList,
}
}
+#[derive(Debug)]
pub enum ExistenceError {
Module(ClauseName),
Procedure(ClauseName, usize),
Stream(Addr),
}
+#[derive(Debug)]
pub enum SessionError {
CannotOverwriteBuiltIn(ClauseName),
CannotOverwriteImport(ClauseName),
ParserError(ParserError),
}
+#[derive(Debug)]
pub enum EvalSession {
EntrySuccess,
Error(SessionError),
use std::cmp::Ordering;
use std::collections::{BTreeMap, VecDeque};
use std::convert::TryFrom;
+use std::fmt;
use std::mem;
use std::ops::{Add, AddAssign, Sub, SubAssign};
use std::rc::Rc;
-#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
+#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct OrderedOpDirKey(pub ClauseName, pub Fixity);
pub type OssifiedOpDir = BTreeMap<OrderedOpDirKey, (usize, Specifier)>;
-#[derive(Clone, PartialEq, Eq, Hash)]
+#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum DBRef {
NamedPred(ClauseName, usize, Option<SharedOpDesc>),
Op(
}
// 7.2
-#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
+#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
pub enum TermOrderCategory {
Variable,
FloatingPoint,
Compound,
}
-#[derive(Clone, Copy, PartialEq, Eq, Hash)]
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Addr {
AttrVar(usize),
Char(char),
Usize(usize),
}
-#[derive(Clone, Copy, Hash, Eq, PartialEq, PartialOrd)]
+#[derive(Debug, Clone, Copy, Hash, Eq, PartialEq, PartialOrd)]
pub enum Ref {
AttrVar(usize),
HeapCell(usize),
}
}
-#[derive(Clone, Copy)]
+#[derive(Debug, Clone, Copy)]
pub enum TrailRef {
Ref(Ref),
AttrVarHeapLink(usize),
}
}
+#[derive(Debug)]
pub enum HeapCellValue {
Addr(Addr),
Atom(ClauseName, Option<SharedOpDesc>),
}
}
-#[derive(Clone, Copy, Eq, PartialEq, Ord, PartialOrd)]
+#[derive(Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd)]
pub enum IndexPtr {
DynamicUndefined, // a predicate, declared as dynamic, whose location in code is as yet undefined.
Undefined,
UserTermExpansion
}
-#[derive(Clone, Ord, PartialOrd, Eq, PartialEq)]
+#[derive(Debug, Clone, Ord, PartialOrd, Eq, PartialEq)]
pub struct CodeIndex(pub Rc<RefCell<(IndexPtr, ClauseName)>>);
impl CodeIndex {
}
}
-#[derive(Clone, Copy, PartialEq)]
+#[derive(Debug, Clone, Copy, PartialEq)]
pub enum DynamicAssertPlace {
Back,
Front,
}
}
-#[derive(Clone, Copy, PartialEq)]
+#[derive(Debug, Clone, Copy, PartialEq)]
pub enum DynamicTransactionType {
Abolish,
Assert(DynamicAssertPlace),
Retract, // dynamic index of the clause to remove.
}
-#[derive(Clone, Copy, PartialOrd, Ord, PartialEq, Eq)]
+#[derive(Debug, Clone, Copy, PartialOrd, Ord, PartialEq, Eq)]
pub enum REPLCodePtr {
CompileBatch,
UseModule,
UseQualifiedModuleFromFile
}
-#[derive(Clone, PartialEq)]
+#[derive(Debug, Clone, PartialEq)]
pub enum CodePtr {
BuiltInClause(BuiltInClauseType, LocalCodePtr), // local is the successor call.
CallN(usize, LocalCodePtr, bool), // arity, local, last call.
pub type HeapVarDict = IndexMap<Rc<Var>, Addr>;
pub type AllocVarDict = IndexMap<Rc<Var>, VarData>;
-#[derive(Clone)]
+#[derive(Debug, Clone)]
pub struct DynamicPredicateInfo {
pub(super) clauses_subsection_p: usize, // a LocalCodePtr::DirEntry value.
}
pub type GlobalVarDir = IndexMap<ClauseName, (Ball, Option<usize>)>;
+#[derive(Debug)]
pub(crate) struct ModuleStub {
pub(crate) atom_tbl: TabledData<Atom>,
pub(crate) in_situ_code_dir: InSituCodeDir,
pub(crate) type ModuleStubDir = IndexMap<ClauseName, ModuleStub>;
pub(crate) type StreamAliasDir = IndexMap<ClauseName, Stream>;
+#[derive(Debug)]
pub struct IndexStore {
pub(super) atom_tbl: TabledData<Atom>,
pub(super) code_dir: CodeDir,
pub type CodeDir = BTreeMap<PredicateKey, CodeIndex>;
pub type TermDir = IndexMap<PredicateKey, (Predicate, VecDeque<TopLevel>)>;
+#[derive(Debug)]
pub struct TermDirQuantumEntry {
pub old_terms: (Predicate, VecDeque<TopLevel>),
pub new_terms: (Predicate, VecDeque<TopLevel>),
}
}
+#[derive(Debug)]
pub struct TermDirQuantum(IndexMap<PredicateKey, TermDirQuantumEntry>);
impl TermDirQuantum {
}
}
-#[derive(Clone, Copy, PartialEq, Eq, Ord, PartialOrd)]
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Ord, PartialOrd)]
pub enum CompileTimeHook {
GoalExpansion,
TermExpansion,
Owned(T),
}
+impl<'a, T: 'a + fmt::Debug> fmt::Debug for RefOrOwned<'a, T> {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ match self {
+ &RefOrOwned::Borrowed(ref borrowed) =>
+ write!(f, "Borrowed({:?})", borrowed),
+ &RefOrOwned::Owned(ref owned) => write!(f, "Owned({:?})", owned),
+ }
+ }
+}
+
impl<'a, T> RefOrOwned<'a, T> {
pub fn as_ref(&'a self) -> &'a T {
match self {
use std::cmp::Ordering;
use std::convert::TryFrom;
+use std::fmt;
use std::io::Write;
use std::mem;
use std::ops::{Index, IndexMut};
+#[derive(Debug)]
pub(crate) struct HeapPStrIter<'a> {
focus: Addr,
machine_st: &'a MachineState,
}
}
-#[derive(Clone, Copy)]
+#[derive(Debug, Clone, Copy)]
pub(crate) enum PStrIteratee {
Char(char),
PStrSegment(usize, usize),
} else {
Addr::EmptyList
};
-
+
return Some(PStrIteratee::PStrSegment(h, n));
} else {
unreachable!()
Some(s_offset)
}
+#[derive(Debug)]
pub struct Ball {
pub(super) boundary: usize,
pub(super) stub: Heap,
}
}
+#[derive(Debug)]
pub(super) struct CopyTerm<'a> {
state: &'a mut MachineState,
}
}
}
+#[derive(Debug)]
pub(super) struct CopyBallTerm<'a> {
stack: &'a mut Stack,
heap: &'a mut Heap,
pub type Registers = Vec<Addr>;
-#[derive(Clone, Copy)]
+#[derive(Debug, Clone, Copy)]
pub(super) enum MachineMode {
Read,
Write,
}
-#[derive(Clone)]
+#[derive(Debug, Clone)]
pub(super) enum HeapPtr {
HeapCell(usize),
PStrChar(usize, usize),
}
}
+#[derive(Debug)]
pub struct MachineState {
pub(super) s: HeapPtr,
pub(super) p: CodePtr,
pub(crate) type CallResult = Result<(), Vec<HeapCellValue>>;
-pub(crate) trait CallPolicy: Any {
+pub(crate) trait CallPolicy: Any + fmt::Debug {
fn retry_me_else(&mut self, machine_st: &mut MachineState, offset: usize) -> CallResult {
let b = machine_st.b;
let n = machine_st.stack.index_or_frame(b).prelude.univ_prelude.num_cells;
downcast!(dyn CallPolicy);
+#[derive(Debug)]
pub(crate) struct DefaultCallPolicy {}
impl CallPolicy for DefaultCallPolicy {}
+#[derive(Debug)]
pub(crate) struct CWILCallPolicy {
pub(crate) prev_policy: Box<dyn CallPolicy>,
count: Integer,
}
}
-pub(crate) trait CutPolicy: Any {
+pub(crate) trait CutPolicy: Any + fmt::Debug {
// returns true iff we fail or cut redirected the MachineState's p itself
fn cut(&mut self, machine_st: &mut MachineState, r: RegType) -> bool;
}
false
}
+#[derive(Debug)]
pub(crate) struct DefaultCutPolicy {}
pub(super) fn deref_cut(machine_st: &mut MachineState, r: RegType) {
}
}
+#[derive(Debug)]
pub(crate) struct SCCCutPolicy {
// locations of cleaners, cut points, the previous block
cont_pts: Vec<(Addr, usize, usize)>,
use std::rc::Rc;
use std::sync::atomic::AtomicBool;
+#[derive(Debug)]
pub struct MachinePolicies {
call_policy: Box<dyn CallPolicy>,
cut_policy: Box<dyn CutPolicy>,
}
}
+#[derive(Debug)]
pub struct Machine {
pub(super) machine_st: MachineState,
pub(super) inner_heap: Heap,
use std::slice;
use std::str;
+#[derive(Debug)]
pub struct PartialString {
buf: *const u8,
len: usize,
terminator_idx
}
+#[derive(Debug)]
pub struct PStrIter {
buf: *const u8,
len: usize,
}
}
+#[derive(Debug)]
pub(crate) struct RawBlock<T: RawBlockTraits> {
pub(crate) size: usize,
pub(crate) base: *const u8,
use std::ops::{Index, IndexMut};
use std::ptr;
+#[derive(Debug)]
struct StackTraits {}
impl RawBlockTraits for StackTraits {
(size & !(align - 1)) + align
}
+#[derive(Debug)]
pub struct Stack {
buf: RawBlock<StackTraits>,
_marker: PhantomData<Addr>,
}
}
-#[derive(Clone, Copy)]
+#[derive(Debug, Clone, Copy)]
pub struct FramePrelude {
pub num_cells: usize,
}
+#[derive(Debug)]
pub struct AndFramePrelude {
pub univ_prelude: FramePrelude,
pub e: usize,
pub interrupt_cp: LocalCodePtr,
}
+#[derive(Debug)]
pub struct AndFrame {
pub prelude: AndFramePrelude,
}
}
}
+#[derive(Debug)]
pub struct OrFramePrelude {
pub univ_prelude: FramePrelude,
pub e: usize,
pub attr_var_init_bindings_b: usize,
}
+#[derive(Debug)]
pub struct OrFrame {
pub prelude: OrFramePrelude,
}
use std::net::TcpStream;
use std::rc::Rc;
-#[derive(Clone, Copy, PartialEq, Eq, Hash)]
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum StreamType {
Binary,
Text,
}
-#[derive(Clone, Copy, PartialEq, Eq, Hash)]
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum EOFAction {
EOFCode,
Error,
TcpStream(TcpStream),
}
-#[derive(Clone)]
+impl fmt::Debug for StreamInstance {
+ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
+ match self {
+ &StreamInstance::Bytes(ref bytes) =>
+ write!(fmt, "Bytes({:?})", bytes),
+ &StreamInstance::DynReadSource(_) =>
+ write!(fmt, "DynReadSource(_)"), // Hacky solution.
+ &StreamInstance::File(ref file) => write!(fmt, "File({:?})", file),
+ &StreamInstance::Null => write!(fmt, "Null"),
+ &StreamInstance::ReadlineStream(ref readline_stream) =>
+ write!(fmt, "ReadlineStream({:?})", readline_stream),
+ &StreamInstance::Stdin => write!(fmt, "Stdin"),
+ &StreamInstance::Stdout => write!(fmt, "Stdout"),
+ &StreamInstance::TcpStream(ref tcp_stream) =>
+ write!(fmt, "TcpStream({:?})", tcp_stream),
+ }
+ }
+}
+
+#[derive(Debug, Clone)]
struct WrappedStreamInstance(Rc<RefCell<StreamInstance>>);
impl WrappedStreamInstance {
impl Error for StreamError {}
-#[derive(Clone, PartialEq, Eq, Hash)]
+#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct StreamOptions {
pub stream_type: StreamType,
pub reposition: bool,
}
}
-#[derive(Clone, PartialEq, Eq, Hash)]
+#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Stream {
pub options: StreamOptions,
stream_inst: WrappedStreamInstance,
c
}
+#[derive(Debug)]
struct BrentAlgState {
hare: Addr,
tortoise: Addr,
}
}
+#[derive(Debug)]
pub struct TermStream<'a> {
stack: Vec<Term>,
pub(crate) wam: &'a mut Machine,
top_level_terms: Vec<(Term, usize, usize)>, // term, line_num, col_num.
}
+#[derive(Debug)]
pub struct ExpansionAdditionResult {
term_expansion_additions: (Predicate, VecDeque<TopLevel>),
goal_expansion_additions: (Predicate, VecDeque<TopLevel>),
use std::cell::Cell;
use std::collections::VecDeque;
use std::convert::TryFrom;
+use std::fmt;
use std::mem;
use std::ops::DerefMut;
use std::rc::Rc;
Local(&'a mut T)
}
+impl<'a, T: fmt::Debug> fmt::Debug for IndexSource<'a, T> {
+ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
+ match self {
+ IndexSource::TermStream => write!(fmt, "TermStream"),
+ IndexSource::Local(ref local) => write!(fmt, "Local({:?})", local),
+ }
+ }
+}
+
fn op_dir<'a, 'b: 'a>(from: &'b IndexSource<'a, IndexStore>) -> RefOrOwned<'a, OpDir> {
match from {
IndexSource::TermStream => RefOrOwned::Owned(OpDir::new()),
}
}
+#[derive(Debug)]
struct CompositeIndices<'a, 'b, 'c> {
term_stream: &'b mut TermStream<'a>,
index_src: IndexSource<'c, IndexStore>,
}
}
+#[derive(Debug)]
struct RelationWorker {
flags: MachineFlags,
dynamic_clauses: Vec<(Term, Term)>, // Head, Body.
pub type DynamicClauseMap = IndexMap<(ClauseName, usize), DynamicClause>;
+#[derive(Debug)]
pub struct TopLevelBatchWorker<'a> {
pub(crate) term_stream: TermStream<'a>,
rel_worker: RelationWorker,
}
}
+ #[derive(Debug)]
pub struct ReadlineStream {
rl: Editor<()>,
pending_input: Cursor<String>,
term_writer.write_term_to_heap(term)
}
+#[derive(Debug)]
struct TermWriter<'a> {
machine_st: &'a mut MachineState,
queue: SubtermDeque,
var_dict: HeapVarDict,
}
+#[derive(Debug)]
pub struct TermWriteResult {
pub(crate) heap_loc: usize,
pub(crate) var_dict: HeapVarDict,
assertz((p(X, Y) :- q(Z), p(X, X))),
once(p(X,b)),
retract((p(X, Y) :- q(Z), p(X, X))),
- retract(q(z)).
+ retract(q(z)).
:- initialization(test_queries_on_predicates).
findall(Pat, catch(setup_call_cleanup(true,throw(goal),throw(cl)), Pat, true), [goal]),
findall(Pat, catch(( setup_call_cleanup(true,(G=1;G=2),throw(cl)), throw(cont)), Pat, true), [cont]),
findall([X,Y], (setup_call_cleanup(true, (X=1;X=2), writeq(a)), setup_call_cleanup(true,(Y=1;Y=2),writeq(b)), !), [[1,1]]).
-
+
:- initialization(test_queries_on_setup_call_cleanup).