mirror of
https://github.com/leafo/moonscript.git
synced 2025-01-09 00:04:22 +00:00
local declared before fndef to allow recursion
This commit is contained in:
parent
66fcb9593d
commit
b9e8b3014d
6
moonc
6
moonc
@ -61,7 +61,11 @@ function compile_file(from, to)
|
||||
return nil, err
|
||||
end
|
||||
|
||||
local code = compile.tree(tree)
|
||||
local good, code = pcall(compile.tree, tree)
|
||||
if not good then
|
||||
return nil, "Compile critical failure: "..code
|
||||
end
|
||||
-- local code = compile.tree(tree)
|
||||
|
||||
mkdir(get_dir(to))
|
||||
local out_f = io.open(to, "w")
|
||||
|
@ -416,6 +416,13 @@ local compiler_index = {
|
||||
end
|
||||
|
||||
local compact = not block_statements[ntype(values)] and #undeclared_names == #names
|
||||
-- if there is an fndef in there, don't do compact
|
||||
for _, v in ipairs(values) do
|
||||
if ntype(v) == "fndef" then
|
||||
compact = false
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
local lines = {}
|
||||
local num_undeclared = #undeclared_names
|
||||
|
@ -54,8 +54,10 @@ for z in items do
|
||||
end
|
||||
end
|
||||
require("util")
|
||||
local dump = function(x) return print(util.dump(x)) end
|
||||
local range = function(count)
|
||||
local dump
|
||||
dump = function(x) return print(util.dump(x)) end
|
||||
local range
|
||||
range = function(count)
|
||||
local i = 0
|
||||
return(coroutine.wrap(function()
|
||||
while i < count do
|
||||
|
@ -1,4 +1,5 @@
|
||||
local x = function() return print(what) end
|
||||
local x
|
||||
x = function() return print(what) end
|
||||
local _ = function() end
|
||||
_ = function()
|
||||
return function() return function() end end
|
||||
@ -7,9 +8,11 @@ go(to(the(barn)))
|
||||
open(function() return the(function() return door end) end)
|
||||
open(function()
|
||||
the(door)
|
||||
local hello = function() return my(func) end
|
||||
local hello
|
||||
hello = function() return my(func) end
|
||||
end)
|
||||
local h = function() return hi end
|
||||
local h
|
||||
h = function() return hi end
|
||||
eat(function() end, world)
|
||||
local a = 1 + 2 * 3 / 6
|
||||
local bunch, go, here
|
||||
@ -17,7 +20,8 @@ a, bunch, go, here = another, world
|
||||
func(arg1, arg2, another, arg3)
|
||||
local we
|
||||
here, we = function() end, yeah
|
||||
local the, different = function() return approach end, yeah
|
||||
local the, different
|
||||
the, different = function() return approach end, yeah
|
||||
dad()
|
||||
dad(lord)
|
||||
hello(one, two)();
|
||||
|
Loading…
Reference in New Issue
Block a user