mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-02-18 11:31:20 -05:00
fixed misdentation in a?.b = c
This commit is contained in:
46
lib/nodes.js
46
lib/nodes.js
@@ -974,7 +974,7 @@
|
||||
return this.variable instanceof Value;
|
||||
};
|
||||
Assign.prototype.compileNode = function(o) {
|
||||
var isValue, match, name, node, stmt, top, val;
|
||||
var ifn, isValue, match, name, stmt, top, val;
|
||||
if (isValue = this.isValue()) {
|
||||
if (this.variable.isArray() || this.variable.isObject()) {
|
||||
return this.compilePatternMatch(o);
|
||||
@@ -982,8 +982,9 @@
|
||||
if (this.variable.isSplice()) {
|
||||
return this.compileSplice(o);
|
||||
}
|
||||
if (node = Value.unfoldSoak(o, this, 'variable')) {
|
||||
return node.compile(o);
|
||||
if (ifn = Value.unfoldSoak(o, this, 'variable')) {
|
||||
delete o.top;
|
||||
return ifn.compile(o);
|
||||
}
|
||||
}
|
||||
top = del(o, 'top');
|
||||
@@ -1792,9 +1793,9 @@
|
||||
var _ref2;
|
||||
return (((_ref2 = this.elseBody) != null) ? _ref2.unwrap() : undefined);
|
||||
};
|
||||
If.prototype.addElse = function(elseBody, statement) {
|
||||
If.prototype.addElse = function(elseBody) {
|
||||
if (this.isChain) {
|
||||
this.elseBodyNode().addElse(elseBody, statement);
|
||||
this.elseBodyNode().addElse(elseBody);
|
||||
} else {
|
||||
this.isChain = elseBody instanceof If;
|
||||
this.elseBody = this.ensureExpressions(elseBody);
|
||||
@@ -1802,22 +1803,12 @@
|
||||
return this;
|
||||
};
|
||||
If.prototype.isStatement = function(o) {
|
||||
return this.statement || (this.statement = !!((o && o.top) || this.bodyNode().isStatement(o) || (this.elseBody && this.elseBodyNode().isStatement(o))));
|
||||
var _ref2;
|
||||
return this.statement || (this.statement = ((o != null) ? o.top : undefined) || this.bodyNode().isStatement(o) || (((_ref2 = this.elseBodyNode()) != null) ? _ref2.isStatement(o) : undefined));
|
||||
};
|
||||
If.prototype.compileCondition = function(o) {
|
||||
var _i, _len, _result, cond, conditions;
|
||||
conditions = flatten([this.condition]);
|
||||
if (conditions.length === 1) {
|
||||
conditions[0].parenthetical = true;
|
||||
}
|
||||
return (function() {
|
||||
_result = [];
|
||||
for (_i = 0, _len = conditions.length; _i < _len; _i++) {
|
||||
cond = conditions[_i];
|
||||
_result.push(cond.compile(o));
|
||||
}
|
||||
return _result;
|
||||
})().join(' || ');
|
||||
this.condition.parenthetical = true;
|
||||
return this.condition.compile(o);
|
||||
};
|
||||
If.prototype.compileNode = function(o) {
|
||||
return this.isStatement(o) ? this.compileStatement(o) : this.compileExpression(o);
|
||||
@@ -1835,24 +1826,23 @@
|
||||
return node instanceof Expressions ? node : new Expressions([node]);
|
||||
};
|
||||
If.prototype.compileStatement = function(o) {
|
||||
var body, child, comDent, condO, elsePart, ifDent, ifPart, top;
|
||||
var child, condO, ifPart, top;
|
||||
top = del(o, 'top');
|
||||
child = del(o, 'chainChild');
|
||||
condO = merge(o);
|
||||
o.indent = this.idt(1);
|
||||
o.top = true;
|
||||
ifDent = child || (top && !this.isStatement(o)) ? '' : this.idt();
|
||||
comDent = child ? this.idt() : '';
|
||||
body = this.body.compile(o);
|
||||
ifPart = ("" + ifDent + "if (" + (this.compileCondition(condO)) + ") {\n" + body + "\n" + (this.tab) + "}");
|
||||
ifPart = ("if (" + (this.compileCondition(condO)) + ") {\n" + (this.body.compile(o)) + "\n" + (this.tab) + "}");
|
||||
if (!child) {
|
||||
ifPart = this.tab + ifPart;
|
||||
}
|
||||
if (!this.elseBody) {
|
||||
return ifPart;
|
||||
}
|
||||
elsePart = this.isChain ? ' else ' + this.elseBodyNode().compile(merge(o, {
|
||||
indent: this.idt(),
|
||||
return ifPart + (this.isChain ? ' else ' + this.elseBodyNode().compile(merge(o, {
|
||||
indent: this.tab,
|
||||
chainChild: true
|
||||
})) : (" else {\n" + (this.elseBody.compile(o)) + "\n" + (this.tab) + "}");
|
||||
return "" + ifPart + elsePart;
|
||||
})) : (" else {\n" + (this.elseBody.compile(o)) + "\n" + (this.tab) + "}"));
|
||||
};
|
||||
If.prototype.compileExpression = function(o) {
|
||||
var code, elsePart, ifPart;
|
||||
|
||||
Reference in New Issue
Block a user