mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-02-17 11:01:25 -05:00
CoffeeScript-in-CoffeeScript can compile object[indexes]
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
(function(){
|
(function(){
|
||||||
var AccessorNode, CallNode, CommentNode, Expressions, ExtendsNode, LiteralNode, Node, ReturnNode, TAB, TRAILING_WHITESPACE, ValueNode, any, compact, del, dup, flatten, inherit, merge, statement;
|
var AccessorNode, CallNode, CommentNode, Expressions, ExtendsNode, IndexNode, LiteralNode, Node, ReturnNode, TAB, TRAILING_WHITESPACE, ValueNode, any, compact, del, dup, flatten, inherit, merge, statement;
|
||||||
var __hasProp = Object.prototype.hasOwnProperty;
|
var __hasProp = Object.prototype.hasOwnProperty;
|
||||||
process.mixin(require('./scope'));
|
process.mixin(require('./scope'));
|
||||||
// The abstract base class for all CoffeeScript nodes.
|
// The abstract base class for all CoffeeScript nodes.
|
||||||
@@ -734,4 +734,14 @@
|
|||||||
return '.' + (this.prototype ? 'prototype.' : '') + this.name.compile(o);
|
return '.' + (this.prototype ? 'prototype.' : '') + this.name.compile(o);
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
// An indexed accessor into a part of an array or object.
|
||||||
|
IndexNode = (exports.IndexNode = inherit(Node, {
|
||||||
|
constructor: function constructor(index) {
|
||||||
|
this.children = [(this.index = index)];
|
||||||
|
return this;
|
||||||
|
},
|
||||||
|
compile_node: function compile_node(o) {
|
||||||
|
return '[' + this.index.compile(o) + ']';
|
||||||
|
}
|
||||||
|
}));
|
||||||
})();
|
})();
|
||||||
@@ -460,6 +460,19 @@ AccessorNode: exports.AccessorNode: inherit Node, {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# An indexed accessor into a part of an array or object.
|
||||||
|
IndexNode: exports.IndexNode: inherit Node, {
|
||||||
|
|
||||||
|
constructor: (index) ->
|
||||||
|
@children: [@index: index]
|
||||||
|
this
|
||||||
|
|
||||||
|
compile_node: (o) ->
|
||||||
|
'[' + @index.compile(o) + ']'
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user