mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-04-11 03:00:13 -04:00
removing the 'var' declaration from arguments-to-array conversions
This commit is contained in:
@@ -230,14 +230,13 @@
|
|||||||
// Compile the expressions body, with declarations of all inner variables
|
// Compile the expressions body, with declarations of all inner variables
|
||||||
// pushed up to the top.
|
// pushed up to the top.
|
||||||
compile_with_declarations: function compile_with_declarations(o) {
|
compile_with_declarations: function compile_with_declarations(o) {
|
||||||
var args, argv, code;
|
var args, code;
|
||||||
code = this.compile_node(o);
|
code = this.compile_node(o);
|
||||||
args = this.contains(function(node) {
|
args = this.contains(function(node) {
|
||||||
return node instanceof ValueNode && node.is_arguments();
|
return node instanceof ValueNode && node.is_arguments();
|
||||||
});
|
});
|
||||||
argv = args && o.scope.check('arguments') ? '' : 'var ';
|
|
||||||
if (args) {
|
if (args) {
|
||||||
code = this.idt() + argv + "arguments = Array.prototype.slice.call(arguments, 0);\n" + code;
|
code = this.idt() + "arguments = Array.prototype.slice.call(arguments, 0);\n" + code;
|
||||||
}
|
}
|
||||||
if (o.scope.has_assignments(this)) {
|
if (o.scope.has_assignments(this)) {
|
||||||
code = this.idt() + 'var ' + o.scope.compiled_assignments() + ";\n" + code;
|
code = this.idt() + 'var ' + o.scope.compiled_assignments() + ";\n" + code;
|
||||||
|
|||||||
@@ -156,8 +156,7 @@ Expressions: exports.Expressions: inherit Node, {
|
|||||||
compile_with_declarations: (o) ->
|
compile_with_declarations: (o) ->
|
||||||
code: @compile_node(o)
|
code: @compile_node(o)
|
||||||
args: @contains (node) -> node instanceof ValueNode and node.is_arguments()
|
args: @contains (node) -> node instanceof ValueNode and node.is_arguments()
|
||||||
argv: if args and o.scope.check('arguments') then '' else 'var '
|
code: @idt() + "arguments = Array.prototype.slice.call(arguments, 0);\n" + code if args
|
||||||
code: @idt() + argv + "arguments = Array.prototype.slice.call(arguments, 0);\n" + code if args
|
|
||||||
code: @idt() + 'var ' + o.scope.compiled_assignments() + ";\n" + code if o.scope.has_assignments(this)
|
code: @idt() + 'var ' + o.scope.compiled_assignments() + ";\n" + code if o.scope.has_assignments(this)
|
||||||
code: @idt() + 'var ' + o.scope.compiled_declarations() + ";\n" + code if o.scope.has_declarations(this)
|
code: @idt() + 'var ' + o.scope.compiled_declarations() + ";\n" + code if o.scope.has_declarations(this)
|
||||||
code
|
code
|
||||||
|
|||||||
Reference in New Issue
Block a user