update accumulator after expression

This commit is contained in:
leaf corcoran 2013-01-12 13:01:34 -08:00
parent d4ed7c91ea
commit 7cd0fcc632
7 changed files with 67 additions and 67 deletions

View File

@ -1238,7 +1238,7 @@ do
wrap = function(self, node) wrap = function(self, node)
return build.block_exp({ return build.block_exp({
build.assign_one(self.accum_name, build.table()), build.assign_one(self.accum_name, build.table()),
build.assign_one(self.len_name, 0), build.assign_one(self.len_name, 1),
node, node,
self.accum_name self.accum_name
}) })
@ -1273,13 +1273,13 @@ do
val = self.value_name val = self.value_name
end end
local update = { local update = {
build.assign_one(self.accum_name:index(self.len_name), val),
{ {
"update", "update",
self.len_name, self.len_name,
"+=", "+=",
1 1
}, }
build.assign_one(self.accum_name:index(self.len_name), val)
} }
if skip_nil then if skip_nil then
table.insert(body, build["if"]({ table.insert(body, build["if"]({

View File

@ -691,7 +691,7 @@ class Accumulator
wrap: (node) => wrap: (node) =>
build.block_exp { build.block_exp {
build.assign_one @accum_name, build.table! build.assign_one @accum_name, build.table!
build.assign_one @len_name, 0 build.assign_one @len_name, 1
node node
@accum_name @accum_name
} }
@ -715,8 +715,8 @@ class Accumulator
@value_name @value_name
update = { update = {
{"update", @len_name, "+=", 1}
build.assign_one @accum_name\index(@len_name), val build.assign_one @accum_name\index(@len_name), val
{"update", @len_name, "+=", 1}
} }
if skip_nil if skip_nil

View File

@ -8,38 +8,38 @@ local dont_bubble
dont_bubble = function() dont_bubble = function()
return (function() return (function()
local _accum_0 = { } local _accum_0 = { }
local _len_0 = 0 local _len_0 = 1
for x in (function(...) for x in (function(...)
return print(...) return print(...)
end)("hello") do end)("hello") do
_len_0 = _len_0 + 1
_accum_0[_len_0] = x _accum_0[_len_0] = x
_len_0 = _len_0 + 1
end end
return _accum_0 return _accum_0
end)() end)()
end end
local k = (function() local k = (function()
local _accum_0 = { } local _accum_0 = { }
local _len_0 = 0 local _len_0 = 1
for x in (function(...) for x in (function(...)
return print(...) return print(...)
end)("hello") do end)("hello") do
_len_0 = _len_0 + 1
_accum_0[_len_0] = x _accum_0[_len_0] = x
_len_0 = _len_0 + 1
end end
return _accum_0 return _accum_0
end)() end)()
local j = (function() local j = (function()
local _accum_0 = { } local _accum_0 = { }
local _len_0 = 0 local _len_0 = 1
for i = 1, 10 do for i = 1, 10 do
local _value_0 local _value_0
_value_0 = function(...) _value_0 = function(...)
return print(...) return print(...)
end end
if _value_0 ~= nil then if _value_0 ~= nil then
_len_0 = _len_0 + 1
_accum_0[_len_0] = _value_0 _accum_0[_len_0] = _value_0
_len_0 = _len_0 + 1
end end
end end
return _accum_0 return _accum_0
@ -48,15 +48,15 @@ local m
m = function(...) m = function(...)
return (function(...) return (function(...)
local _accum_0 = { } local _accum_0 = { }
local _len_0 = 0 local _len_0 = 1
local _list_0 = { local _list_0 = {
... ...
} }
for _index_0 = 1, #_list_0 do for _index_0 = 1, #_list_0 do
local x = _list_0[_index_0] local x = _list_0[_index_0]
if f(...) > 4 then if f(...) > 4 then
_len_0 = _len_0 + 1
_accum_0[_len_0] = x _accum_0[_len_0] = x
_len_0 = _len_0 + 1
end end
end end
return _accum_0 return _accum_0
@ -64,7 +64,7 @@ m = function(...)
end end
local x = (function(...) local x = (function(...)
local _accum_0 = { } local _accum_0 = { }
local _len_0 = 0 local _len_0 = 1
local _list_0 = { local _list_0 = {
... ...
} }
@ -72,59 +72,59 @@ local x = (function(...)
local i = _list_0[_index_0] local i = _list_0[_index_0]
local _value_0 = i local _value_0 = i
if _value_0 ~= nil then if _value_0 ~= nil then
_len_0 = _len_0 + 1
_accum_0[_len_0] = _value_0 _accum_0[_len_0] = _value_0
_len_0 = _len_0 + 1
end end
end end
return _accum_0 return _accum_0
end)(...) end)(...)
local y = (function(...) local y = (function(...)
local _accum_0 = { } local _accum_0 = { }
local _len_0 = 0 local _len_0 = 1
local _list_0 = { local _list_0 = {
... ...
} }
for _index_0 = 1, #_list_0 do for _index_0 = 1, #_list_0 do
x = _list_0[_index_0] x = _list_0[_index_0]
_len_0 = _len_0 + 1
_accum_0[_len_0] = x _accum_0[_len_0] = x
_len_0 = _len_0 + 1
end end
return _accum_0 return _accum_0
end)(...) end)(...)
local z = (function(...) local z = (function(...)
local _accum_0 = { } local _accum_0 = { }
local _len_0 = 0 local _len_0 = 1
for x in hallo do for x in hallo do
if f(...) > 4 then if f(...) > 4 then
_len_0 = _len_0 + 1
_accum_0[_len_0] = x _accum_0[_len_0] = x
_len_0 = _len_0 + 1
end end
end end
return _accum_0 return _accum_0
end)(...) end)(...)
local a = (function(...) local a = (function(...)
local _accum_0 = { } local _accum_0 = { }
local _len_0 = 0 local _len_0 = 1
for i = 1, 10 do for i = 1, 10 do
local _value_0 = ... local _value_0 = ...
if _value_0 ~= nil then if _value_0 ~= nil then
_len_0 = _len_0 + 1
_accum_0[_len_0] = _value_0 _accum_0[_len_0] = _value_0
_len_0 = _len_0 + 1
end end
end end
return _accum_0 return _accum_0
end)(...) end)(...)
local b = (function() local b = (function()
local _accum_0 = { } local _accum_0 = { }
local _len_0 = 0 local _len_0 = 1
for i = 1, 10 do for i = 1, 10 do
local _value_0 local _value_0
_value_0 = function() _value_0 = function()
return print(...) return print(...)
end end
if _value_0 ~= nil then if _value_0 ~= nil then
_len_0 = _len_0 + 1
_accum_0[_len_0] = _value_0 _accum_0[_len_0] = _value_0
_len_0 = _len_0 + 1
end end
end end
return _accum_0 return _accum_0

View File

@ -68,10 +68,10 @@ return (function()
x = _list_0[_index_0] x = _list_0[_index_0]
local _key_0, _val_0 = unpack((function() local _key_0, _val_0 = unpack((function()
local _accum_0 = { } local _accum_0 = { }
local _len_0 = 0 local _len_0 = 1
for i, a in ipairs(x) do for i, a in ipairs(x) do
_len_0 = _len_0 + 1
_accum_0[_len_0] = a * i _accum_0[_len_0] = a * i
_len_0 = _len_0 + 1
end end
return _accum_0 return _accum_0
end)()) end)())

View File

@ -1,14 +1,14 @@
local hi = (function() local hi = (function()
local _accum_0 = { } local _accum_0 = { }
local _len_0 = 0 local _len_0 = 1
for _, x in ipairs({ for _, x in ipairs({
1, 1,
2, 2,
3, 3,
4 4
}) do }) do
_len_0 = _len_0 + 1
_accum_0[_len_0] = x * 2 _accum_0[_len_0] = x * 2
_len_0 = _len_0 + 1
end end
return _accum_0 return _accum_0
end)() end)()
@ -22,10 +22,10 @@ local items = {
} }
local mm = (function() local mm = (function()
local _accum_0 = { } local _accum_0 = { }
local _len_0 = 0 local _len_0 = 1
for self.x in ipairs(items) do for self.x in ipairs(items) do
_len_0 = _len_0 + 1
_accum_0[_len_0] = self.x _accum_0[_len_0] = self.x
_len_0 = _len_0 + 1
end end
return _accum_0 return _accum_0
end)() end)()
@ -36,7 +36,7 @@ for z in ipairs(items) do
end end
local rad = (function() local rad = (function()
local _accum_0 = { } local _accum_0 = { }
local _len_0 = 0 local _len_0 = 1
for a in ipairs({ for a in ipairs({
1, 1,
2, 2,
@ -46,10 +46,10 @@ local rad = (function()
6 6
}) do }) do
if good_number(a) then if good_number(a) then
_len_0 = _len_0 + 1
_accum_0[_len_0] = { _accum_0[_len_0] = {
a a
} }
_len_0 = _len_0 + 1
end end
end end
return _accum_0 return _accum_0
@ -78,24 +78,24 @@ range = function(count)
end end
dump((function() dump((function()
local _accum_0 = { } local _accum_0 = { }
local _len_0 = 0 local _len_0 = 1
for x in range(10) do for x in range(10) do
_len_0 = _len_0 + 1
_accum_0[_len_0] = x _accum_0[_len_0] = x
_len_0 = _len_0 + 1
end end
return _accum_0 return _accum_0
end)()) end)())
dump((function() dump((function()
local _accum_0 = { } local _accum_0 = { }
local _len_0 = 0 local _len_0 = 1
for x in range(5) do for x in range(5) do
if x > 2 then if x > 2 then
for y in range(5) do for y in range(5) do
_len_0 = _len_0 + 1
_accum_0[_len_0] = { _accum_0[_len_0] = {
x, x,
y y
} }
_len_0 = _len_0 + 1
end end
end end
end end
@ -103,13 +103,13 @@ dump((function()
end)()) end)())
local things = (function() local things = (function()
local _accum_0 = { } local _accum_0 = { }
local _len_0 = 0 local _len_0 = 1
for x in range(10) do for x in range(10) do
if x > 5 then if x > 5 then
for y in range(10) do for y in range(10) do
if y > 7 then if y > 7 then
_len_0 = _len_0 + 1
_accum_0[_len_0] = x + y _accum_0[_len_0] = x + y
_len_0 = _len_0 + 1
end end
end end
end end
@ -139,10 +139,10 @@ for x in x do
end end
local x = (function() local x = (function()
local _accum_0 = { } local _accum_0 = { }
local _len_0 = 0 local _len_0 = 1
for x in x do for x in x do
_len_0 = _len_0 + 1
_accum_0[_len_0] = x _accum_0[_len_0] = x
_len_0 = _len_0 + 1
end end
return _accum_0 return _accum_0
end)() end)()
@ -163,12 +163,12 @@ for x in ipairs({
end end
local double = (function() local double = (function()
local _accum_0 = { } local _accum_0 = { }
local _len_0 = 0 local _len_0 = 1
local _list_0 = items local _list_0 = items
for _index_0 = 1, #_list_0 do for _index_0 = 1, #_list_0 do
x = _list_0[_index_0] x = _list_0[_index_0]
_len_0 = _len_0 + 1
_accum_0[_len_0] = x * 2 _accum_0[_len_0] = x * 2
_len_0 = _len_0 + 1
end end
return _accum_0 return _accum_0
end)() end)()
@ -179,28 +179,28 @@ for _index_0 = 1, #_list_0 do
end end
local cut = (function() local cut = (function()
local _accum_0 = { } local _accum_0 = { }
local _len_0 = 0 local _len_0 = 1
local _list_1 = items local _list_1 = items
for _index_0 = 1, #_list_1 do for _index_0 = 1, #_list_1 do
x = _list_1[_index_0] x = _list_1[_index_0]
if x > 3 then if x > 3 then
_len_0 = _len_0 + 1
_accum_0[_len_0] = x _accum_0[_len_0] = x
_len_0 = _len_0 + 1
end end
end end
return _accum_0 return _accum_0
end)() end)()
local hello = (function() local hello = (function()
local _accum_0 = { } local _accum_0 = { }
local _len_0 = 0 local _len_0 = 1
local _list_1 = items local _list_1 = items
for _index_0 = 1, #_list_1 do for _index_0 = 1, #_list_1 do
x = _list_1[_index_0] x = _list_1[_index_0]
local _list_2 = items local _list_2 = items
for _index_1 = 1, #_list_2 do for _index_1 = 1, #_list_2 do
local y = _list_2[_index_1] local y = _list_2[_index_1]
_len_0 = _len_0 + 1
_accum_0[_len_0] = x + y _accum_0[_len_0] = x + y
_len_0 = _len_0 + 1
end end
end end
return _accum_0 return _accum_0
@ -257,10 +257,10 @@ local normal
normal = function(hello) normal = function(hello)
return (function() return (function()
local _accum_0 = { } local _accum_0 = { }
local _len_0 = 0 local _len_0 = 1
for x in yeah do for x in yeah do
_len_0 = _len_0 + 1
_accum_0[_len_0] = x _accum_0[_len_0] = x
_len_0 = _len_0 + 1
end end
return _accum_0 return _accum_0
end)() end)()
@ -289,12 +289,12 @@ end
return function() return function()
return (function() return (function()
local _accum_0 = { } local _accum_0 = { }
local _len_0 = 0 local _len_0 = 1
local _list_9 = things local _list_9 = things
for _index_0 = 1, #_list_9 do for _index_0 = 1, #_list_9 do
x = _list_9[_index_0] x = _list_9[_index_0]
_len_0 = _len_0 + 1
_accum_0[_len_0] = x _accum_0[_len_0] = x
_len_0 = _len_0 + 1
end end
return _accum_0 return _accum_0
end)() end)()

View File

@ -50,7 +50,7 @@ local hello = {
} }
x = (function() x = (function()
local _accum_0 = { } local _accum_0 = { }
local _len_0 = 0 local _len_0 = 1
local _list_1 = hello local _list_1 = hello
for _index_0 = 1, #_list_1 do for _index_0 = 1, #_list_1 do
local y = _list_1[_index_0] local y = _list_1[_index_0]
@ -59,8 +59,8 @@ x = (function()
_value_0 = y _value_0 = y
end end
if _value_0 ~= nil then if _value_0 ~= nil then
_len_0 = _len_0 + 1
_accum_0[_len_0] = _value_0 _accum_0[_len_0] = _value_0
_len_0 = _len_0 + 1
end end
end end
return _accum_0 return _accum_0
@ -74,12 +74,12 @@ x = function()
end end
local t = (function() local t = (function()
local _accum_0 = { } local _accum_0 = { }
local _len_0 = 0 local _len_0 = 1
for i = 10, 20 do for i = 10, 20 do
local _value_0 = i * 2 local _value_0 = i * 2
if _value_0 ~= nil then if _value_0 ~= nil then
_len_0 = _len_0 + 1
_accum_0[_len_0] = _value_0 _accum_0[_len_0] = _value_0
_len_0 = _len_0 + 1
end end
end end
return _accum_0 return _accum_0
@ -87,13 +87,13 @@ end)()
local hmm = 0 local hmm = 0
local y = (function() local y = (function()
local _accum_0 = { } local _accum_0 = { }
local _len_0 = 0 local _len_0 = 1
for j = 3, 30, 8 do for j = 3, 30, 8 do
hmm = hmm + 1 hmm = hmm + 1
local _value_0 = j * hmm local _value_0 = j * hmm
if _value_0 ~= nil then if _value_0 ~= nil then
_len_0 = _len_0 + 1
_accum_0[_len_0] = _value_0 _accum_0[_len_0] = _value_0
_len_0 = _len_0 + 1
end end
end end
return _accum_0 return _accum_0
@ -107,12 +107,12 @@ end
_ = function() _ = function()
return (function() return (function()
local _accum_0 = { } local _accum_0 = { }
local _len_0 = 0 local _len_0 = 1
for k = 10, 40 do for k = 10, 40 do
local _value_0 = "okay" local _value_0 = "okay"
if _value_0 ~= nil then if _value_0 ~= nil then
_len_0 = _len_0 + 1
_accum_0[_len_0] = _value_0 _accum_0[_len_0] = _value_0
_len_0 = _len_0 + 1
end end
end end
return _accum_0 return _accum_0
@ -132,41 +132,41 @@ end
local i = 0 local i = 0
x = (function() x = (function()
local _accum_0 = { } local _accum_0 = { }
local _len_0 = 0 local _len_0 = 1
while i < 10 do while i < 10 do
local _value_0 local _value_0
i = i + 1 i = i + 1
if _value_0 ~= nil then if _value_0 ~= nil then
_len_0 = _len_0 + 1
_accum_0[_len_0] = _value_0 _accum_0[_len_0] = _value_0
_len_0 = _len_0 + 1
end end
end end
return _accum_0 return _accum_0
end)() end)()
x = (function() x = (function()
local _accum_0 = { } local _accum_0 = { }
local _len_0 = 0 local _len_0 = 1
local _list_1 = 3 local _list_1 = 3
for _index_0 = 1, #_list_1 do for _index_0 = 1, #_list_1 do
local thing = _list_1[_index_0] local thing = _list_1[_index_0]
local _value_0 local _value_0
y = "hello" y = "hello"
if _value_0 ~= nil then if _value_0 ~= nil then
_len_0 = _len_0 + 1
_accum_0[_len_0] = _value_0 _accum_0[_len_0] = _value_0
_len_0 = _len_0 + 1
end end
end end
return _accum_0 return _accum_0
end)() end)()
x = (function() x = (function()
local _accum_0 = { } local _accum_0 = { }
local _len_0 = 0 local _len_0 = 1
for x = 1, 2 do for x = 1, 2 do
local _value_0 local _value_0
y = "hello" y = "hello"
if _value_0 ~= nil then if _value_0 ~= nil then
_len_0 = _len_0 + 1
_accum_0[_len_0] = _value_0 _accum_0[_len_0] = _value_0
_len_0 = _len_0 + 1
end end
end end
return _accum_0 return _accum_0
@ -205,7 +205,7 @@ for x = 1, 10 do
end end
local list = (function() local list = (function()
local _accum_0 = { } local _accum_0 = { }
local _len_0 = 0 local _len_0 = 1
for x = 1, 10 do for x = 1, 10 do
local _continue_0 = false local _continue_0 = false
repeat repeat
@ -215,8 +215,8 @@ local list = (function()
end end
local _value_0 = x local _value_0 = x
if _value_0 ~= nil then if _value_0 ~= nil then
_len_0 = _len_0 + 1
_accum_0[_len_0] = _value_0 _accum_0[_len_0] = _value_0
_len_0 = _len_0 + 1
end end
_continue_0 = true _continue_0 = true
until true until true

View File

@ -91,10 +91,10 @@ x = -hello(world(one(two)))
local hi = -"herfef" local hi = -"herfef"
x = -(function() x = -(function()
local _accum_0 = { } local _accum_0 = { }
local _len_0 = 0 local _len_0 = 1
for x in x do for x in x do
_len_0 = _len_0 + 1
_accum_0[_len_0] = x _accum_0[_len_0] = x
_len_0 = _len_0 + 1
end end
return _accum_0 return _accum_0
end)() end)()