[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [patch] dynamically link liblua to luac
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Sun, 7 Dec 2008 18:17:48 -0200
> In the below patch, I modified luac.c to take an approach somewhat
> like the luac.lua above, eliminating the dependencies on internal
> functions in the Lua library.
I did something similar as a proof-of-concept when I was writing luac.lua;
see the code below. With this change, luac.c no longer depends on *any*
internal function, except luaU_dump. It still need access to the contents
of L, though.
static const Proto* combine(lua_State* L, int n)
{
if (n==1)
return toproto(L,-1);
else
{
int i;
Proto* f;
for (i=0; i<n; i++) lua_pushliteral(L,"(function()end)();");
lua_concat(L,n);
luaL_loadbuffer(L,lua_tostring(L,-1),lua_objlen(L,-1),"=(" PROGNAME ")");
f=toproto(L,-1);
for (i=0; i<n; i++) f->p[i]=toproto(L,i-n-2);
return f;
}
}
This version of combine is really much easier to read, maintain, and hack.
Let's see what happens to luac in 5.2...
--lhf