Use s2v macro to convert StackValue* to TValue*
This is more in line with the rest of the PUC-Lua code.
@@ -73,7 +73,7 @@ int luaopen_${MODNAME}(lua_State *L)
CClosure *func = luaF_newCclosure(L, 1);
func->f = init_${MODNAME};
sethvalue(L, &func->upvalue[0], titan_globals);
- setclCvalue(L, &L->top->val, func);
+ setclCvalue(L, s2v(L->top), func);
api_incr_top(L);
lua_call(L, 0, 0);
@@ -312,7 +312,7 @@ generate_program = function(prog, modname)
-- TODO: fix: the error message is not able specify if the
-- given type is float or integer (it prints "number")
local decl = util.render([[
- ${SLOT_DECL} = &(L->ci->func + ${I})->val;
+ ${SLOT_DECL} = s2v(L->ci->func + ${I});
if (!${CHECK_TAG}) {
luaL_error(L,
"wrong type for argument %s at line %d, "
@@ -352,7 +352,7 @@ generate_program = function(prog, modname)
RET_DECL = c_declaration(ctype(ret_typ), "ret"),
ARGS_DECL = table.concat(args_decl, "\n"),
ARGS = table.concat(args, ", "),
- SET_RET = set_slot(ret_typ, "&L->top->val", "ret"),
+ SET_RET = set_slot(ret_typ, "s2v(L->top)", "ret"),
})
)
end
@@ -370,7 +370,7 @@ generate_program = function(prog, modname)
if n_toplevel > 0 then
table.insert(parts,
- [[Table *titan_globals = hvalue(&clCvalue(&L->ci->func->val)->upvalue[0]);]])
+ [[Table *titan_globals = hvalue(&clCvalue(s2v(L->ci->func))->upvalue[0]);]])
end
for _, tl_node in ipairs(prog) do
