Skip to content

Commit ff5317e

Browse files
committed
update for changes to loop expressions #66
1 parent d244440 commit ff5317e

File tree

7 files changed

+58
-40
lines changed

7 files changed

+58
-40
lines changed

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,9 @@ global:
1111
compile:
1212
bin/moonc moon/ moonscript/
1313

14+
15+
compile_global:
16+
moonc moon/ moonscript/
17+
1418
watch:
1519
moonc -w moon/ moonscript/

moonscript/compile.lua

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -356,25 +356,33 @@ do
356356
local _len_0 = 1
357357
local _list_0 = names
358358
for _index_0 = 1, #_list_0 do
359-
local name = _list_0[_index_0]
360-
local is_local = false
361-
local real_name
362-
local _exp_0 = mtype(name)
363-
if LocalName == _exp_0 then
364-
is_local = true
365-
real_name = name:get_name(self)
366-
elseif NameProxy == _exp_0 then
367-
real_name = name:get_name(self)
368-
elseif "string" == _exp_0 then
369-
real_name = name
370-
end
371-
local _value_0
372-
if is_local or real_name and not self:has_name(real_name) then
373-
_value_0 = real_name
374-
end
375-
if _value_0 ~= nil then
376-
_accum_0[_len_0] = _value_0
377-
_len_0 = _len_0 + 1
359+
local _continue_0 = false
360+
repeat
361+
local name = _list_0[_index_0]
362+
local is_local = false
363+
local real_name
364+
local _exp_0 = mtype(name)
365+
if LocalName == _exp_0 then
366+
is_local = true
367+
real_name = name:get_name(self)
368+
elseif NameProxy == _exp_0 then
369+
real_name = name:get_name(self)
370+
elseif "string" == _exp_0 then
371+
real_name = name
372+
end
373+
if not (is_local or real_name and not self:has_name(real_name)) then
374+
_continue_0 = true
375+
break
376+
end
377+
local _value_0 = real_name
378+
if _value_0 ~= nil then
379+
_accum_0[_len_0] = _value_0
380+
_len_0 = _len_0 + 1
381+
end
382+
_continue_0 = true
383+
until true
384+
if not _continue_0 then
385+
break
378386
end
379387
end
380388
return _accum_0

moonscript/compile.moon

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,8 @@ class Block
216216
when NameProxy then name\get_name self
217217
when "string" then name
218218

219-
real_name if is_local or real_name and not @has_name real_name
219+
continue unless is_local or real_name and not @has_name real_name
220+
real_name
220221

221222
@put_name name for name in *undeclared
222223
undeclared

moonscript/compile/value.lua

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -209,11 +209,8 @@ local value_compilers = {
209209
local _list_2 = args
210210
for _index_0 = 1, #_list_2 do
211211
local arg = _list_2[_index_0]
212-
local _value_0 = arg[1]
213-
if _value_0 ~= nil then
214-
_accum_0[_len_0] = _value_0
215-
_len_0 = _len_0 + 1
216-
end
212+
_accum_0[_len_0] = arg[1]
213+
_len_0 = _len_0 + 1
217214
end
218215
return _accum_0
219216
end)()

moonscript/compile/value.moon

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,9 @@ value_compilers =
112112
\stms block
113113

114114
-- inject more args if the block manipulated arguments
115+
-- only varargs bubbling does this currently
115116
if #args > #arg_names -- will only work for simple adjustments
116-
arg_names = for arg in *args
117-
arg[1]
117+
arg_names = [arg[1] for arg in *args]
118118

119119
.header = "function("..concat(arg_names, ", ")..")"
120120

moonscript/transform.lua

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -875,18 +875,26 @@ local Statement = Transformer({
875875
local _len_0 = 1
876876
local _list_1 = properties
877877
for _index_0 = 1, #_list_1 do
878-
local tuple = _list_1[_index_0]
879-
local key = tuple[1]
880-
local _value_0
881-
if key[1] == "key_literal" and key[2] == constructor_name then
882-
constructor = tuple[2]
883-
_value_0 = nil
884-
else
885-
_value_0 = tuple
886-
end
887-
if _value_0 ~= nil then
888-
_accum_0[_len_0] = _value_0
889-
_len_0 = _len_0 + 1
878+
local _continue_0 = false
879+
repeat
880+
local tuple = _list_1[_index_0]
881+
local key = tuple[1]
882+
local _value_0
883+
if key[1] == "key_literal" and key[2] == constructor_name then
884+
constructor = tuple[2]
885+
_continue_0 = true
886+
break
887+
else
888+
_value_0 = tuple
889+
end
890+
if _value_0 ~= nil then
891+
_accum_0[_len_0] = _value_0
892+
_len_0 = _len_0 + 1
893+
end
894+
_continue_0 = true
895+
until true
896+
if not _continue_0 then
897+
break
890898
end
891899
end
892900
return _accum_0

moonscript/transform.moon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ Statement = Transformer {
486486
key = tuple[1]
487487
if key[1] == "key_literal" and key[2] == constructor_name
488488
constructor = tuple[2]
489-
nil
489+
continue
490490
else
491491
tuple
492492

0 commit comments

Comments
 (0)