redo-ing nodes.coffee with named classes.

This commit is contained in:
Jeremy Ashkenas
2010-10-04 23:24:46 -04:00
parent 19a92a4493
commit 6f9ac01e71
2 changed files with 4 additions and 63 deletions

View File

@@ -112,7 +112,7 @@
}
return _result;
}).call(this).join('');
klass = override || this["class"] + (this.soakNode || this.exist ? '?' : '');
klass = override || this.constructor.name + (this.soakNode || this.exist ? '?' : '');
return '\n' + idt + klass + children;
};
BaseNode.prototype.eachChild = function(func) {
@@ -151,7 +151,6 @@
return child instanceof BaseNode && (crossScope || !(child instanceof CodeNode)) ? child.traverseChildren(crossScope, func) : undefined;
});
};
BaseNode.prototype["class"] = 'BaseNode';
BaseNode.prototype.children = [];
BaseNode.prototype.unwrap = THIS;
BaseNode.prototype.isStatement = NO;
@@ -169,7 +168,6 @@
};
})();
__extends(Expressions, BaseNode);
Expressions.prototype["class"] = 'Expressions';
Expressions.prototype.children = ['expressions'];
Expressions.prototype.isStatement = YES;
Expressions.prototype.push = function(node) {
@@ -256,7 +254,6 @@
};
})();
__extends(LiteralNode, BaseNode);
LiteralNode.prototype["class"] = 'LiteralNode';
LiteralNode.prototype.makeReturn = function() {
return this.isStatement() ? this : LiteralNode.__super__.makeReturn.call(this);
};
@@ -286,7 +283,6 @@
};
})();
__extends(ReturnNode, BaseNode);
ReturnNode.prototype["class"] = 'ReturnNode';
ReturnNode.prototype.isStatement = YES;
ReturnNode.prototype.isPureStatement = YES;
ReturnNode.prototype.children = ['expression'];
@@ -321,7 +317,6 @@
};
})();
__extends(ValueNode, BaseNode);
ValueNode.prototype["class"] = 'ValueNode';
ValueNode.prototype.children = ['base', 'properties'];
ValueNode.prototype.push = function(prop) {
this.properties.push(prop);
@@ -450,7 +445,6 @@
};
})();
__extends(CommentNode, BaseNode);
CommentNode.prototype["class"] = 'CommentNode';
CommentNode.prototype.isStatement = YES;
CommentNode.prototype.makeReturn = THIS;
CommentNode.prototype.compileNode = function(o) {
@@ -472,7 +466,6 @@
};
})();
__extends(CallNode, BaseNode);
CallNode.prototype["class"] = 'CallNode';
CallNode.prototype.children = ['variable', 'args'];
CallNode.prototype.compileSplatArguments = function(o) {
return SplatNode.compileSplattedArray(this.args, o);
@@ -619,7 +612,6 @@
};
})();
__extends(ExtendsNode, BaseNode);
ExtendsNode.prototype["class"] = 'ExtendsNode';
ExtendsNode.prototype.children = ['child', 'parent'];
ExtendsNode.prototype.compileNode = function(o) {
var ref;
@@ -639,7 +631,6 @@
};
})();
__extends(AccessorNode, BaseNode);
AccessorNode.prototype["class"] = 'AccessorNode';
AccessorNode.prototype.children = ['name'];
AccessorNode.prototype.compileNode = function(o) {
var name, namePart;
@@ -659,7 +650,6 @@
};
})();
__extends(IndexNode, BaseNode);
IndexNode.prototype["class"] = 'IndexNode';
IndexNode.prototype.children = ['index'];
IndexNode.prototype.compileNode = function(o) {
var idx, prefix;
@@ -684,7 +674,6 @@
};
})();
__extends(RangeNode, BaseNode);
RangeNode.prototype["class"] = 'RangeNode';
RangeNode.prototype.children = ['from', 'to'];
RangeNode.prototype.compileVariables = function(o) {
var _ref2, parts;
@@ -773,7 +762,6 @@
};
})();
__extends(SliceNode, BaseNode);
SliceNode.prototype["class"] = 'SliceNode';
SliceNode.prototype.children = ['range'];
SliceNode.prototype.compileNode = function(o) {
var from, to;
@@ -796,7 +784,6 @@
};
})();
__extends(ObjectNode, BaseNode);
ObjectNode.prototype["class"] = 'ObjectNode';
ObjectNode.prototype.children = ['properties'];
ObjectNode.prototype.topSensitive = YES;
ObjectNode.prototype.compileNode = function(o) {
@@ -853,7 +840,6 @@
};
})();
__extends(ArrayNode, BaseNode);
ArrayNode.prototype["class"] = 'ArrayNode';
ArrayNode.prototype.children = ['objects'];
ArrayNode.prototype.compileSplatLiteral = function(o) {
return SplatNode.compileSplattedArray(this.objects, o);
@@ -894,7 +880,6 @@
};
})();
__extends(ClassNode, BaseNode);
ClassNode.prototype["class"] = 'ClassNode';
ClassNode.prototype.children = ['variable', 'parent', 'properties'];
ClassNode.prototype.isStatement = YES;
ClassNode.prototype.makeReturn = function() {
@@ -980,7 +965,6 @@
})();
__extends(AssignNode, BaseNode);
AssignNode.prototype.METHOD_DEF = /^(?:(\S+)\.prototype\.)?([$A-Za-z_][$\w]*)$/;
AssignNode.prototype["class"] = 'AssignNode';
AssignNode.prototype.children = ['variable', 'value'];
AssignNode.prototype.topSensitive = YES;
AssignNode.prototype.isValue = function() {
@@ -1109,7 +1093,6 @@
};
})();
__extends(CodeNode, BaseNode);
CodeNode.prototype["class"] = 'CodeNode';
CodeNode.prototype.children = ['params', 'body'];
CodeNode.prototype.compileNode = function(o) {
var _i, _len, _ref2, _ref3, _result, close, code, empty, func, i, open, param, params, sharedScope, splat, top, value;
@@ -1194,7 +1177,6 @@
};
})();
__extends(ParamNode, BaseNode);
ParamNode.prototype["class"] = 'ParamNode';
ParamNode.prototype.children = ['name'];
ParamNode.prototype.compileNode = function(o) {
return this.value.compile(o);
@@ -1224,7 +1206,6 @@
};
})();
__extends(SplatNode, BaseNode);
SplatNode.prototype["class"] = 'SplatNode';
SplatNode.prototype.children = ['name'];
SplatNode.prototype.compileNode = function(o) {
return (this.index != null) ? this.compileParam(o) : this.name.compile(o);
@@ -1300,7 +1281,6 @@
};
})();
__extends(WhileNode, BaseNode);
WhileNode.prototype["class"] = 'WhileNode';
WhileNode.prototype.children = ['condition', 'guard', 'body'];
WhileNode.prototype.isStatement = YES;
WhileNode.prototype.addBody = function(body) {
@@ -1375,7 +1355,6 @@
OpNode.prototype.CHAINABLE = ['<', '>', '>=', '<=', '===', '!=='];
OpNode.prototype.ASSIGNMENT = ['||=', '&&=', '?='];
OpNode.prototype.PREFIX_OPERATORS = ['new', 'typeof', 'delete'];
OpNode.prototype["class"] = 'OpNode';
OpNode.prototype.children = ['first', 'second'];
OpNode.prototype.isUnary = function() {
return !this.second;
@@ -1398,7 +1377,7 @@
return (this.operator = this.INVERSIONS[this.operator]);
};
OpNode.prototype.toString = function(idt) {
return OpNode.__super__.toString.call(this, idt, this["class"] + ' ' + this.operator);
return OpNode.__super__.toString.call(this, idt, this.constructor.name + ' ' + this.operator);
};
OpNode.prototype.compileNode = function(o) {
var node;
@@ -1470,7 +1449,6 @@
};
})();
__extends(InNode, BaseNode);
InNode.prototype["class"] = 'InNode';
InNode.prototype.children = ['object', 'array'];
InNode.prototype.isArray = function() {
return this.array instanceof ValueNode && this.array.isArray();
@@ -1517,7 +1495,6 @@
};
})();
__extends(TryNode, BaseNode);
TryNode.prototype["class"] = 'TryNode';
TryNode.prototype.children = ['attempt', 'recovery', 'ensure'];
TryNode.prototype.isStatement = YES;
TryNode.prototype.makeReturn = function() {
@@ -1550,7 +1527,6 @@
};
})();
__extends(ThrowNode, BaseNode);
ThrowNode.prototype["class"] = 'ThrowNode';
ThrowNode.prototype.children = ['expression'];
ThrowNode.prototype.isStatement = YES;
ThrowNode.prototype.makeReturn = THIS;
@@ -1568,7 +1544,6 @@
};
})();
__extends(ExistenceNode, BaseNode);
ExistenceNode.prototype["class"] = 'ExistenceNode';
ExistenceNode.prototype.children = ['expression'];
ExistenceNode.prototype.compileNode = function(o) {
var code;
@@ -1587,7 +1562,6 @@
};
})();
__extends(ParentheticalNode, BaseNode);
ParentheticalNode.prototype["class"] = 'ParentheticalNode';
ParentheticalNode.prototype.children = ['expression'];
ParentheticalNode.prototype.isStatement = function(o) {
return this.expression.isStatement(o);
@@ -1640,7 +1614,6 @@
};
})();
__extends(ForNode, BaseNode);
ForNode.prototype["class"] = 'ForNode';
ForNode.prototype.children = ['body', 'source', 'guard'];
ForNode.prototype.isStatement = YES;
ForNode.prototype.topSensitive = YES;
@@ -1768,7 +1741,6 @@
};
})();
__extends(SwitchNode, BaseNode);
SwitchNode.prototype["class"] = 'SwitchNode';
SwitchNode.prototype.children = ['subject', 'cases', 'otherwise'];
SwitchNode.prototype.isStatement = YES;
SwitchNode.prototype.makeReturn = function() {
@@ -1834,7 +1806,6 @@
};
})();
__extends(IfNode, BaseNode);
IfNode.prototype["class"] = 'IfNode';
IfNode.prototype.children = ['condition', 'body', 'elseBody', 'assigner'];
IfNode.prototype.topSensitive = YES;
IfNode.prototype.bodyNode = function() {