From 2360ada21fac914a4bc5eeec752966cb3f3bba71 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Fri, 14 Dec 2018 19:25:59 -0800 Subject: Codegen tweak --- nomsu_compiler.moon | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'nomsu_compiler.moon') diff --git a/nomsu_compiler.moon b/nomsu_compiler.moon index 720fe03..bffec92 100644 --- a/nomsu_compiler.moon +++ b/nomsu_compiler.moon @@ -174,12 +174,14 @@ compile = setmetatable({ lua = LuaCode\from(tree.source) lua\add((stub)\as_lua_id!,"(") - for i, arg in ipairs tree\get_args! + for argnum, arg in ipairs tree\get_args! arg_lua = compile(arg) if arg.type == "Block" arg_lua = LuaCode\from(arg.source, "(function()\n ", arg_lua, "\nend)()") - lua\add "," if i > 1 - lua\add(lua\trailing_line_len! + #arg_lua\text! > MAX_LINE and "\n " or " ") + if lua\trailing_line_len! + #arg_lua\text! > MAX_LINE + lua\add(argnum > 1 and ",\n " or "\n ") + elseif argnum > 1 + lua\add ", " lua\add arg_lua lua\add ")" return lua -- cgit v1.2.3