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

View File

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

View File

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