This commit is contained in:
leaf corcoran 2013-06-10 19:58:18 -07:00
parent f8c2e0b3ab
commit 39c280138a
5 changed files with 50 additions and 68 deletions

View File

@ -185,16 +185,13 @@ local value_compilers = {
} }
}) })
end end
local self_arg_values = (function() local self_arg_values = { }
local _accum_0 = { } local _len_0 = 1
local _len_0 = 1 for _index_0 = 1, #self_args do
for _index_0 = 1, #self_args do local arg = self_args[_index_0]
local arg = self_args[_index_0] self_arg_values[_len_0] = arg[2]
_accum_0[_len_0] = arg[2] _len_0 = _len_0 + 1
_len_0 = _len_0 + 1 end
end
return _accum_0
end)()
if #self_args > 0 then if #self_args > 0 then
_with_0:stm({ _with_0:stm({
"assign", "assign",
@ -204,16 +201,13 @@ local value_compilers = {
end end
_with_0:stms(block) _with_0:stms(block)
if #args > #arg_names then if #args > #arg_names then
arg_names = (function() arg_names = { }
local _accum_0 = { } local _len_1 = 1
local _len_0 = 1 for _index_0 = 1, #args do
for _index_0 = 1, #args do local arg = args[_index_0]
local arg = args[_index_0] arg_names[_len_1] = arg[1]
_accum_0[_len_0] = arg[1] _len_1 = _len_1 + 1
_len_0 = _len_0 + 1 end
end
return _accum_0
end)()
end end
_with_0.header = "function(" .. concat(arg_names, ", ") .. ")" _with_0.header = "function(" .. concat(arg_names, ", ") .. ")"
return _with_0 return _with_0

View File

@ -9,16 +9,13 @@ flat_value = function(op, depth)
if type(op) ~= "table" then if type(op) ~= "table" then
return tostring(op) return tostring(op)
end end
local items = (function() local items = { }
local _accum_0 = { } local _len_0 = 1
local _len_0 = 1 for _index_0 = 1, #op do
for _index_0 = 1, #op do local item = op[_index_0]
local item = op[_index_0] items[_len_0] = flat_value(item, depth + 1)
_accum_0[_len_0] = flat_value(item, depth + 1) _len_0 = _len_0 + 1
_len_0 = _len_0 + 1 end
end
return _accum_0
end)()
local pos = op[-1] local pos = op[-1]
return "{" .. (pos and "[" .. pos .. "] " or "") .. table.concat(items, ", ") .. "}" return "{" .. (pos and "[" .. pos .. "] " or "") .. table.concat(items, ", ") .. "}"
end end

View File

@ -42,18 +42,15 @@ truncate_traceback = function(traceback, chunk_func)
end end
stop = stop - 1 stop = stop - 1
end end
traceback = (function() traceback = { }
local _accum_0 = { } local _len_0 = 1
local _len_0 = 1 local _list_0 = traceback
local _list_0 = traceback local _max_0 = stop
local _max_0 = stop for _index_0 = 1, _max_0 < 0 and #_list_0 + _max_0 or _max_0 do
for _index_0 = 1, _max_0 < 0 and #_list_0 + _max_0 or _max_0 do local t = _list_0[_index_0]
local t = _list_0[_index_0] traceback[_len_0] = t
_accum_0[_len_0] = t _len_0 = _len_0 + 1
_len_0 = _len_0 + 1 end
end
return _accum_0
end)()
local rep = "function '" .. chunk_func .. "'" local rep = "function '" .. chunk_func .. "'"
traceback[#traceback] = traceback[#traceback]:gsub(rep, "main chunk") traceback[#traceback] = traceback[#traceback]:gsub(rep, "main chunk")
return concat(traceback, "\n") return concat(traceback, "\n")

View File

@ -1109,17 +1109,14 @@ Statement = Transformer({
end end
return self:set("super", function(block, chain) return self:set("super", function(block, chain)
if chain then if chain then
local slice = (function() local slice = { }
local _accum_0 = { } local _len_0 = 1
local _len_0 = 1 local _list_0 = chain
local _list_0 = chain for _index_0 = 3, #_list_0 do
for _index_0 = 3, #_list_0 do local item = _list_0[_index_0]
local item = _list_0[_index_0] slice[_len_0] = item
_accum_0[_len_0] = item _len_0 = _len_0 + 1
_len_0 = _len_0 + 1 end
end
return _accum_0
end)()
local new_chain = { local new_chain = {
"chain", "chain",
parent_cls_name parent_cls_name

View File

@ -119,24 +119,21 @@ dump = function(what)
end end
local debug_posmap local debug_posmap
debug_posmap = function(posmap, moon_code, lua_code) debug_posmap = function(posmap, moon_code, lua_code)
local tuples = (function() local tuples = { }
local _accum_0 = { } local _len_0 = 1
local _len_0 = 1 for k, v in pairs(posmap) do
for k, v in pairs(posmap) do tuples[_len_0] = {
_accum_0[_len_0] = { k,
k, v
v }
} _len_0 = _len_0 + 1
_len_0 = _len_0 + 1 end
end
return _accum_0
end)()
table.sort(tuples, function(a, b) table.sort(tuples, function(a, b)
return a[1] < b[1] return a[1] < b[1]
end) end)
local lines = (function() local lines = (function()
local _accum_0 = { } local _accum_0 = { }
local _len_0 = 1 local _len_1 = 1
for _index_0 = 1, #tuples do for _index_0 = 1, #tuples do
local pair = tuples[_index_0] local pair = tuples[_index_0]
local lua_line, pos = unpack(pair) local lua_line, pos = unpack(pair)
@ -144,8 +141,8 @@ debug_posmap = function(posmap, moon_code, lua_code)
local lua_text = get_line(lua_code, lua_line) local lua_text = get_line(lua_code, lua_line)
local moon_text = get_closest_line(moon_code, moon_line) local moon_text = get_closest_line(moon_code, moon_line)
local _value_0 = tostring(pos) .. "\t " .. tostring(lua_line) .. ":[ " .. tostring(trim(lua_text)) .. " ] >> " .. tostring(moon_line) .. ":[ " .. tostring(trim(moon_text)) .. " ]" local _value_0 = tostring(pos) .. "\t " .. tostring(lua_line) .. ":[ " .. tostring(trim(lua_text)) .. " ] >> " .. tostring(moon_line) .. ":[ " .. tostring(trim(moon_text)) .. " ]"
_accum_0[_len_0] = _value_0 _accum_0[_len_1] = _value_0
_len_0 = _len_0 + 1 _len_1 = _len_1 + 1
end end
return _accum_0 return _accum_0
end)() end)()