Codegen tweak
This commit is contained in:
parent
83a40b7493
commit
2360ada21f
@ -236,15 +236,16 @@ local compile = setmetatable({
|
|||||||
end
|
end
|
||||||
local lua = LuaCode:from(tree.source)
|
local lua = LuaCode:from(tree.source)
|
||||||
lua:add((stub):as_lua_id(), "(")
|
lua:add((stub):as_lua_id(), "(")
|
||||||
for i, arg in ipairs(tree:get_args()) do
|
for argnum, arg in ipairs(tree:get_args()) do
|
||||||
local arg_lua = compile(arg)
|
local arg_lua = compile(arg)
|
||||||
if arg.type == "Block" then
|
if arg.type == "Block" then
|
||||||
arg_lua = LuaCode:from(arg.source, "(function()\n ", arg_lua, "\nend)()")
|
arg_lua = LuaCode:from(arg.source, "(function()\n ", arg_lua, "\nend)()")
|
||||||
end
|
end
|
||||||
if i > 1 then
|
if lua:trailing_line_len() + #arg_lua:text() > MAX_LINE then
|
||||||
|
lua:add(argnum > 1 and ",\n " or "\n ")
|
||||||
|
elseif argnum > 1 then
|
||||||
lua:add(", ")
|
lua:add(", ")
|
||||||
end
|
end
|
||||||
lua:add(lua:trailing_line_len() + #arg_lua:text() > MAX_LINE and "\n " or " ")
|
|
||||||
lua:add(arg_lua)
|
lua:add(arg_lua)
|
||||||
end
|
end
|
||||||
lua:add(")")
|
lua:add(")")
|
||||||
|
@ -174,12 +174,14 @@ compile = setmetatable({
|
|||||||
|
|
||||||
lua = LuaCode\from(tree.source)
|
lua = LuaCode\from(tree.source)
|
||||||
lua\add((stub)\as_lua_id!,"(")
|
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)
|
arg_lua = compile(arg)
|
||||||
if arg.type == "Block"
|
if arg.type == "Block"
|
||||||
arg_lua = LuaCode\from(arg.source, "(function()\n ", arg_lua, "\nend)()")
|
arg_lua = LuaCode\from(arg.source, "(function()\n ", arg_lua, "\nend)()")
|
||||||
lua\add "," if i > 1
|
if lua\trailing_line_len! + #arg_lua\text! > MAX_LINE
|
||||||
lua\add(lua\trailing_line_len! + #arg_lua\text! > MAX_LINE and "\n " or " ")
|
lua\add(argnum > 1 and ",\n " or "\n ")
|
||||||
|
elseif argnum > 1
|
||||||
|
lua\add ", "
|
||||||
lua\add arg_lua
|
lua\add arg_lua
|
||||||
lua\add ")"
|
lua\add ")"
|
||||||
return lua
|
return lua
|
||||||
|
Loading…
Reference in New Issue
Block a user