mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-02-18 11:31:20 -05:00
Passing the arguments object directly when generating a closure.
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, meth;
|
||||
var args, call, func, mentionsArgs;
|
||||
if (expressions.containsPureStatement()) {
|
||||
return expressions;
|
||||
}
|
||||
func = new Parens(new Code([], Expressions.wrap([expressions])));
|
||||
mentionsArgs = expressions.contains(this.literalArgs);
|
||||
func = new Parens(new Code((mentionsArgs ? [new Literal('arguments')] : []), Expressions.wrap([expressions])));
|
||||
args = [];
|
||||
if ((mentionsArgs = expressions.contains(this.literalArgs)) || (expressions.contains(this.literalThis))) {
|
||||
meth = new Literal(mentionsArgs ? 'apply' : 'call');
|
||||
if (mentionsArgs || expressions.contains(this.literalThis)) {
|
||||
args = [new Literal('this')];
|
||||
if (mentionsArgs) {
|
||||
args.push(new Literal('arguments'));
|
||||
}
|
||||
func = new Value(func, [new Accessor(meth)]);
|
||||
func = new Value(func, [new Accessor(new Literal('call'))]);
|
||||
func.noReturn = noReturn;
|
||||
}
|
||||
call = new Call(func, args);
|
||||
|
||||
Reference in New Issue
Block a user