[−][src]Struct dyon::runtime::Runtime
Stores data needed for running a Dyon program.
Fields
module: Arc<Module>
Stores the current module in use.
stack: Vec<Variable>
Stores variables on the stack.
call_stack: Vec<Call>
name, file, stack_len, local_len.
local_stack: Vec<(Arc<String>, usize)>
Stores stack of locals.
current_stack: Vec<(Arc<String>, usize)>
Stores stack of current objects.
When a current object is used, the runtime searches backwards until it finds the last current variable with the name.
arg_err_index: Cell<Option<usize>>
External functions can choose to report an error on an argument.
Implementations
impl Runtime
[src]
pub fn new() -> Runtime
[src]
Creates a new Runtime.
pub fn pop<T: PopVariable>(&mut self) -> Result<T, String>
[src]
Pops variable from stack.
pub fn pop_vec4<T: ConvertVec4>(&mut self) -> Result<T, String>
[src]
Pops 4D vector from stack.
pub fn pop_mat4<T: ConvertMat4>(&mut self) -> Result<T, String>
[src]
Pops 4D matrix from stack.
pub fn var<T: PopVariable>(&self, var: &Variable) -> Result<T, String>
[src]
Gets variable.
pub fn current_object<T: PopVariable>(&self, name: &str) -> Result<T, String>
[src]
Gets Current Object variable from the stack for Current Objects
by finding the corresponding entry in the normal stack.
If the Current Object can't be found in the stack of current objects,
the error ("Could not find current variable {}
", name) is thrown.
##Examples
Dyon code:
~ entity := 42
teleport()
Rust code:
use dyon::Runtime; fn teleport(rt: &mut Runtime) -> Result<(), String> { let current_entity_id = rt.current_object::<u32>("entity")?; assert_eq!(current_entity_id, 42); Ok(()) }
pub fn var_vec4<T: ConvertVec4>(&self, var: &Variable) -> Result<T, String>
[src]
Gets 4D vector.
pub fn var_mat4<T: ConvertMat4>(&self, var: &Variable) -> Result<T, String>
[src]
Gets 4D matrix.
pub fn push<T: PushVariable>(&mut self, val: T)
[src]
Push value to stack.
pub fn push_vec4<T: ConvertVec4>(&mut self, val: T)
[src]
Push Vec4 to stack.
pub fn push_mat4<T: ConvertMat4>(&mut self, val: T)
[src]
Push Mat4 to stack.
pub fn push_rust<T: 'static>(&mut self, val: T)
[src]
Pushes Rust object to stack.
pub fn expected_arg(&self, arg: usize, var: &Variable, ty: &str) -> String
[src]
Generates error message that a certain type was expected for argument.
Sets argument error index on runtime such that external functions can report proper range.
pub fn expected(&self, var: &Variable, ty: &str) -> String
[src]
Generates error message that a certain type was expected.
pub fn resolve<'a>(&'a self, var: &'a Variable) -> &'a Variable
[src]
Resolves a variable reference if any, getting a pointer to the variable on the stack.
pub fn run(&mut self, module: &Arc<Module>) -> Result<(), String>
[src]
Run main
function in a module.
pub fn go(&mut self, go: &Go) -> Result<(Option<Variable>, Flow), String>
[src]
Start a new thread and return the handle.
pub fn call_closure(
&mut self,
call: &CallClosure
) -> Result<(Option<Variable>, Flow), String>
[src]
&mut self,
call: &CallClosure
) -> Result<(Option<Variable>, Flow), String>
Call closure.
pub fn call(
&mut self,
call: &Call,
module: &Arc<Module>
) -> Result<(Option<Variable>, Flow), String>
[src]
&mut self,
call: &Call,
module: &Arc<Module>
) -> Result<(Option<Variable>, Flow), String>
Called from the outside, e.g. a loader script by call
or call_ret
intrinsic.
pub fn call_str(
&mut self,
function: &str,
args: &[Variable],
module: &Arc<Module>
) -> Result<(), String>
[src]
&mut self,
function: &str,
args: &[Variable],
module: &Arc<Module>
) -> Result<(), String>
Calls function by name.
pub fn call_str_ret(
&mut self,
function: &str,
args: &[Variable],
module: &Arc<Module>
) -> Result<Variable, String>
[src]
&mut self,
function: &str,
args: &[Variable],
module: &Arc<Module>
) -> Result<Variable, String>
Call function by name, returning a value.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Runtime
impl Send for Runtime
impl !Sync for Runtime
impl Unpin for Runtime
impl !UnwindSafe for Runtime
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, 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<T, U> TryInto<U> for T where
U: TryFrom<T>,
U: TryFrom<T>,