Merging in Stephank's fix for #692.
This commit is contained in:
parent
72d7fe2f7a
commit
4b2d40d3b5
10
lib/nodes.js
10
lib/nodes.js
|
@ -497,7 +497,7 @@
|
|||
})());
|
||||
};
|
||||
CallNode.prototype.compileNode = function(o) {
|
||||
var _b, _c, _d, _e, _f, _g, _h, _i, _j, arg, args, code, methodAccessor, op;
|
||||
var _b, _c, _d, _e, _f, _g, _h, _i, _j, arg, args, code, first, meth, methodAccessor, op;
|
||||
if (!(o.chainRoot)) {
|
||||
o.chainRoot = this;
|
||||
}
|
||||
|
@ -506,10 +506,10 @@
|
|||
if (this.variable instanceof ValueNode && this.variable.properties[this.variable.properties.length - 1] instanceof AccessorNode) {
|
||||
methodAccessor = this.variable.properties.pop();
|
||||
_b = this.variable.compileReference(o);
|
||||
this.first = _b[0];
|
||||
this.meth = _b[1];
|
||||
this.first = new ValueNode(this.first, [methodAccessor]).compile(o);
|
||||
this.meth = new ValueNode(this.meth, [methodAccessor]).compile(o);
|
||||
first = _b[0];
|
||||
meth = _b[1];
|
||||
this.first = new ValueNode(first, [methodAccessor]).compile(o);
|
||||
this.meth = new ValueNode(meth, [methodAccessor]).compile(o);
|
||||
} else {
|
||||
_c = this.variable.compileReference(o, {
|
||||
precompile: true
|
||||
|
|
|
@ -454,14 +454,15 @@ exports.CallNode = class CallNode extends BaseNode
|
|||
if @exist
|
||||
if @variable instanceof ValueNode and @variable.properties[@variable.properties.length - 1] instanceof AccessorNode
|
||||
methodAccessor = @variable.properties.pop()
|
||||
[@first, @meth] = @variable.compileReference o
|
||||
@first = new ValueNode(@first, [methodAccessor]).compile o
|
||||
@meth = new ValueNode(@meth, [methodAccessor]).compile o
|
||||
[first, meth] = @variable.compileReference o
|
||||
@first = new ValueNode(first, [methodAccessor]).compile o
|
||||
@meth = new ValueNode(meth, [methodAccessor]).compile o
|
||||
else
|
||||
[@first, @meth] = @variable.compileReference o, precompile: yes
|
||||
@first = "(typeof #{@first} === \"function\" ? "
|
||||
@last = " : undefined)"
|
||||
else if @variable then @meth = @variable.compile o
|
||||
else if @variable
|
||||
@meth = @variable.compile o
|
||||
for arg in @args when arg instanceof SplatNode
|
||||
code = @compileSplat(o)
|
||||
if not code
|
||||
|
|
|
@ -126,7 +126,9 @@ ok duration is 0
|
|||
|
||||
# Function soaks.
|
||||
plus1 = (x) -> x + 1
|
||||
count = 0
|
||||
obj = {
|
||||
counter: -> count += 1; this
|
||||
returnThis: -> this
|
||||
}
|
||||
|
||||
|
@ -135,6 +137,8 @@ ok (plus1? 41) is 42
|
|||
ok plus2?(41) is undefined
|
||||
ok (plus2? 41) is undefined
|
||||
ok obj.returnThis?() is obj
|
||||
ok obj.counter().counter().returnThis?() is obj
|
||||
ok count is 2
|
||||
|
||||
maybe_close = (f, arg) -> if typeof f is 'function' then () -> f(arg) else -1
|
||||
|
||||
|
|
Loading…
Reference in New Issue