lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

awesome job!

---- Ativado Dom, 23 jan 2022 22:08:07 -0300 Spar <> escreveu ----

Greetings. Today I want to announce the beta release of Lua To Lua C API site-tool.
The idea is to get a fast draft of C code using Lua code.
This tool uses Fengari (that is it supports Lua 5.3 syntax) and parses its bytecode then each instruction is transpiled to their equivalent or not so equivalent in C API.

This is a very basic version, it doesn't follow register placement, it assumes they are pushed at the end.
It doesn't produce nice code, conditionals and generic for loops are messy because of how bytecode is mapped.
But it works, and as a proof of concept can be used.

- Input:
print("Hello World")

- Output:
static int lua_openmodule(lua_State* L) {
    lua_getglobal(L, "print");
    lua_pushstring(L, "Hello World");
    lua_call(L, 1, 0);
    return 0;