This commit is contained in:
Jeremy Ashkenas
2010-03-10 21:53:33 -05:00
parent 3f9fd85afb
commit 0379431812
2 changed files with 9 additions and 6 deletions

View File

@@ -461,7 +461,7 @@
return '' + (meth) + ".call(this" + (args.length ? ', ' : '') + args + ")"; return '' + (meth) + ".call(this" + (args.length ? ', ' : '') + args + ")";
}; };
// If you call a function with a splat, it's converted into a JavaScript // If you call a function with a splat, it's converted into a JavaScript
// `.apply()` call to allow the variable-length arguments. // `.apply()` call to allow an array of arguments to be passed.
CallNode.prototype.compile_splat = function compile_splat(o) { CallNode.prototype.compile_splat = function compile_splat(o) {
var _a, _b, _c, arg, args, code, i, meth, obj, temp; var _a, _b, _c, arg, args, code, i, meth, obj, temp;
meth = this.variable.compile(o); meth = this.variable.compile(o);
@@ -523,12 +523,14 @@
__extends(AccessorNode, BaseNode); __extends(AccessorNode, BaseNode);
AccessorNode.prototype.type = 'Accessor'; AccessorNode.prototype.type = 'Accessor';
AccessorNode.prototype.compile_node = function compile_node(o) { AccessorNode.prototype.compile_node = function compile_node(o) {
return '.' + (this.prototype ? 'prototype.' : '') + this.name.compile(o); var proto_part;
proto_part = this.prototype ? 'prototype.' : '';
return "." + proto_part + (this.name.compile(o));
}; };
return AccessorNode; return AccessorNode;
}).call(this); }).call(this);
//### IndexNode //### IndexNode
// An indexed accessor into an array or object. // A `[ ... ]` indexed accessor into an array or object.
exports.IndexNode = (function() { exports.IndexNode = (function() {
IndexNode = function IndexNode(index, tag) { IndexNode = function IndexNode(index, tag) {
this.children = [(this.index = index)]; this.children = [(this.index = index)];

View File

@@ -352,7 +352,7 @@ exports.CallNode: class CallNode extends BaseNode
"${meth}.call(this${ if args.length then ', ' else '' }$args)" "${meth}.call(this${ if args.length then ', ' else '' }$args)"
# If you call a function with a splat, it's converted into a JavaScript # If you call a function with a splat, it's converted into a JavaScript
# `.apply()` call to allow the variable-length arguments. # `.apply()` call to allow an array of arguments to be passed.
compile_splat: (o) -> compile_splat: (o) ->
meth: @variable.compile o meth: @variable.compile o
obj: @variable.source or 'this' obj: @variable.source or 'this'
@@ -408,11 +408,12 @@ exports.AccessorNode: class AccessorNode extends BaseNode
this this
compile_node: (o) -> compile_node: (o) ->
'.' + (if @prototype then 'prototype.' else '') + @name.compile(o) proto_part: if @prototype then 'prototype.' else ''
".$proto_part${@name.compile(o)}"
#### IndexNode #### IndexNode
# An indexed accessor into an array or object. # A `[ ... ]` indexed accessor into an array or object.
exports.IndexNode: class IndexNode extends BaseNode exports.IndexNode: class IndexNode extends BaseNode
type: 'Index' type: 'Index'