[−][src]Struct ketos::interpreter::Interpreter
Provides a context in which to compile and execute code.
Values created by one interpreter are exclusive to that interpreter.
They should not be passed directly into another interpreter.
Specifically, unexpected behavior or a panic may occur if another
interpreter attempts to operate on Name
/Keyword
values created by
another interpreter or any values which may contain arbitrary values
(Struct
, StructDef
, List
, Lambda
, Quote
, etc.).
Methods
impl Interpreter
[src]
pub fn new() -> Interpreter
[src]
Creates a new Interpreter
.
pub fn with_loader(loader: Box<dyn ModuleLoader>) -> Interpreter
[src]
Creates a new Interpreter
using the given ModuleLoader
instance.
pub fn with_context(context: Context) -> Interpreter
[src]
Creates a new Interpreter
using the given Context
instance.
pub fn with_scope(scope: Scope) -> Interpreter
[src]
Creates a new Interpreter
using the given Scope
instance.
pub fn with_search_paths(paths: Vec<PathBuf>) -> Interpreter
[src]
Creates a new Interpreter
that searches for module files in a given
series of directories.
pub fn clear_codemap(&self)
[src]
Clears cached source from the contained CodeMap
.
Note
This will invalidate any previously created ParseError
values.
pub fn display_error(&self, e: &Error)
[src]
Prints an error to stderr
.
pub fn display_trace(&self, trace: &Trace)
[src]
Prints traceback information to stderr
.
pub fn display_value(&self, value: &Value)
[src]
Prints a string representation of a value to stdout
.
pub fn format_error(&self, e: &Error) -> String
[src]
Formats an error into a String
.
pub fn format_trace(&self, trace: &Trace) -> String
[src]
Formats a Trace
into a String
.
The result does not include the "Traceback:"
preamble.
pub fn get_traceback(&self) -> Option<Trace>
[src]
Returns the traceback from the most recent error.
The traceback will remain stored for future calls to get_traceback
.
pub fn take_traceback(&self) -> Option<Trace>
[src]
Removes and returns the traceback from the most recent error.
pub fn format_value(&self, value: &Value) -> String
[src]
Formats a value into a string.
pub fn execute(&self, code: Code) -> Result<Value, Error>
[src]
Executes a bare Code
object taking no parameters.
pub fn execute_code(&self, code: Rc<Code>) -> Result<Value, Error>
[src]
Executes a Rc<Code>
object taking no parameters.
pub fn execute_program(&self, code: Vec<Code>) -> Result<Value, Error>
[src]
Executes a series of code objects sequentially and returns the value
of the final expression. If code
is empty, the value ()
is returned.
pub fn call(&self, name: &str, args: Vec<Value>) -> Result<Value, Error>
[src]
Calls a named function with the given arguments.
pub fn call_value(&self, value: Value, args: Vec<Value>) -> Result<Value, Error>
[src]
Calls a function with the given arguments.
pub fn get_value(&self, name: &str) -> Option<Value>
[src]
Returns a value, if present, in the interpreter scope.
pub fn context(&self) -> &Context
[src]
Returns a borrowed reference to the contained context.
pub fn scope(&self) -> &Scope
[src]
Returns a borrowed reference to the contained scope.
pub fn set_args<T: AsRef<str>>(&self, args: &[T])
[src]
Sets the value of argv
within the execution scope.
pub fn run_file(&self, path: &Path) -> Result<(), Error>
[src]
Compiles and executes the contents of a file.
pub fn run_single_expr(
&self,
input: &str,
path: Option<String>
) -> Result<Value, Error>
[src]
&self,
input: &str,
path: Option<String>
) -> Result<Value, Error>
Compiles and executes an input expression.
pub fn run_code(
&self,
input: &str,
path: Option<String>
) -> Result<Value, Error>
[src]
&self,
input: &str,
path: Option<String>
) -> Result<Value, Error>
Parses and executes a series of expressions and return the last value.
pub fn compile_single_expr(
&self,
input: &str,
path: Option<String>
) -> Result<Code, Error>
[src]
&self,
input: &str,
path: Option<String>
) -> Result<Code, Error>
Compiles and compiles a single expression and returns a code object. If the input string contains more than one expression, an error is returned.
pub fn compile_exprs(&self, input: &str) -> Result<Vec<Code>, Error>
[src]
Compiles and compiles a series of expressions.
pub fn parse_single_expr(
&self,
input: &str,
path: Option<String>
) -> Result<Value, Error>
[src]
&self,
input: &str,
path: Option<String>
) -> Result<Value, Error>
Parses a single expression and returns it as a Value
.
If input
contains more than one expression, an error is returned.
pub fn parse_exprs(
&self,
input: &str,
path: Option<String>
) -> Result<Vec<Value>, Error>
[src]
&self,
input: &str,
path: Option<String>
) -> Result<Vec<Value>, Error>
Parses a series of expressions and returns them as Value
s.
pub fn parse_file(
&self,
input: &str,
path: Option<String>
) -> Result<Vec<Value>, Error>
[src]
&self,
input: &str,
path: Option<String>
) -> Result<Vec<Value>, Error>
Parses a series of expressions from the contents of a file and
returns them as Value
s.
Trait Implementations
impl Clone for Interpreter
[src]
fn clone(&self) -> Interpreter
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Auto Trait Implementations
impl !RefUnwindSafe for Interpreter
impl !Send for Interpreter
impl !Sync for Interpreter
impl Unpin for Interpreter
impl !UnwindSafe for Interpreter
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,