conditionals with no alternative now evaluate to 'undefined' instead of 'null'

This commit is contained in:
Jeremy Ashkenas
2010-10-01 20:52:23 -04:00
parent 4fd878447e
commit 26de26f88f
10 changed files with 32 additions and 31 deletions

View File

@@ -55,7 +55,7 @@
return [compiled, reference];
}
}).call(this);
if (((options != null) ? options.precompile : null)) {
if (((options != null) ? options.precompile : undefined)) {
for (i = 0, _len = pair.length; i < _len; i++) {
node = pair[i];
(pair[i] = node.compile(o));
@@ -146,7 +146,7 @@
if (func(child) === false) {
return false;
}
return child instanceof BaseNode && (crossScope || !(child instanceof CodeNode)) ? child.traverseChildren(crossScope, func) : null;
return child instanceof BaseNode && (crossScope || !(child instanceof CodeNode)) ? child.traverseChildren(crossScope, func) : undefined;
});
};
BaseNode.prototype["class"] = 'BaseNode';
@@ -344,7 +344,7 @@
ValueNode.prototype.cacheReference = function(o) {
var base, bref, name, nref;
name = last(this.properties);
if (!this.base.isComplex() && this.properties.length < 2 && !((name != null) ? name.isComplex() : null)) {
if (!this.base.isComplex() && this.properties.length < 2 && !((name != null) ? name.isComplex() : undefined)) {
return [this, this];
}
base = new ValueNode(this.base, this.properties.slice(0, -1));
@@ -1132,7 +1132,7 @@
};
CodeNode.prototype.topSensitive = YES;
CodeNode.prototype.traverseChildren = function(crossScope, func) {
return crossScope ? CodeNode.__super__.traverseChildren.call(this, crossScope, func) : null;
return crossScope ? CodeNode.__super__.traverseChildren.call(this, crossScope, func) : undefined;
};
return CodeNode;
})();
@@ -1189,7 +1189,7 @@
o.scope.assign(len, "arguments.length");
variadic = o.scope.freeVariable('result');
o.scope.assign(variadic, len + ' >= ' + this.arglength);
end = this.trailings.length ? (", " + (len) + " - " + (this.trailings.length)) : null;
end = this.trailings.length ? (", " + (len) + " - " + (this.trailings.length)) : undefined;
_ref2 = this.trailings;
for (idx = 0, _len = _ref2.length; idx < _len; idx++) {
trailing = _ref2[idx];
@@ -1237,14 +1237,14 @@
exports.WhileNode = (function() {
WhileNode = function(condition, opts) {
WhileNode.__super__.constructor.call(this);
if (((opts != null) ? opts.invert : null)) {
if (((opts != null) ? opts.invert : undefined)) {
if (condition instanceof OpNode) {
condition = new ParentheticalNode(condition);
}
condition = new OpNode('!', condition);
}
this.condition = condition;
this.guard = ((opts != null) ? opts.guard : null);
this.guard = ((opts != null) ? opts.guard : undefined);
return this;
};
__extends(WhileNode, BaseNode);
@@ -1774,11 +1774,11 @@
IfNode.prototype.topSensitive = YES;
IfNode.prototype.bodyNode = function() {
var _ref2;
return (((_ref2 = this.body) != null) ? _ref2.unwrap() : null);
return (((_ref2 = this.body) != null) ? _ref2.unwrap() : undefined);
};
IfNode.prototype.elseBodyNode = function() {
var _ref2;
return (((_ref2 = this.elseBody) != null) ? _ref2.unwrap() : null);
return (((_ref2 = this.elseBody) != null) ? _ref2.unwrap() : undefined);
};
IfNode.prototype.addElse = function(elseBody, statement) {
if (this.isChain) {
@@ -1849,7 +1849,7 @@
this.elseBodyNode().tags.operation = true;
}
ifPart = this.condition.compile(o) + ' ? ' + this.bodyNode().compile(o);
elsePart = this.elseBody ? this.elseBodyNode().compile(o) : 'null';
elsePart = this.elseBody ? this.elseBodyNode().compile(o) : 'undefined';
code = ("" + (ifPart) + " : " + (elsePart));
return this.tags.operation ? ("(" + (code) + ")") : code;
};