mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-02-17 11:01:25 -05:00
Self-compiler can compile splats.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
(function(){
|
||||
var AccessorNode, ArrayNode, AssignNode, CallNode, ClosureNode, CodeNode, CommentNode, Expressions, ExtendsNode, IndexNode, LiteralNode, Node, ObjectNode, PushNode, RangeNode, ReturnNode, SliceNode, TAB, TRAILING_WHITESPACE, ThisNode, ValueNode, any, compact, del, dup, flatten, inherit, merge, statement;
|
||||
var AccessorNode, ArrayNode, AssignNode, CallNode, ClosureNode, CodeNode, CommentNode, Expressions, ExtendsNode, IndexNode, LiteralNode, Node, ObjectNode, PushNode, RangeNode, ReturnNode, SliceNode, SplatNode, TAB, TRAILING_WHITESPACE, ThisNode, ValueNode, any, compact, del, dup, flatten, inherit, merge, statement;
|
||||
var __hasProp = Object.prototype.hasOwnProperty;
|
||||
process.mixin(require('./scope'));
|
||||
// The abstract base class for all CoffeeScript nodes.
|
||||
@@ -980,4 +980,22 @@
|
||||
return true;
|
||||
}
|
||||
}));
|
||||
// A splat, either as a parameter to a function, an argument to a call,
|
||||
// or in a destructuring assignment.
|
||||
SplatNode = (exports.SplatNode = inherit(Node, {
|
||||
constructor: function constructor(name) {
|
||||
this.children = [(this.name = name)];
|
||||
return this;
|
||||
},
|
||||
compile_node: function compile_node(o) {
|
||||
return this.index ? this.compile_param(o) : this.name.compile(o);
|
||||
},
|
||||
compile_param: function compile_param(o) {
|
||||
o.scope.find(this.name);
|
||||
return this.name + ' = Array.prototype.slice.call(arguments, ' + this.index + ')';
|
||||
},
|
||||
compile_value: function compile_value(o, name, index) {
|
||||
return "Array.prototype.slice.call(" + this.name + ', ' + this.index + ')';
|
||||
}
|
||||
}));
|
||||
})();
|
||||
Reference in New Issue
Block a user