CoffeeScript-in-CoffeeScript can compile @property references.

This commit is contained in:
Jeremy Ashkenas
2010-02-08 23:51:34 -05:00
parent 863de88671
commit 522df2a355
4 changed files with 38 additions and 1 deletions

View File

@@ -1,5 +1,5 @@
(function(){
var AccessorNode, CallNode, CommentNode, Expressions, ExtendsNode, IndexNode, 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, 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.
@@ -744,4 +744,13 @@
return '[' + this.index.compile(o) + ']';
}
}));
// A this-reference, using '@'.
ThisNode = (exports.ThisNode = inherit(Node, {
constructor: function constructor(property) {
return this.property = property || null;
},
compile_node: function compile_node(o) {
return 'this' + (this.property ? '.' + this.property : '');
}
}));
})();