@@ -9,11 +9,11 @@ import reversed from util
99import ntype, build, smart_node, is_slice from types
1010import insert from table
1111
12- export stm , value , NameProxy , Run
12+ export Statement , Value , NameProxy , Run
1313
1414-- TODO refactor
1515is_value = ( stm) ->
16- moonscript. compile. Block \ is_value( stm) or value . can_transform stm
16+ moonscript. compile. Block \ is_value( stm) or Value . can_transform stm
1717
1818class NameProxy
1919 new : ( @prefix ) =>
@@ -57,7 +57,7 @@ class Run
5757
5858-- transform the last stm is a list of stms
5959-- will puke on group
60- apply_to_last = ( stms, fn using nil ) ->
60+ apply_to_last = ( stms, fn) ->
6161 -- find last (real) exp
6262 last_exp_id = 0
6363 for i = # stms, 1 , - 1
@@ -105,7 +105,7 @@ Transformer = (transformers) ->
105105 __call : ( ... ) => self . transform ...
106106 }
107107
108- stm = Transformer {
108+ Statement = Transformer {
109109 comprehension : ( node, action) ->
110110 _, exp, clauses = unpack node
111111
@@ -126,6 +126,11 @@ stm = Transformer {
126126
127127 current_stms[ 1 ]
128128
129+ -- handle cascading return decorator
130+ if : ( node, ret) ->
131+ print " node:" , node, " ret:" , ret
132+ node
133+
129134 foreach : ( node) ->
130135 smart_node node
131136 if ntype( node. iter) == " unpack"
@@ -166,7 +171,7 @@ stm = Transformer {
166171 }
167172 }
168173
169- class : ( node using nil ) ->
174+ class : ( node) ->
170175 _, name, parent_val, tbl = unpack node
171176
172177 constructor = nil
@@ -328,14 +333,14 @@ class Accumulator
328333default_accumulator = ( node) ->
329334 Accumulator !\ convert node
330335
331- value = Transformer {
336+ Value = Transformer {
332337 for : default_accumulator
333338 while : default_accumulator
334339 foreach : default_accumulator
335340
336341 comprehension : ( node) ->
337342 a = Accumulator !
338- node = stm node, ( exp) ->
343+ node = Statement node, ( exp) ->
339344 a\ mutate_body { exp} , false
340345 a\ wrap node
341346
@@ -344,9 +349,9 @@ value = Transformer {
344349
345350 node. body = apply_to_last node. body, ( stm) ->
346351 t = ntype stm
347- -- TODO okay this needs a refactor
348352 if types. manual_return[ t] or not is_value stm
349353 stm
354+ -- elseif types.cascading[t]
350355 else
351356 { " return" , stm}
352357
0 commit comments