adding a statement-as-expression test, and returning null from while loops, if asked

This commit is contained in:
Jeremy Ashkenas
2010-01-03 18:58:34 -05:00
parent d53d85d03e
commit cb1815885c
3 changed files with 16 additions and 4 deletions

View File

@@ -575,12 +575,13 @@ module CoffeeScript
end
def compile_node(o)
o.delete(:return)
returns = o.delete(:return)
indent = o[:indent]
o[:indent] += TAB
o[:top] = true
cond = @condition.compile(o)
write("#{indent}while (#{cond}) {\n#{@body.compile(o)}\n#{indent}}")
post = returns ? "\n#{indent}return null;" : ''
write("#{indent}while (#{cond}) {\n#{@body.compile(o)}\n#{indent}}#{post}")
end
end