mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-02-19 03:44:23 -05:00
Actually caching the splatted constructor this time.
This commit is contained in:
@@ -547,7 +547,7 @@
|
|||||||
a = o.scope.freeVariable();
|
a = o.scope.freeVariable();
|
||||||
b = o.scope.freeVariable();
|
b = o.scope.freeVariable();
|
||||||
c = o.scope.freeVariable();
|
c = o.scope.freeVariable();
|
||||||
return "" + (this.first) + "(function() {\n" + (this.idt(1)) + "var ctor = function(){};\n" + (this.idt(1)) + "__extends(ctor, " + (a) + " = " + (meth) + ");\n" + (this.idt(1)) + "return typeof (" + (b) + " = " + (meth) + ".apply(" + (c) + " = new ctor, " + (this.compileSplatArguments(o)) + ")) === \"object\" ? " + (b) + " : " + (c) + ";\n" + (this.tab) + "})." + (mentionsArgs ? 'apply(this, arguments)' : 'call(this)') + (this.last);
|
return "" + (this.first) + "(function() {\n" + (this.idt(1)) + "var ctor = function(){};\n" + (this.idt(1)) + "__extends(ctor, " + (a) + " = " + (meth) + ");\n" + (this.idt(1)) + "return typeof (" + (b) + " = " + (a) + ".apply(" + (c) + " = new ctor, " + (this.compileSplatArguments(o)) + ")) === \"object\" ? " + (b) + " : " + (c) + ";\n" + (this.tab) + "})." + (mentionsArgs ? 'apply(this, arguments)' : 'call(this)') + (this.last);
|
||||||
} else {
|
} else {
|
||||||
return "" + (this.first) + (this.prefix()) + (meth) + ".apply(" + (obj) + ", " + (this.compileSplatArguments(o)) + ")" + (this.last);
|
return "" + (this.first) + (this.prefix()) + (meth) + ".apply(" + (obj) + ", " + (this.compileSplatArguments(o)) + ")" + (this.last);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -486,7 +486,7 @@ exports.CallNode = class CallNode extends BaseNode
|
|||||||
#{@first}(function() {
|
#{@first}(function() {
|
||||||
#{@idt(1)}var ctor = function(){};
|
#{@idt(1)}var ctor = function(){};
|
||||||
#{@idt(1)}__extends(ctor, #{a} = #{meth});
|
#{@idt(1)}__extends(ctor, #{a} = #{meth});
|
||||||
#{@idt(1)}return typeof (#{b} = #{meth}.apply(#{c} = new ctor, #{ @compileSplatArguments(o) })) === "object" ? #{b} : #{c};
|
#{@idt(1)}return typeof (#{b} = #{a}.apply(#{c} = new ctor, #{ @compileSplatArguments(o) })) === "object" ? #{b} : #{c};
|
||||||
#{@tab}}).#{ if mentionsArgs then 'apply(this, arguments)' else 'call(this)'}#{@last}
|
#{@tab}}).#{ if mentionsArgs then 'apply(this, arguments)' else 'call(this)'}#{@last}
|
||||||
"""
|
"""
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -238,3 +238,9 @@ type = new Type args...
|
|||||||
|
|
||||||
ok type and type instanceof Type
|
ok type and type instanceof Type
|
||||||
ok v is args[i] for v, i in type.args
|
ok v is args[i] for v, i in type.args
|
||||||
|
|
||||||
|
|
||||||
|
# Ensure that constructors invoked with splats cache the function.
|
||||||
|
called = 0
|
||||||
|
get = -> if called++ then false else class Type
|
||||||
|
new get() args...
|
||||||
|
|||||||
Reference in New Issue
Block a user