[Date Prev][Date Next][Thread Prev][Thread Next]
- 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 <email@example.com> 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 .
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 , and it appears also with Yueliang . You
can stumble with things like "continue" statements, which Lua doesn't
directly support, so you may need to do some pre-translation