Make the Lua entry point a little bit prettier
Don't generate the `slot = s2v(base + i)` line if there is not going to be a
corresponding tag check (that is, if the parameter has type `value`).
@@ -428,15 +428,18 @@ function Coder:lua_entry_point_definition(f_id)
local type_checks = {}
for i, typ in ipairs(arg_types) do
local name = func.vars[i].comment
+ local check_tag =
+ self:check_tag(typ, "slot", func.loc, "argument %s", C.string(name))
+ if check_tag ~= "" then
table.insert(type_checks, util.render([[
slot = s2v(base + $i);
${check_tag}
]], {
i = C.integer(i),
- check_tag = self:check_tag(
- typ, "slot", func.loc, "argument %s", C.string(name)),
+ check_tag = check_tag,
}))
end
+ end
local arg_vars = {}
local init_args = {}
