remove/rearrange misc

This commit is contained in:
leaf corcoran 2013-06-30 20:44:06 -07:00
parent 931596d6af
commit dcf95321c0
3 changed files with 8 additions and 14 deletions

View File

@ -378,8 +378,7 @@ Statement = Transformer({
}) })
end end
node = self.transform.statement(first_value, action, node) node = self.transform.statement(first_value, action, node)
local wrapped = a:wrap(node) return build.assign_one(first_name, a:wrap(node))
return build.assign_one(first_name, wrapped)
end end
end end
local transformed local transformed
@ -689,7 +688,7 @@ Statement = Transformer({
end)() end)()
}) })
end, end,
foreach = function(self, node, _, parent_assign) foreach = function(self, node, _)
smart_node(node) smart_node(node)
local source = unpack(node.iter) local source = unpack(node.iter)
local destructures = { } local destructures = { }
@ -717,11 +716,7 @@ Statement = Transformer({
if ntype(source) == "unpack" then if ntype(source) == "unpack" then
local list = source[2] local list = source[2]
local index_name = NameProxy("index") local index_name = NameProxy("index")
local assign_name local list_name = self:is_local(list) and list or NameProxy("list")
if parent_assign then
assign_name = parent_assign[2][1]
end
local list_name = assign_name ~= list and self:is_local(list) and list or NameProxy("list")
local slice_var = nil local slice_var = nil
local bounds local bounds
if is_slice(list) then if is_slice(list) then

View File

@ -194,9 +194,7 @@ Statement = Transformer {
a = Accumulator! a = Accumulator!
action = (exp) -> a\mutate_body { exp } action = (exp) -> a\mutate_body { exp }
node = @transform.statement first_value, action, node node = @transform.statement first_value, action, node
return build.assign_one first_name, a\wrap node
wrapped = a\wrap node
return build.assign_one first_name, wrapped
-- bubble cascading assigns -- bubble cascading assigns
transformed = if num_values == 1 transformed = if num_values == 1
@ -384,7 +382,7 @@ Statement = Transformer {
ret scope_name ret scope_name
} }
foreach: (node, _, parent_assign) => foreach: (node, _) =>
smart_node node smart_node node
source = unpack node.iter source = unpack node.iter
@ -404,8 +402,7 @@ Statement = Transformer {
list = source[2] list = source[2]
index_name = NameProxy "index" index_name = NameProxy "index"
assign_name = parent_assign[2][1] if parent_assign list_name = @is_local(list) and list or NameProxy "list"
list_name = assign_name != list and @is_local(list) and list or NameProxy "list"
slice_var = nil slice_var = nil
bounds = if is_slice list bounds = if is_slice list

View File

@ -122,8 +122,10 @@ build = nil
build = setmetatable { build = setmetatable {
group: (body={}) -> group: (body={}) ->
{"group", body} {"group", body}
do: (body) -> do: (body) ->
{"do", body} {"do", body}
assign_one: (name, value) -> assign_one: (name, value) ->
build.assign { build.assign {
names: {name} names: {name}