mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-02-18 19:34:27 -05:00
a bit more work on keywords-in-object-literals...
This commit is contained in:
@@ -147,7 +147,9 @@
|
|||||||
id = ("'" + id + "'");
|
id = ("'" + id + "'");
|
||||||
if (forcedIdentifier === 'accessor') {
|
if (forcedIdentifier === 'accessor') {
|
||||||
close_index = true;
|
close_index = true;
|
||||||
this.tokens.pop();
|
if (this.tag() !== '@') {
|
||||||
|
this.tokens.pop();
|
||||||
|
}
|
||||||
this.token('INDEX_START', '[');
|
this.token('INDEX_START', '[');
|
||||||
}
|
}
|
||||||
} else if (include(RESERVED, id)) {
|
} else if (include(RESERVED, id)) {
|
||||||
|
|||||||
54
lib/nodes.js
54
lib/nodes.js
@@ -141,7 +141,7 @@
|
|||||||
BaseNode.prototype.toString = function(idt) {
|
BaseNode.prototype.toString = function(idt) {
|
||||||
var _b, _c, _d, _e, child;
|
var _b, _c, _d, _e, child;
|
||||||
idt = idt || '';
|
idt = idt || '';
|
||||||
return '\n' + idt + this.type + (function() {
|
return '\n' + idt + this['class'] + (function() {
|
||||||
_b = []; _d = this.collectChildren();
|
_b = []; _d = this.collectChildren();
|
||||||
for (_c = 0, _e = _d.length; _c < _e; _c++) {
|
for (_c = 0, _e = _d.length; _c < _e; _c++) {
|
||||||
child = _d[_c];
|
child = _d[_c];
|
||||||
@@ -188,7 +188,7 @@
|
|||||||
};
|
};
|
||||||
// Default implementations of the common node properties and methods. Nodes
|
// Default implementations of the common node properties and methods. Nodes
|
||||||
// will override these with custom logic, if needed.
|
// will override these with custom logic, if needed.
|
||||||
BaseNode.prototype.type = 'BaseNode';
|
BaseNode.prototype['class'] = 'BaseNode';
|
||||||
BaseNode.prototype.children = [];
|
BaseNode.prototype.children = [];
|
||||||
BaseNode.prototype.unwrap = function() {
|
BaseNode.prototype.unwrap = function() {
|
||||||
return this;
|
return this;
|
||||||
@@ -214,7 +214,7 @@
|
|||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
__extends(Expressions, BaseNode);
|
__extends(Expressions, BaseNode);
|
||||||
Expressions.prototype.type = 'Expressions';
|
Expressions.prototype['class'] = 'Expressions';
|
||||||
Expressions.prototype.children = ['expressions'];
|
Expressions.prototype.children = ['expressions'];
|
||||||
Expressions.prototype.isStatement = function() {
|
Expressions.prototype.isStatement = function() {
|
||||||
return true;
|
return true;
|
||||||
@@ -339,7 +339,7 @@
|
|||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
__extends(LiteralNode, BaseNode);
|
__extends(LiteralNode, BaseNode);
|
||||||
LiteralNode.prototype.type = 'LiteralNode';
|
LiteralNode.prototype['class'] = 'LiteralNode';
|
||||||
// Break and continue must be treated as pure statements -- they lose their
|
// Break and continue must be treated as pure statements -- they lose their
|
||||||
// meaning when wrapped in a closure.
|
// meaning when wrapped in a closure.
|
||||||
LiteralNode.prototype.isStatement = function() {
|
LiteralNode.prototype.isStatement = function() {
|
||||||
@@ -366,7 +366,7 @@
|
|||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
__extends(ReturnNode, BaseNode);
|
__extends(ReturnNode, BaseNode);
|
||||||
ReturnNode.prototype.type = 'ReturnNode';
|
ReturnNode.prototype['class'] = 'ReturnNode';
|
||||||
ReturnNode.prototype.isStatement = function() {
|
ReturnNode.prototype.isStatement = function() {
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
@@ -405,7 +405,7 @@
|
|||||||
};
|
};
|
||||||
__extends(ValueNode, BaseNode);
|
__extends(ValueNode, BaseNode);
|
||||||
ValueNode.prototype.SOAK = " == undefined ? undefined : ";
|
ValueNode.prototype.SOAK = " == undefined ? undefined : ";
|
||||||
ValueNode.prototype.type = 'ValueNode';
|
ValueNode.prototype['class'] = 'ValueNode';
|
||||||
ValueNode.prototype.children = ['base', 'properties'];
|
ValueNode.prototype.children = ['base', 'properties'];
|
||||||
// A **ValueNode** has a base and a list of property accesses.
|
// A **ValueNode** has a base and a list of property accesses.
|
||||||
// Add a property access to the list.
|
// Add a property access to the list.
|
||||||
@@ -514,7 +514,7 @@
|
|||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
__extends(CommentNode, BaseNode);
|
__extends(CommentNode, BaseNode);
|
||||||
CommentNode.prototype.type = 'CommentNode';
|
CommentNode.prototype['class'] = 'CommentNode';
|
||||||
CommentNode.prototype.isStatement = function() {
|
CommentNode.prototype.isStatement = function() {
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
@@ -547,7 +547,7 @@
|
|||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
__extends(CallNode, BaseNode);
|
__extends(CallNode, BaseNode);
|
||||||
CallNode.prototype.type = 'CallNode';
|
CallNode.prototype['class'] = 'CallNode';
|
||||||
CallNode.prototype.children = ['variable', 'args'];
|
CallNode.prototype.children = ['variable', 'args'];
|
||||||
// Tag this invocation as creating a new instance.
|
// Tag this invocation as creating a new instance.
|
||||||
CallNode.prototype.newInstance = function() {
|
CallNode.prototype.newInstance = function() {
|
||||||
@@ -635,7 +635,7 @@
|
|||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
__extends(ExtendsNode, BaseNode);
|
__extends(ExtendsNode, BaseNode);
|
||||||
ExtendsNode.prototype.type = 'ExtendsNode';
|
ExtendsNode.prototype['class'] = 'ExtendsNode';
|
||||||
ExtendsNode.prototype.children = ['child', 'parent'];
|
ExtendsNode.prototype.children = ['child', 'parent'];
|
||||||
// Hooks one constructor into another's prototype chain.
|
// Hooks one constructor into another's prototype chain.
|
||||||
ExtendsNode.prototype.compileNode = function(o) {
|
ExtendsNode.prototype.compileNode = function(o) {
|
||||||
@@ -656,7 +656,7 @@
|
|||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
__extends(AccessorNode, BaseNode);
|
__extends(AccessorNode, BaseNode);
|
||||||
AccessorNode.prototype.type = 'AccessorNode';
|
AccessorNode.prototype['class'] = 'AccessorNode';
|
||||||
AccessorNode.prototype.children = ['name'];
|
AccessorNode.prototype.children = ['name'];
|
||||||
AccessorNode.prototype.compileNode = function(o) {
|
AccessorNode.prototype.compileNode = function(o) {
|
||||||
var name, namePart;
|
var name, namePart;
|
||||||
@@ -675,7 +675,7 @@
|
|||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
__extends(IndexNode, BaseNode);
|
__extends(IndexNode, BaseNode);
|
||||||
IndexNode.prototype.type = 'IndexNode';
|
IndexNode.prototype['class'] = 'IndexNode';
|
||||||
IndexNode.prototype.children = ['index'];
|
IndexNode.prototype.children = ['index'];
|
||||||
IndexNode.prototype.compileNode = function(o) {
|
IndexNode.prototype.compileNode = function(o) {
|
||||||
var idx, prefix;
|
var idx, prefix;
|
||||||
@@ -698,7 +698,7 @@
|
|||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
__extends(RangeNode, BaseNode);
|
__extends(RangeNode, BaseNode);
|
||||||
RangeNode.prototype.type = 'RangeNode';
|
RangeNode.prototype['class'] = 'RangeNode';
|
||||||
RangeNode.prototype.children = ['from', 'to'];
|
RangeNode.prototype.children = ['from', 'to'];
|
||||||
// Compiles the range's source variables -- where it starts and where it ends.
|
// Compiles the range's source variables -- where it starts and where it ends.
|
||||||
// But only if they need to be cached to avoid double evaluation.
|
// But only if they need to be cached to avoid double evaluation.
|
||||||
@@ -766,7 +766,7 @@
|
|||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
__extends(SliceNode, BaseNode);
|
__extends(SliceNode, BaseNode);
|
||||||
SliceNode.prototype.type = 'SliceNode';
|
SliceNode.prototype['class'] = 'SliceNode';
|
||||||
SliceNode.prototype.children = ['range'];
|
SliceNode.prototype.children = ['range'];
|
||||||
SliceNode.prototype.compileNode = function(o) {
|
SliceNode.prototype.compileNode = function(o) {
|
||||||
var from, plusPart, to;
|
var from, plusPart, to;
|
||||||
@@ -785,7 +785,7 @@
|
|||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
__extends(ObjectNode, BaseNode);
|
__extends(ObjectNode, BaseNode);
|
||||||
ObjectNode.prototype.type = 'ObjectNode';
|
ObjectNode.prototype['class'] = 'ObjectNode';
|
||||||
ObjectNode.prototype.children = ['properties'];
|
ObjectNode.prototype.children = ['properties'];
|
||||||
// All the mucking about with commas is to make sure that CommentNodes and
|
// All the mucking about with commas is to make sure that CommentNodes and
|
||||||
// AssignNodes get interleaved correctly, with no trailing commas or
|
// AssignNodes get interleaved correctly, with no trailing commas or
|
||||||
@@ -840,7 +840,7 @@
|
|||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
__extends(ArrayNode, BaseNode);
|
__extends(ArrayNode, BaseNode);
|
||||||
ArrayNode.prototype.type = 'ArrayNode';
|
ArrayNode.prototype['class'] = 'ArrayNode';
|
||||||
ArrayNode.prototype.children = ['objects'];
|
ArrayNode.prototype.children = ['objects'];
|
||||||
ArrayNode.prototype.compileNode = function(o) {
|
ArrayNode.prototype.compileNode = function(o) {
|
||||||
var _b, _c, code, i, obj, objects;
|
var _b, _c, code, i, obj, objects;
|
||||||
@@ -880,7 +880,7 @@
|
|||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
__extends(ClassNode, BaseNode);
|
__extends(ClassNode, BaseNode);
|
||||||
ClassNode.prototype.type = 'ClassNode';
|
ClassNode.prototype['class'] = 'ClassNode';
|
||||||
ClassNode.prototype.children = ['variable', 'parent', 'properties'];
|
ClassNode.prototype.children = ['variable', 'parent', 'properties'];
|
||||||
ClassNode.prototype.isStatement = function() {
|
ClassNode.prototype.isStatement = function() {
|
||||||
return true;
|
return true;
|
||||||
@@ -951,7 +951,7 @@
|
|||||||
// Matchers for detecting prototype assignments.
|
// Matchers for detecting prototype assignments.
|
||||||
AssignNode.prototype.PROTO_ASSIGN = /^(\S+)\.prototype/;
|
AssignNode.prototype.PROTO_ASSIGN = /^(\S+)\.prototype/;
|
||||||
AssignNode.prototype.LEADING_DOT = /^\.(prototype\.)?/;
|
AssignNode.prototype.LEADING_DOT = /^\.(prototype\.)?/;
|
||||||
AssignNode.prototype.type = 'AssignNode';
|
AssignNode.prototype['class'] = 'AssignNode';
|
||||||
AssignNode.prototype.children = ['variable', 'value'];
|
AssignNode.prototype.children = ['variable', 'value'];
|
||||||
AssignNode.prototype.topSensitive = function() {
|
AssignNode.prototype.topSensitive = function() {
|
||||||
return true;
|
return true;
|
||||||
@@ -1084,7 +1084,7 @@
|
|||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
__extends(CodeNode, BaseNode);
|
__extends(CodeNode, BaseNode);
|
||||||
CodeNode.prototype.type = 'CodeNode';
|
CodeNode.prototype['class'] = 'CodeNode';
|
||||||
CodeNode.prototype.children = ['params', 'body'];
|
CodeNode.prototype.children = ['params', 'body'];
|
||||||
// Compilation creates a new scope unless explicitly asked to share with the
|
// Compilation creates a new scope unless explicitly asked to share with the
|
||||||
// outer scope. Handles splat parameters in the parameter list by peeking at
|
// outer scope. Handles splat parameters in the parameter list by peeking at
|
||||||
@@ -1181,7 +1181,7 @@
|
|||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
__extends(SplatNode, BaseNode);
|
__extends(SplatNode, BaseNode);
|
||||||
SplatNode.prototype.type = 'SplatNode';
|
SplatNode.prototype['class'] = 'SplatNode';
|
||||||
SplatNode.prototype.children = ['name'];
|
SplatNode.prototype.children = ['name'];
|
||||||
SplatNode.prototype.compileNode = function(o) {
|
SplatNode.prototype.compileNode = function(o) {
|
||||||
var _b;
|
var _b;
|
||||||
@@ -1262,7 +1262,7 @@
|
|||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
__extends(WhileNode, BaseNode);
|
__extends(WhileNode, BaseNode);
|
||||||
WhileNode.prototype.type = 'WhileNode';
|
WhileNode.prototype['class'] = 'WhileNode';
|
||||||
WhileNode.prototype.children = ['condition', 'guard', 'body'];
|
WhileNode.prototype.children = ['condition', 'guard', 'body'];
|
||||||
WhileNode.prototype.isStatement = function() {
|
WhileNode.prototype.isStatement = function() {
|
||||||
return true;
|
return true;
|
||||||
@@ -1330,7 +1330,7 @@
|
|||||||
OpNode.prototype.ASSIGNMENT = ['||=', '&&=', '?='];
|
OpNode.prototype.ASSIGNMENT = ['||=', '&&=', '?='];
|
||||||
// Operators must come before their operands with a space.
|
// Operators must come before their operands with a space.
|
||||||
OpNode.prototype.PREFIX_OPERATORS = ['typeof', 'delete'];
|
OpNode.prototype.PREFIX_OPERATORS = ['typeof', 'delete'];
|
||||||
OpNode.prototype.type = 'OpNode';
|
OpNode.prototype['class'] = 'OpNode';
|
||||||
OpNode.prototype.children = ['first', 'second'];
|
OpNode.prototype.children = ['first', 'second'];
|
||||||
OpNode.prototype.isUnary = function() {
|
OpNode.prototype.isUnary = function() {
|
||||||
return !this.second;
|
return !this.second;
|
||||||
@@ -1421,7 +1421,7 @@
|
|||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
__extends(TryNode, BaseNode);
|
__extends(TryNode, BaseNode);
|
||||||
TryNode.prototype.type = 'TryNode';
|
TryNode.prototype['class'] = 'TryNode';
|
||||||
TryNode.prototype.children = ['attempt', 'recovery', 'ensure'];
|
TryNode.prototype.children = ['attempt', 'recovery', 'ensure'];
|
||||||
TryNode.prototype.isStatement = function() {
|
TryNode.prototype.isStatement = function() {
|
||||||
return true;
|
return true;
|
||||||
@@ -1457,7 +1457,7 @@
|
|||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
__extends(ThrowNode, BaseNode);
|
__extends(ThrowNode, BaseNode);
|
||||||
ThrowNode.prototype.type = 'ThrowNode';
|
ThrowNode.prototype['class'] = 'ThrowNode';
|
||||||
ThrowNode.prototype.children = ['expression'];
|
ThrowNode.prototype.children = ['expression'];
|
||||||
ThrowNode.prototype.isStatement = function() {
|
ThrowNode.prototype.isStatement = function() {
|
||||||
return true;
|
return true;
|
||||||
@@ -1481,7 +1481,7 @@
|
|||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
__extends(ExistenceNode, BaseNode);
|
__extends(ExistenceNode, BaseNode);
|
||||||
ExistenceNode.prototype.type = 'ExistenceNode';
|
ExistenceNode.prototype['class'] = 'ExistenceNode';
|
||||||
ExistenceNode.prototype.children = ['expression'];
|
ExistenceNode.prototype.children = ['expression'];
|
||||||
ExistenceNode.prototype.compileNode = function(o) {
|
ExistenceNode.prototype.compileNode = function(o) {
|
||||||
return ExistenceNode.compileTest(o, this.expression);
|
return ExistenceNode.compileTest(o, this.expression);
|
||||||
@@ -1509,7 +1509,7 @@
|
|||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
__extends(ParentheticalNode, BaseNode);
|
__extends(ParentheticalNode, BaseNode);
|
||||||
ParentheticalNode.prototype.type = 'ParentheticalNode';
|
ParentheticalNode.prototype['class'] = 'ParentheticalNode';
|
||||||
ParentheticalNode.prototype.children = ['expression'];
|
ParentheticalNode.prototype.children = ['expression'];
|
||||||
ParentheticalNode.prototype.isStatement = function() {
|
ParentheticalNode.prototype.isStatement = function() {
|
||||||
return this.expression.isStatement();
|
return this.expression.isStatement();
|
||||||
@@ -1565,7 +1565,7 @@
|
|||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
__extends(ForNode, BaseNode);
|
__extends(ForNode, BaseNode);
|
||||||
ForNode.prototype.type = 'ForNode';
|
ForNode.prototype['class'] = 'ForNode';
|
||||||
ForNode.prototype.children = ['body', 'source', 'guard'];
|
ForNode.prototype.children = ['body', 'source', 'guard'];
|
||||||
ForNode.prototype.isStatement = function() {
|
ForNode.prototype.isStatement = function() {
|
||||||
return true;
|
return true;
|
||||||
@@ -1695,7 +1695,7 @@
|
|||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
__extends(IfNode, BaseNode);
|
__extends(IfNode, BaseNode);
|
||||||
IfNode.prototype.type = 'IfNode';
|
IfNode.prototype['class'] = 'IfNode';
|
||||||
IfNode.prototype.children = ['condition', 'switchSubject', 'body', 'elseBody', 'assigner'];
|
IfNode.prototype.children = ['condition', 'switchSubject', 'body', 'elseBody', 'assigner'];
|
||||||
IfNode.prototype.bodyNode = function() {
|
IfNode.prototype.bodyNode = function() {
|
||||||
return this.body == undefined ? undefined : this.body.unwrap();
|
return this.body == undefined ? undefined : this.body.unwrap();
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ exports.Lexer: class Lexer
|
|||||||
id: "'$id'"
|
id: "'$id'"
|
||||||
if forcedIdentifier is 'accessor'
|
if forcedIdentifier is 'accessor'
|
||||||
close_index: true
|
close_index: true
|
||||||
@tokens.pop()
|
@tokens.pop() if @tag() isnt '@'
|
||||||
@token 'INDEX_START', '['
|
@token 'INDEX_START', '['
|
||||||
else if include(RESERVED, id)
|
else if include(RESERVED, id)
|
||||||
@identifierError id
|
@identifierError id
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ exports.BaseNode: class BaseNode
|
|||||||
# This is what `coffee --nodes` prints out.
|
# This is what `coffee --nodes` prints out.
|
||||||
toString: (idt) ->
|
toString: (idt) ->
|
||||||
idt: or ''
|
idt: or ''
|
||||||
'\n' + idt + @type + (child.toString(idt + TAB) for child in @collectChildren()).join('')
|
'\n' + idt + @class + (child.toString(idt + TAB) for child in @collectChildren()).join('')
|
||||||
|
|
||||||
eachChild: (func) ->
|
eachChild: (func) ->
|
||||||
return unless @children
|
return unless @children
|
||||||
@@ -131,7 +131,7 @@ exports.BaseNode: class BaseNode
|
|||||||
|
|
||||||
# Default implementations of the common node properties and methods. Nodes
|
# Default implementations of the common node properties and methods. Nodes
|
||||||
# will override these with custom logic, if needed.
|
# will override these with custom logic, if needed.
|
||||||
type: 'BaseNode'
|
class: 'BaseNode'
|
||||||
children: []
|
children: []
|
||||||
|
|
||||||
unwrap: -> this
|
unwrap: -> this
|
||||||
@@ -146,7 +146,7 @@ exports.BaseNode: class BaseNode
|
|||||||
# `if`, `switch`, or `try`, and so on...
|
# `if`, `switch`, or `try`, and so on...
|
||||||
exports.Expressions: class Expressions extends BaseNode
|
exports.Expressions: class Expressions extends BaseNode
|
||||||
|
|
||||||
type: 'Expressions'
|
class: 'Expressions'
|
||||||
children: ['expressions']
|
children: ['expressions']
|
||||||
isStatement: -> yes
|
isStatement: -> yes
|
||||||
|
|
||||||
@@ -228,7 +228,7 @@ Expressions.wrap: (nodes) ->
|
|||||||
# `true`, `false`, `null`...
|
# `true`, `false`, `null`...
|
||||||
exports.LiteralNode: class LiteralNode extends BaseNode
|
exports.LiteralNode: class LiteralNode extends BaseNode
|
||||||
|
|
||||||
type: 'LiteralNode'
|
class: 'LiteralNode'
|
||||||
|
|
||||||
constructor: (value) ->
|
constructor: (value) ->
|
||||||
@value: value
|
@value: value
|
||||||
@@ -253,7 +253,7 @@ exports.LiteralNode: class LiteralNode extends BaseNode
|
|||||||
# make sense.
|
# make sense.
|
||||||
exports.ReturnNode: class ReturnNode extends BaseNode
|
exports.ReturnNode: class ReturnNode extends BaseNode
|
||||||
|
|
||||||
type: 'ReturnNode'
|
class: 'ReturnNode'
|
||||||
isStatement: -> yes
|
isStatement: -> yes
|
||||||
isPureStatement: -> yes
|
isPureStatement: -> yes
|
||||||
children: ['expression']
|
children: ['expression']
|
||||||
@@ -282,7 +282,7 @@ exports.ValueNode: class ValueNode extends BaseNode
|
|||||||
|
|
||||||
SOAK: " == undefined ? undefined : "
|
SOAK: " == undefined ? undefined : "
|
||||||
|
|
||||||
type: 'ValueNode'
|
class: 'ValueNode'
|
||||||
children: ['base', 'properties']
|
children: ['base', 'properties']
|
||||||
|
|
||||||
# A **ValueNode** has a base and a list of property accesses.
|
# A **ValueNode** has a base and a list of property accesses.
|
||||||
@@ -366,7 +366,7 @@ exports.ValueNode: class ValueNode extends BaseNode
|
|||||||
# same position.
|
# same position.
|
||||||
exports.CommentNode: class CommentNode extends BaseNode
|
exports.CommentNode: class CommentNode extends BaseNode
|
||||||
|
|
||||||
type: 'CommentNode'
|
class: 'CommentNode'
|
||||||
isStatement: -> yes
|
isStatement: -> yes
|
||||||
|
|
||||||
constructor: (lines, kind) ->
|
constructor: (lines, kind) ->
|
||||||
@@ -389,7 +389,7 @@ exports.CommentNode: class CommentNode extends BaseNode
|
|||||||
# calls against the prototype's function of the same name.
|
# calls against the prototype's function of the same name.
|
||||||
exports.CallNode: class CallNode extends BaseNode
|
exports.CallNode: class CallNode extends BaseNode
|
||||||
|
|
||||||
type: 'CallNode'
|
class: 'CallNode'
|
||||||
children: ['variable', 'args']
|
children: ['variable', 'args']
|
||||||
|
|
||||||
constructor: (variable, args) ->
|
constructor: (variable, args) ->
|
||||||
@@ -451,7 +451,7 @@ exports.CallNode: class CallNode extends BaseNode
|
|||||||
# [Closure Library](http://closure-library.googlecode.com/svn/docs/closureGoogBase.js.html).
|
# [Closure Library](http://closure-library.googlecode.com/svn/docs/closureGoogBase.js.html).
|
||||||
exports.ExtendsNode: class ExtendsNode extends BaseNode
|
exports.ExtendsNode: class ExtendsNode extends BaseNode
|
||||||
|
|
||||||
type: 'ExtendsNode'
|
class: 'ExtendsNode'
|
||||||
children: ['child', 'parent']
|
children: ['child', 'parent']
|
||||||
|
|
||||||
constructor: (child, parent) ->
|
constructor: (child, parent) ->
|
||||||
@@ -469,7 +469,7 @@ exports.ExtendsNode: class ExtendsNode extends BaseNode
|
|||||||
# an accessor into the object's prototype.
|
# an accessor into the object's prototype.
|
||||||
exports.AccessorNode: class AccessorNode extends BaseNode
|
exports.AccessorNode: class AccessorNode extends BaseNode
|
||||||
|
|
||||||
type: 'AccessorNode'
|
class: 'AccessorNode'
|
||||||
children: ['name']
|
children: ['name']
|
||||||
|
|
||||||
constructor: (name, tag) ->
|
constructor: (name, tag) ->
|
||||||
@@ -488,7 +488,7 @@ exports.AccessorNode: class AccessorNode extends BaseNode
|
|||||||
# A `[ ... ]` 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: 'IndexNode'
|
class: 'IndexNode'
|
||||||
children: ['index']
|
children: ['index']
|
||||||
|
|
||||||
constructor: (index) ->
|
constructor: (index) ->
|
||||||
@@ -507,7 +507,7 @@ exports.IndexNode: class IndexNode extends BaseNode
|
|||||||
# corresponding array of integers at runtime.
|
# corresponding array of integers at runtime.
|
||||||
exports.RangeNode: class RangeNode extends BaseNode
|
exports.RangeNode: class RangeNode extends BaseNode
|
||||||
|
|
||||||
type: 'RangeNode'
|
class: 'RangeNode'
|
||||||
children: ['from', 'to']
|
children: ['from', 'to']
|
||||||
|
|
||||||
constructor: (from, to, exclusive) ->
|
constructor: (from, to, exclusive) ->
|
||||||
@@ -557,7 +557,7 @@ exports.RangeNode: class RangeNode extends BaseNode
|
|||||||
# is the index of the beginning.
|
# is the index of the beginning.
|
||||||
exports.SliceNode: class SliceNode extends BaseNode
|
exports.SliceNode: class SliceNode extends BaseNode
|
||||||
|
|
||||||
type: 'SliceNode'
|
class: 'SliceNode'
|
||||||
children: ['range']
|
children: ['range']
|
||||||
|
|
||||||
constructor: (range) ->
|
constructor: (range) ->
|
||||||
@@ -574,7 +574,7 @@ exports.SliceNode: class SliceNode extends BaseNode
|
|||||||
# An object literal, nothing fancy.
|
# An object literal, nothing fancy.
|
||||||
exports.ObjectNode: class ObjectNode extends BaseNode
|
exports.ObjectNode: class ObjectNode extends BaseNode
|
||||||
|
|
||||||
type: 'ObjectNode'
|
class: 'ObjectNode'
|
||||||
children: ['properties']
|
children: ['properties']
|
||||||
|
|
||||||
constructor: (props) ->
|
constructor: (props) ->
|
||||||
@@ -603,7 +603,7 @@ exports.ObjectNode: class ObjectNode extends BaseNode
|
|||||||
# An array literal.
|
# An array literal.
|
||||||
exports.ArrayNode: class ArrayNode extends BaseNode
|
exports.ArrayNode: class ArrayNode extends BaseNode
|
||||||
|
|
||||||
type: 'ArrayNode'
|
class: 'ArrayNode'
|
||||||
children: ['objects']
|
children: ['objects']
|
||||||
|
|
||||||
constructor: (objects) ->
|
constructor: (objects) ->
|
||||||
@@ -635,7 +635,7 @@ exports.ArrayNode: class ArrayNode extends BaseNode
|
|||||||
# The CoffeeScript class definition.
|
# The CoffeeScript class definition.
|
||||||
exports.ClassNode: class ClassNode extends BaseNode
|
exports.ClassNode: class ClassNode extends BaseNode
|
||||||
|
|
||||||
type: 'ClassNode'
|
class: 'ClassNode'
|
||||||
children: ['variable', 'parent', 'properties']
|
children: ['variable', 'parent', 'properties']
|
||||||
isStatement: -> yes
|
isStatement: -> yes
|
||||||
|
|
||||||
@@ -700,7 +700,7 @@ exports.AssignNode: class AssignNode extends BaseNode
|
|||||||
PROTO_ASSIGN: /^(\S+)\.prototype/
|
PROTO_ASSIGN: /^(\S+)\.prototype/
|
||||||
LEADING_DOT: /^\.(prototype\.)?/
|
LEADING_DOT: /^\.(prototype\.)?/
|
||||||
|
|
||||||
type: 'AssignNode'
|
class: 'AssignNode'
|
||||||
children: ['variable', 'value']
|
children: ['variable', 'value']
|
||||||
|
|
||||||
constructor: (variable, value, context) ->
|
constructor: (variable, value, context) ->
|
||||||
@@ -799,7 +799,7 @@ exports.AssignNode: class AssignNode extends BaseNode
|
|||||||
# has no *children* -- they're within the inner scope.
|
# has no *children* -- they're within the inner scope.
|
||||||
exports.CodeNode: class CodeNode extends BaseNode
|
exports.CodeNode: class CodeNode extends BaseNode
|
||||||
|
|
||||||
type: 'CodeNode'
|
class: 'CodeNode'
|
||||||
children: ['params', 'body']
|
children: ['params', 'body']
|
||||||
|
|
||||||
constructor: (params, body, tag) ->
|
constructor: (params, body, tag) ->
|
||||||
@@ -863,7 +863,7 @@ exports.CodeNode: class CodeNode extends BaseNode
|
|||||||
# or as part of a destructuring assignment.
|
# or as part of a destructuring assignment.
|
||||||
exports.SplatNode: class SplatNode extends BaseNode
|
exports.SplatNode: class SplatNode extends BaseNode
|
||||||
|
|
||||||
type: 'SplatNode'
|
class: 'SplatNode'
|
||||||
children: ['name']
|
children: ['name']
|
||||||
|
|
||||||
constructor: (name) ->
|
constructor: (name) ->
|
||||||
@@ -921,7 +921,7 @@ exports.SplatNode: class SplatNode extends BaseNode
|
|||||||
# flexibility or more speed than a comprehension can provide.
|
# flexibility or more speed than a comprehension can provide.
|
||||||
exports.WhileNode: class WhileNode extends BaseNode
|
exports.WhileNode: class WhileNode extends BaseNode
|
||||||
|
|
||||||
type: 'WhileNode'
|
class: 'WhileNode'
|
||||||
children: ['condition', 'guard', 'body']
|
children: ['condition', 'guard', 'body']
|
||||||
isStatement: -> yes
|
isStatement: -> yes
|
||||||
|
|
||||||
@@ -986,7 +986,7 @@ exports.OpNode: class OpNode extends BaseNode
|
|||||||
# Operators must come before their operands with a space.
|
# Operators must come before their operands with a space.
|
||||||
PREFIX_OPERATORS: ['typeof', 'delete']
|
PREFIX_OPERATORS: ['typeof', 'delete']
|
||||||
|
|
||||||
type: 'OpNode'
|
class: 'OpNode'
|
||||||
children: ['first', 'second']
|
children: ['first', 'second']
|
||||||
|
|
||||||
constructor: (operator, first, second, flip) ->
|
constructor: (operator, first, second, flip) ->
|
||||||
@@ -1048,7 +1048,7 @@ exports.OpNode: class OpNode extends BaseNode
|
|||||||
# A classic *try/catch/finally* block.
|
# A classic *try/catch/finally* block.
|
||||||
exports.TryNode: class TryNode extends BaseNode
|
exports.TryNode: class TryNode extends BaseNode
|
||||||
|
|
||||||
type: 'TryNode'
|
class: 'TryNode'
|
||||||
children: ['attempt', 'recovery', 'ensure']
|
children: ['attempt', 'recovery', 'ensure']
|
||||||
isStatement: -> yes
|
isStatement: -> yes
|
||||||
|
|
||||||
@@ -1079,7 +1079,7 @@ exports.TryNode: class TryNode extends BaseNode
|
|||||||
# Simple node to throw an exception.
|
# Simple node to throw an exception.
|
||||||
exports.ThrowNode: class ThrowNode extends BaseNode
|
exports.ThrowNode: class ThrowNode extends BaseNode
|
||||||
|
|
||||||
type: 'ThrowNode'
|
class: 'ThrowNode'
|
||||||
children: ['expression']
|
children: ['expression']
|
||||||
isStatement: -> yes
|
isStatement: -> yes
|
||||||
|
|
||||||
@@ -1100,7 +1100,7 @@ exports.ThrowNode: class ThrowNode extends BaseNode
|
|||||||
# table.
|
# table.
|
||||||
exports.ExistenceNode: class ExistenceNode extends BaseNode
|
exports.ExistenceNode: class ExistenceNode extends BaseNode
|
||||||
|
|
||||||
type: 'ExistenceNode'
|
class: 'ExistenceNode'
|
||||||
children: ['expression']
|
children: ['expression']
|
||||||
|
|
||||||
constructor: (expression) ->
|
constructor: (expression) ->
|
||||||
@@ -1125,7 +1125,7 @@ exports.ExistenceNode: class ExistenceNode extends BaseNode
|
|||||||
# Parentheses are a good way to force any statement to become an expression.
|
# Parentheses are a good way to force any statement to become an expression.
|
||||||
exports.ParentheticalNode: class ParentheticalNode extends BaseNode
|
exports.ParentheticalNode: class ParentheticalNode extends BaseNode
|
||||||
|
|
||||||
type: 'ParentheticalNode'
|
class: 'ParentheticalNode'
|
||||||
children: ['expression']
|
children: ['expression']
|
||||||
|
|
||||||
constructor: (expression) ->
|
constructor: (expression) ->
|
||||||
@@ -1155,7 +1155,7 @@ exports.ParentheticalNode: class ParentheticalNode extends BaseNode
|
|||||||
# you can map and filter in a single pass.
|
# you can map and filter in a single pass.
|
||||||
exports.ForNode: class ForNode extends BaseNode
|
exports.ForNode: class ForNode extends BaseNode
|
||||||
|
|
||||||
type: 'ForNode'
|
class: 'ForNode'
|
||||||
children: ['body', 'source', 'guard']
|
children: ['body', 'source', 'guard']
|
||||||
isStatement: -> yes
|
isStatement: -> yes
|
||||||
|
|
||||||
@@ -1245,7 +1245,7 @@ exports.ForNode: class ForNode extends BaseNode
|
|||||||
# because ternaries are already proper expressions, and don't need conversion.
|
# because ternaries are already proper expressions, and don't need conversion.
|
||||||
exports.IfNode: class IfNode extends BaseNode
|
exports.IfNode: class IfNode extends BaseNode
|
||||||
|
|
||||||
type: 'IfNode'
|
class: 'IfNode'
|
||||||
children: ['condition', 'switchSubject', 'body', 'elseBody', 'assigner']
|
children: ['condition', 'switchSubject', 'body', 'elseBody', 'assigner']
|
||||||
|
|
||||||
constructor: (condition, body, tags) ->
|
constructor: (condition, body, tags) ->
|
||||||
|
|||||||
@@ -123,5 +123,8 @@ ok maya.name is 'Maya'
|
|||||||
# Class with JS-keyword properties.
|
# Class with JS-keyword properties.
|
||||||
class Class
|
class Class
|
||||||
class: 'class'
|
class: 'class'
|
||||||
|
name: -> @class
|
||||||
|
|
||||||
ok (new Class()).class is 'class'
|
instance: new Class()
|
||||||
|
ok instance.class is 'class'
|
||||||
|
ok instance.name() is 'class'
|
||||||
Reference in New Issue
Block a user