mirror of
https://github.com/leafo/moonscript.git
synced 2024-11-22 02:44:23 +00:00
remove/rearrange misc
This commit is contained in:
parent
931596d6af
commit
dcf95321c0
@ -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
|
||||
|
@ -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
|
||||
|
@ -122,8 +122,10 @@ build = nil
|
||||
build = setmetatable {
|
||||
group: (body={}) ->
|
||||
{"group", body}
|
||||
|
||||
do: (body) ->
|
||||
{"do", body}
|
||||
|
||||
assign_one: (name, value) ->
|
||||
build.assign {
|
||||
names: {name}
|
||||
|
Loading…
Reference in New Issue
Block a user