lua-users home
lua-l archive

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


On Sat, Jun 26, 2010 at 10:49 AM, Stuart P. Bentley
<stuart@testtrack4.com> wrote:
> Is this a problem inherent to TCC?


it's a known issue.  in short, TCC handles most of it's context in a
opaque structure (similar to Lua's LuaState structure).  you can add C
code to the context and iteratively compile it; but before exercuting
it, you have to do a 'link' operation.  after that, the code is
executable, but can't add more C to it.

What i tried to to was to hold several contgexts at the same time
(each one referenced by a Lua userdata), that way it would be possible
to link and execute one piece of C code, and later on compile/link
another one on a different context.

unfortunately, there are a few crucial variables stored not in the
context structure but on global variables.  that simple detail means
you can't manage more than one compiler context at the same time and
keep them separate.  so, after you link, you can't compile anymore.
IOW: it's not useful for using C as a scripting language for a
long-running application.

i did a couple (feeble) attempts at hacking TCC's code, but i was lost
pretty soon.  knowing that it evolved from a C code obfuscation winner
didn't help either :-)

-- 
Javier