Skip to content
LuaJIT 2.0 bytecode parser, viewer, assembler and test VM
C++ C QMake
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples refactored print1 to dbgout, new demo Nov 13, 2019
luajit-2.0
syntax
BcViewer.cpp fixes; disasm stripped; suspended array support; composer redesigned Nov 9, 2019
BcViewer.h
Engine2.cpp
Engine2.h
ExpressionParser.cpp
ExpressionParser.h write asm; engine add source libs; JitComposer; headers updated; fixes Oct 7, 2019
LICENSE.GPL2 initial publication Aug 29, 2019
LICENSE.GPL3 initial publication Aug 29, 2019
LjAsmEditor.cpp refactored Named; import options; call record special handling and al… Nov 14, 2019
LjAsmEditor.h
LjAsmEditor.pro
LjAssembler.cpp fixes Nov 15, 2019
LjAssembler.h
LjBcViewer.pro additions to statically include LuaJIT Nov 10, 2019
LjBcViewerMain.cpp fixes; bcviewer automatic compile Nov 10, 2019
LjBcViewerMain.h
LjDisasm.cpp
LjDisasm.h refactored Named; import options; call record special handling and al… Nov 14, 2019
LjasErrors.cpp
LjasErrors.h
LjasFileCache.cpp added LjAsm lexer, parser, token, highlighter etc. and generated file… Oct 25, 2019
LjasFileCache.h added LjAsm lexer, parser, token, highlighter etc. and generated file… Oct 25, 2019
LjasHighlighter.cpp
LjasHighlighter.h
LjasLexer.cpp fixes; disasm stripped; suspended array support; composer redesigned Nov 9, 2019
LjasLexer.h
LjasParser.cpp
LjasParser.h fixes; added slot preset for vars Nov 12, 2019
LjasSynTree.cpp fixes; added slot preset for vars Nov 12, 2019
LjasSynTree.h
LjasToken.cpp
LjasToken.h added LjAsm lexer, parser, token, highlighter etc. and generated file… Oct 25, 2019
LjasTokenType.cpp fixes; disasm stripped; suspended array support; composer redesigned Nov 9, 2019
LjasTokenType.h fixes; disasm stripped; suspended array support; composer redesigned Nov 9, 2019
LuaHighlighter.cpp initial publication Aug 29, 2019
LuaHighlighter.h
LuaJitBytecode.cpp
LuaJitBytecode.h
LuaJitComposer.cpp added Xref and navigation to editor; refactoring; fixes Nov 11, 2019
LuaJitComposer.h fixes; disasm stripped; suspended array support; composer redesigned Nov 9, 2019
LuaJitEngine.cpp refactored print1 to dbgout, new demo Nov 13, 2019
LuaJitEngine.h
README.md
StreamSpy.h JitBytecode::write implemented; test cases produce same md5sum like t… Nov 4, 2019
Terminal2.cpp fixes; disasm stripped; suspended array support; composer redesigned Nov 9, 2019
Terminal2.h fixes; disasm stripped; suspended array support; composer redesigned Nov 9, 2019
lj_code.cpp bcview new disasm; new assembler, register allocator; fixes Nov 2, 2019

README.md

This is a parser, browser, assembler and test VM for LuaJIT 2.0 bytecode written in C++ and Qt. See http://luajit.org/ for more information about LuaJIT.

The goal of this project (work in progress) is to better understand how LuaJIT works, and to support the development of alternative front ends which generate LuaJIT bytecode (as it is e.g. done in https://github.com/rochus-keller/Oberon).

The viewer can be used to edit and compile Lua source code and display it side by side with its corresponding LuaJIT bytecode. The test VM implements a subset of LuaJIT bytecodes to study and validate their functions (see the examples subfolder).

Here is a Lua BcViewer screenshot: LjBcViewer Screenshot

The assembler can be used to directly program and test with LuaJIT bytecode. The syntax is defined in LjAsm.ebnf; here is a PDF: http://software.rochus-keller.info/LjAsm_Syntax.pdf. It slightly abstracts from original LuaJIT bytecode and supports automatic register allocation. Documentation of the syntax is TBD; varargs and for loops are not yet supported (because most likely not used by the new front ends). The editor supports semantic highlighting and navigation (CTRL+Click on ident), and shows a list of cross-references when an ident is selected.

Here is an Asm Editor screenshot: LjAsmEditor Screenshot

Build Steps

Follow these steps if you want to build LjBcViewer yourself:

  1. Make sure a Qt 5.x (libraries and headers) version compatible with your C++ compiler is installed on your system.
  2. A compiled version of LuaJIT 2.0 is also required; your distro likely includes a dev package. Alternatively download the source from http://luajit.org/download/LuaJIT-2.0.5.tar.gz and run the Makefile; make sure the resulting libluajit.so/lib is accessible to the linker.
  3. Create a directory; let's call it BUILD_DIR
  4. Download the source code from https://github.com/rochus-keller/LjTools/archive/master.zip to the BUILD_DIR; rename the subdirectory to "LjTools".
  5. Download the GuiTools source code from https://github.com/rochus-keller/GuiTools/archive/master.zip and unpack it to the BUILD_DIR; rename it to "GuiTools".
  6. Goto the BUILD_DIR/LjTools subdirectory and execute QTDIR/bin/qmake LjBcViewer.pro (see the Qt documentation concerning QTDIR).
  7. Run make; after a couple of seconds you will find the executable in the build directory.

Alternatively you can open LjBcViewer.pro using QtCreator and build it there.

LjAsmEditor.pro is compiled in the same way. The application makes use of a parser generated by Coco/R based on input from EbnfStudio (see https://github.com/rochus-keller/EbnfStudio). There is no other dependency than the Qt Basic library. The repository already contains the generated files. In order to regenerate LjasParser.cpp/h you have to use this version of Coco/R: https://github.com/rochus-keller/Coco.

The repository includes the original LuaJIT 2.0.5 headers for convenience.

You can’t perform that action at this time.