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

@@ -15,11 +15,11 @@
if (!action) {
_ref = [description, action], action = _ref[0], description = _ref[1];
}
return (tasks[name] = {
return tasks[name] = {
name: name,
description: description,
action: action
});
};
},
option: function(letter, flag, description) {
return switches.push([letter, flag, description]);

View File

@@ -64,7 +64,7 @@
},
setInput: function(tokens) {
this.tokens = tokens;
return (this.pos = 0);
return this.pos = 0;
},
upcomingInput: function() {
return "";

View File

@@ -208,7 +208,7 @@
o.compile || (o.compile = !!o.output);
o.run = !(o.compile || o.print || o.lint);
o.print = !!(o.print || (o.eval || o.stdio && o.compile));
return (sources = o.arguments);
return sources = o.arguments;
};
compileOptions = function(fileName) {
return {

View File

@@ -342,7 +342,7 @@
if (!prev[1].reserved && (_ref2 = prev[1], __indexOf.call(JS_FORBIDDEN, _ref2) >= 0)) {
this.assignmentError();
}
if (((_ref3 = prev[1]) === '||' || _ref3 === '&&')) {
if ((_ref3 = prev[1]) === '||' || _ref3 === '&&') {
prev[0] = 'COMPOUND_ASSIGN';
prev[1] += '=';
return true;

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;
})();

View File

@@ -112,7 +112,7 @@
return ((_ref = token[0]) === ')' || _ref === 'CALL_END') || token[0] === 'OUTDENT' && this.tag(i - 1) === ')';
};
action = function(token, i) {
return (this.tokens[token[0] === 'OUTDENT' ? i - 1 : i][0] = 'CALL_END');
return this.tokens[token[0] === 'OUTDENT' ? i - 1 : i][0] = 'CALL_END';
};
return this.scanTokens(function(token, i) {
if (token[0] === 'CALL_START') {
@@ -125,10 +125,10 @@
var action, condition;
condition = function(token, i) {
var _ref;
return ((_ref = token[0]) === ']' || _ref === 'INDEX_END');
return (_ref = token[0]) === ']' || _ref === 'INDEX_END';
};
action = function(token, i) {
return (token[0] = 'INDEX_END');
return token[0] = 'INDEX_END';
};
return this.scanTokens(function(token, i) {
if (token[0] === 'INDEX_START') {
@@ -142,7 +142,7 @@
stack = [];
condition = function(token, i) {
var _ref, _ref2, one, tag, three, two;
if (('HERECOMMENT' === this.tag(i + 1) || 'HERECOMMENT' === this.tag(i - 1))) {
if ('HERECOMMENT' === this.tag(i + 1) || 'HERECOMMENT' === this.tag(i - 1)) {
return false;
}
_ref = this.tokens.slice(i + 1, i + 4), one = _ref[0], two = _ref[1], three = _ref[2];
@@ -211,7 +211,7 @@
return true;
}
tag = token[0];
if ((tag === 'IF' || tag === 'ELSE' || tag === 'UNLESS' || tag === '->' || tag === '=>')) {
if (tag === 'IF' || tag === 'ELSE' || tag === 'UNLESS' || tag === '->' || tag === '=>') {
seenSingle = true;
}
if (tag === 'PROPERTY_ACCESS' && this.tag(i - 1) === 'OUTDENT') {
@@ -265,7 +265,7 @@
var condition;
condition = function(token, i) {
var _ref;
return ((_ref = token[0]) === 'TERMINATOR' || _ref === 'INDENT');
return (_ref = token[0]) === 'TERMINATOR' || _ref === 'INDENT';
};
return this.scanTokens(function(token, i) {
var _ref, original;

View File

@@ -110,7 +110,7 @@
Scope.prototype.hasDeclarations = function(body) {
return body === this.expressions && this.any(function(v) {
var _ref2;
return ((_ref2 = v.type) === 'var' || _ref2 === 'reuse');
return (_ref2 = v.type) === 'var' || _ref2 === 'reuse';
});
};
Scope.prototype.hasAssignments = function(body) {
@@ -124,7 +124,7 @@
_result = [];
for (_i = 0, _len = (_ref2 = this.variables).length; _i < _len; _i++) {
v = _ref2[_i];
if (((_ref3 = v.type) === 'var' || _ref3 === 'reuse')) {
if ((_ref3 = v.type) === 'var' || _ref3 === 'reuse') {
_result.push(v.name);
}
}