[−][src]Trait mruby::eval::MrbEval
Interpreters that implement MrbEval
expose methods for injecting code
into a sys::mrb_state
and extracting Value
s from the interpereter.
Implementations are expected to maintain a stack of EvalContext
objects
that maintain filename context across nested invocations of
MrbEval::eval
.
Required methods
fn eval<T>(&self, code: T) -> Result<Value, MrbError> where
T: AsRef<[u8]>,
T: AsRef<[u8]>,
Eval code on the mruby interpreter using the current EvalContext
or
EvalContext::root
if none is present on the stack.
fn unchecked_eval<T>(&self, code: T) -> Value where
T: AsRef<[u8]>,
T: AsRef<[u8]>,
Eval code on the mruby interpreter using the current EvalContext
or
EvalContext::root
if none is present on the stack.
This function does not wrap calls to the mruby VM in mrb_protect
which
means exceptions will unwind past this call.
fn eval_with_context<T>(
&self,
code: T,
context: EvalContext
) -> Result<Value, MrbError> where
T: AsRef<[u8]>,
&self,
code: T,
context: EvalContext
) -> Result<Value, MrbError> where
T: AsRef<[u8]>,
Eval code on the mruby interpreter using a custom EvalContext
.
EvalContext
allows manipulating interpreter state before eval, for
example, setting the __FILE__
magic constant.
fn unchecked_eval_with_context<T>(&self, code: T, context: EvalContext) -> Value where
T: AsRef<[u8]>,
T: AsRef<[u8]>,
Eval code on the mruby interpreter using a custom EvalContext
.
EvalContext
allows manipulating interpreter state before eval, for
example, setting the __FILE__
magic constant.
This function does not wrap calls to the mruby VM in mrb_protect
which
means exceptions will unwind past this call.
fn peek_context(&self) -> Option<EvalContext>
Peek at the top of the EvalContext
stack.
fn push_context(&self, context: EvalContext)
Push an EvalContext
onto the stack.
fn pop_context(&self)
Pop an EvalContext
from the stack.
Implementors
impl MrbEval for Mrb
[src]
fn eval<T>(&self, code: T) -> Result<Value, MrbError> where
T: AsRef<[u8]>,
[src]
T: AsRef<[u8]>,
fn unchecked_eval<T>(&self, code: T) -> Value where
T: AsRef<[u8]>,
[src]
T: AsRef<[u8]>,
fn eval_with_context<T>(
&self,
code: T,
context: EvalContext
) -> Result<Value, MrbError> where
T: AsRef<[u8]>,
[src]
&self,
code: T,
context: EvalContext
) -> Result<Value, MrbError> where
T: AsRef<[u8]>,
fn unchecked_eval_with_context<T>(&self, code: T, context: EvalContext) -> Value where
T: AsRef<[u8]>,
[src]
T: AsRef<[u8]>,