mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-05-03 03:00:14 -04:00
Revert "Passing the arguments object directly when generating a closure."
This reverts commit 7b887f065d.
This commit is contained in:
10
lib/nodes.js
10
lib/nodes.js
@@ -1734,19 +1734,19 @@
|
||||
};
|
||||
Closure = {
|
||||
wrap: function(expressions, statement, noReturn) {
|
||||
var args, call, func, mentionsArgs;
|
||||
var args, call, func, mentionsArgs, meth;
|
||||
if (expressions.containsPureStatement()) {
|
||||
return expressions;
|
||||
}
|
||||
mentionsArgs = expressions.contains(this.literalArgs);
|
||||
func = new Parens(new Code((mentionsArgs ? [new Literal('arguments')] : []), Expressions.wrap([expressions])));
|
||||
func = new Parens(new Code([], Expressions.wrap([expressions])));
|
||||
args = [];
|
||||
if (mentionsArgs || expressions.contains(this.literalThis)) {
|
||||
if ((mentionsArgs = expressions.contains(this.literalArgs)) || (expressions.contains(this.literalThis))) {
|
||||
meth = new Literal(mentionsArgs ? 'apply' : 'call');
|
||||
args = [new Literal('this')];
|
||||
if (mentionsArgs) {
|
||||
args.push(new Literal('arguments'));
|
||||
}
|
||||
func = new Value(func, [new Accessor(new Literal('call'))]);
|
||||
func = new Value(func, [new Accessor(meth)]);
|
||||
func.noReturn = noReturn;
|
||||
}
|
||||
call = new Call(func, args);
|
||||
|
||||
@@ -1480,13 +1480,14 @@ Closure =
|
||||
# then make sure that the closure wrapper preserves the original values.
|
||||
wrap: (expressions, statement, noReturn) ->
|
||||
return expressions if expressions.containsPureStatement()
|
||||
mentionsArgs = expressions.contains @literalArgs
|
||||
func = new Parens new Code (if mentionsArgs then [new Literal 'arguments'] else []), Expressions.wrap [expressions]
|
||||
func = new Parens new Code [], Expressions.wrap [expressions]
|
||||
args = []
|
||||
if mentionsArgs or expressions.contains @literalThis
|
||||
if (mentionsArgs = expressions.contains @literalArgs) or
|
||||
( expressions.contains @literalThis)
|
||||
meth = new Literal if mentionsArgs then 'apply' else 'call'
|
||||
args = [new Literal 'this']
|
||||
args.push new Literal 'arguments' if mentionsArgs
|
||||
func = new Value func, [new Accessor new Literal 'call']
|
||||
func = new Value func, [new Accessor meth]
|
||||
func.noReturn = noReturn
|
||||
call = new Call func, args
|
||||
if statement then Expressions.wrap [call] else call
|
||||
|
||||
@@ -70,9 +70,7 @@ ok result.join(' ') is '6 4 2'
|
||||
|
||||
# Closure-wrapped comprehensions that refer to the "arguments" object.
|
||||
expr = ->
|
||||
result = for item in arguments
|
||||
ok arguments.callee is expr
|
||||
item * item
|
||||
result = item * item for item in arguments
|
||||
|
||||
ok expr(2, 4, 8).join(' ') is '4 16 64'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user