Add Machine::set_user_input(&mut self, input: String) and get_user_output() -> String. Make read_term_from_user_input() handle Stream::Byte.
This commit is contained in:
@@ -495,6 +495,10 @@ impl MachineState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let Stream::Byte(_) = stream {
|
||||||
|
return self.read_term(stream, indices)
|
||||||
|
}
|
||||||
|
|
||||||
unreachable!("Stream must be a Stream::Readline(_)")
|
unreachable!("Stream must be a Stream::Readline(_)")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ use ordered_float::OrderedFloat;
|
|||||||
|
|
||||||
use std::cmp::Ordering;
|
use std::cmp::Ordering;
|
||||||
use std::env;
|
use std::env;
|
||||||
|
use std::io::Read;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::sync::atomic::AtomicBool;
|
use std::sync::atomic::AtomicBool;
|
||||||
use tokio::runtime::Runtime;
|
use tokio::runtime::Runtime;
|
||||||
@@ -306,6 +307,15 @@ impl Machine {
|
|||||||
self.run_module_predicate(atom!("$toplevel"), (atom!("$repl"), 1));
|
self.run_module_predicate(atom!("$toplevel"), (atom!("$repl"), 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn set_user_input(&mut self, input: String) {
|
||||||
|
self.user_input = Stream::from_owned_string(input, &mut self.machine_st.arena);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_user_output(&mut self) -> String {
|
||||||
|
let output_bytes: Vec<_> = self.user_output.bytes().map(|b| b.unwrap()).collect();
|
||||||
|
String::from_utf8(output_bytes).unwrap()
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) fn configure_modules(&mut self) {
|
pub(crate) fn configure_modules(&mut self) {
|
||||||
fn update_call_n_indices(loader: &Module, target_code_dir: &mut CodeDir, arena: &mut Arena) {
|
fn update_call_n_indices(loader: &Module, target_code_dir: &mut CodeDir, arena: &mut Arena) {
|
||||||
for arity in 1..66 {
|
for arity in 1..66 {
|
||||||
|
|||||||
Reference in New Issue
Block a user