This commit is contained in:
leaf corcoran 2013-06-10 19:20:44 -07:00
parent 4978054a8f
commit dc9d5507a1
10 changed files with 79 additions and 114 deletions

View File

@ -125,9 +125,8 @@ mixin = function(self, cls, ...)
return cls.__init(self, ...) return cls.__init(self, ...)
end end
mixin_object = function(self, object, methods) mixin_object = function(self, object, methods)
local _list_0 = methods for _index_0 = 1, #methods do
for _index_0 = 1, #_list_0 do local name = methods[_index_0]
local name = _list_0[_index_0]
self[name] = function(parent, ...) self[name] = function(parent, ...)
return object[name](object, ...) return object[name](object, ...)
end end
@ -135,9 +134,8 @@ mixin_object = function(self, object, methods)
end end
mixin_table = function(self, tbl, keys) mixin_table = function(self, tbl, keys)
if keys then if keys then
local _list_0 = keys for _index_0 = 1, #keys do
for _index_0 = 1, #_list_0 do local key = keys[_index_0]
local key = _list_0[_index_0]
self[key] = tbl[key] self[key] = tbl[key]
end end
else else

View File

@ -118,9 +118,8 @@ do
return (function() return (function()
local _accum_0 = { } local _accum_0 = { }
local _len_0 = 1 local _len_0 = 1
local _list_0 = t for _index_0 = 1, #t do
for _index_0 = 1, #_list_0 do local v = t[_index_0]
local v = _list_0[_index_0]
_accum_0[_len_0] = strip(v) _accum_0[_len_0] = strip(v)
_len_0 = _len_0 + 1 _len_0 = _len_0 + 1
end end
@ -174,9 +173,8 @@ do
if not (self.pos) then if not (self.pos) then
self.pos = item.pos self.pos = item.pos
end end
local _list_0 = item for _index_0 = 1, #item do
for _index_0 = 1, #_list_0 do local value = item[_index_0]
local value = _list_0[_index_0]
self:_append_single(value) self:_append_single(value)
end end
else else
@ -210,14 +208,13 @@ do
buffer:add(concat(current)) buffer:add(concat(current))
return buffer:mark_pos(self.pos) return buffer:mark_pos(self.pos)
end end
local _list_0 = self for _index_0 = 1, #self do
for _index_0 = 1, #_list_0 do local chunk = self[_index_0]
local chunk = _list_0[_index_0]
local _exp_0 = mtype(chunk) local _exp_0 = mtype(chunk)
if Block == _exp_0 then if Block == _exp_0 then
local _list_1 = chunk:render(Lines()) local _list_0 = chunk:render(Lines())
for _index_1 = 1, #_list_1 do for _index_1 = 1, #_list_0 do
local block_chunk = _list_1[_index_1] local block_chunk = _list_0[_index_1]
if "string" == type(block_chunk) then if "string" == type(block_chunk) then
insert(current, block_chunk) insert(current, block_chunk)
else else
@ -357,11 +354,10 @@ do
local undeclared = (function() local undeclared = (function()
local _accum_0 = { } local _accum_0 = { }
local _len_0 = 1 local _len_0 = 1
local _list_0 = names for _index_0 = 1, #names do
for _index_0 = 1, #_list_0 do
local _continue_0 = false local _continue_0 = false
repeat repeat
local name = _list_0[_index_0] local name = names[_index_0]
local is_local = false local is_local = false
local real_name local real_name
local _exp_0 = mtype(name) local _exp_0 = mtype(name)
@ -543,9 +539,8 @@ do
_with_0:append_list((function() _with_0:append_list((function()
local _accum_0 = { } local _accum_0 = { }
local _len_0 = 1 local _len_0 = 1
local _list_0 = values for _index_0 = 1, #values do
for _index_0 = 1, #_list_0 do local v = values[_index_0]
local v = _list_0[_index_0]
_accum_0[_len_0] = self:value(v) _accum_0[_len_0] = self:value(v)
_len_0 = _len_0 + 1 _len_0 = _len_0 + 1
end end

View File

@ -27,9 +27,8 @@ local statement_compilers = {
_with_0:append_list((function() _with_0:append_list((function()
local _accum_0 = { } local _accum_0 = { }
local _len_0 = 1 local _len_0 = 1
local _list_0 = undeclared for _index_0 = 1, #undeclared do
for _index_0 = 1, #_list_0 do local name = undeclared[_index_0]
local name = _list_0[_index_0]
_accum_0[_len_0] = self:name(name) _accum_0[_len_0] = self:name(name)
_len_0 = _len_0 + 1 _len_0 = _len_0 + 1
end end
@ -47,9 +46,8 @@ local statement_compilers = {
_with_0:append_list((function() _with_0:append_list((function()
local _accum_0 = { } local _accum_0 = { }
local _len_0 = 1 local _len_0 = 1
local _list_0 = names for _index_0 = 1, #names do
for _index_0 = 1, #_list_0 do local name = names[_index_0]
local name = _list_0[_index_0]
_accum_0[_len_0] = self:name(name) _accum_0[_len_0] = self:name(name)
_len_0 = _len_0 + 1 _len_0 = _len_0 + 1
end end
@ -81,9 +79,8 @@ local statement_compilers = {
_with_0:append_list((function() _with_0:append_list((function()
local _accum_0 = { } local _accum_0 = { }
local _len_0 = 1 local _len_0 = 1
local _list_0 = names for _index_0 = 1, #names do
for _index_0 = 1, #_list_0 do local name = names[_index_0]
local name = _list_0[_index_0]
_accum_0[_len_0] = self:value(name) _accum_0[_len_0] = self:value(name)
_len_0 = _len_0 + 1 _len_0 = _len_0 + 1
end end
@ -94,9 +91,8 @@ local statement_compilers = {
_with_0:append_list((function() _with_0:append_list((function()
local _accum_0 = { } local _accum_0 = { }
local _len_0 = 1 local _len_0 = 1
local _list_0 = values for _index_0 = 1, #values do
for _index_0 = 1, #_list_0 do local v = values[_index_0]
local v = _list_0[_index_0]
_accum_0[_len_0] = self:value(v) _accum_0[_len_0] = self:value(v)
_len_0 = _len_0 + 1 _len_0 = _len_0 + 1
end end
@ -190,9 +186,8 @@ local statement_compilers = {
loop:append_list((function() loop:append_list((function()
local _accum_0 = { } local _accum_0 = { }
local _len_0 = 1 local _len_0 = 1
local _list_0 = names for _index_0 = 1, #names do
for _index_0 = 1, #_list_0 do local name = names[_index_0]
local name = _list_0[_index_0]
_accum_0[_len_0] = _with_0:name(name, false) _accum_0[_len_0] = _with_0:name(name, false)
_len_0 = _len_0 + 1 _len_0 = _len_0 + 1
end end
@ -202,9 +197,8 @@ local statement_compilers = {
loop:append_list((function() loop:append_list((function()
local _accum_0 = { } local _accum_0 = { }
local _len_0 = 1 local _len_0 = 1
local _list_0 = exps for _index_0 = 1, #exps do
for _index_0 = 1, #_list_0 do local exp = exps[_index_0]
local exp = _list_0[_index_0]
_accum_0[_len_0] = self:value(exp) _accum_0[_len_0] = self:value(exp)
_len_0 = _len_0 + 1 _len_0 = _len_0 + 1
end end

View File

@ -126,9 +126,8 @@ local value_compilers = {
local arg_names = (function() local arg_names = (function()
local _accum_0 = { } local _accum_0 = { }
local _len_0 = 1 local _len_0 = 1
local _list_0 = args for _index_0 = 1, #args do
for _index_0 = 1, #_list_0 do local arg = args[_index_0]
local arg = _list_0[_index_0]
local name, default_value = unpack(arg) local name, default_value = unpack(arg)
if type(name) == "string" then if type(name) == "string" then
name = name name = name
@ -155,14 +154,12 @@ local value_compilers = {
if #whitelist > 0 then if #whitelist > 0 then
_with_0:whitelist_names(whitelist) _with_0:whitelist_names(whitelist)
end end
local _list_0 = arg_names for _index_0 = 1, #arg_names do
for _index_0 = 1, #_list_0 do local name = arg_names[_index_0]
local name = _list_0[_index_0]
_with_0:put_name(name) _with_0:put_name(name)
end end
local _list_1 = default_args for _index_0 = 1, #default_args do
for _index_0 = 1, #_list_1 do local default = default_args[_index_0]
local default = _list_1[_index_0]
local name, value = unpack(default) local name, value = unpack(default)
if type(name) == "table" then if type(name) == "table" then
name = name[2] name = name[2]
@ -191,9 +188,8 @@ local value_compilers = {
local self_arg_values = (function() local self_arg_values = (function()
local _accum_0 = { } local _accum_0 = { }
local _len_0 = 1 local _len_0 = 1
local _list_2 = self_args for _index_0 = 1, #self_args do
for _index_0 = 1, #_list_2 do local arg = self_args[_index_0]
local arg = _list_2[_index_0]
_accum_0[_len_0] = arg[2] _accum_0[_len_0] = arg[2]
_len_0 = _len_0 + 1 _len_0 = _len_0 + 1
end end
@ -211,9 +207,8 @@ local value_compilers = {
arg_names = (function() arg_names = (function()
local _accum_0 = { } local _accum_0 = { }
local _len_0 = 1 local _len_0 = 1
local _list_2 = args for _index_0 = 1, #args do
for _index_0 = 1, #_list_2 do local arg = args[_index_0]
local arg = _list_2[_index_0]
_accum_0[_len_0] = arg[1] _accum_0[_len_0] = arg[1]
_len_0 = _len_0 + 1 _len_0 = _len_0 + 1
end end

View File

@ -2,9 +2,8 @@ local concat, remove, insert = table.concat, table.remove, table.insert
local Set local Set
Set = function(items) Set = function(items)
local self = { } local self = { }
local _list_0 = items for _index_0 = 1, #items do
for _index_0 = 1, #_list_0 do local key = items[_index_0]
local key = _list_0[_index_0]
self[key] = true self[key] = true
end end
return self return self

View File

@ -12,9 +12,8 @@ flat_value = function(op, depth)
local items = (function() local items = (function()
local _accum_0 = { } local _accum_0 = { }
local _len_0 = 1 local _len_0 = 1
local _list_0 = op for _index_0 = 1, #op do
for _index_0 = 1, #_list_0 do local item = op[_index_0]
local item = _list_0[_index_0]
_accum_0[_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

View File

@ -352,11 +352,10 @@ local Statement = Transformer({
names = (function() names = (function()
local _accum_0 = { } local _accum_0 = { }
local _len_0 = 1 local _len_0 = 1
local _list_0 = names for _index_0 = 1, #names do
for _index_0 = 1, #_list_0 do
local _continue_0 = false local _continue_0 = false
repeat repeat
local name = _list_0[_index_0] local name = names[_index_0]
if not (name:match("^%u")) then if not (name:match("^%u")) then
_continue_0 = true _continue_0 = true
break break
@ -480,9 +479,8 @@ local Statement = Transformer({
local stubs = (function() local stubs = (function()
local _accum_0 = { } local _accum_0 = { }
local _len_0 = 1 local _len_0 = 1
local _list_0 = names for _index_0 = 1, #names do
for _index_0 = 1, #_list_0 do local name = names[_index_0]
local name = _list_0[_index_0]
if type(name) == "table" then if type(name) == "table" then
_accum_0[_len_0] = name _accum_0[_len_0] = name
else else
@ -498,9 +496,8 @@ local Statement = Transformer({
local real_names = (function() local real_names = (function()
local _accum_0 = { } local _accum_0 = { }
local _len_0 = 1 local _len_0 = 1
local _list_0 = names for _index_0 = 1, #names do
for _index_0 = 1, #_list_0 do local name = names[_index_0]
local name = _list_0[_index_0]
_accum_0[_len_0] = type(name) == "table" and name[2] or name _accum_0[_len_0] = type(name) == "table" and name[2] or name
_len_0 = _len_0 + 1 _len_0 = _len_0 + 1
end end
@ -512,9 +509,8 @@ local Statement = Transformer({
values = (function() values = (function()
local _accum_0 = { } local _accum_0 = { }
local _len_0 = 1 local _len_0 = 1
local _list_0 = stubs for _index_0 = 1, #stubs do
for _index_0 = 1, #_list_0 do local stub = stubs[_index_0]
local stub = _list_0[_index_0]
_accum_0[_len_0] = build.chain({ _accum_0[_len_0] = build.chain({
base = source, base = source,
stub stub
@ -538,9 +534,8 @@ local Statement = Transformer({
values = (function() values = (function()
local _accum_0 = { } local _accum_0 = { }
local _len_0 = 1 local _len_0 = 1
local _list_0 = stubs for _index_0 = 1, #stubs do
for _index_0 = 1, #_list_0 do local stub = stubs[_index_0]
local stub = _list_0[_index_0]
_accum_0[_len_0] = build.chain({ _accum_0[_len_0] = build.chain({
base = source_name, base = source_name,
stub stub
@ -867,9 +862,8 @@ local Statement = Transformer({
local if_stm = { local if_stm = {
"if" "if"
} }
local _list_0 = conds for _index_0 = 1, #conds do
for _index_0 = 1, #_list_0 do local cond = conds[_index_0]
local cond = _list_0[_index_0]
local if_cond = convert_cond(cond) local if_cond = convert_cond(cond)
if first then if first then
first = false first = false
@ -888,16 +882,15 @@ local Statement = Transformer({
local _, name, parent_val, body = unpack(node) local _, name, parent_val, body = unpack(node)
local statements = { } local statements = { }
local properties = { } local properties = { }
local _list_0 = body for _index_0 = 1, #body do
for _index_0 = 1, #_list_0 do local item = body[_index_0]
local item = _list_0[_index_0]
local _exp_0 = item[1] local _exp_0 = item[1]
if "stm" == _exp_0 then if "stm" == _exp_0 then
insert(statements, item[2]) insert(statements, item[2])
elseif "props" == _exp_0 then elseif "props" == _exp_0 then
local _list_1 = item local _list_0 = item
for _index_1 = 2, #_list_1 do for _index_1 = 2, #_list_0 do
local tuple = _list_1[_index_1] local tuple = _list_0[_index_1]
if ntype(tuple[1]) == "self" then if ntype(tuple[1]) == "self" then
insert(statements, build.assign_one(unpack(tuple))) insert(statements, build.assign_one(unpack(tuple)))
else else
@ -910,11 +903,10 @@ local Statement = Transformer({
properties = (function() properties = (function()
local _accum_0 = { } local _accum_0 = { }
local _len_0 = 1 local _len_0 = 1
local _list_1 = properties for _index_0 = 1, #properties do
for _index_0 = 1, #_list_1 do
local _continue_0 = false local _continue_0 = false
repeat repeat
local tuple = _list_1[_index_0] local tuple = properties[_index_0]
local key = tuple[1] local key = tuple[1]
local _value_0 local _value_0
if key[1] == "key_literal" and key[2] == constructor_name then if key[1] == "key_literal" and key[2] == constructor_name then
@ -1112,9 +1104,9 @@ local Statement = Transformer({
local slice = (function() local slice = (function()
local _accum_0 = { } local _accum_0 = { }
local _len_0 = 1 local _len_0 = 1
local _list_1 = chain local _list_0 = chain
for _index_0 = 3, #_list_1 do for _index_0 = 3, #_list_0 do
local item = _list_1[_index_0] local item = _list_0[_index_0]
_accum_0[_len_0] = item _accum_0[_len_0] = item
_len_0 = _len_0 + 1 _len_0 = _len_0 + 1
end end
@ -1163,9 +1155,8 @@ local Statement = Transformer({
} }
} }
end end
local _list_1 = slice for _index_0 = 1, #slice do
for _index_0 = 1, #_list_1 do local item = slice[_index_0]
local item = _list_1[_index_0]
insert(new_chain, item) insert(new_chain, item)
end end
return new_chain return new_chain

View File

@ -29,9 +29,8 @@ join = function(...)
} }
for _index_0 = 1, #_list_0 do for _index_0 = 1, #_list_0 do
local tbl = _list_0[_index_0] local tbl = _list_0[_index_0]
local _list_1 = tbl for _index_1 = 1, #tbl do
for _index_1 = 1, #_list_1 do local v = tbl[_index_1]
local v = _list_1[_index_1]
out[i] = v out[i] = v
i = i + 1 i = i + 1
end end
@ -41,9 +40,8 @@ join = function(...)
end end
local has_destructure local has_destructure
has_destructure = function(names) has_destructure = function(names)
local _list_0 = names for _index_0 = 1, #names do
for _index_0 = 1, #_list_0 do local n = names[_index_0]
local n = _list_0[_index_0]
if ntype(n) == "table" then if ntype(n) == "table" then
return true return true
end end
@ -133,9 +131,8 @@ build_assign = function(scope, destruct_literal, receiver)
obj = obj obj = obj
end end
end end
local _list_0 = extracted_names for _index_0 = 1, #extracted_names do
for _index_0 = 1, #_list_0 do local tuple = extracted_names[_index_0]
local tuple = _list_0[_index_0]
insert(names, tuple[1]) insert(names, tuple[1])
insert(values, NameProxy.chain(obj, unpack(tuple[2]))) insert(values, NameProxy.chain(obj, unpack(tuple[2])))
end end

View File

@ -232,9 +232,8 @@ build = setmetatable({
if tbl == nil then if tbl == nil then
tbl = { } tbl = { }
end end
local _list_0 = tbl for _index_0 = 1, #tbl do
for _index_0 = 1, #_list_0 do local tuple = tbl[_index_0]
local tuple = _list_0[_index_0]
if type(tuple[1]) == "string" then if type(tuple[1]) == "string" then
tuple[1] = { tuple[1] = {
"key_literal", "key_literal",
@ -259,9 +258,8 @@ build = setmetatable({
"chain", "chain",
base base
} }
local _list_0 = parts for _index_0 = 1, #parts do
for _index_0 = 1, #_list_0 do local part = parts[_index_0]
local part = _list_0[_index_0]
insert(node, part) insert(node, part)
end end
return node return node

View File

@ -137,9 +137,8 @@ debug_posmap = function(posmap, moon_code, lua_code)
local lines = (function() local lines = (function()
local _accum_0 = { } local _accum_0 = { }
local _len_0 = 1 local _len_0 = 1
local _list_0 = tuples for _index_0 = 1, #tuples do
for _index_0 = 1, #_list_0 do local pair = tuples[_index_0]
local pair = _list_0[_index_0]
local lua_line, pos = unpack(pair) local lua_line, pos = unpack(pair)
local moon_line = pos_to_line(moon_code, pos) local moon_line = pos_to_line(moon_code, pos)
local lua_text = get_line(lua_code, lua_line) local lua_text = get_line(lua_code, lua_line)