This is an Odin port of the clox vm from Robert Nystroms book "Crafting Interpreters".
This implementation comes with a few additions over the original clox vm, these include:
- Run-Length-Encoding of bytecode line numbers to improve memory usage
- Support for more than 255 constants per chunk, while keeping backwards compatibility in performance for single byte constant instructions
- Support for Values as keys in hash tables
- Switch Statements
- Break Statements to break out of loops
- Final keyword, which gets checked at compile time
- Improved performance of garbage collection.
This project includes an extensive test suite and a test runner written in c++, which can be found in test/test.cpp. To use it compile the test runner (c++ version 17+) and pass it the path to the compiled compiler/vm.
Requires an Odin compiler.
odin build src -out=olox
./olox <srcfile>.lox
./olox