pub struct Interpreter<Buffer: IoWrite, LibCore: StdCore> { /* private fields */ }
Implementations§
Source§impl<Buffer: IoWrite, LibCore: StdCore> Interpreter<Buffer, LibCore>
impl<Buffer: IoWrite, LibCore: StdCore> Interpreter<Buffer, LibCore>
Sourcepub fn repl(&mut self, repl: bool) -> &mut Self
pub fn repl(&mut self, repl: bool) -> &mut Self
Enable or disable REPL mode (print last value to output buffer)
Sourcepub fn with_color(buffer: Buffer) -> Self
pub fn with_color(buffer: Buffer) -> Self
Enable ansi colored error message
pub fn load_ext( &mut self, extension: Extension<Buffer>, ) -> Result<(), Extension<Buffer>>
Sourcepub fn impl_extern_function<F>(&mut self, name: impl Into<String>, f: F)where
F: Fn(&mut State<'_, Buffer>, &[DiatomValue], &mut Buffer) -> Result<DiatomValue, String> + 'static + Send + Sync,
pub fn impl_extern_function<F>(&mut self, name: impl Into<String>, f: F)where
F: Fn(&mut State<'_, Buffer>, &[DiatomValue], &mut Buffer) -> Result<DiatomValue, String> + 'static + Send + Sync,
Directly declare external function as variable
Sourcepub fn verify_input_completeness(&self, code: impl AsRef<str>) -> bool
pub fn verify_input_completeness(&self, code: impl AsRef<str>) -> bool
Check if input is completeness
Incomplete input usually contains unclosed parentheses, quotes or open expression.
Sourcepub fn decompile(
&mut self,
code: impl AsRef<str>,
source: impl AsRef<OsStr>,
is_phony: bool,
) -> Result<String, String>
pub fn decompile( &mut self, code: impl AsRef<str>, source: impl AsRef<OsStr>, is_phony: bool, ) -> Result<String, String>
Show decompiled byte code for given source code.
If compilation failed, Err
will be returned.
Sourcepub fn replace_buffer(&mut self, buffer: Buffer) -> Buffer
pub fn replace_buffer(&mut self, buffer: Buffer) -> Buffer
Replace output buffer and get the old one
Sourcepub fn exec(
&mut self,
code: impl AsRef<str>,
source: impl AsRef<OsStr>,
is_phony: bool,
) -> Result<(), String>
pub fn exec( &mut self, code: impl AsRef<str>, source: impl AsRef<OsStr>, is_phony: bool, ) -> Result<(), String>
Run a piece of diatom source code
§Parameters
code
- Source codesource
- name of source code file or where it is fromis_phony
- Whether source is a real path or a place holder
§Return
- Return the output of the program
- If compilation failed or error occurs durning execution, an
Err(String)
that illustrates the error is returned.
Auto Trait Implementations§
impl<Buffer, LibCore> Freeze for Interpreter<Buffer, LibCore>where
Buffer: Freeze,
impl<Buffer, LibCore> !RefUnwindSafe for Interpreter<Buffer, LibCore>
impl<Buffer, LibCore> Send for Interpreter<Buffer, LibCore>where
Buffer: Send,
impl<Buffer, LibCore> !Sync for Interpreter<Buffer, LibCore>
impl<Buffer, LibCore> Unpin for Interpreter<Buffer, LibCore>
impl<Buffer, LibCore> !UnwindSafe for Interpreter<Buffer, LibCore>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more