fixing closurenode wrapping of bodies with bound function declarations inside -- this doesn't have to be mentioned explicitly.

This commit is contained in:
Jeremy Ashkenas
2010-06-30 21:54:16 -04:00
parent 5ca5a504a4
commit 7a5f014014
3 changed files with 19 additions and 4 deletions

View File

@@ -1381,8 +1381,11 @@ ClosureNode: exports.ClosureNode: {
return expressions if expressions.containsPureStatement()
func: new ParentheticalNode(new CodeNode([], Expressions.wrap([expressions])))
args: []
mentionsArgs: expressions.contains (n) -> (n instanceof LiteralNode) and (n.value is 'arguments')
mentionsThis: expressions.contains (n) -> (n instanceof LiteralNode) and (n.value is 'this')
mentionsArgs: expressions.contains (n) ->
n instanceof LiteralNode and (n.value is 'arguments')
mentionsThis: expressions.contains (n) ->
(n instanceof LiteralNode and (n.value is 'this')) or
(n instanceof CodeNode and n.bound)
if mentionsArgs or mentionsThis
meth: literal(if mentionsArgs then 'apply' else 'call')
args: [literal('this')]