fix attribute_goals/2 display bugs, cycle detection bug

This commit is contained in:
Mark Thom
2019-02-14 01:12:52 -07:00
parent f616b4ddfd
commit cd5549ee5b
12 changed files with 176 additions and 107 deletions

View File

@@ -12,13 +12,13 @@ use prolog::or_stack::*;
use downcast::Any;
use std::cmp::Ordering;
use std::io::stdin;
use std::io::{Write, stdin, stdout};
use std::mem::swap;
use std::ops::{Index, IndexMut};
use std::rc::Rc;
pub(super) struct Ball {
pub(super) boundary: usize, // ball.0
pub(super) boundary: usize, // ball.0
pub(super) stub: MachineStub, // ball.1
}
@@ -378,7 +378,7 @@ pub(crate) trait CallPolicy: Any {
machine_st.pstr_trail.truncate(machine_st.pstr_tr);
machine_st.heap.truncate(machine_st.or_stack[b].h);
machine_st.hb = machine_st.heap.h;
machine_st.p += offset;
@@ -547,6 +547,13 @@ pub(crate) trait CallPolicy: Any {
machine_st.fail = !machine_st.is_cyclic_term(addr);
return_from_clause!(machine_st.last_call, machine_st)
},
&BuiltInClauseType::Nl => {
let mut stdout = stdout();
write!(stdout, "\n\r").unwrap();
stdout.flush().unwrap();
return_from_clause!(machine_st.last_call, machine_st)
},
&BuiltInClauseType::Read => {
match machine_st.read(stdin(), indices.atom_tbl.clone(), &indices.op_dir) {
Ok(offset) => {