lua-users home
lua-l archive

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


>it has the Lua code in this buffer, I want to be able to tell Lua "Okay,
>parse this and turn it in to byte code, but don't execute it. Oh, and I need
>the byte code back from you please". This would allow me to cache the
>bytecode in memory, rather then keeping the source text hanging around.

You can still use load_buffer for this and keep the function it leaves on the
stack (use a reference for instance).

In Lua 4.0, you can wrap your Lua code inside "return function() XXX end",
run lua_dobuffer and then get the value it returns.

In both cases, you'll have a Lua precompiled Lua function that you can run
at anytime with lua_call(L,0,0).
--lhf