removed extra parens from soak compilations

This commit is contained in:
satyr
2010-10-21 04:51:11 +09:00
parent c1dc74fc8b
commit c11ca94870
5 changed files with 44 additions and 41 deletions

View File

@@ -56,7 +56,7 @@
return [compiled, reference];
}
}).call(this);
if (((options != null) ? options.precompile : undefined)) {
if ((options != null) ? options.precompile : undefined) {
for (i = 0, _len = pair.length; i < _len; i++) {
node = pair[i];
(pair[i] = node.compile(o));
@@ -301,7 +301,7 @@
Return.prototype.makeReturn = THIS;
Return.prototype.compile = function(o) {
var _ref2, expr;
expr = (((_ref2 = this.expression) != null) ? _ref2.makeReturn() : undefined);
expr = ((_ref2 = this.expression) != null) ? _ref2.makeReturn() : undefined;
if (expr && !(expr instanceof Return)) {
return expr.compile(o);
}
@@ -430,16 +430,19 @@
fst = new Parens(new Assign(ref, fst));
snd.base = ref;
}
ifn = new If(new Existence(fst), snd, {
soak: true
return new If(new Existence(fst), snd, {
soak: true,
operation: this.tags.operation
});
return ifn;
}
}
return null;
};
Value.wrap = function(node) {
return node instanceof Value ? node : new Value(node);
};
return Value;
})();
}).call(this);
exports.Comment = (function() {
Comment = (function() {
function Comment(_arg) {
@@ -496,13 +499,13 @@
return method.klass ? "" + (method.klass) + ".__super__." + name : "" + name + ".__super__.constructor";
};
Call.prototype.unfoldSoak = function(o) {
var _i, _len, _ref2, _ref3, call, ifn, left, list, rite, val;
var _i, _len, _ref2, _ref3, call, ifn, left, list, rite;
if (this.soakNode) {
if (val = this.variable) {
if (!(val instanceof Value)) {
val = new Value(val);
if (this.variable) {
if (ifn = If.unfoldSoak(o, this, 'variable')) {
return ifn;
}
_ref2 = val.cacheReference(o), left = _ref2[0], rite = _ref2[1];
_ref2 = Value.wrap(this.variable).cacheReference(o), left = _ref2[0], rite = _ref2[1];
} else {
left = new Literal(this.superReference(o));
rite = new Value(left);
@@ -510,10 +513,10 @@
rite = new Call(rite, this.args);
rite.isNew = this.isNew;
left = new Literal("typeof " + (left.compile(o)) + " === \"function\"");
ifn = new If(left, new Value(rite), {
soak: true
return new If(left, new Value(rite), {
soak: true,
operation: this.tags.operation
});
return ifn;
}
call = this;
list = [];
@@ -549,7 +552,7 @@
if (ifn = this.unfoldSoak(o)) {
return ifn.compile(o);
}
(((_ref2 = this.variable) != null) ? _ref2.tags.front = this.tags.front : undefined);
((_ref2 = this.variable) != null) ? _ref2.tags.front = this.tags.front : undefined;
for (_i = 0, _len = (_ref3 = this.args).length; _i < _len; _i++) {
arg = _ref3[_i];
if (arg instanceof Splat) {
@@ -576,9 +579,7 @@
return ("" + (this.superReference(o)) + ".apply(this, " + splatargs + ")");
}
if (!this.isNew) {
if (!((base = this.variable) instanceof Value)) {
base = new Value(base);
}
base = Value.wrap(this.variable);
if ((name = base.properties.pop()) && base.isComplex()) {
ref = o.scope.freeVariable('this');
fun = "(" + ref + " = " + (base.compile(o)) + ")" + (name.compile(o));
@@ -1032,11 +1033,8 @@
} else {
idx = isObject ? obj.tags["this"] ? obj.properties[0].name : obj : new Literal(0);
}
if (!(value instanceof Value)) {
value = new Value(value);
}
accessClass = IDENTIFIER.test(idx.value) ? Accessor : Index;
value.properties.push(new accessClass(idx));
(value = Value.wrap(value)).properties.push(new accessClass(idx));
return new Assign(obj, value).compile(o);
}
top = del(o, 'top');
@@ -1298,7 +1296,7 @@
function While(condition, opts) {
While.__super__.constructor.call(this);
this.condition = ((opts != null) ? opts.invert : undefined) ? condition.invert() : condition;
this.guard = ((opts != null) ? opts.guard : undefined);
this.guard = (opts != null) ? opts.guard : undefined;
return this;
};
return While;
@@ -1826,11 +1824,11 @@
If.prototype.topSensitive = YES;
If.prototype.bodyNode = function() {
var _ref2;
return (((_ref2 = this.body) != null) ? _ref2.unwrap() : undefined);
return ((_ref2 = this.body) != null) ? _ref2.unwrap() : undefined;
};
If.prototype.elseBodyNode = function() {
var _ref2;
return (((_ref2 = this.elseBody) != null) ? _ref2.unwrap() : undefined);
return ((_ref2 = this.elseBody) != null) ? _ref2.unwrap() : undefined;
};
If.prototype.addElse = function(elseBody) {
if (this.isChain) {
@@ -1881,8 +1879,9 @@
};
If.prototype.compileExpression = function(o) {
var _ref2, code;
this.condition.tags.operation = true;
code = this.condition.compile(o) + ' ? ' + this.bodyNode().compileBare(o) + ' : ' + (((_ref2 = this.elseBodyNode()) != null) ? _ref2.compileBare(o) : undefined);
return this.tags.operation || this.soakNode ? "(" + code + ")" : code;
return this.tags.operation ? "(" + code + ")" : code;
};
If.prototype.unfoldSoak = function() {
return this.soakNode && this;
@@ -1894,6 +1893,9 @@
}
parent[name] = ifn.body;
ifn.body = new Value(parent);
if (parent.tags.operation) {
ifn.tags.operation = true;
}
return ifn;
};
return If;