Skip to content

Instantly share code, notes, and snippets.

@StanAngeloff
Created July 12, 2010 15:54
Show Gist options
  • Save StanAngeloff/472634 to your computer and use it in GitHub Desktop.
Save StanAngeloff/472634 to your computer and use it in GitHub Desktop.
diff --git a/src/nodes.coffee b/src/nodes.coffee
index 275d9b3..06f2ea8 100644
--- a/src/nodes.coffee
+++ b/src/nodes.coffee
@@ -447,7 +447,11 @@ exports.CallNode: class CallNode extends BaseNode
temp: o.scope.freeVariable()
obj: temp
meth: "($temp = ${ @variable.source })${ @variable.last }"
- "${@prefix()}${meth}.apply($obj, ${ @compileSplatArguments(o) })"
+ if @isNew
+ utility 'extends'
+ "(function() {\n${@idt(1)}var ctor = function(){ };\n${@idt(1)}__extends(ctor, $meth);\n${@idt(1)}return ${meth}.apply(new ctor, ${ @compileSplatArguments(o) });\n${@idt()}}).call(this)"
+ else
+ "${@prefix()}${meth}.apply($obj, ${ @compileSplatArguments(o) })"
#### ExtendsNode
$ git checkout lib/ && bin/cake build && bin/coffee -ep '@connection: new Connection(args...)'
(function(){
var __extends = function(child, parent) {
var ctor = function(){ };
ctor.prototype = parent.prototype;
child.__superClass__ = parent.prototype;
child.prototype = new ctor();
child.prototype.constructor = child;
};
this.connection = (function() {
var ctor = function(){ };
__extends(ctor, Connection);
return Connection.apply(new ctor, args);
}).call(this);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment