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
impl LuaEnv
pub fn new() -> LuaEnv
Sourcepub fn is_feed_pending(&self) -> bool
pub fn is_feed_pending(&self) -> bool
Returns if there is uncompleted interpreter line, waiting for more input
Sourcepub fn clear_feed_pending(&mut self)
pub fn clear_feed_pending(&mut self)
Clears uncompleted line
Sourcepub fn feed_line(&mut self, source: &[u8]) -> Result<(), RuntimeError>
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.
Sourcepub fn eval_chunk(&mut self, source: &[u8]) -> Result<(), RuntimeError>
pub fn eval_chunk(&mut self, source: &[u8]) -> Result<(), RuntimeError>
parse lua chunk from source and evaluate it.
Sourcepub fn get_global(&self, name: &str) -> LuaValue
pub fn get_global(&self, name: &str) -> LuaValue
Get global variable name name.
Sourcepub fn set_global(&mut self, name: &str, value: LuaValue) -> LuaValue
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.
pub fn push(&self, value: LuaValue)
pub fn pop(&self) -> LuaValue
pub fn get_metavalue( &self, value: &LuaValue, key: &'static str, ) -> Option<LuaValue>
Sourcepub fn tostring(&mut self) -> Result<(), RuntimeError>
pub fn tostring(&mut self) -> Result<(), RuntimeError>
string-fy a value
Sourcepub fn add(&mut self) -> Result<(), RuntimeError>
pub fn add(&mut self) -> Result<(), RuntimeError>
add operation with __add metamethod
Sourcepub fn sub(&mut self) -> Result<(), RuntimeError>
pub fn sub(&mut self) -> Result<(), RuntimeError>
sub operation with __sub metamethod
Sourcepub fn mul(&mut self) -> Result<(), RuntimeError>
pub fn mul(&mut self) -> Result<(), RuntimeError>
mul operation with __mul metamethod
Sourcepub fn div(&mut self) -> Result<(), RuntimeError>
pub fn div(&mut self) -> Result<(), RuntimeError>
div operation with __div metamethod
Sourcepub fn mod_(&mut self) -> Result<(), RuntimeError>
pub fn mod_(&mut self) -> Result<(), RuntimeError>
mod operation with __mod metamethod
Sourcepub fn pow(&mut self) -> Result<(), RuntimeError>
pub fn pow(&mut self) -> Result<(), RuntimeError>
pow operation with __pow metamethod
Sourcepub fn unm(&mut self) -> Result<(), RuntimeError>
pub fn unm(&mut self) -> Result<(), RuntimeError>
unary minus operation with __unm metamethod
Sourcepub fn idiv(&mut self) -> Result<(), RuntimeError>
pub fn idiv(&mut self) -> Result<(), RuntimeError>
floor division operation with __idiv metamethod
Sourcepub fn band(&mut self) -> Result<(), RuntimeError>
pub fn band(&mut self) -> Result<(), RuntimeError>
bitwise and operation with __band metamethod
Sourcepub fn bor(&mut self) -> Result<(), RuntimeError>
pub fn bor(&mut self) -> Result<(), RuntimeError>
bitwise or operation with __bor metamethod
Sourcepub fn bxor(&mut self) -> Result<(), RuntimeError>
pub fn bxor(&mut self) -> Result<(), RuntimeError>
bitwise xor operation with __bxor metamethod
Sourcepub fn shl(&mut self) -> Result<(), RuntimeError>
pub fn shl(&mut self) -> Result<(), RuntimeError>
bitwise shift left operation with __shl metamethod
Sourcepub fn shr(&mut self) -> Result<(), RuntimeError>
pub fn shr(&mut self) -> Result<(), RuntimeError>
bitwise shift right operation with __shr metamethod
Sourcepub fn bnot(&mut self) -> Result<(), RuntimeError>
pub fn bnot(&mut self) -> Result<(), RuntimeError>
bitwise not operation with __bnot metamethod
Sourcepub fn concat(&mut self) -> Result<(), RuntimeError>
pub fn concat(&mut self) -> Result<(), RuntimeError>
concat operation with __concat metamethod
Sourcepub fn len(&mut self) -> Result<(), RuntimeError>
pub fn len(&mut self) -> Result<(), RuntimeError>
# length operation with __len metamethod
Sourcepub fn index(&mut self) -> Result<(), RuntimeError>
pub fn index(&mut self) -> Result<(), RuntimeError>
table index get operation with __index metamethod
Sourcepub fn newindex(&mut self) -> Result<(), RuntimeError>
pub fn newindex(&mut self) -> Result<(), RuntimeError>
table index set operation with __newindex metamethod
Sourcepub fn eq(&mut self) -> Result<(), RuntimeError>
pub fn eq(&mut self) -> Result<(), RuntimeError>
equality operation with __eq metamethod
Sourcepub fn lt(&mut self) -> Result<(), RuntimeError>
pub fn lt(&mut self) -> Result<(), RuntimeError>
less than operation with __lt metamethod
pub fn le(&mut self) -> Result<(), RuntimeError>
Sourcepub fn function_call(
&mut self,
args_num: usize,
func: LuaValue,
expected_ret: Option<usize>,
) -> Result<(), RuntimeError>
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.
Sourcepub fn run_instruction(
&mut self,
instruction: Instruction,
) -> Result<(), RuntimeError>
pub fn run_instruction( &mut self, instruction: Instruction, ) -> Result<(), RuntimeError>
execute single instruction
Sourcepub fn cycle(&mut self) -> Result<(), RuntimeError>
pub fn cycle(&mut self) -> Result<(), RuntimeError>
run single instruction