add current_output, printing of stream terms

This commit is contained in:
Mark Thom
2020-03-11 00:38:01 -06:00
parent 25babff827
commit 4c88e97330
14 changed files with 236 additions and 32 deletions

View File

@@ -673,6 +673,7 @@ impl MachineState {
call_policy: &mut Box<dyn CallPolicy>,
cut_policy: &mut Box<dyn CutPolicy>,
current_input_stream: &mut Stream,
current_output_stream: &mut Stream,
) -> CallResult {
match ct {
&SystemClauseType::AbolishClause => {
@@ -748,6 +749,32 @@ impl MachineState {
}
}
}
&SystemClauseType::CurrentOutput => {
let addr = self.store(self.deref(self[temp_v!(1)].clone()));
let stream = current_output_stream.clone();
match addr {
addr if addr.is_ref() => {
self.unify(Addr::Stream(stream), addr);
}
Addr::Stream(other_stream) => {
self.fail = stream != other_stream;
}
addr => {
let stub = MachineError::functor_stub(
clause_name!("current_input"),
1,
);
let err = MachineError::domain_error(
DomainError::Stream,
addr,
);
return Err(self.error_form(err, stub));
}
}
}
&SystemClauseType::AtEndOfExpansion => {
if self.cp == LocalCodePtr::TopLevel(0, 0) {
self.at_end_of_expansion = true;