SkillAgentSearch skills...

Goluago

[on hold] Port of Lua 5.1 interpreter to Go Language Toolchain. [Work In Progress.] See also: http://lua.org and http://golang.org

Install / Use

/learn @akavel/Goluago
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

Library goluago aims to become a port of Lua 5.1 interpreter to Go Language Toolchain (first 8c/6c/5c, ultimately maybe pure Go).

The library is at early stage of development (not feature complete / not ready for production use), but some important goals were already completed successfully:

STATUS

ON HOLD/DORMANT as of 2016. I have trouble (and not enough time to dive deeper) understanding and exploring c2go's type unification code, and I need that to be able to add various missing operators (e.g. the ternary operator ?: ) and constructs (e.g. assignment in expressions, i.e. while((x=y++)<3) ). If someone cares enough to add them to c2go, I'd be happy to come back this project. (In any case, if you'd like discussing something related to the project, you're very welcome to contact me at czapkofan@gmail.com).

Pushback (2014-12-10: Go 1.4):

NOTE: because the go command's support for the internal C compiler was removed with Go 1.4, the goluago project won't build successfully with go get under Go 1.4+ anymore. On one hand, that's a major setback. But on the other hand, that's a strong motivation to explore the possible use of Russ Cox's c2go to convert the Lua C sources to pure Go (with no more C).

That's what I'm aiming for with the current "c2go" branch of the goluago project.

Alpha2 (2014-05-15):

C API: ~57% complete (81/142 + 1), ~15% have some test (21/143)

  • [MILESTONE][API] most of the core C API implemented (details below)

What works - new in alpha1 (2013-12-30):

  • [MILESTONE] workaround in ldebug.c for a bug in Go toolchain's C compiler
  • [MILESTONE][Lua] nearly all standard libraries available (with notable exception of file access)
  • [Lua] most of the Lua Testsuite test code now passes successfully
  • [API] wrapper for lua_pcall() added
  • now uses new, more complete version of the http://github.com/akavel/gostdc library

What works since pre-alpha preview 2:

  • [MILESTONE] parsing & compiling Lua scripts to bytecode (via luaL_loadbuffer())
  • [Lua] standard libraries: basic library (print(), ipairs(), assert(), loadstring(), etc.)
  • [Lua] passes parts of the Lua testsuite (tested on fragment of "calls.lua")
  • [API] basic strings API (lua_pushlstring(), lua_tolstring())
  • [API] exposing Go funcs into Lua (lua_pushgofunction(), lua_dump())
  • [tools] Lua script for embedding Lua testsuite parts in Go unit tests (wrap-test.lua)
  • [API, Lua] string <-> number conversions

What works since pre-alpha preview 1:

  • [API] creating/destroying new Lua state (luaL_newstate(), lua_close())
  • [API] basic integer operations on stack (lua_pushinteger(), lua_gettop(), lua_equal())
  • [API] running simple precompiled Lua code chunk (luaL_loadbuffer(), lua_call(), tested on precompiled chunk "return 2+3")
  • compiled and tested on: x86 (8c+8g), x64 (6c+6g), Windows/Linux
  • [tools] Lua script to simplify generation of Go+C wrappers for Lua API functions (internal/gen_wrappers.lua)

Build & Testsuite Status: Build & Testsuite Status

See also: Build & Testsuite Status on Travis-CI. Please note, that the project is still officially at early stage of development, so if the testsuite fails, it's nothing unexpected; rather, it's very good news that it builds and big part of the testsuite does already succeed!

WANTED / PLANS

Crucial:

  • fix/implement all the rest of needed C standard library functions (leveraging Go standard library where possible) in http://github.com/akavel/gostdc -- the embedded "panicstring" calls shall emit a runtime panic when a stub function is called, making them easier to spot.
    • preferably switch github.com/akavel/gostdc back from Plan9's APE C lib licensed with weird Lucent license, to my handmade lib, which is based where possible on thin wrappers over Go lib.
    • some most notably missing Lua functions now:
      • file & filesystem access
      • os.exit()
      • time-related functions
    • enable support for Lua's package library
  • MILESTONE: get goluago to fully pass the Lua 5.1 testsuite (lua5.1-tests/*.lua)
    • still missing: math.lua, big.lua, verybig.lua, attrib.lua
  • collect some other Lua testsuites from teh Internets and use them for testing too
  • MILESTONE: expose full Lua API in Go (except functions not compatible with Go)
    • notably still missing:
      • coroutine ("thread") -related
      • lua_Debug -related
      • many luaL_* functions, although they're reportedly all doable with the non-luaL ones
  • fix allocator, to be per-State for custom synchronization & for GC-ability
  • ARM support, and other architectures later

Would be nice-ies:

  • write prettier interface on top of official Lua API (maybe converge with http://github.com/stevedonovan/luar)
  • Lua 5.2
  • write unit tests for C standard library functions implemented for Lua;
  • improve C standard library in http://github.com/akavel/gostdc
    • maybe use some non-GPL Open Source code (FreeBSD? some stdlib for embedded systems?);
    • try to go back to non-APE version of the code, to avoid the nonstandard Lucent license
  • extract C standard library to separate package;
  • later, "ANSI C to Go translator", in extent needed by the Lua sources?

NOTE: you're welcome to contribute anything if you fancy, and not necessarily from this list. The points above are mostly ideas as to what I believe would be most useful at this moment.

BACKGROUND INFO

Lua?

http://lua.org

Lua is a nice scripting language. Small, written in ANSI C, highly portable, reportedly fast. Especially popular among computer games producers, but not only. Easily embeddable (one of its core goals), mature (Lua 1.0 ~ 1993, many applications worldwide since then). MIT-style licensed.

Go Language?

http://golang.org

Fairly new language developed at Google. Authors are however experienced in building and experimenting with programming languages (specifically C, Limbo), with notable uses, including OS development (Unix, Plan9/Inferno). Highly portable (x86/x64, ARM; Linux/*nix, Windows, Mac OS X, other ports in progress), written (bootstrapped) in C. BSD-style licensed. Popularity hard to determine given short time on market, but has several nice and interesting features and properties.

INSTALLATION

With the Go environment properly set up, type:

go get github.com/akavel/goluago/internal
go test github.com/akavel/goluago/internal

To retrieve and run a sample program:

go get github.com/akavel/goluago/testlua
cd $GOROOT   # or, see $GOPATH; on Windows %GOROOT%, %GOPATH%
bin/testlua  # on Windows: bin\testlua.exe
<a name="C-API-STATUS"/> C API STATUS ------------

~57% complete (81/142 + 1), ~15% have some test (21/143)

| Go | C | tests? | | --- | --- | ------ | | | luaL_addchar | | | | luaL_addlstring | | | | luaL_addsize | | | | luaL_addstring | | | | luaL_addvalue | | | | luaL_argcheck | | | | luaL_argerror | | | | luaL_buffinit | | | | luaL_callmeta | | | | luaL_checkany | | | | luaL_checkint | | | | luaL_checkinteger | | | | luaL_checklong | | | | luaL_checklstring | | | | luaL_checknumber | | | | luaL_checkoption | | | | luaL_checkstack | | | | luaL_checkstring | | | | luaL_checktype | | | | luaL_checkudata | | | | luaL_dofile | | | | luaL_dostring | | | | luaL_error | | | | luaL_getmetafield | | | | luaL_getmetatable | | | | luaL_gsub | | | State.Loadbuffer | luaL_loadbuffer | has test! | | | luaL_loadfile | | | | luaL_loadstring | | | | luaL_newmetatable | |

View on GitHub
GitHub Stars173
CategoryDevelopment
Updated1mo ago
Forks11

Languages

C

Security Score

85/100

Audited on Feb 3, 2026

No findings