mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-02-17 02:51:25 -05:00
CoffeeScript-in-CoffeeScript can compile dotted accessors
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
(function(){
|
||||
var 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, LiteralNode, Node, ReturnNode, TAB, TRAILING_WHITESPACE, 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.
|
||||
@@ -553,7 +553,8 @@
|
||||
},
|
||||
push: function push(prop) {
|
||||
this.properties.push(prop);
|
||||
return this.children.push(prop);
|
||||
this.children.push(prop);
|
||||
return this;
|
||||
},
|
||||
has_properties: function has_properties() {
|
||||
return this.properties.length || this.base instanceof ThisNode;
|
||||
@@ -640,7 +641,8 @@
|
||||
},
|
||||
push: function push(arg) {
|
||||
this.args.push(arg);
|
||||
return this.children.push(arg);
|
||||
this.children.push(arg);
|
||||
return this;
|
||||
},
|
||||
// Compile a vanilla function call.
|
||||
compile_node: function compile_node(o) {
|
||||
@@ -718,4 +720,18 @@
|
||||
}
|
||||
}));
|
||||
statement(ExtendsNode);
|
||||
// A dotted accessor into a part of a value, or the :: shorthand for
|
||||
// an accessor into the object's prototype.
|
||||
AccessorNode = (exports.AccessorNode = inherit(Node, {
|
||||
constructor: function constructor(name, tag) {
|
||||
this.name = name;
|
||||
this.children = [this.name];
|
||||
this.prototype = tag === 'prototype';
|
||||
this.soak = tag === 'soak';
|
||||
return this;
|
||||
},
|
||||
compile_node: function compile_node(o) {
|
||||
return '.' + (this.prototype ? 'prototype.' : '') + this.name.compile(o);
|
||||
}
|
||||
}));
|
||||
})();
|
||||
Reference in New Issue
Block a user