[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Converting C Code to Lua
- From: David Manura <dm.lua@...>
- Date: Mon, 5 Apr 2010 22:22:03 -0400
On Sat, Apr 3, 2010 at 12:35 AM, Vafa Khalighi <vafa@users.berlios.de> wrote:
>> In what sense? Do you want to use your compiled C function in Lua, or do
>> you want to convert a C procedure into its equivalent in Lua? ...
> Thanks. I meant the latter.
If you want this in a general sense, see David Given's clue [1,2], but
it's said to be experimental, and I doubt your result will be pretty.
This might be analogous to what Alchemy/LLVM does [5].
I have found that C code can be translated into Lua code in a mostly
mechanical way if want to preserve structure over efficiency. Even
something like a pointer into a C array can be translated into an
index into a Lua table array. That was the case with Lua's lstrlib.c
translated into Lua [3], and it appears also with Yueliang [4]. You
can stumble with things like "continue" statements, which Lua doesn't
directly support, so you may need to do some pre-translation
reworking.
[1] http://lua-users.org/lists/lua-l/2008-07/msg00114.html
[2] http://lua-users.org/wiki/LuaImplementations
[3] http://lua-users.org/wiki/StringLibraryInLua
[4] http://yueliang.luaforge.net/
[5] http://labs.adobe.com/technologies/alchemy/