mirror of
https://github.com/jashkenas/coffeescript.git
synced 2022-11-09 12:23:24 -05:00
Issue #641. Rename __superClass__ to __super__
This commit is contained in:
parent
1b88d18d61
commit
bd3471b3d1
3 changed files with 43 additions and 43 deletions
76
lib/nodes.js
76
lib/nodes.js
|
@ -6,7 +6,7 @@
|
|||
child.prototype = new ctor();
|
||||
child.prototype.constructor = child;
|
||||
if (typeof parent.extended === "function") parent.extended(child);
|
||||
child.__superClass__ = parent.prototype;
|
||||
child.__super__ = parent.prototype;
|
||||
};
|
||||
if (typeof process !== "undefined" && process !== null) {
|
||||
Scope = require('./scope').Scope;
|
||||
|
@ -170,7 +170,7 @@
|
|||
})();
|
||||
exports.Expressions = (function() {
|
||||
Expressions = function(nodes) {
|
||||
Expressions.__superClass__.constructor.call(this);
|
||||
Expressions.__super__.constructor.call(this);
|
||||
this.expressions = compact(flatten(nodes || []));
|
||||
return this;
|
||||
};
|
||||
|
@ -209,7 +209,7 @@
|
|||
};
|
||||
Expressions.prototype.compile = function(o) {
|
||||
o || (o = {});
|
||||
return o.scope ? Expressions.__superClass__.compile.call(this, o) : this.compileRoot(o);
|
||||
return o.scope ? Expressions.__super__.compile.call(this, o) : this.compileRoot(o);
|
||||
};
|
||||
Expressions.prototype.compileNode = function(o) {
|
||||
var _b, _c, _d, _e, node;
|
||||
|
@ -260,13 +260,13 @@
|
|||
exports.LiteralNode = (function() {
|
||||
LiteralNode = function(_b) {
|
||||
this.value = _b;
|
||||
LiteralNode.__superClass__.constructor.call(this);
|
||||
LiteralNode.__super__.constructor.call(this);
|
||||
return this;
|
||||
};
|
||||
__extends(LiteralNode, BaseNode);
|
||||
LiteralNode.prototype["class"] = 'LiteralNode';
|
||||
LiteralNode.prototype.makeReturn = function() {
|
||||
return this.isStatement() ? this : LiteralNode.__superClass__.makeReturn.call(this);
|
||||
return this.isStatement() ? this : LiteralNode.__super__.makeReturn.call(this);
|
||||
};
|
||||
LiteralNode.prototype.isStatement = function() {
|
||||
return this.value === 'break' || this.value === 'continue';
|
||||
|
@ -286,7 +286,7 @@
|
|||
exports.ReturnNode = (function() {
|
||||
ReturnNode = function(_b) {
|
||||
this.expression = _b;
|
||||
ReturnNode.__superClass__.constructor.call(this);
|
||||
ReturnNode.__super__.constructor.call(this);
|
||||
return this;
|
||||
};
|
||||
__extends(ReturnNode, BaseNode);
|
||||
|
@ -307,7 +307,7 @@
|
|||
if (!(expr instanceof ReturnNode)) {
|
||||
return expr.compile(o);
|
||||
}
|
||||
return ReturnNode.__superClass__.compile.call(this, o);
|
||||
return ReturnNode.__super__.compile.call(this, o);
|
||||
};
|
||||
ReturnNode.prototype.compileNode = function(o) {
|
||||
if (this.expression.isStatement(o)) {
|
||||
|
@ -321,7 +321,7 @@
|
|||
ValueNode = function(_b, _c) {
|
||||
this.properties = _c;
|
||||
this.base = _b;
|
||||
ValueNode.__superClass__.constructor.call(this);
|
||||
ValueNode.__super__.constructor.call(this);
|
||||
this.properties || (this.properties = []);
|
||||
return this;
|
||||
};
|
||||
|
@ -345,7 +345,7 @@
|
|||
return this.hasProperties() && this.properties[this.properties.length - 1] instanceof SliceNode;
|
||||
};
|
||||
ValueNode.prototype.makeReturn = function() {
|
||||
return this.hasProperties() ? ValueNode.__superClass__.makeReturn.call(this) : this.base.makeReturn();
|
||||
return this.hasProperties() ? ValueNode.__super__.makeReturn.call(this) : this.base.makeReturn();
|
||||
};
|
||||
ValueNode.prototype.unwrap = function() {
|
||||
return this.properties.length ? this : this.base;
|
||||
|
@ -379,7 +379,7 @@
|
|||
return [this, copy];
|
||||
};
|
||||
ValueNode.prototype.compile = function(o) {
|
||||
return !o.top || this.properties.length ? ValueNode.__superClass__.compile.call(this, o) : this.base.compile(o);
|
||||
return !o.top || this.properties.length ? ValueNode.__super__.compile.call(this, o) : this.base.compile(o);
|
||||
};
|
||||
ValueNode.prototype.compileNode = function(o) {
|
||||
var _b, _c, _d, baseline, complete, i, only, op, props;
|
||||
|
@ -426,7 +426,7 @@
|
|||
exports.CommentNode = (function() {
|
||||
CommentNode = function(_b) {
|
||||
this.comment = _b;
|
||||
CommentNode.__superClass__.constructor.call(this);
|
||||
CommentNode.__super__.constructor.call(this);
|
||||
return this;
|
||||
};
|
||||
__extends(CommentNode, BaseNode);
|
||||
|
@ -445,7 +445,7 @@
|
|||
exports.CallNode = (function() {
|
||||
CallNode = function(variable, _b) {
|
||||
this.args = _b;
|
||||
CallNode.__superClass__.constructor.call(this);
|
||||
CallNode.__super__.constructor.call(this);
|
||||
this.isNew = false;
|
||||
this.isSuper = variable === 'super';
|
||||
this.variable = this.isSuper ? null : variable;
|
||||
|
@ -470,9 +470,9 @@
|
|||
methname = o.scope.method.name;
|
||||
return (meth = (function() {
|
||||
if (o.scope.method.proto) {
|
||||
return "" + (o.scope.method.proto) + ".__superClass__." + (methname);
|
||||
return "" + (o.scope.method.proto) + ".__super__." + (methname);
|
||||
} else if (methname) {
|
||||
return "" + (methname) + ".__superClass__.constructor";
|
||||
return "" + (methname) + ".__super__.constructor";
|
||||
} else {
|
||||
throw new Error("cannot call super on an anonymous function.");
|
||||
}
|
||||
|
@ -531,7 +531,7 @@
|
|||
ExtendsNode = function(_b, _c) {
|
||||
this.parent = _c;
|
||||
this.child = _b;
|
||||
ExtendsNode.__superClass__.constructor.call(this);
|
||||
ExtendsNode.__super__.constructor.call(this);
|
||||
return this;
|
||||
};
|
||||
__extends(ExtendsNode, BaseNode);
|
||||
|
@ -547,7 +547,7 @@
|
|||
exports.AccessorNode = (function() {
|
||||
AccessorNode = function(_b, tag) {
|
||||
this.name = _b;
|
||||
AccessorNode.__superClass__.constructor.call(this);
|
||||
AccessorNode.__super__.constructor.call(this);
|
||||
this.prototype = tag === 'prototype' ? '.prototype' : '';
|
||||
this.soakNode = tag === 'soak';
|
||||
return this;
|
||||
|
@ -567,7 +567,7 @@
|
|||
exports.IndexNode = (function() {
|
||||
IndexNode = function(_b) {
|
||||
this.index = _b;
|
||||
IndexNode.__superClass__.constructor.call(this);
|
||||
IndexNode.__super__.constructor.call(this);
|
||||
return this;
|
||||
};
|
||||
__extends(IndexNode, BaseNode);
|
||||
|
@ -586,7 +586,7 @@
|
|||
RangeNode = function(_b, _c, exclusive) {
|
||||
this.to = _c;
|
||||
this.from = _b;
|
||||
RangeNode.__superClass__.constructor.call(this);
|
||||
RangeNode.__super__.constructor.call(this);
|
||||
this.exclusive = !!exclusive;
|
||||
this.equals = this.exclusive ? '' : '=';
|
||||
return this;
|
||||
|
@ -683,7 +683,7 @@
|
|||
exports.SliceNode = (function() {
|
||||
SliceNode = function(_b) {
|
||||
this.range = _b;
|
||||
SliceNode.__superClass__.constructor.call(this);
|
||||
SliceNode.__super__.constructor.call(this);
|
||||
return this;
|
||||
};
|
||||
__extends(SliceNode, BaseNode);
|
||||
|
@ -703,7 +703,7 @@
|
|||
})();
|
||||
exports.ObjectNode = (function() {
|
||||
ObjectNode = function(props) {
|
||||
ObjectNode.__superClass__.constructor.call(this);
|
||||
ObjectNode.__super__.constructor.call(this);
|
||||
this.objects = (this.properties = props || []);
|
||||
return this;
|
||||
};
|
||||
|
@ -758,7 +758,7 @@
|
|||
exports.ArrayNode = (function() {
|
||||
ArrayNode = function(_b) {
|
||||
this.objects = _b;
|
||||
ArrayNode.__superClass__.constructor.call(this);
|
||||
ArrayNode.__super__.constructor.call(this);
|
||||
this.objects || (this.objects = []);
|
||||
this.compileSplatLiteral = function(o) {
|
||||
return SplatNode.compileSplattedArray.call(this, this.objects, o);
|
||||
|
@ -796,7 +796,7 @@
|
|||
this.properties = _d;
|
||||
this.parent = _c;
|
||||
this.variable = _b;
|
||||
ClassNode.__superClass__.constructor.call(this);
|
||||
ClassNode.__super__.constructor.call(this);
|
||||
this.properties || (this.properties = []);
|
||||
this.returns = false;
|
||||
return this;
|
||||
|
@ -884,7 +884,7 @@
|
|||
this.context = _d;
|
||||
this.value = _c;
|
||||
this.variable = _b;
|
||||
AssignNode.__superClass__.constructor.call(this);
|
||||
AssignNode.__super__.constructor.call(this);
|
||||
return this;
|
||||
};
|
||||
__extends(AssignNode, BaseNode);
|
||||
|
@ -902,7 +902,7 @@
|
|||
if (this.isStatement()) {
|
||||
return new Expressions([this, new ReturnNode(this.variable)]);
|
||||
} else {
|
||||
return AssignNode.__superClass__.makeReturn.call(this);
|
||||
return AssignNode.__super__.makeReturn.call(this);
|
||||
}
|
||||
};
|
||||
AssignNode.prototype.isStatement = function() {
|
||||
|
@ -1002,7 +1002,7 @@
|
|||
CodeNode = function(_b, _c, tag) {
|
||||
this.body = _c;
|
||||
this.params = _b;
|
||||
CodeNode.__superClass__.constructor.call(this);
|
||||
CodeNode.__super__.constructor.call(this);
|
||||
this.params || (this.params = []);
|
||||
this.body || (this.body = new Expressions());
|
||||
this.bound = tag === 'boundfunc';
|
||||
|
@ -1083,7 +1083,7 @@
|
|||
};
|
||||
CodeNode.prototype.traverseChildren = function(crossScope, func) {
|
||||
if (crossScope) {
|
||||
return CodeNode.__superClass__.traverseChildren.call(this, crossScope, func);
|
||||
return CodeNode.__super__.traverseChildren.call(this, crossScope, func);
|
||||
}
|
||||
};
|
||||
CodeNode.prototype.toString = function(idt) {
|
||||
|
@ -1106,7 +1106,7 @@
|
|||
this.splat = _d;
|
||||
this.attach = _c;
|
||||
this.name = _b;
|
||||
ParamNode.__superClass__.constructor.call(this);
|
||||
ParamNode.__super__.constructor.call(this);
|
||||
this.value = literal(this.name);
|
||||
return this;
|
||||
};
|
||||
|
@ -1123,7 +1123,7 @@
|
|||
})();
|
||||
exports.SplatNode = (function() {
|
||||
SplatNode = function(name) {
|
||||
SplatNode.__superClass__.constructor.call(this);
|
||||
SplatNode.__super__.constructor.call(this);
|
||||
if (!(name.compile)) {
|
||||
name = literal(name);
|
||||
}
|
||||
|
@ -1194,7 +1194,7 @@
|
|||
}).call(this);
|
||||
exports.WhileNode = (function() {
|
||||
WhileNode = function(condition, opts) {
|
||||
WhileNode.__superClass__.constructor.call(this);
|
||||
WhileNode.__super__.constructor.call(this);
|
||||
if (opts && opts.invert) {
|
||||
if (condition instanceof OpNode) {
|
||||
condition = new ParentheticalNode(condition);
|
||||
|
@ -1257,7 +1257,7 @@
|
|||
this.second = _d;
|
||||
this.first = _c;
|
||||
this.operator = _b;
|
||||
OpNode.__superClass__.constructor.call(this);
|
||||
OpNode.__super__.constructor.call(this);
|
||||
this.operator = this.CONVERSIONS[this.operator] || this.operator;
|
||||
this.flip = !!flip;
|
||||
if (this.first instanceof ValueNode && this.first.base instanceof ObjectNode) {
|
||||
|
@ -1301,7 +1301,7 @@
|
|||
return (this.operator = this.INVERSIONS[this.operator]);
|
||||
};
|
||||
OpNode.prototype.toString = function(idt) {
|
||||
return OpNode.__superClass__.toString.call(this, idt, this["class"] + ' ' + this.operator);
|
||||
return OpNode.__super__.toString.call(this, idt, this["class"] + ' ' + this.operator);
|
||||
};
|
||||
OpNode.prototype.compileNode = function(o) {
|
||||
if (this.isChainable() && this.first.unwrap() instanceof OpNode && this.first.unwrap().isChainable()) {
|
||||
|
@ -1380,7 +1380,7 @@
|
|||
InNode = function(_b, _c) {
|
||||
this.array = _c;
|
||||
this.object = _b;
|
||||
InNode.__superClass__.constructor.call(this);
|
||||
InNode.__super__.constructor.call(this);
|
||||
return this;
|
||||
};
|
||||
__extends(InNode, BaseNode);
|
||||
|
@ -1431,7 +1431,7 @@
|
|||
this.recovery = _d;
|
||||
this.error = _c;
|
||||
this.attempt = _b;
|
||||
TryNode.__superClass__.constructor.call(this);
|
||||
TryNode.__super__.constructor.call(this);
|
||||
return this;
|
||||
};
|
||||
__extends(TryNode, BaseNode);
|
||||
|
@ -1464,7 +1464,7 @@
|
|||
exports.ThrowNode = (function() {
|
||||
ThrowNode = function(_b) {
|
||||
this.expression = _b;
|
||||
ThrowNode.__superClass__.constructor.call(this);
|
||||
ThrowNode.__super__.constructor.call(this);
|
||||
return this;
|
||||
};
|
||||
__extends(ThrowNode, BaseNode);
|
||||
|
@ -1484,7 +1484,7 @@
|
|||
exports.ExistenceNode = (function() {
|
||||
ExistenceNode = function(_b) {
|
||||
this.expression = _b;
|
||||
ExistenceNode.__superClass__.constructor.call(this);
|
||||
ExistenceNode.__super__.constructor.call(this);
|
||||
return this;
|
||||
};
|
||||
__extends(ExistenceNode, BaseNode);
|
||||
|
@ -1509,7 +1509,7 @@
|
|||
exports.ParentheticalNode = (function() {
|
||||
ParentheticalNode = function(_b) {
|
||||
this.expression = _b;
|
||||
ParentheticalNode.__superClass__.constructor.call(this);
|
||||
ParentheticalNode.__super__.constructor.call(this);
|
||||
return this;
|
||||
};
|
||||
__extends(ParentheticalNode, BaseNode);
|
||||
|
@ -1545,7 +1545,7 @@
|
|||
this.index = _d;
|
||||
this.name = _c;
|
||||
this.body = _b;
|
||||
ForNode.__superClass__.constructor.call(this);
|
||||
ForNode.__super__.constructor.call(this);
|
||||
this.index || (this.index = null);
|
||||
this.source = source.source;
|
||||
this.guard = source.guard;
|
||||
|
@ -1860,7 +1860,7 @@
|
|||
}
|
||||
});
|
||||
UTILITIES = {
|
||||
"extends": "function(child, parent) {\n var ctor = function(){};\n ctor.prototype = parent.prototype;\n child.prototype = new ctor();\n child.prototype.constructor = child;\n if (typeof parent.extended === \"function\") parent.extended(child);\n child.__superClass__ = parent.prototype;\n }",
|
||||
"extends": "function(child, parent) {\n var ctor = function(){};\n ctor.prototype = parent.prototype;\n child.prototype = new ctor();\n child.prototype.constructor = child;\n if (typeof parent.extended === \"function\") parent.extended(child);\n child.__super__ = parent.prototype;\n }",
|
||||
bind: "function(func, context) {\n return function(){ return func.apply(context, arguments); };\n }",
|
||||
hasProp: 'Object.prototype.hasOwnProperty',
|
||||
slice: 'Array.prototype.slice'
|
||||
|
|
|
@ -431,9 +431,9 @@ exports.CallNode = class CallNode extends BaseNode
|
|||
superReference: (o) ->
|
||||
methname = o.scope.method.name
|
||||
meth = if o.scope.method.proto
|
||||
"#{o.scope.method.proto}.__superClass__.#{methname}"
|
||||
"#{o.scope.method.proto}.__super__.#{methname}"
|
||||
else if methname
|
||||
"#{methname}.__superClass__.constructor"
|
||||
"#{methname}.__super__.constructor"
|
||||
else throw new Error "cannot call super on an anonymous function."
|
||||
|
||||
# Compile a vanilla function call.
|
||||
|
@ -1571,7 +1571,7 @@ UTILITIES =
|
|||
child.prototype = new ctor();
|
||||
child.prototype.constructor = child;
|
||||
if (typeof parent.extended === "function") parent.extended(child);
|
||||
child.__superClass__ = parent.prototype;
|
||||
child.__super__ = parent.prototype;
|
||||
}
|
||||
"""
|
||||
|
||||
|
|
|
@ -207,13 +207,13 @@ class Element extends Base
|
|||
@node = node
|
||||
|
||||
ok Element.extended is Base.extended
|
||||
ok Element.__superClass__ is Base.prototype
|
||||
ok Element.__super__ is Base.prototype
|
||||
|
||||
class MyElement extends Element
|
||||
|
||||
ok MyElement.extended is Base.extended
|
||||
ok MyElement.fromHTML is Element.fromHTML
|
||||
ok MyElement.__superClass__ is Element.prototype
|
||||
ok MyElement.__super__ is Element.prototype
|
||||
|
||||
|
||||
# Test classes wrapped in decorators.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue