diff --git a/moonscript/compile/value.lua b/moonscript/compile/value.lua index b0cab82..0e6fad0 100644 --- a/moonscript/compile/value.lua +++ b/moonscript/compile/value.lua @@ -185,16 +185,13 @@ local value_compilers = { } }) end - local self_arg_values = (function() - local _accum_0 = { } - local _len_0 = 1 - for _index_0 = 1, #self_args do - local arg = self_args[_index_0] - _accum_0[_len_0] = arg[2] - _len_0 = _len_0 + 1 - end - return _accum_0 - end)() + local self_arg_values = { } + local _len_0 = 1 + for _index_0 = 1, #self_args do + local arg = self_args[_index_0] + self_arg_values[_len_0] = arg[2] + _len_0 = _len_0 + 1 + end if #self_args > 0 then _with_0:stm({ "assign", @@ -204,16 +201,13 @@ local value_compilers = { end _with_0:stms(block) if #args > #arg_names then - arg_names = (function() - local _accum_0 = { } - local _len_0 = 1 - for _index_0 = 1, #args do - local arg = args[_index_0] - _accum_0[_len_0] = arg[1] - _len_0 = _len_0 + 1 - end - return _accum_0 - end)() + arg_names = { } + local _len_1 = 1 + for _index_0 = 1, #args do + local arg = args[_index_0] + arg_names[_len_1] = arg[1] + _len_1 = _len_1 + 1 + end end _with_0.header = "function(" .. concat(arg_names, ", ") .. ")" return _with_0 diff --git a/moonscript/dump.lua b/moonscript/dump.lua index 5b5fea2..3536bab 100644 --- a/moonscript/dump.lua +++ b/moonscript/dump.lua @@ -9,16 +9,13 @@ flat_value = function(op, depth) if type(op) ~= "table" then return tostring(op) end - local items = (function() - local _accum_0 = { } - local _len_0 = 1 - for _index_0 = 1, #op do - local item = op[_index_0] - _accum_0[_len_0] = flat_value(item, depth + 1) - _len_0 = _len_0 + 1 - end - return _accum_0 - end)() + local items = { } + local _len_0 = 1 + for _index_0 = 1, #op do + local item = op[_index_0] + items[_len_0] = flat_value(item, depth + 1) + _len_0 = _len_0 + 1 + end local pos = op[-1] return "{" .. (pos and "[" .. pos .. "] " or "") .. table.concat(items, ", ") .. "}" end diff --git a/moonscript/errors.lua b/moonscript/errors.lua index af3c98e..83e701d 100644 --- a/moonscript/errors.lua +++ b/moonscript/errors.lua @@ -42,18 +42,15 @@ truncate_traceback = function(traceback, chunk_func) end stop = stop - 1 end - traceback = (function() - local _accum_0 = { } - local _len_0 = 1 - local _list_0 = traceback - local _max_0 = stop - for _index_0 = 1, _max_0 < 0 and #_list_0 + _max_0 or _max_0 do - local t = _list_0[_index_0] - _accum_0[_len_0] = t - _len_0 = _len_0 + 1 - end - return _accum_0 - end)() + traceback = { } + local _len_0 = 1 + local _list_0 = traceback + local _max_0 = stop + for _index_0 = 1, _max_0 < 0 and #_list_0 + _max_0 or _max_0 do + local t = _list_0[_index_0] + traceback[_len_0] = t + _len_0 = _len_0 + 1 + end local rep = "function '" .. chunk_func .. "'" traceback[#traceback] = traceback[#traceback]:gsub(rep, "main chunk") return concat(traceback, "\n") diff --git a/moonscript/transform.lua b/moonscript/transform.lua index 00d89fe..be33939 100644 --- a/moonscript/transform.lua +++ b/moonscript/transform.lua @@ -1109,17 +1109,14 @@ Statement = Transformer({ end return self:set("super", function(block, chain) if chain then - local slice = (function() - local _accum_0 = { } - local _len_0 = 1 - local _list_0 = chain - for _index_0 = 3, #_list_0 do - local item = _list_0[_index_0] - _accum_0[_len_0] = item - _len_0 = _len_0 + 1 - end - return _accum_0 - end)() + local slice = { } + local _len_0 = 1 + local _list_0 = chain + for _index_0 = 3, #_list_0 do + local item = _list_0[_index_0] + slice[_len_0] = item + _len_0 = _len_0 + 1 + end local new_chain = { "chain", parent_cls_name diff --git a/moonscript/util.lua b/moonscript/util.lua index 090a9d0..d0e6bb0 100644 --- a/moonscript/util.lua +++ b/moonscript/util.lua @@ -119,24 +119,21 @@ dump = function(what) end local debug_posmap debug_posmap = function(posmap, moon_code, lua_code) - local tuples = (function() - local _accum_0 = { } - local _len_0 = 1 - for k, v in pairs(posmap) do - _accum_0[_len_0] = { - k, - v - } - _len_0 = _len_0 + 1 - end - return _accum_0 - end)() + local tuples = { } + local _len_0 = 1 + for k, v in pairs(posmap) do + tuples[_len_0] = { + k, + v + } + _len_0 = _len_0 + 1 + end table.sort(tuples, function(a, b) return a[1] < b[1] end) local lines = (function() local _accum_0 = { } - local _len_0 = 1 + local _len_1 = 1 for _index_0 = 1, #tuples do local pair = tuples[_index_0] 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 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)) .. " ]" - _accum_0[_len_0] = _value_0 - _len_0 = _len_0 + 1 + _accum_0[_len_1] = _value_0 + _len_1 = _len_1 + 1 end return _accum_0 end)()