mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-05-03 03:00:14 -04:00
CoffeeScript-in-CoffeeScript can compile @property references.
This commit is contained in:
@@ -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 : '');
|
||||
}
|
||||
}));
|
||||
})();
|
||||
@@ -212,6 +212,8 @@
|
||||
return new ValueNode($1);
|
||||
}), o("Range", function() {
|
||||
return new ValueNode($1);
|
||||
}), o("This", function() {
|
||||
return new ValueNode($1);
|
||||
}), o("Value Accessor", function() {
|
||||
return $1.push($2);
|
||||
}), o("Invocation Accessor", function() {
|
||||
@@ -285,6 +287,13 @@
|
||||
return new CallNode('super', $3);
|
||||
})
|
||||
],
|
||||
// This references, either naked or to a property.
|
||||
This: [o("@", function() {
|
||||
return new ThisNode();
|
||||
}), o("@ IDENTIFIER", function() {
|
||||
return new ThisNode(yytext);
|
||||
})
|
||||
],
|
||||
// The range literal.
|
||||
Range: [o("[ Expression . . Expression ]", function() {
|
||||
return new RangeNode($2, $5);
|
||||
|
||||
Reference in New Issue
Block a user