removed extra parens from in/return compilations

This commit is contained in:
satyr
2010-10-21 07:19:08 +09:00
parent 78835073db
commit 53fbfc7d15
8 changed files with 45 additions and 47 deletions

View File

@@ -263,7 +263,7 @@
};
Literal.prototype.isStatement = function() {
var _ref2;
return ((_ref2 = this.value) === 'break' || _ref2 === 'continue' || _ref2 === 'debugger');
return (_ref2 = this.value) === 'break' || _ref2 === 'continue' || _ref2 === 'debugger';
};
Literal.prototype.isPureStatement = Literal.prototype.isStatement;
Literal.prototype.isComplex = NO;
@@ -314,7 +314,7 @@
if (this.expression.isStatement(o)) {
o.asStatement = true;
}
expr = ' ' + this.expression.compile(o);
expr = ' ' + this.expression.compileBare(o);
}
return "" + (this.tab) + "return" + expr + ";";
};
@@ -576,7 +576,7 @@
var base, fun, idt, name, ref, splatargs;
splatargs = this.compileSplatArguments(o);
if (this.isSuper) {
return ("" + (this.superReference(o)) + ".apply(this, " + splatargs + ")");
return "" + (this.superReference(o)) + ".apply(this, " + splatargs + ")";
}
if (!this.isNew) {
base = Value.wrap(this.variable);
@@ -589,7 +589,7 @@
fun += name.compile(o);
}
}
return ("" + fun + ".apply(" + ref + ", " + splatargs + ")");
return "" + fun + ".apply(" + ref + ", " + splatargs + ")";
}
idt = this.idt(1);
return "(function(func, args, ctor) {\n" + idt + "ctor.prototype = func.prototype;\n" + idt + "var child = new ctor, result = func.apply(child, args);\n" + idt + "return typeof result === \"object\" ? result : child;\n" + (this.tab) + "})(" + (this.variable.compile(o)) + ", " + splatargs + ", function() {})";
@@ -722,7 +722,7 @@
if (this.exclusive) {
range.pop();
}
return ("[" + (range.join(', ')) + "]");
return "[" + (range.join(', ')) + "]";
}
idt = this.idt(1);
i = o.scope.freeVariable('i');
@@ -1006,14 +1006,14 @@
}
val = this.value.compileBare(o);
if (this.context === 'object') {
return ("" + name + ": " + val);
return "" + name + ": " + val;
}
if (!(isValue && (this.variable.hasProperties() || this.variable.namespaced))) {
o.scope.find(name);
}
val = name + (" " + (this.context || '=') + " ") + val;
if (stmt) {
return ("" + (this.tab) + val + ";");
return "" + (this.tab) + val + ";";
}
return top || this.parenthetical ? val : "(" + val + ")";
};
@@ -1181,7 +1181,7 @@
func = "" + open + (params.join(', ')) + ") {" + code + close;
o.scope.endLevel();
if (this.bound) {
return ("" + (utility('bind')) + "(" + func + ", " + (this.context) + ")");
return "" + (utility('bind')) + "(" + func + ", " + (this.context) + ")";
}
return this.tags.front ? "(" + func + ")" : func;
};
@@ -1386,7 +1386,7 @@
};
Op.prototype.isChainable = function() {
var _ref2;
return (_ref2 = this.operator, __indexOf.call(this.CHAINABLE, _ref2) >= 0);
return _ref2 = this.operator, __indexOf.call(this.CHAINABLE, _ref2) >= 0;
};
Op.prototype.invert = function() {
var op;
@@ -1452,37 +1452,35 @@
})();
__extends(In, Base);
In.prototype.children = ['object', 'array'];
In.prototype.isArray = function() {
return this.array instanceof Value && this.array.isArray();
};
In.prototype.compileNode = function(o) {
return this.isArray() ? this.compileOrTest(o) : this.compileLoopTest(o);
var code;
code = this.array instanceof Value && this.array.isArray() ? this.compileOrTest(o) : this.compileLoopTest(o);
return this.parenthetical ? code : "(" + code + ")";
};
In.prototype.compileOrTest = function(o) {
var _len, _ref2, _ref3, _result, i, item, obj1, obj2, tests;
var _len, _ref2, _ref3, _result, i, item, ref, sub, tests;
_ref2 = this.object.compileReference(o, {
precompile: true
}), obj1 = _ref2[0], obj2 = _ref2[1];
}), sub = _ref2[0], ref = _ref2[1];
tests = (function() {
_result = [];
for (i = 0, _len = (_ref3 = this.array.base.objects).length; i < _len; i++) {
item = _ref3[i];
_result.push("" + (i ? obj2 : obj1) + " === " + (item.compile(o)));
_result.push("" + (i ? ref : sub) + " === " + (item.compile(o)));
}
return _result;
}).call(this);
return "(" + (tests.join(' || ')) + ")";
return tests.join(' || ');
};
In.prototype.compileLoopTest = function(o) {
var _ref2, code, obj1, obj2, prefix;
var _ref2, code, ref, sub;
_ref2 = this.object.compileReference(merge(o, {
top: true
}), {
precompile: true
}), obj1 = _ref2[0], obj2 = _ref2[1];
prefix = obj1 !== obj2 ? "" + obj1 + ", " : '';
code = "" + prefix + (utility('indexOf')) + ".call(" + (this.array.compile(o)) + ", " + obj2 + ") >= 0";
return this.parenthetical ? code : "(" + code + ")";
}), sub = _ref2[0], ref = _ref2[1];
code = utility('indexOf') + (".call(" + (this.array.compile(o)) + ", " + ref + ") >= 0");
return sub === ref ? code : sub + ', ' + code;
};
return In;
})();