Struct LuaEnv

Source
pub struct LuaEnv { /* private fields */ }
Expand description

Main entry for Lua runtime. It contains global environment, random number generator, coroutine stack, etc.

Implementations§

Source§

impl LuaEnv

Source

pub fn new() -> LuaEnv

Source

pub fn is_feed_pending(&self) -> bool

Returns if there is uncompleted interpreter line, waiting for more input

Source

pub fn clear_feed_pending(&mut self)

Clears uncompleted line

Source

pub fn feed_line(&mut self, source: &[u8]) -> Result<(), RuntimeError>

Feed lua source code for REPL interpreter.

If source is not a complete line, nothing will be evaluated, and waiting for next feed_line. If source can be evaluated as a Expression, it will be evaluated and printed.

Source

pub fn eval_chunk(&mut self, source: &[u8]) -> Result<(), RuntimeError>

parse lua chunk from source and evaluate it.

Source

pub fn get_global(&self, name: &str) -> LuaValue

Get global variable name name.

Source

pub fn set_global(&mut self, name: &str, value: LuaValue) -> LuaValue

Set global variable name name to value Returns the old value of the variable, or nil if it doesn’t exist. Settting a variable to nil is equivalent to deleting it.

Source

pub fn push(&self, value: LuaValue)

Source

pub fn pop(&self) -> LuaValue

Source

pub fn get_metavalue( &self, value: &LuaValue, key: &'static str, ) -> Option<LuaValue>

Source

pub fn tostring(&mut self) -> Result<(), RuntimeError>

string-fy a value

Source

pub fn add(&mut self) -> Result<(), RuntimeError>

add operation with __add metamethod

Source

pub fn sub(&mut self) -> Result<(), RuntimeError>

sub operation with __sub metamethod

Source

pub fn mul(&mut self) -> Result<(), RuntimeError>

mul operation with __mul metamethod

Source

pub fn div(&mut self) -> Result<(), RuntimeError>

div operation with __div metamethod

Source

pub fn mod_(&mut self) -> Result<(), RuntimeError>

mod operation with __mod metamethod

Source

pub fn pow(&mut self) -> Result<(), RuntimeError>

pow operation with __pow metamethod

Source

pub fn unm(&mut self) -> Result<(), RuntimeError>

unary minus operation with __unm metamethod

Source

pub fn idiv(&mut self) -> Result<(), RuntimeError>

floor division operation with __idiv metamethod

Source

pub fn band(&mut self) -> Result<(), RuntimeError>

bitwise and operation with __band metamethod

Source

pub fn bor(&mut self) -> Result<(), RuntimeError>

bitwise or operation with __bor metamethod

Source

pub fn bxor(&mut self) -> Result<(), RuntimeError>

bitwise xor operation with __bxor metamethod

Source

pub fn shl(&mut self) -> Result<(), RuntimeError>

bitwise shift left operation with __shl metamethod

Source

pub fn shr(&mut self) -> Result<(), RuntimeError>

bitwise shift right operation with __shr metamethod

Source

pub fn bnot(&mut self) -> Result<(), RuntimeError>

bitwise not operation with __bnot metamethod

Source

pub fn concat(&mut self) -> Result<(), RuntimeError>

concat operation with __concat metamethod

Source

pub fn len(&mut self) -> Result<(), RuntimeError>

# length operation with __len metamethod

Source

pub fn index(&mut self) -> Result<(), RuntimeError>

table index get operation with __index metamethod

Source

pub fn newindex(&mut self) -> Result<(), RuntimeError>

table index set operation with __newindex metamethod

Source

pub fn eq(&mut self) -> Result<(), RuntimeError>

equality operation with __eq metamethod

Source

pub fn lt(&mut self) -> Result<(), RuntimeError>

less than operation with __lt metamethod

Source

pub fn le(&mut self) -> Result<(), RuntimeError>

Source

pub fn function_call( &mut self, args_num: usize, func: LuaValue, expected_ret: Option<usize>, ) -> Result<(), RuntimeError>

Function call with given function object. This could search for __call metamethod if the function object is not a function.

Source

pub fn run_instruction( &mut self, instruction: Instruction, ) -> Result<(), RuntimeError>

execute single instruction

Source

pub fn cycle(&mut self) -> Result<(), RuntimeError>

run single instruction

Auto Trait Implementations§

§

impl Freeze for LuaEnv

§

impl !RefUnwindSafe for LuaEnv

§

impl !Send for LuaEnv

§

impl !Sync for LuaEnv

§

impl Unpin for LuaEnv

§

impl !UnwindSafe for LuaEnv

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V