mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-02-18 11:31:20 -05:00
made unless less parenfull
This commit is contained in:
57
lib/nodes.js
57
lib/nodes.js
@@ -43,7 +43,7 @@
|
||||
Base.prototype.compileReference = function(o, options) {
|
||||
var _len, compiled, i, node, pair, reference;
|
||||
pair = (function() {
|
||||
if (!(this.isComplex())) {
|
||||
if (!this.isComplex()) {
|
||||
return [this, this];
|
||||
} else {
|
||||
reference = new Literal(o.scope.freeVariable('ref'));
|
||||
@@ -111,7 +111,7 @@
|
||||
};
|
||||
Base.prototype.eachChild = function(func) {
|
||||
var _i, _j, _len, _len2, _ref2, _ref3, _result, attr, child;
|
||||
if (!(this.children)) {
|
||||
if (!this.children) {
|
||||
return;
|
||||
}
|
||||
_result = [];
|
||||
@@ -362,7 +362,7 @@
|
||||
bref = new Literal(o.scope.freeVariable('base'));
|
||||
base = new Value(new Parens(new Assign(bref, base)));
|
||||
}
|
||||
if (!(name)) {
|
||||
if (!name) {
|
||||
return [base, bref];
|
||||
}
|
||||
if (name.isComplex()) {
|
||||
@@ -428,7 +428,7 @@
|
||||
} else if (node instanceof Value) {
|
||||
ifnode = node.unfoldSoak(o);
|
||||
}
|
||||
if (!(ifnode)) {
|
||||
if (!ifnode) {
|
||||
return;
|
||||
}
|
||||
parent[name] = ifnode.body;
|
||||
@@ -481,11 +481,11 @@
|
||||
Call.prototype.superReference = function(o) {
|
||||
var method, name;
|
||||
method = o.scope.method;
|
||||
if (!(method)) {
|
||||
if (!method) {
|
||||
throw Error("cannot call super outside of a function");
|
||||
}
|
||||
name = method.name;
|
||||
if (!(name)) {
|
||||
if (!name) {
|
||||
throw Error("cannot call super on an anonymous function.");
|
||||
}
|
||||
return method.klass ? ("" + (method.klass) + ".__super__." + name) : ("" + name + ".__super__.constructor");
|
||||
@@ -567,7 +567,7 @@
|
||||
if (this.isSuper) {
|
||||
return ("" + (this.superReference(o)) + ".apply(this, " + splatargs + ")");
|
||||
}
|
||||
if (!(this.isNew)) {
|
||||
if (!this.isNew) {
|
||||
if (!((base = this.variable) instanceof Value)) {
|
||||
base = new Value(base);
|
||||
}
|
||||
@@ -694,7 +694,7 @@
|
||||
Range.prototype.compileNode = function(o) {
|
||||
var compare, idx, incr, intro, step, stepPart, vars;
|
||||
this.compileVariables(o);
|
||||
if (!(o.index)) {
|
||||
if (!o.index) {
|
||||
return this.compileArray(o);
|
||||
}
|
||||
if (this.fromNum && this.toNum) {
|
||||
@@ -1059,7 +1059,7 @@
|
||||
}
|
||||
assigns.push(new Assign(obj, val).compile(otop));
|
||||
}
|
||||
if (!(top)) {
|
||||
if (!top) {
|
||||
assigns.push(valVar);
|
||||
}
|
||||
code = assigns.join(', ');
|
||||
@@ -1141,7 +1141,7 @@
|
||||
}
|
||||
return _result;
|
||||
})();
|
||||
if (!(empty)) {
|
||||
if (!empty) {
|
||||
this.body.makeReturn();
|
||||
}
|
||||
for (_i = 0, _len2 = params.length; _i < _len2; _i++) {
|
||||
@@ -1200,7 +1200,7 @@
|
||||
Splat = (function() {
|
||||
return function Splat(name) {
|
||||
Splat.__super__.constructor.call(this);
|
||||
if (!(name.compile)) {
|
||||
if (!name.compile) {
|
||||
name = new Literal(name);
|
||||
}
|
||||
this.name = name;
|
||||
@@ -1301,7 +1301,7 @@
|
||||
this.condition.parenthetical = true;
|
||||
cond = this.condition.compile(o);
|
||||
set = '';
|
||||
if (!(top)) {
|
||||
if (!top) {
|
||||
rvar = o.scope.freeVariable('result');
|
||||
set = ("" + (this.tab) + rvar + " = [];\n");
|
||||
if (this.body) {
|
||||
@@ -1363,7 +1363,7 @@
|
||||
};
|
||||
Op.prototype.isInvertible = function() {
|
||||
var _ref2;
|
||||
return (('===' === (_ref2 = this.operator) || '!==' === _ref2)) && !(this.first instanceof Op) && !(this.second instanceof Op);
|
||||
return ('===' === (_ref2 = this.operator) || '!==' === _ref2);
|
||||
};
|
||||
Op.prototype.isComplex = function() {
|
||||
return this.operator !== '!' || this.first.isComplex();
|
||||
@@ -1650,7 +1650,7 @@
|
||||
immediate: true
|
||||
});
|
||||
}
|
||||
if (!(topLevel)) {
|
||||
if (!topLevel) {
|
||||
rvar = scope.freeVariable('result');
|
||||
}
|
||||
ivar = range ? name : index;
|
||||
@@ -1672,7 +1672,7 @@
|
||||
immediate: true
|
||||
}))) {
|
||||
sourcePart = ("" + (ref = scope.freeVariable('ref')) + " = " + svar);
|
||||
if (!(this.object)) {
|
||||
if (!this.object) {
|
||||
sourcePart = ("(" + sourcePart + ")");
|
||||
}
|
||||
svar = ref;
|
||||
@@ -1680,7 +1680,7 @@
|
||||
namePart = this.pattern ? new Assign(this.name, new Literal("" + svar + "[" + ivar + "]")).compile(merge(o, {
|
||||
top: true
|
||||
})) : (name ? ("" + name + " = " + svar + "[" + ivar + "]") : undefined);
|
||||
if (!(this.object)) {
|
||||
if (!this.object) {
|
||||
lvar = scope.freeVariable('len');
|
||||
stepPart = this.step ? ("" + ivar + " += " + (this.step.compile(o))) : ("" + ivar + "++");
|
||||
forPart = ("" + ivar + " = 0, " + lvar + " = " + sourcePart + ".length; " + ivar + " < " + lvar + "; " + stepPart);
|
||||
@@ -1688,7 +1688,7 @@
|
||||
}
|
||||
resultPart = rvar ? ("" + (this.tab) + rvar + " = [];\n") : '';
|
||||
returnResult = this.compileReturnValue(rvar, o);
|
||||
if (!(topLevel)) {
|
||||
if (!topLevel) {
|
||||
body = Push.wrap(rvar, body);
|
||||
}
|
||||
if (this.guard) {
|
||||
@@ -1712,7 +1712,7 @@
|
||||
}
|
||||
if (this.object) {
|
||||
forPart = ("" + ivar + " in " + sourcePart);
|
||||
if (!(this.raw)) {
|
||||
if (!this.raw) {
|
||||
guardPart = ("\n" + idt1 + "if (!" + (utility('hasProp')) + ".call(" + svar + ", " + ivar + ")) continue;");
|
||||
}
|
||||
}
|
||||
@@ -1782,18 +1782,23 @@
|
||||
})();
|
||||
exports.If = (function() {
|
||||
If = (function() {
|
||||
return function If(_arg, _arg2, _arg3) {
|
||||
this.tags = _arg3;
|
||||
this.body = _arg2;
|
||||
this.condition = _arg;
|
||||
return function If(condition, _arg, _arg2) {
|
||||
var op;
|
||||
this.tags = _arg2;
|
||||
this.body = _arg;
|
||||
this.tags || (this.tags = {});
|
||||
if (this.tags.invert) {
|
||||
if (this.condition instanceof Op && this.condition.isInvertible()) {
|
||||
this.condition.invert();
|
||||
op = condition instanceof Op;
|
||||
if (op && condition.isInvertible()) {
|
||||
condition.invert();
|
||||
} else {
|
||||
this.condition = new Op('!', new Parens(this.condition));
|
||||
if (op && !condition.isUnary()) {
|
||||
condition = new Parens(condition);
|
||||
}
|
||||
condition = new Op('!', condition);
|
||||
}
|
||||
}
|
||||
this.condition = condition;
|
||||
this.elseBody = null;
|
||||
this.isChain = false;
|
||||
return this;
|
||||
@@ -1863,7 +1868,7 @@
|
||||
comDent = child ? this.idt() : '';
|
||||
body = this.body.compile(o);
|
||||
ifPart = ("" + ifDent + "if (" + (this.compileCondition(condO)) + ") {\n" + body + "\n" + (this.tab) + "}");
|
||||
if (!(this.elseBody)) {
|
||||
if (!this.elseBody) {
|
||||
return ifPart;
|
||||
}
|
||||
elsePart = this.isChain ? ' else ' + this.elseBodyNode().compile(merge(o, {
|
||||
|
||||
Reference in New Issue
Block a user