This is an implementation of a Rust virtual machine for the Lua language. It is a complete rewrite, following the Lua 5.4 language specification.
cargo run --release -- myfile.luaAdditional available flags are:
--debug-lexer: Dump each token read by the lexer, and exit. Do not execute the file.--debug-parser: Same, but for the parser. Dumps out the parsed AST.--disable-optimizer: Disables the optimization passes on the AST before code generation. The optimizer is enabled by default, and performs optimizations such as pre-computing constant expressions (e.g.3 + 4will be optimized to7).--print-bytecode: Print the compiled bytecode before executing it.
The project aims to implement the full Lua 5.4 standard library.
Legend:
- β Fully implemented according to the spec.
β οΈ Partially implemented (some functions missing, incorrect, or incomplete).- π« Functionality not yet implemented.
- Basic functions [20/25]
- β assert
- β collectgarbage Note that the Rust Lua VM does not use garbage collection, so this function is essentially a stub, while mimicking the behavior of the Lua standard library.
- π« dofile
β οΈ error Thelevelargument is not yet implemented.- β
_G - β getmetatable
- β ipairs
β οΈ load Loading binary chunks is not yet supported.- π« loadfile
- β next
- β pairs
- β pcall
- β print
- β rawequal
- β rawget
- β rawlen
- β rawset
- β select
- β setmetatable
- β tonumber
- β tostring
- β type
- β
_VERSION - β warn
- β xpcall
- Coroutine manipulation [0/8]
- π« coroutine.close
- π« coroutine.create
- π« coroutine.isyieldable
- π« coroutine.resume
- π« coroutine.running
- π« coroutine.status
- π« coroutine.wrap
- π« coroutine.yield
- Modules [1/9]
β οΈ require Loading files is supported, butpackage.searchersis not used correctly. Instead, part of the searchers behavior is hardcoded.β οΈ package.config The fourth and fifth lines are not yet supported.- π« package.cpath
- β package.loaded
- π« package.loadlib
β οΈ package.path A static value is used, and it does not read from environment variables on startup. The value cannot be changed at runtime.- π« package.preload
- π« package.searchers
- π« package.searchpath
- String manipulation [12/17]
- β string.byte
- β string.char
- π« string.dump
- β string.find
β οΈ string.format Only thesanddformat specifiers are supported.- β string.gmatch
- π« string.gsub
- β string.len
β οΈ string.lower Only handles UTF-8 input, and does not use current locale.- β string.match
- β string.pack
- β string.packsize
- β string.rep
- β string.reverse
- β string.sub
- β string.unpack
β οΈ string.upper Only handles UTF-8 input, and does not use current locale.
- UTF-8 support [1/6]
- π« utf8.char
- β utf8.charpattern
- π« utf8.codes
- π« utf8.codepoint
- π« utf8.len
- π« utf8.offset
- Table manipulation [3/7]
- β table.concat
- β table.insert
- π« table.move
- β table.pack
- π« table.remove
- π« table.sort
- β table.unpack
- Mathematical functions [24/27]
- β math.abs
- β math.acos
- β math.asin
- π« math.atan
- β math.ceil
- β math.cos
- β math.deg
- β math.exp
- β math.floor
- π« math.fmod
- β math.huge
- β math.log
- β math.max
- β math.maxinteger
- β math.min
- β math.mininteger
- β math.modf
- β math.pi
- β math.rad
- β math.random
- β math.randomseed
- β math.sin
- β math.sqrt
- β math.tan
- β math.tointeger
- β math.type
β οΈ math.ult
- Input and output [7/21]
- β io.close
- π« io.flush
- π« io.input
- π« io.lines
- π« io.open
- β io.output
- π« io.popen
- π« io.read
- β io.stdin
- β io.stderr
- β io.stdout
- π« io.tmpfile
- π« io.type
- β io.write
- β file:close
- π« file:flush
- π« file:lines
- π« file:read
- π« file:seek
- π« file:setvbuf
- β file:write
- Operating system facilities [3/11]
- β os.clock
- π« os.date
- π« os.difftime
- π« os.execute
- π« os.exit
- β os.getenv
- π« os.remove
- π« os.rename
- π« os.setlocale
- β os.time
β οΈ os.tmpname Unlike what the manual specifies, this implementation does not create the temporary file on Unix systems. Instead, it only returns a unique filename.
- Debug library [2/15]
- π« debug.debug
- π« debug.gethook
- π« debug.getinfo
- π« debug.getlocal
- π« debug.getmetatable
- π« debug.getregistry
- β debug.getupvalue
- π« debug.sethook
- π« debug.setlocal
- π« debug.setmetatable
- π« debug.setupvalue
- π« debug.setuservalue
- π« debug.traceback
- β debug.upvalueid
- π« debug.upvaluejoin
This library does not yet implement the Lua C API, but this is planned for the future.