diff --git a/lib/cake.js b/lib/cake.js index 17a10f09..b3ec0ba1 100755 --- a/lib/cake.js +++ b/lib/cake.js @@ -29,13 +29,13 @@ task = _b[name]; _a.push((function() { spaces = 20 - name.length; - spaces = spaces > 0 ? ((function() { + spaces = spaces > 0 ? (function() { _c = []; _f = 0; _g = spaces; for (_e=0, i=_f; (_f <= _g ? i <= _g : i >= _g); (_f <= _g ? i += 1 : i -= 1), _e++) { _c.push(' '); } return _c; - }).call(this)).join('') : ''; + }).call(this).join('') : ''; return puts("cake " + name + spaces + ' # ' + task.description); }).call(this)); } diff --git a/lib/nodes.js b/lib/nodes.js index 19a5fcd9..43737ff6 100644 --- a/lib/nodes.js +++ b/lib/nodes.js @@ -141,14 +141,14 @@ Node.prototype.toString = function toString(idt) { var _a, _b, _c, child; idt = idt || ''; - return '\n' + idt + this.type + ((function() { + return '\n' + idt + this.type + (function() { _a = []; _b = this.children; for (_c = 0; _c < _b.length; _c++) { child = _b[_c]; _a.push(child.toString(idt + TAB)); } return _a; - }).call(this)).join(''); + }).call(this).join(''); }; // Default implementations of the common node methods. Node.prototype.unwrap = function unwrap() { @@ -203,14 +203,14 @@ // Compile each expression in the Expressions body. compile_node: function compile_node(o) { var _a, _b, _c, node; - return ((function() { + return (function() { _a = []; _b = this.expressions; for (_c = 0; _c < _b.length; _c++) { node = _b[_c]; _a.push(this.compile_expression(node, merge(o))); } return _a; - }).call(this)).join("\n"); + }).call(this).join("\n"); }, // If this is the top-level Expressions, wrap everything in a safety closure. compile_root: function compile_root(o) { @@ -421,14 +421,14 @@ if (this.args[this.args.length - 1] instanceof SplatNode) { return this.compile_splat(o); } - args = ((function() { + args = (function() { _a = []; _b = this.args; for (_c = 0; _c < _b.length; _c++) { arg = _b[_c]; _a.push(arg.compile(o)); } return _a; - }).call(this)).join(', '); + }).call(this).join(', '); if (this.variable === 'super') { return this.compile_super(args, o); } @@ -826,14 +826,14 @@ splat.index = this.params.length; this.body.unshift(splat); } - params = ((function() { + params = (function() { _a = []; _b = this.params; for (_c = 0; _c < _b.length; _c++) { param = _b[_c]; _a.push(param.compile(o)); } return _a; - }).call(this)); + }).call(this); _d = params; for (_e = 0; _e < _d.length; _e++) { param = _d[_e]; @@ -858,14 +858,14 @@ var _a, _b, _c, child, children; idt = idt || ''; children = flatten([this.params, this.body.expressions]); - return '\n' + idt + this.type + ((function() { + return '\n' + idt + this.type + (function() { _a = []; _b = children; for (_c = 0; _c < _b.length; _c++) { child = _b[_c]; _a.push(child.toString(idt + TAB)); } return _a; - }).call(this)).join(''); + }).call(this).join(''); } })); // A splat, either as a parameter to a function, an argument to a call, @@ -1069,13 +1069,19 @@ // An extra set of parentheses, specified explicitly in the source. ParentheticalNode = (exports.ParentheticalNode = inherit(Node, { type: 'Paren', - constructor: function constructor(expressions) { - this.children = [(this.expressions = expressions)]; + constructor: function constructor(expression) { + this.children = [(this.expression = expression)]; return this; }, + is_statement: function is_statement() { + return this.expression.is_statement(); + }, compile_node: function compile_node(o) { var code, l; - code = this.expressions.compile(o); + code = this.expression.compile(o); + if (this.is_statement()) { + return code; + } l = code.length; if (code.substr(l - 1, 1) === ';') { code = code.substr(o, l - 1); @@ -1247,14 +1253,14 @@ }, compile_condition: function compile_condition(o) { var _a, _b, _c, cond; - return ((function() { + return (function() { _a = []; _b = flatten([this.condition]); for (_c = 0; _c < _b.length; _c++) { cond = _b[_c]; _a.push(cond.compile(o)); } return _a; - }).call(this)).join(' || '); + }).call(this).join(' || '); }, compile_node: function compile_node(o) { return this.is_statement() ? this.compile_statement(o) : this.compile_ternary(o); diff --git a/lib/scope.js b/lib/scope.js index 62002dc6..753e4dd8 100644 --- a/lib/scope.js +++ b/lib/scope.js @@ -79,7 +79,7 @@ // Return the list of variables first declared in current scope. Scope.prototype.declared_variables = function declared_variables() { var _a, _b, key, val; - return ((function() { + return (function() { _a = []; _b = this.variables; for (key in _b) if (__hasProp.call(_b, key)) { val = _b[key]; @@ -88,13 +88,13 @@ } } return _a; - }).call(this)).sort(); + }).call(this).sort(); }; // Return the list of variables that are supposed to be assigned at the top // of scope. Scope.prototype.assigned_variables = function assigned_variables() { var _a, _b, key, val; - return ((function() { + return (function() { _a = []; _b = this.variables; for (key in _b) if (__hasProp.call(_b, key)) { val = _b[key]; @@ -103,20 +103,20 @@ } } return _a; - }).call(this)).sort(); + }).call(this).sort(); }; Scope.prototype.compiled_declarations = function compiled_declarations() { return this.declared_variables().join(', '); }; Scope.prototype.compiled_assignments = function compiled_assignments() { var _a, _b, _c, t; - return ((function() { + return (function() { _a = []; _b = this.assigned_variables(); for (_c = 0; _c < _b.length; _c++) { t = _b[_c]; _a.push(t[0] + ' = ' + t[1]); } return _a; - }).call(this)).join(', '); + }).call(this).join(', '); }; })(); \ No newline at end of file diff --git a/src/nodes.coffee b/src/nodes.coffee index 48a245bf..e5d2dd1f 100644 --- a/src/nodes.coffee +++ b/src/nodes.coffee @@ -859,12 +859,16 @@ ExistenceNode.compile_test: (o, variable) -> ParentheticalNode: exports.ParentheticalNode: inherit Node, { type: 'Paren' - constructor: (expressions) -> - @children: [@expressions: expressions] + constructor: (expression) -> + @children: [@expression: expression] this + is_statement: -> + @expression.is_statement() + compile_node: (o) -> - code: @expressions.compile(o) + code: @expression.compile(o) + return code if @is_statement() l: code.length code: code.substr(o, l-1) if code.substr(l-1, 1) is ';' '(' + code + ')'