mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-02-17 19:11:22 -05:00
fixing the extends keyword when the expressions are complex, and should only be run once -- not that it's good style -- ticket #143
This commit is contained in:
@@ -480,11 +480,22 @@
|
||||
},
|
||||
// Hooking one constructor into another's prototype chain.
|
||||
compile_node: function compile_node(o) {
|
||||
var child, construct, parent;
|
||||
var child, child_var, construct, parent, parent_var, prefix;
|
||||
construct = o.scope.free_variable();
|
||||
child = this.child.compile(o);
|
||||
parent = this.parent.compile(o);
|
||||
return this.idt() + construct + ' = function(){};\n' + this.idt() + construct + '.prototype = ' + parent + ".prototype;\n" + this.idt() + child + '.__superClass__ = ' + parent + ".prototype;\n" + this.idt() + child + '.prototype = new ' + construct + "();\n" + this.idt() + child + '.prototype.constructor = ' + child + ';';
|
||||
prefix = '';
|
||||
if (!(this.child instanceof ValueNode) || this.child.has_properties() || !(this.child.unwrap() instanceof LiteralNode)) {
|
||||
child_var = o.scope.free_variable();
|
||||
prefix += this.idt() + child_var + ' = ' + child + ';\n';
|
||||
child = child_var;
|
||||
}
|
||||
if (!(this.parent instanceof ValueNode) || this.parent.has_properties() || !(this.parent.unwrap() instanceof LiteralNode)) {
|
||||
parent_var = o.scope.free_variable();
|
||||
prefix += this.idt() + parent_var + ' = ' + parent + ';\n';
|
||||
parent = parent_var;
|
||||
}
|
||||
return prefix + this.idt() + construct + ' = function(){};\n' + this.idt() + construct + '.prototype = ' + parent + ".prototype;\n" + this.idt() + child + '.__superClass__ = ' + parent + ".prototype;\n" + this.idt() + child + '.prototype = new ' + construct + "();\n" + this.idt() + child + '.prototype.constructor = ' + child + ';';
|
||||
}
|
||||
}));
|
||||
statement(ExtendsNode);
|
||||
|
||||
Reference in New Issue
Block a user