2010-01-16 17:10:31 +00:00
|
|
|
# Ensure that we don't wrap Nodes that are "statement_only" in a closure.
|
|
|
|
|
2010-02-11 07:39:57 +00:00
|
|
|
# items: [1, 2, 3, "bacon", 4, 5]
|
|
|
|
#
|
|
|
|
# for item in items
|
|
|
|
# break if item is "bacon"
|
2010-01-16 17:10:31 +00:00
|
|
|
|
2010-01-26 15:52:05 +00:00
|
|
|
findit: (items) ->
|
2010-01-16 17:10:31 +00:00
|
|
|
for item in items
|
|
|
|
return item if item is "bacon"
|
|
|
|
|
2010-01-30 04:30:54 +00:00
|
|
|
puts findit(items) is "bacon"
|
2010-01-16 17:10:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
# When when a closure wrapper is generated for expression conversion, make sure
|
|
|
|
# that references to "this" within the wrapper are safely converted as well.
|
|
|
|
|
2010-02-11 07:39:57 +00:00
|
|
|
# obj: {
|
|
|
|
# num: 5
|
|
|
|
# func: ->
|
|
|
|
# this.result: if false
|
|
|
|
# 10
|
|
|
|
# else
|
|
|
|
# "a"
|
|
|
|
# "b"
|
|
|
|
# this.num
|
|
|
|
# }
|
|
|
|
#
|
|
|
|
# puts obj.num is obj.func()
|
|
|
|
# puts obj.num is obj.result
|