add read_term_from_chars/3 (#637)
This commit is contained in:
@@ -4270,6 +4270,14 @@ impl Machine {
|
||||
self.quoted_token();
|
||||
step_or_fail!(self, self.machine_st.p = self.machine_st.cp);
|
||||
}
|
||||
&Instruction::CallReadFromChars => {
|
||||
try_or_throw!(self.machine_st, self.read_from_chars());
|
||||
step_or_fail!(self, self.machine_st.p += 1);
|
||||
}
|
||||
&Instruction::ExecuteReadFromChars => {
|
||||
try_or_throw!(self.machine_st, self.read_from_chars());
|
||||
step_or_fail!(self, self.machine_st.p = self.machine_st.cp);
|
||||
}
|
||||
&Instruction::CallReadTermFromChars => {
|
||||
try_or_throw!(self.machine_st, self.read_term_from_chars());
|
||||
step_or_fail!(self, self.machine_st.p += 1);
|
||||
|
||||
@@ -5792,7 +5792,7 @@ impl Machine {
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub(crate) fn read_term_from_chars(&mut self) -> CallResult {
|
||||
pub(crate) fn read_from_chars(&mut self) -> CallResult {
|
||||
if let Some(atom_or_string) = self.machine_st.value_to_str_like(self.machine_st.registers[1]) {
|
||||
let chars = CharReader::new(ByteStream::from_string(atom_or_string.to_string()));
|
||||
let mut parser = Parser::new(chars, &mut self.machine_st);
|
||||
@@ -5829,6 +5829,16 @@ impl Machine {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub(crate) fn read_term_from_chars(&mut self) -> CallResult {
|
||||
if let Some(atom_or_string) = self.machine_st.value_to_str_like(self.machine_st.registers[1]) {
|
||||
let stream = Stream::from_owned_string(atom_or_string.to_string(), &mut self.machine_st.arena);
|
||||
self.machine_st.read_term(stream, &mut self.indices)
|
||||
} else {
|
||||
unreachable!()
|
||||
}
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub(crate) fn reset_block(&mut self) {
|
||||
let addr = self.deref_register(1);
|
||||
|
||||
Reference in New Issue
Block a user