mirror of
https://github.com/jashkenas/coffeescript.git
synced 2022-11-09 12:23:24 -05:00
using @containsType.
This commit is contained in:
parent
3a20d7dacb
commit
ea3aa6803a
2 changed files with 20 additions and 28 deletions
44
lib/nodes.js
44
lib/nodes.js
|
@ -50,9 +50,7 @@
|
|||
var compiled, pair, reference;
|
||||
options || (options = {});
|
||||
pair = (function() {
|
||||
if (!((this instanceof CallNode || this.contains(function(n) {
|
||||
return n instanceof CallNode;
|
||||
})) || (this instanceof ValueNode && (!(this.base instanceof LiteralNode) || this.hasProperties())))) {
|
||||
if (!(this.containsType(CallNode) || (this instanceof ValueNode && (!(this.base instanceof LiteralNode) || this.hasProperties())))) {
|
||||
return [this, this];
|
||||
} else if (this instanceof ValueNode && options.assignment) {
|
||||
return this.cacheIndexes(o);
|
||||
|
@ -387,7 +385,7 @@
|
|||
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;
|
||||
var _b, _c, baseline, complete, i, only, op, part, prop, props, temp;
|
||||
only = del(o, 'onlyFirst');
|
||||
op = this.tags.operation;
|
||||
props = only ? this.properties.slice(0, this.properties.length - 1) : this.properties;
|
||||
|
@ -400,29 +398,23 @@
|
|||
baseline = ("(" + (baseline) + ")");
|
||||
}
|
||||
complete = (this.last = baseline);
|
||||
_c = props;
|
||||
for (_b = 0, _d = _c.length; _b < _d; _b++) {
|
||||
(function() {
|
||||
var part, temp;
|
||||
var i = _b;
|
||||
var prop = _c[_b];
|
||||
this.source = baseline;
|
||||
if (prop.soakNode) {
|
||||
if (this.base instanceof CallNode || this.base.contains(function(n) {
|
||||
return n instanceof CallNode;
|
||||
}) && i === 0) {
|
||||
temp = o.scope.freeVariable();
|
||||
complete = ("(" + (baseline = temp) + " = (" + (complete) + "))");
|
||||
}
|
||||
complete = i === 0 ? ("(typeof " + (complete) + " === \"undefined\" || " + (baseline) + " === null) ? undefined : ") : ("" + (complete) + " == null ? undefined : ");
|
||||
return complete += (baseline += prop.compile(o));
|
||||
} else {
|
||||
part = prop.compile(o);
|
||||
baseline += part;
|
||||
complete += part;
|
||||
return (this.last = part);
|
||||
_b = props;
|
||||
for (i = 0, _c = _b.length; i < _c; i++) {
|
||||
prop = _b[i];
|
||||
this.source = baseline;
|
||||
if (prop.soakNode) {
|
||||
if (this.base.containsType(CallNode) && i === 0) {
|
||||
temp = o.scope.freeVariable();
|
||||
complete = ("(" + (baseline = temp) + " = (" + (complete) + "))");
|
||||
}
|
||||
}).call(this);
|
||||
complete = i === 0 ? ("(typeof " + (complete) + " === \"undefined\" || " + (baseline) + " === null) ? undefined : ") : ("" + (complete) + " == null ? undefined : ");
|
||||
complete += (baseline += prop.compile(o));
|
||||
} else {
|
||||
part = prop.compile(o);
|
||||
baseline += part;
|
||||
complete += part;
|
||||
this.last = part;
|
||||
}
|
||||
}
|
||||
return op && this.wrapped ? ("(" + (complete) + ")") : complete;
|
||||
};
|
||||
|
|
|
@ -64,7 +64,7 @@ exports.BaseNode = class BaseNode
|
|||
# by assigning it to a temporary variable.
|
||||
compileReference: (o, options) ->
|
||||
options or= {}
|
||||
pair = if not ((this instanceof CallNode or @contains((n) -> n instanceof CallNode)) or
|
||||
pair = if not (@containsType(CallNode) or
|
||||
(this instanceof ValueNode and (not (@base instanceof LiteralNode) or @hasProperties())))
|
||||
[this, this]
|
||||
else if this instanceof ValueNode and options.assignment
|
||||
|
@ -369,7 +369,7 @@ exports.ValueNode = class ValueNode extends BaseNode
|
|||
for prop, i in props
|
||||
@source = baseline
|
||||
if prop.soakNode
|
||||
if @base instanceof CallNode or @base.contains((n) -> n instanceof CallNode) and i is 0
|
||||
if @base.containsType(CallNode) and i is 0
|
||||
temp = o.scope.freeVariable()
|
||||
complete = "(#{ baseline = temp } = (#{complete}))"
|
||||
complete = if i is 0
|
||||
|
|
Loading…
Reference in a new issue