]> Repositorios git - scryer-prolog.git/commitdiff
Implemented the Debug trait for all data structures
authornotoria <[email protected]>
Sun, 26 Apr 2020 00:18:45 +0000 (02:18 +0200)
committernotoria <[email protected]>
Sun, 26 Apr 2020 00:20:24 +0000 (02:20 +0200)
33 files changed:
Cargo.toml
src/prolog/arithmetic.rs
src/prolog/clause_types.rs
src/prolog/codegen.rs
src/prolog/debray_allocator.rs
src/prolog/examples/least_time.pl
src/prolog/fixtures.rs
src/prolog/forms.rs
src/prolog/heap_iter.rs
src/prolog/heap_print.rs
src/prolog/instructions.rs
src/prolog/iterators.rs
src/prolog/lib/between.pl
src/prolog/lib/tabling/batched_worklist.pl
src/prolog/machine/attributed_variables.rs
src/prolog/machine/code_repo.rs
src/prolog/machine/compile.rs
src/prolog/machine/copier.rs
src/prolog/machine/heap.rs
src/prolog/machine/machine_errors.rs
src/prolog/machine/machine_indices.rs
src/prolog/machine/machine_state.rs
src/prolog/machine/mod.rs
src/prolog/machine/partial_string.rs
src/prolog/machine/raw_block.rs
src/prolog/machine/stack.rs
src/prolog/machine/streams.rs
src/prolog/machine/system_calls.rs
src/prolog/machine/term_expansion.rs
src/prolog/machine/toplevel.rs
src/prolog/read.rs
src/tests/predicates.pl
src/tests/setup_call_cleanup.pl

index 462ca3565e59dbf04cea0ef41ae43d98e6d52233..8cc5497a7fa869f47c40a55116fedf65bc8d8666 100644 (file)
@@ -27,7 +27,7 @@ libc = "0.2.62"
 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"
index 6946f5f415430ec4c5e75f44d5d69d57d1c49a98..fb20678e4ee7b951b2de70fb5ea3f2668705950b 100644 (file)
@@ -23,6 +23,7 @@ use std::ops::{Add, Div, Mul, Neg, Sub};
 use std::rc::Rc;
 use std::vec::Vec;
 
+#[derive(Debug)]
 pub struct ArithInstructionIterator<'a> {
     state_stack: Vec<TermIterState<'a>>,
 }
@@ -68,6 +69,7 @@ impl<'a> ArithInstructionIterator<'a> {
     }
 }
 
+#[derive(Debug)]
 pub enum ArithTermRef<'a> {
     Constant(&'a Constant),
     Op(ClauseName, usize), // name, arity.
@@ -109,6 +111,7 @@ impl<'a> Iterator for ArithInstructionIterator<'a> {
     }
 }
 
+#[derive(Debug)]
 pub struct ArithmeticEvaluator<'a> {
     bindings: &'a AllocVarDict,
     interm: Vec<ArithmeticTerm>,
index 756080ca82c5a8f34baa544737ae7f1cb3f5ed28..9b550c35b859e5aed1d0415545ab6980fc2ea83b 100644 (file)
@@ -8,7 +8,7 @@ use ref_thread_local::RefThreadLocal;
 
 use std::collections::BTreeMap;
 
-#[derive(Clone, Copy, Eq, PartialEq)]
+#[derive(Debug, Clone, Copy, Eq, PartialEq)]
 pub enum CompareNumberQT {
     GreaterThan,
     LessThan,
@@ -31,7 +31,7 @@ impl CompareNumberQT {
     }
 }
 
-#[derive(Clone, Copy, PartialEq, Eq)]
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
 pub enum CompareTermQT {
     LessThan,
     LessThanOrEqual,
@@ -50,7 +50,7 @@ impl CompareTermQT {
     }
 }
 
-#[derive(Clone, PartialEq, Eq)]
+#[derive(Debug, Clone, PartialEq, Eq)]
 pub enum ArithmeticTerm {
     Reg(RegType),
     Interm(usize),
@@ -67,7 +67,7 @@ impl ArithmeticTerm {
     }
 }
 
-#[derive(Clone, Eq, PartialEq)]
+#[derive(Debug, Clone, Eq, PartialEq)]
 pub enum InlinedClauseType {
     CompareNumber(CompareNumberQT, ArithmeticTerm, ArithmeticTerm),
     IsAtom(RegType),
@@ -145,7 +145,7 @@ impl InlinedClauseType {
     }
 }
 
-#[derive(Copy, Clone, Eq, PartialEq)]
+#[derive(Debug, Copy, Clone, Eq, PartialEq)]
 pub enum SystemClauseType {
     AbolishClause,
     AbolishModuleClause,
@@ -557,7 +557,7 @@ impl SystemClauseType {
     }
 }
 
-#[derive(Clone, Eq, PartialEq)]
+#[derive(Debug, Clone, Eq, PartialEq)]
 pub enum BuiltInClauseType {
     AcyclicTerm,
     Arg,
@@ -575,7 +575,7 @@ pub enum BuiltInClauseType {
     Sort,
 }
 
-#[derive(Clone, PartialEq, Eq)]
+#[derive(Debug, Clone, PartialEq, Eq)]
 pub enum ClauseType {
     BuiltIn(BuiltInClauseType),
     CallN,
index 34d5a1f2b59d8f129906aa78e4eec3a890f55add..ffe9490d5a1a7e66907ffbf194276c82f3ad00a3 100644 (file)
@@ -17,12 +17,14 @@ use std::cell::Cell;
 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,
index 28eb44016612b870e330dced9c4d7355c66752f1..64fa1461ce2a77cd129ef4acd8c2336e141d674d 100644 (file)
@@ -12,6 +12,7 @@ use std::cell::Cell;
 use std::collections::BTreeSet;
 use std::rc::Rc;
 
+#[derive(Debug)]
 pub struct DebrayAllocator {
     bindings: IndexMap<Rc<Var>, VarData>,
     arg_c: usize,
index 4f04034036ea9f1c8beaef17aea43671fc26746f..100c68d5b6de5174021a052ae7e4ee8e33132b78 100644 (file)
@@ -30,7 +30,7 @@ valid_time([H1,H2,M1,M2], T) :-
     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
index 6400bfec7c90d3423bf4f776d3d051f2ca255c9b..70a3b9b83afbb65f65cda78c339b58fc1d6e6050 100644 (file)
@@ -13,6 +13,7 @@ use std::rc::Rc;
 use std::vec::Vec;
 
 // labeled with chunk numbers.
+#[derive(Debug)]
 pub enum VarStatus {
     Perm(usize),
     Temp(usize, TempVarData), // Perm(chunk_num) | Temp(chunk_num, _)
@@ -22,6 +23,7 @@ pub type OccurrenceSet = BTreeSet<(GenContext, usize)>;
 
 // 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),
@@ -36,6 +38,7 @@ impl VarData {
     }
 }
 
+#[derive(Debug)]
 pub struct TempVarData {
     pub last_term_arity: usize,
     pub use_set: OccurrenceSet,
@@ -79,6 +82,7 @@ impl TempVarData {
 
 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>>
@@ -248,6 +252,7 @@ impl<'a> VariableFixtures<'a> {
     }
 }
 
+#[derive(Debug)]
 pub struct UnsafeVarMarker {
     pub unsafe_vars: IndexMap<RegType, usize>,
     pub safe_vars: IndexSet<RegType>,
index 95af1e8ea4d3d57dff1a4a0df86b16be024b2df4..9f95a855c81a9d27b1cce129c75b1feb0a02fc8d 100644 (file)
@@ -22,7 +22,7 @@ pub type PredicateKey = (ClauseName, usize); // name, arity.
 // 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
@@ -42,7 +42,7 @@ impl TopLevel {
     }
 }
 
-#[derive(Clone, Copy)]
+#[derive(Debug, Clone, Copy)]
 pub enum Level {
     Deep,
     Root,
@@ -58,7 +58,7 @@ impl Level {
     }
 }
 
-#[derive(Clone)]
+#[derive(Debug, Clone)]
 pub enum QueryTerm {
     // register, clause type, subterms, use default call policy.
     Clause(Cell<RegType>, ClauseType, Vec<Box<Term>>, bool),
@@ -86,13 +86,13 @@ impl QueryTerm {
     }
 }
 
-#[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 {
@@ -114,7 +114,7 @@ impl Predicate {
     }
 }
 
-#[derive(Clone)]
+#[derive(Debug, Clone)]
 pub enum ListingSource {
     File(ClauseName, PathBuf), // filename, path
     User,
@@ -326,7 +326,7 @@ impl ClauseConsistency for Predicate {
 
 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.
@@ -371,7 +371,7 @@ impl PredicateClause {
     }
 }
 
-#[derive(Clone)]
+#[derive(Debug, Clone)]
 pub enum ModuleSource {
     Library(ClauseName),
     File(ClauseName),
@@ -392,13 +392,13 @@ impl ModuleSource {
 
 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,
@@ -433,7 +433,7 @@ impl Declaration {
     }
 }
 
-#[derive(Clone, PartialEq, Eq, PartialOrd, Ord)]
+#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
 pub struct OpDecl(pub usize, pub Specifier, pub ClauseName);
 
 impl OpDecl {
@@ -558,18 +558,19 @@ pub fn fetch_op_spec(
 
 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,
@@ -587,7 +588,7 @@ pub struct Module {
     pub listing_src: ListingSource,
  }
 
-#[derive(Clone)]
+#[derive(Debug, Clone)]
 pub enum Number {
     Float(OrderedFloat<f64>),
     Integer(Rc<Integer>),
index 1815ee199a07ee8f486320043eebcf7919bf492a..c30918fb04c15628bd702f7b177b386a139e427e 100644 (file)
@@ -7,6 +7,7 @@ use std::cmp::Ordering;
 use std::ops::Deref;
 use std::vec::Vec;
 
+#[derive(Debug)]
 pub struct HCPreOrderIterator<'a> {
     pub machine_st: &'a MachineState,
     pub state_stack: Vec<Addr>,
@@ -127,6 +128,7 @@ pub trait MutStackHCIterator<'b> where Self: Iterator
     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.
@@ -229,6 +231,7 @@ impl<'b, 'a: 'b> MutStackHCIterator<'b> for HCPreOrderIterator<'a> {
     }
 }
 
+#[derive(Debug)]
 pub struct HCAcyclicIterator<'a> {
     iter: HCPreOrderIterator<'a>,
     seen: IndexSet<Addr>,
@@ -269,6 +272,7 @@ impl<'a> Iterator for HCAcyclicIterator<'a>
     }
 }
 
+#[derive(Debug)]
 pub struct HCZippedAcyclicIterator<'a> {
     i1: HCPreOrderIterator<'a>,
     i2: HCPreOrderIterator<'a>,
index a57be201cb354cd65c411572599c42f3b12969ce..5e36c35c564afdcf6bcab07c13a765564831b152 100644 (file)
@@ -18,7 +18,7 @@ use std::ops::{Range, RangeFrom};
 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),
@@ -162,7 +162,7 @@ fn char_to_string(is_quoted: bool, c: char) -> String {
     }
 }
 
-#[derive(Clone)]
+#[derive(Debug, Clone)]
 enum TokenOrRedirect {
     Atom(ClauseName),
     BarAsOp,
@@ -197,6 +197,7 @@ pub trait HCValueOutputter {
     fn range_from(&self, range: RangeFrom<usize>) -> &str;
 }
 
+#[derive(Debug)]
 pub struct PrinterOutputter {
     contents: String,
 }
@@ -335,6 +336,7 @@ impl MachineState {
 
 type ReverseHeapVarDict = IndexMap<Addr, Rc<Var>>;
 
+#[derive(Debug)]
 pub struct HCPrinter<'a, Outputter> {
     outputter: Outputter,
     machine_st: &'a MachineState,
index 6b88c52fd7be547c3b10b8faecbc52dba91dfae1..93199289994ec92b753efc8f25c813830ec0ac79 100644 (file)
@@ -45,6 +45,7 @@ impl ArithmeticTerm {
     }
 }
 
+#[derive(Debug)]
 pub enum ChoiceInstruction {
     DefaultRetryMeElse(usize),
     DefaultTrustMe,
@@ -75,6 +76,7 @@ impl ChoiceInstruction {
     }
 }
 
+#[derive(Debug)]
 pub enum CutInstruction {
     Cut(RegType),
     GetLevel(RegType),
@@ -104,6 +106,7 @@ impl CutInstruction {
     }
 }
 
+#[derive(Debug)]
 pub enum IndexedChoiceInstruction {
     Retry(usize),
     Trust(usize),
@@ -140,6 +143,7 @@ impl IndexedChoiceInstruction {
     }
 }
 
+#[derive(Debug)]
 pub enum Line {
     Arithmetic(ArithmeticInstruction),
     Choice(ChoiceInstruction),
@@ -175,7 +179,7 @@ impl Line {
     }
 }
 
-#[derive(Clone)]
+#[derive(Debug, Clone)]
 pub enum ArithmeticInstruction {
     Add(ArithmeticTerm, ArithmeticTerm, usize),
     Sub(ArithmeticTerm, ArithmeticTerm, usize),
@@ -374,6 +378,7 @@ impl ArithmeticInstruction {
     }
 }
 
+#[derive(Debug)]
 pub enum ControlInstruction {
     Allocate(usize), // num_frames.
     // name, arity, perm_vars after threshold, last call, use default call policy.
@@ -419,6 +424,7 @@ impl ControlInstruction {
     }
 }
 
+#[derive(Debug)]
 pub enum IndexingInstruction {
     SwitchOnTerm(usize, usize, usize, usize),
     SwitchOnConstant(usize, IndexMap<Constant, usize>),
@@ -459,7 +465,7 @@ impl IndexingInstruction {
     }
 }
 
-#[derive(Clone)]
+#[derive(Debug, Clone)]
 pub enum FactInstruction {
     GetConstant(Level, Constant, RegType),
     GetList(Level, RegType),
@@ -571,7 +577,7 @@ impl FactInstruction {
     }
 }
 
-#[derive(Clone)]
+#[derive(Debug, Clone)]
 pub enum QueryInstruction {
     GetVariable(RegType, usize),
     PutConstant(Level, Constant, RegType),
index 83c6fab26f4716e669fd62ac75a4a0d0c75dc994..28da88e44e4d33d180c69accbbb6084b114ffc74 100644 (file)
@@ -6,11 +6,12 @@ use crate::prolog::machine::machine_indices::*;
 
 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),
@@ -33,6 +34,7 @@ impl<'a> TermRef<'a> {
     }
 }
 
+#[derive(Debug)]
 pub enum TermIterState<'a> {
     AnonVar(Level),
     Constant(Level, &'a Cell<RegType>, &'a Constant),
@@ -124,6 +126,7 @@ impl<'a> TermIterState<'a> {
     }
 }
 
+#[derive(Debug)]
 pub struct QueryIterator<'a> {
     state_stack: Vec<TermIterState<'a>>,
 }
@@ -294,6 +297,7 @@ impl<'a> Iterator for QueryIterator<'a> {
     }
 }
 
+#[derive(Debug)]
 pub struct FactIterator<'a> {
     state_queue: VecDeque<TermIterState<'a>>,
     iterable_root: bool,
@@ -402,6 +406,7 @@ pub fn breadth_first_iter(term: &Term, iterable_root: bool) -> FactIterator {
     FactIterator::new(term, iterable_root)
 }
 
+#[derive(Debug)]
 pub enum ChunkedTerm<'a> {
     HeadClause(ClauseName, &'a Vec<Box<Term>>),
     BodyTerm(&'a QueryTerm),
@@ -439,6 +444,18 @@ pub struct ChunkedIterator<'a> {
     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>);
 
index 1f49dfc781da1096b8b0a969cba6b59feadb1ff2..16c7314591f506be79898a2e5ebbc5373cfd1fea 100644 (file)
@@ -9,7 +9,7 @@ between(Lower, Upper, X) :-
     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.
index 444ef6ceb880409d2d74a69061e6747d2c71a3e4..36a67c1626d86f692a263ab4e1ed1fff0e3b185e 100644 (file)
@@ -291,7 +291,7 @@ wkl_add_to_existing_answer_cluster(Worklist, Answer) :-
 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])).
 
index b216a48caac0213c70a10287c7f93c949a652d99..d853a5f83b72beec91cece6fb1ce70999967d8aa 100644 (file)
@@ -8,6 +8,7 @@ pub static PROJECT_ATTRS: &str = include_str!("project_attributes.pl");
 
 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>,
index e56a3571b69a4bc8be29881cd3ba48a450c4b7f4..eba8c5c926c8e371c2afbf4bb715e8aae44bab17 100644 (file)
@@ -12,6 +12,7 @@ use indexmap::IndexSet;
 use std::collections::VecDeque;
 use std::mem;
 
+#[derive(Debug)]
 pub struct CodeRepo {
     pub(super) cached_query: Code,
     pub(super) goal_expanders: Code,
index 3e059ffa066d39932f3c06d26b246cc58b56d794..10bc46e936d4c8313e254939fdc2e6da20637a57 100644 (file)
@@ -409,6 +409,7 @@ fn compile_into_module_impl(
     Ok(compiler.drop_expansions(&mut wam.code_repo))
 }
 
+#[derive(Debug)]
 pub struct GatherResult {
     dynamic_clause_map: DynamicClauseMap,
     pub(crate) worker_results: Vec<PredicateCompileQueue>,
@@ -423,6 +424,7 @@ pub struct GatherResult {
     in_situ_module_dir: ModuleStubDir,
 }
 
+#[derive(Debug)]
 pub struct ClauseCodeGenerator {
     len_offset: usize,
     code: Code,
@@ -529,6 +531,7 @@ fn insert_or_refresh_term_dir_quantum(
     }
 }
 
+#[derive(Debug)]
 pub struct ListingCompiler {
     module: Option<Module>,
     user_term_dir: TermDir,
index c5a3ef180faedf55e92ce924cf134e987ae6c127..08c41944317370932d170824ad2c7f8c7e5c2908 100644 (file)
@@ -7,7 +7,7 @@ use std::ops::IndexMut;
 
 type Trail = Vec<(Ref, HeapCellValue)>;
 
-#[derive(Clone, Copy)]
+#[derive(Debug, Clone, Copy)]
 pub enum AttrVarPolicy {
     DeepCopy,
     StripAttributes
@@ -28,6 +28,7 @@ fn copy_term<T: CopierTarget>(target: T, addr: Addr, attr_var_policy: AttrVarPol
     copy_term_state.copy_term_impl(addr);
 }
 
+#[derive(Debug)]
 struct CopyTermState<T: CopierTarget> {
     trail: Trail,
     scan: usize,
index eceb55a35f841e645808927f03312a1bc3651b86..9d8cbfe746cdfc02e691834accddee5d69a5c530 100644 (file)
@@ -11,6 +11,7 @@ use std::mem;
 use std::ops::{Index, IndexMut};
 use std::ptr;
 
+#[derive(Debug)]
 pub(crate) struct StandardHeapTraits {}
 
 impl RawBlockTraits for StandardHeapTraits {
@@ -25,6 +26,7 @@ impl RawBlockTraits for StandardHeapTraits {
     }
 }
 
+#[derive(Debug)]
 pub(crate) struct HeapTemplate<T: RawBlockTraits> {
     buf: RawBlock<T>,
     _marker: PhantomData<HeapCellValue>,
@@ -39,6 +41,7 @@ impl<T: RawBlockTraits> Drop for HeapTemplate<T> {
     }
 }
 
+#[derive(Debug)]
 pub(crate)
 struct HeapIntoIter<T: RawBlockTraits> {
     offset: usize,
@@ -72,6 +75,7 @@ impl<T: RawBlockTraits> Iterator for HeapIntoIter<T> {
     }
 }
 
+#[derive(Debug)]
 pub(crate)
 struct HeapIter<'a, T: RawBlockTraits> {
     offset: usize,
@@ -110,6 +114,7 @@ fn print_heap_terms<'a, I: Iterator<Item = &'a HeapCellValue>>(heap: I, h: usize
     }
 }
 
+#[derive(Debug)]
 pub(crate)
 struct HeapIterMut<'a, T: RawBlockTraits> {
     offset: usize,
index 9948787cb8e205208fc45e1da2665a2770bede5d..fd1e93978e91bf10ddbbebfdae033d9c69547fad 100644 (file)
@@ -10,12 +10,13 @@ use std::rc::Rc;
 
 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
@@ -447,7 +448,7 @@ impl MachineError {
     }
 }
 
-#[derive(Clone, Copy)]
+#[derive(Debug, Clone, Copy)]
 pub enum Permission {
     Access,
     Create,
@@ -469,7 +470,7 @@ impl Permission {
 }
 
 // from 7.12.2 b) of 13211-1:1995
-#[derive(Clone, Copy)]
+#[derive(Debug, Clone, Copy)]
 pub enum ValidType {
     Atom,
     Atomic,
@@ -514,7 +515,7 @@ impl ValidType {
     }
 }
 
-#[derive(Clone, Copy)]
+#[derive(Debug, Clone, Copy)]
 pub enum DomainErrorType {
     NotLessThanZero,
     Order,
@@ -534,7 +535,7 @@ impl DomainErrorType {
 }
 
 // from 7.12.2 f) of 13211-1:1995
-#[derive(Clone, Copy)]
+#[derive(Debug, Clone, Copy)]
 pub enum RepFlag {
     Character,
     CharacterCode,
@@ -558,7 +559,7 @@ impl RepFlag {
 }
 
 // from 7.12.2 g) of 13211-1:1995
-#[derive(Clone, Copy)]
+#[derive(Debug, Clone, Copy)]
 pub enum EvalError {
     FloatOverflow,
     Undefined,
@@ -578,7 +579,7 @@ impl EvalError {
 }
 
 // used by '$skip_max_list'.
-#[derive(Clone, Copy)]
+#[derive(Debug, Clone, Copy)]
 pub(super) enum CycleSearchResult {
     EmptyList,
     NotList,
@@ -722,6 +723,7 @@ impl MachineState {
     }
 }
 
+#[derive(Debug)]
 pub enum ExistenceError {
     Module(ClauseName),
     Procedure(ClauseName, usize),
@@ -729,6 +731,7 @@ pub enum ExistenceError {
     Stream(Addr),
 }
 
+#[derive(Debug)]
 pub enum SessionError {
     CannotOverwriteBuiltIn(ClauseName),
     CannotOverwriteImport(ClauseName),
@@ -741,6 +744,7 @@ pub enum SessionError {
     ParserError(ParserError),
 }
 
+#[derive(Debug)]
 pub enum EvalSession {
     EntrySuccess,
     Error(SessionError),
index a11d2c1afc8adc534a5e13ef469faeb2264a1da5..fe885bb948d1854f739297fbb7e0c37dfe289dfc 100644 (file)
@@ -21,16 +21,17 @@ use std::cell::RefCell;
 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(
@@ -43,7 +44,7 @@ pub enum DBRef {
 }
 
 // 7.2
-#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
+#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
 pub enum TermOrderCategory {
     Variable,
     FloatingPoint,
@@ -52,7 +53,7 @@ pub enum TermOrderCategory {
     Compound,
 }
 
-#[derive(Clone, Copy, PartialEq, Eq, Hash)]
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
 pub enum Addr {
     AttrVar(usize),
     Char(char),
@@ -71,7 +72,7 @@ pub enum Addr {
     Usize(usize),
 }
 
-#[derive(Clone, Copy, Hash, Eq, PartialEq, PartialOrd)]
+#[derive(Debug, Clone, Copy, Hash, Eq, PartialEq, PartialOrd)]
 pub enum Ref {
     AttrVar(usize),
     HeapCell(usize),
@@ -361,7 +362,7 @@ impl SubAssign<usize> for Addr {
     }
 }
 
-#[derive(Clone, Copy)]
+#[derive(Debug, Clone, Copy)]
 pub enum TrailRef {
     Ref(Ref),
     AttrVarHeapLink(usize),
@@ -374,6 +375,7 @@ impl From<Ref> for TrailRef {
     }
 }
 
+#[derive(Debug)]
 pub enum HeapCellValue {
     Addr(Addr),
     Atom(ClauseName, Option<SharedOpDesc>),
@@ -446,7 +448,7 @@ impl From<Addr> for HeapCellValue {
     }
 }
 
-#[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,
@@ -456,7 +458,7 @@ pub enum IndexPtr {
     UserTermExpansion
 }
 
-#[derive(Clone, Ord, PartialOrd, Eq, PartialEq)]
+#[derive(Debug, Clone, Ord, PartialOrd, Eq, PartialEq)]
 pub struct CodeIndex(pub Rc<RefCell<(IndexPtr, ClauseName)>>);
 
 impl CodeIndex {
@@ -511,7 +513,7 @@ impl From<(usize, ClauseName)> for CodeIndex {
     }
 }
 
-#[derive(Clone, Copy, PartialEq)]
+#[derive(Debug, Clone, Copy, PartialEq)]
 pub enum DynamicAssertPlace {
     Back,
     Front,
@@ -535,7 +537,7 @@ impl DynamicAssertPlace {
     }
 }
 
-#[derive(Clone, Copy, PartialEq)]
+#[derive(Debug, Clone, Copy, PartialEq)]
 pub enum DynamicTransactionType {
     Abolish,
     Assert(DynamicAssertPlace),
@@ -545,7 +547,7 @@ pub enum DynamicTransactionType {
     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,
@@ -554,7 +556,7 @@ pub enum REPLCodePtr {
     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.
@@ -773,7 +775,7 @@ impl AddAssign<usize> for CodePtr {
 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.
 }
@@ -793,6 +795,7 @@ pub type DynamicCodeDir = IndexMap<(ClauseName, ClauseName, usize), DynamicPredi
 
 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,
@@ -810,6 +813,7 @@ impl ModuleStub {
 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,
@@ -960,6 +964,7 @@ impl IndexStore {
 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>),
@@ -988,6 +993,7 @@ impl TermDirQuantumEntry {
     }
 }
 
+#[derive(Debug)]
 pub struct TermDirQuantum(IndexMap<PredicateKey, TermDirQuantumEntry>);
 
 impl TermDirQuantum {
@@ -1031,7 +1037,7 @@ impl TermDirQuantum {
     }
 }
 
-#[derive(Clone, Copy, PartialEq, Eq, Ord, PartialOrd)]
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Ord, PartialOrd)]
 pub enum CompileTimeHook {
     GoalExpansion,
     TermExpansion,
@@ -1085,6 +1091,16 @@ pub enum RefOrOwned<'a, T: 'a> {
     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 {
index d247abe52aca85370ea30711c5eae23118f7b782..97e05e31107f24ab6b6d2414f357f4a767f244a5 100644 (file)
@@ -21,10 +21,12 @@ use indexmap::{IndexMap, IndexSet};
 
 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,
@@ -74,7 +76,7 @@ impl<'a> HeapPStrIter<'a> {
     }
 }
 
-#[derive(Clone, Copy)]
+#[derive(Debug, Clone, Copy)]
 pub(crate) enum PStrIteratee {
     Char(char),
     PStrSegment(usize, usize),
@@ -100,7 +102,7 @@ impl<'a> Iterator for HeapPStrIter<'a> {
                     } else {
                         Addr::EmptyList
                     };
-                    
+
                     return Some(PStrIteratee::PStrSegment(h, n));
                 } else {
                     unreachable!()
@@ -306,6 +308,7 @@ fn compare_pstr_to_string<'a>(
     Some(s_offset)
 }
 
+#[derive(Debug)]
 pub struct Ball {
     pub(super) boundary: usize,
     pub(super) stub: Heap,
@@ -357,6 +360,7 @@ impl Ball {
     }
 }
 
+#[derive(Debug)]
 pub(super) struct CopyTerm<'a> {
     state: &'a mut MachineState,
 }
@@ -404,6 +408,7 @@ impl<'a> CopierTarget for CopyTerm<'a> {
     }
 }
 
+#[derive(Debug)]
 pub(super) struct CopyBallTerm<'a> {
     stack: &'a mut Stack,
     heap: &'a mut Heap,
@@ -529,13 +534,13 @@ impl IndexMut<RegType> for MachineState {
 
 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),
@@ -576,6 +581,7 @@ impl Default for HeapPtr {
     }
 }
 
+#[derive(Debug)]
 pub struct MachineState {
     pub(super) s: HeapPtr,
     pub(super) p: CodePtr,
@@ -934,7 +940,7 @@ fn try_in_situ(
 
 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;
@@ -1517,10 +1523,12 @@ impl CallPolicy for CWILCallPolicy {
 
 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,
@@ -1601,7 +1609,7 @@ impl CWILCallPolicy {
     }
 }
 
-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;
 }
@@ -1627,6 +1635,7 @@ fn cut_body(machine_st: &mut MachineState, addr: &Addr) -> bool {
     false
 }
 
+#[derive(Debug)]
 pub(crate) struct DefaultCutPolicy {}
 
 pub(super) fn deref_cut(machine_st: &mut MachineState, r: RegType) {
@@ -1641,6 +1650,7 @@ impl CutPolicy for DefaultCutPolicy {
     }
 }
 
+#[derive(Debug)]
 pub(crate) struct SCCCutPolicy {
     // locations of cleaners, cut points, the previous block
     cont_pts: Vec<(Addr, usize, usize)>,
index c951135f0a4127046d90e7640aacf531101e6520..215d10b111a9f1f5db21cf419dee1b98a29376b9 100644 (file)
@@ -53,6 +53,7 @@ use std::path::PathBuf;
 use std::rc::Rc;
 use std::sync::atomic::AtomicBool;
 
+#[derive(Debug)]
 pub struct MachinePolicies {
     call_policy: Box<dyn CallPolicy>,
     cut_policy: Box<dyn CutPolicy>,
@@ -79,6 +80,7 @@ impl Default for MachinePolicies {
     }
 }
 
+#[derive(Debug)]
 pub struct Machine {
     pub(super) machine_st: MachineState,
     pub(super) inner_heap: Heap,
index cb95b44c15f579df36fb2ae56e44f8eec1d88d24..ea36d409c838b3f1d609d7528a47d486687b447f 100644 (file)
@@ -7,6 +7,7 @@ use std::ops::RangeFrom;
 use std::slice;
 use std::str;
 
+#[derive(Debug)]
 pub struct PartialString {
     buf: *const u8,
     len: usize,
@@ -46,6 +47,7 @@ fn scan_for_terminator<Iter: Iterator<Item = char>>(iter: Iter) -> usize {
     terminator_idx
 }
 
+#[derive(Debug)]
 pub struct PStrIter {
     buf: *const u8,
     len: usize,
index 64135048eb79bacb8066d7773054f80e57d15195..e44b714b7fb1920155ba72aebbd725f82525d963 100644 (file)
@@ -14,6 +14,7 @@ pub(crate) trait RawBlockTraits {
     }
 }
 
+#[derive(Debug)]
 pub(crate) struct RawBlock<T: RawBlockTraits> {
     pub(crate) size: usize,
     pub(crate) base: *const u8,
index 4468899c00d9318b481ebcb514c0cccf55e28cde..071cb3a03ab4f2dc94fcb7a03563542929ef0cf4 100644 (file)
@@ -7,6 +7,7 @@ use std::mem;
 use std::ops::{Index, IndexMut};
 use std::ptr;
 
+#[derive(Debug)]
 struct StackTraits {}
 
 impl RawBlockTraits for StackTraits {
@@ -35,6 +36,7 @@ const fn prelude_size<Prelude>() -> usize {
     (size & !(align - 1)) + align
 }
 
+#[derive(Debug)]
 pub struct Stack {
     buf: RawBlock<StackTraits>,
     _marker: PhantomData<Addr>,
@@ -47,11 +49,12 @@ impl Drop for Stack {
     }
 }
 
-#[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,
@@ -59,6 +62,7 @@ pub struct AndFramePrelude {
     pub interrupt_cp: LocalCodePtr,
 }
 
+#[derive(Debug)]
 pub struct AndFrame {
     pub prelude: AndFramePrelude,
 }
@@ -99,6 +103,7 @@ impl IndexMut<usize> for AndFrame {
     }
 }
 
+#[derive(Debug)]
 pub struct OrFramePrelude {
     pub univ_prelude: FramePrelude,
     pub e: usize,
@@ -113,6 +118,7 @@ pub struct OrFramePrelude {
     pub attr_var_init_bindings_b: usize,
 }
 
+#[derive(Debug)]
 pub struct OrFrame {
     pub prelude: OrFramePrelude,
 }
index 1653defb2b97667929eb3850584b751cc6e769a4..d9a8393469b1d25800455fe38b61048f1e0c2283 100644 (file)
@@ -11,13 +11,13 @@ use std::hash::{Hash, Hasher};
 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,
@@ -37,7 +37,26 @@ pub enum StreamInstance {
     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 {
@@ -95,7 +114,7 @@ impl fmt::Display for StreamError {
 
 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,
@@ -115,7 +134,7 @@ impl Default for StreamOptions {
     }
 }
 
-#[derive(Clone, PartialEq, Eq, Hash)]
+#[derive(Debug, Clone, PartialEq, Eq, Hash)]
 pub struct Stream {
     pub options: StreamOptions,
     stream_inst: WrappedStreamInstance,
index 4c0fed6b683454aa18dcfa7e24d49e249d10a61e..f307483944ad08fef517e7b4feaf6ae059a4ef7c 100644 (file)
@@ -61,6 +61,7 @@ pub fn get_single_char() -> char {
     c
 }
 
+#[derive(Debug)]
 struct BrentAlgState {
     hare: Addr,
     tortoise: Addr,
index d86904834489f007e020b6742d0f0b0d284cff8b..06d7b3be81b6b0a991b2fbb24622cbbae91941f4 100644 (file)
@@ -47,6 +47,7 @@ fn extract_from_list(
     }
 }
 
+#[derive(Debug)]
 pub struct TermStream<'a> {
     stack: Vec<Term>,
     pub(crate) wam: &'a mut Machine,
@@ -57,6 +58,7 @@ pub struct TermStream<'a> {
     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>),
index e4198a68b6726bd99e704ea7821fc94186480406..c8004acad4fb609a4971cf6f4357219f361219a8 100644 (file)
@@ -14,6 +14,7 @@ use std::borrow::BorrowMut;
 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;
@@ -23,6 +24,15 @@ enum IndexSource<'a, T> {
     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()),
@@ -30,6 +40,7 @@ fn op_dir<'a, 'b: 'a>(from: &'b IndexSource<'a, IndexStore>) -> RefOrOwned<'a, O
     }
 }
 
+#[derive(Debug)]
 struct CompositeIndices<'a, 'b, 'c> {
     term_stream: &'b mut TermStream<'a>,
     index_src: IndexSource<'c, IndexStore>,
@@ -690,6 +701,7 @@ fn setup_declaration<'a, 'b, 'c>(
     }
 }
 
+#[derive(Debug)]
 struct RelationWorker {
     flags: MachineFlags,
     dynamic_clauses: Vec<(Term, Term)>, // Head, Body.
@@ -1141,6 +1153,7 @@ pub type DynamicClause = Vec<(Term, Term)>;
 
 pub type DynamicClauseMap = IndexMap<(ClauseName, usize), DynamicClause>;
 
+#[derive(Debug)]
 pub struct TopLevelBatchWorker<'a> {
     pub(crate) term_stream: TermStream<'a>,
     rel_worker: RelationWorker,
index 72be1b1870e1d5006f81f609dcf0814ab45796cf..28d35358e0040f9aefdb5a7b7135362989c7879a 100644 (file)
@@ -35,6 +35,7 @@ pub mod readline {
         }
     }
 
+    #[derive(Debug)]
     pub struct ReadlineStream {
         rl: Editor<()>,
         pending_input: Cursor<String>,
@@ -114,12 +115,14 @@ fn write_term_to_heap(term: &Term, machine_st: &mut MachineState) -> TermWriteRe
     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,
index 44d0b06418164c0edec1109bb0464c3ad0afde0b..024c242d5fe2e2b7d94396a92f78b64f063c7b3e 100644 (file)
@@ -33,6 +33,6 @@ test_queries_on_predicates :-
     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).
index a58697312c239508b9e2e04cb5e40a842bd1bb63..331f50f4bdde35078340741ccd008685dbcb80ae 100644 (file)
@@ -24,5 +24,5 @@ test_queries_on_setup_call_cleanup :-
     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).