[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Problem compiling lua chunks with just tables...
- From: "Tham" <tham@...>
- Date: Sat, 7 Feb 2004 20:00:57 +0800
hi,
I'm using codes luac.c as an example to compile output lua chunks. The
modified code (now integrated into my app) is tested to be working for
compiling Lua functions. However i have problem
compiling just lua tables. These are the scenarios that i have investigated
and their results.
Scenario 1:
Compile the following script
t001 = {t001_name = "mytable"}
F001 = t001
Result:
a chunk about 0x99 bytes long. A look into the binary chunk using hex editor
i can see symbols like t001, t001_name, mytable F001.
Scenario 2:
Compile the following script
t001 = {t001_name = "mytable"}
Result:
a chunk about 0x45 bytes long. A look into the binary chunk reveals no such
symbols like t001, t001_name or mytable.
Scnenario 3:
Build a table using the following algorithm, and output the chunk
lua_newtable(L);
lua_pushstring(L,"t001_name");
lua_pushstring(L,"mytable");
lua_settable(L, -3);
lua_setglobal(L,"t001");
Result:
same as Scenario 2:
Scnenario 4:
Build a table using the following algorithm, and output the chunk
lua_newtable(L);
lua_pushstring(L,"t001_name");
lua_pushstring(L,"mytable");
lua_settable(L, -3);
lua_setglobal(L,"t001");
lua_getglobal(L,"t001");
lua_setglobal(L,"F001");
Result:
same as Scenario 2:
These tests led me to my conclusion which is:
In scenario 1 because there is a line of 'code' that assigns t001 to F001
therefore t001 along with F001 is compile out.
On theother hand, Scenario 2 and 3 doesnt have any code therefore nothing is
compiled.
For Scenario 4, although i did set "F001" to "t001", this just modifies the
global table but there arent any code. So i get the same result as Scenario
2.
Therefore, there must be some code that uses these globals or else it is
droped from the lua_dump..
Is this true?
Do i need a different setup to compile the other scenario?
thanks
tham