From cf5a0862637ed6262da12555b2ab6e7dc226afb4 Mon Sep 17 00:00:00 2001 From: Timothy Jones Date: Wed, 20 Oct 2010 04:07:10 +1300 Subject: [PATCH] Removing accidental superfluous temp variables. --- lib/cake.js | 4 ++-- lib/command.js | 6 ++--- lib/grammar.js | 10 ++++---- lib/helpers.js | 8 +++---- lib/index.js | 2 +- lib/lexer.js | 6 ++--- lib/nodes.js | 62 ++++++++++++++++++++++++------------------------ lib/optparse.js | 16 ++++++------- lib/rewriter.js | 8 +++---- lib/scope.js | 8 +++---- src/nodes.coffee | 2 +- 11 files changed, 66 insertions(+), 66 deletions(-) diff --git a/lib/cake.js b/lib/cake.js index bf3980d4..770a648b 100755 --- a/lib/cake.js +++ b/lib/cake.js @@ -33,7 +33,7 @@ }); exports.run = function() { return path.exists('Cakefile', function(exists) { - var _i, _j, _len, _ref, _result, arg, args; + var _i, _len, _ref, _result, arg, args; if (!exists) { throw new Error("Cakefile not found in " + (process.cwd())); } @@ -55,7 +55,7 @@ }); }; printTasks = function() { - var _i, _ref, desc, name, spaces, task; + var _ref, desc, name, spaces, task; puts(''); for (name in _ref = tasks) { task = _ref[name]; diff --git a/lib/command.js b/lib/command.js index c369f751..58a27745 100644 --- a/lib/command.js +++ b/lib/command.js @@ -64,7 +64,7 @@ return fs.stat(source, function(err, stats) { if (stats.isDirectory()) { return fs.readdir(source, function(err, files) { - var _k, _l, _len2, _result2, file; + var _k, _len2, _result2, file; _result2 = []; for (_k = 0, _len2 = files.length; _k < _len2; _k++) { file = files[_k]; @@ -89,7 +89,7 @@ return _result; }; compileScript = function(file, input, base) { - var _i, _j, _len, _ref2, o, options, req, t, task; + var _i, _len, _ref2, o, options, req, t, task; o = opts; options = compileOptions(file); if (o.require) { @@ -187,7 +187,7 @@ return jsl.stdin.end(); }; printTokens = function(tokens) { - var _i, _j, _len, _ref2, _result, strings, tag, token, value; + var _i, _len, _ref2, _result, strings, tag, token, value; strings = (function() { _result = []; for (_i = 0, _len = tokens.length; _i < _len; _i++) { diff --git a/lib/grammar.js b/lib/grammar.js index 8371679f..e038a740 100644 --- a/lib/grammar.js +++ b/lib/grammar.js @@ -1,5 +1,5 @@ (function() { - var Parser, _i, _j, _k, _l, _len, _len2, _m, _ref, _result, alt, alternatives, grammar, name, o, operators, token, tokens, unwrap; + var Parser, _i, _j, _len, _len2, _ref, _result, alt, alternatives, grammar, name, o, operators, token, tokens, unwrap; var __hasProp = Object.prototype.hasOwnProperty; Parser = require('jison').Parser; unwrap = /function\s*\(\)\s*\{\s*return\s*([\s\S]*);\s*\}/; @@ -595,11 +595,11 @@ alternatives = grammar[name]; grammar[name] = (function() { _result = []; - for (_j = 0, _len = alternatives.length; _j < _len; _j++) { - alt = alternatives[_j]; + for (_i = 0, _len = alternatives.length; _i < _len; _i++) { + alt = alternatives[_i]; _result.push((function() { - for (_l = 0, _len2 = (_ref = alt[0].split(' ')).length; _l < _len2; _l++) { - token = _ref[_l]; + for (_j = 0, _len2 = (_ref = alt[0].split(' ')).length; _j < _len2; _j++) { + token = _ref[_j]; if (!grammar[token]) { tokens.push(token); } diff --git a/lib/helpers.js b/lib/helpers.js index d68cf68f..5983bf6d 100644 --- a/lib/helpers.js +++ b/lib/helpers.js @@ -3,7 +3,7 @@ indexOf = (exports.indexOf = Array.indexOf || (Array.prototype.indexOf ? function(array, item, from) { return array.indexOf(item, from); } : function(array, item, from) { - var _i, _len, index, other; + var _len, index, other; for (index = 0, _len = array.length; index < _len; index++) { other = array[index]; if (other === item && (!from || (from <= index))) { @@ -24,7 +24,7 @@ return literal === string.substr(string.length - len - (back || 0), len); }; exports.compact = function(array) { - var _i, _j, _len, _result, item; + var _i, _len, _result, item; _result = []; for (_i = 0, _len = array.length; _i < _len; _i++) { item = array[_i]; @@ -46,7 +46,7 @@ return extend(extend({}, options), overrides); }; extend = (exports.extend = function(object, properties) { - var _i, key, val; + var key, val; for (key in properties) { val = properties[key]; object[key] = val; @@ -54,7 +54,7 @@ return object; }); exports.flatten = (flatten = function(array) { - var _i, _j, _len, element, flattened; + var _i, _len, element, flattened; flattened = []; for (_i = 0, _len = array.length; _i < _len; _i++) { element = array[_i]; diff --git a/lib/index.js b/lib/index.js index 60d00f4c..dc5ab13c 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,5 +1,5 @@ (function() { - var _i, _ref, key, val; + var _ref, key, val; var __hasProp = Object.prototype.hasOwnProperty; for (key in _ref = require('./coffee-script')) { if (!__hasProp.call(_ref, key)) continue; diff --git a/lib/lexer.js b/lib/lexer.js index d3a41581..ce25616b 100644 --- a/lib/lexer.js +++ b/lib/lexer.js @@ -200,7 +200,7 @@ return true; }; Lexer.prototype.heregexToken = function(match) { - var _i, _j, _len, _ref2, _ref3, _ref4, _this, body, flags, heregex, re, tag, tokens, value; + var _i, _len, _ref2, _ref3, _ref4, _this, body, flags, heregex, re, tag, tokens, value; heregex = match[0], body = match[1], flags = match[2]; this.i += heregex.length; if (0 > body.indexOf('#{')) { @@ -454,7 +454,7 @@ throw SyntaxError("Reserved word \"" + (this.value()) + "\" on line " + (this.line + 1) + " can't be assigned"); }; Lexer.prototype.balancedString = function(str, delimited, options) { - var _i, _j, _len, close, i, levels, open, pair, slen; + var _i, _len, close, i, levels, open, pair, slen; options || (options = {}); levels = []; i = 0; @@ -492,7 +492,7 @@ return !i ? false : str.slice(0, i); }; Lexer.prototype.interpolateString = function(str, options) { - var _i, _len, _ref2, _ref3, _this, expr, heredoc, i, inner, interpolated, letter, nested, pi, regex, tag, tokens, value; + var _len, _ref2, _ref3, _this, expr, heredoc, i, inner, interpolated, letter, nested, pi, regex, tag, tokens, value; _ref2 = options || (options = {}), heredoc = _ref2.heredoc, regex = _ref2.regex; tokens = []; pi = 0; diff --git a/lib/nodes.js b/lib/nodes.js index 2b027cc4..097780a6 100644 --- a/lib/nodes.js +++ b/lib/nodes.js @@ -43,7 +43,7 @@ return Closure.wrap(this).compile(o); }; Base.prototype.compileReference = function(o, options) { - var _i, _len, compiled, i, node, pair, reference; + var _len, compiled, i, node, pair, reference; pair = (function() { if (!this.isComplex()) { return [this, this]; @@ -98,7 +98,7 @@ return this.traverseChildren(true, block); }; Base.prototype.toString = function(idt, override) { - var _i, _j, _len, _ref2, _result, child, children, klass; + var _i, _len, _ref2, _result, child, children, klass; idt || (idt = ''); children = (function() { _result = []; @@ -112,7 +112,7 @@ return '\n' + idt + klass + children; }; Base.prototype.eachChild = function(func) { - var _i, _j, _k, _l, _len, _len2, _ref2, _ref3, _result, attr, child; + var _i, _j, _len, _len2, _ref2, _ref3, _result, attr, child; if (!this.children) { return; } @@ -120,8 +120,8 @@ for (_i = 0, _len = (_ref2 = this.children).length; _i < _len; _i++) { attr = _ref2[_i]; if (this[attr]) { - for (_k = 0, _len2 = (_ref3 = flatten([this[attr]])).length; _k < _len2; _k++) { - child = _ref3[_k]; + for (_j = 0, _len2 = (_ref3 = flatten([this[attr]])).length; _j < _len2; _j++) { + child = _ref3[_j]; if (func(child) === false) { return; } @@ -201,7 +201,7 @@ return o.scope ? Expressions.__super__.compile.call(this, o) : this.compileRoot(o); }; Expressions.prototype.compileNode = function(o) { - var _i, _j, _len, _ref2, _result, node; + var _i, _len, _ref2, _result, node; return (function() { _result = []; for (_i = 0, _len = (_ref2 = this.expressions).length; _i < _len; _i++) { @@ -395,7 +395,7 @@ return !o.top || this.properties.length ? Value.__super__.compile.call(this, o) : this.base.compile(o); }; Value.prototype.compileNode = function(o) { - var _i, _j, _len, code, ifn, prop, props; + var _i, _len, code, ifn, prop, props; if (ifn = this.unfoldSoak(o)) { return ifn.compile(o); } @@ -414,7 +414,7 @@ return code; }; Value.prototype.unfoldSoak = function(o) { - var _i, _len, _ref2, fst, i, ifn, prop, ref, snd; + var _len, _ref2, fst, i, ifn, prop, ref, snd; if (ifn = this.base.unfoldSoak(o)) { Array.prototype.push.apply(ifn.body.properties, this.properties); return ifn; @@ -496,7 +496,7 @@ return method.klass ? ("" + (method.klass) + ".__super__." + name) : ("" + name + ".__super__.constructor"); }; Call.prototype.unfoldSoak = function(o) { - var _i, _j, _len, _ref2, _ref3, call, ifn, left, list, rite, val; + var _i, _len, _ref2, _ref3, call, ifn, left, list, rite, val; if (this.soakNode) { if (val = this.variable) { if (!(val instanceof Value)) { @@ -545,7 +545,7 @@ return ifn; }; Call.prototype.compileNode = function(o) { - var _i, _j, _k, _l, _len, _len2, _ref2, _ref3, _ref4, _result, arg, args, ifn; + var _i, _j, _len, _len2, _ref2, _ref3, _ref4, _result, arg, args, ifn; if (ifn = this.unfoldSoak(o)) { return ifn.compile(o); } @@ -558,8 +558,8 @@ } args = (function() { _result = []; - for (_k = 0, _len2 = (_ref4 = this.args).length; _k < _len2; _k++) { - arg = _ref4[_k]; + for (_j = 0, _len2 = (_ref4 = this.args).length; _j < _len2; _j++) { + arg = _ref4[_j]; _result.push((arg.parenthetical = true) && arg.compile(o)); } return _result; @@ -781,7 +781,7 @@ __extends(ObjectLiteral, Base); ObjectLiteral.prototype.children = ['properties']; ObjectLiteral.prototype.compileNode = function(o) { - var _i, _j, _len, _ref2, _result, i, indent, join, lastNoncom, nonComments, obj, prop, props, top; + var _i, _len, _ref2, _result, i, indent, join, lastNoncom, nonComments, obj, prop, props, top; top = del(o, 'top'); o.indent = this.idt(1); nonComments = (function() { @@ -817,7 +817,7 @@ return this.tags.front ? ("(" + obj + ")") : obj; }; ObjectLiteral.prototype.assigns = function(name) { - var _i, _j, _len, _ref2, prop; + var _i, _len, _ref2, prop; for (_i = 0, _len = (_ref2 = this.properties).length; _i < _len; _i++) { prop = _ref2[_i]; if (prop.assigns(name)) { @@ -844,7 +844,7 @@ return Splat.compileSplattedArray(this.objects, o); }; ArrayLiteral.prototype.compileNode = function(o) { - var _i, _j, _k, _len, _len2, _ref2, _ref3, code, i, obj, objects; + var _i, _len, _len2, _ref2, _ref3, code, i, obj, objects; o.indent = this.idt(1); for (_i = 0, _len = (_ref2 = this.objects).length; _i < _len; _i++) { obj = _ref2[_i]; @@ -862,7 +862,7 @@ return 0 < objects.indexOf('\n') ? ("[\n" + (o.indent) + objects + "\n" + (this.tab) + "]") : ("[" + objects + "]"); }; ArrayLiteral.prototype.assigns = function(name) { - var _i, _j, _len, _ref2, obj; + var _i, _len, _ref2, obj; for (_i = 0, _len = (_ref2 = this.objects).length; _i < _len; _i++) { obj = _ref2[_i]; if (obj.assigns(name)) { @@ -894,7 +894,7 @@ return this; }; Class.prototype.compileNode = function(o) { - var _i, _j, _len, _ref2, _ref3, _ref4, access, applied, apply, className, constScope, construct, constructor, extension, func, me, pname, prop, props, pvar, ref, returns, val, variable; + var _i, _len, _ref2, _ref3, _ref4, access, applied, apply, className, constScope, construct, constructor, extension, func, me, pname, prop, props, pvar, ref, returns, val, variable; variable = this.variable; if (variable.value === '__temp__') { variable = new Literal(o.scope.freeVariable('ctor')); @@ -1024,7 +1024,7 @@ return top || this.parenthetical ? val : ("(" + val + ")"); }; Assign.prototype.compilePatternMatch = function(o) { - var _i, _len, _ref2, _ref3, accessClass, assigns, code, i, idx, isObject, obj, objects, olength, otop, ref, splat, top, val, valVar, value; + var _len, _ref2, _ref3, accessClass, assigns, code, i, idx, isObject, obj, objects, olength, otop, ref, splat, top, val, valVar, value; if ((value = this.value).isStatement(o)) { value = Closure.wrap(value); } @@ -1123,7 +1123,7 @@ __extends(Code, Base); Code.prototype.children = ['params', 'body']; Code.prototype.compileNode = function(o) { - var _i, _j, _k, _len, _len2, _ref2, _ref3, _result, close, code, comm, empty, func, i, open, param, params, sharedScope, splat, top, value; + var _i, _len, _len2, _ref2, _ref3, _result, close, code, comm, empty, func, i, open, param, params, sharedScope, splat, top, value; sharedScope = del(o, 'sharedScope'); top = del(o, 'top'); o.scope = sharedScope || new Scope(o.scope, this.body, this); @@ -1162,8 +1162,8 @@ o.scope.startLevel(); params = (function() { _result = []; - for (_j = 0, _len2 = params.length; _j < _len2; _j++) { - param = params[_j]; + for (_i = 0, _len2 = params.length; _i < _len2; _i++) { + param = params[_i]; _result.push(param.compile(o)); } return _result; @@ -1171,8 +1171,8 @@ if (!(empty || this.noReturn)) { this.body.makeReturn(); } - for (_j = 0, _len2 = params.length; _j < _len2; _j++) { - param = params[_j]; + for (_i = 0, _len2 = params.length; _i < _len2; _i++) { + param = params[_i]; (o.scope.parameter(param)); } comm = this.comment ? this.comment.compile(o) + '\n' : ''; @@ -1242,7 +1242,7 @@ return (this.index != null) ? this.compileParam(o) : this.name.compile(o); }; Splat.prototype.compileParam = function(o) { - var _i, _len, _ref2, assign, end, idx, len, name, pos, trailing, variadic; + var _len, _ref2, assign, end, idx, len, name, pos, trailing, variadic; name = this.name.compile(o); o.scope.find(name); end = ''; @@ -1271,7 +1271,7 @@ return "" + (utility('slice')) + ".call(" + name + ", " + index + trail + ")"; }; Splat.compileSplattedArray = function(list, o) { - var _i, _len, arg, args, code, end, i, prev; + var _len, arg, args, code, end, i, prev; args = []; end = -1; for (i = 0, _len = list.length; i < _len; i++) { @@ -1485,7 +1485,7 @@ return this.isArray() ? this.compileOrTest(o) : this.compileLoopTest(o); }; In.prototype.compileOrTest = function(o) { - var _i, _len, _ref2, _result, i, item, tests; + var _len, _ref2, _result, i, item, tests; tests = (function() { _result = []; for (i = 0, _len = (_ref2 = this.array.base.objects).length; i < _len; i++) { @@ -1684,7 +1684,7 @@ if (!ivar || codeInBody) { ivar = scope.freeVariable('i'); } - if (name && !range) { + if (name && !range && codeInBody) { nvar = scope.freeVariable('i'); } varPart = ''; @@ -1787,7 +1787,7 @@ Switch.prototype.children = ['subject', 'cases', 'otherwise']; Switch.prototype.isStatement = YES; Switch.prototype.makeReturn = function() { - var _i, _j, _len, _ref2, pair; + var _i, _len, _ref2, pair; for (_i = 0, _len = (_ref2 = this.cases).length; _i < _len; _i++) { pair = _ref2[_i]; pair[1].makeReturn(); @@ -1798,7 +1798,7 @@ return this; }; Switch.prototype.compileNode = function(o) { - var _i, _j, _k, _l, _len, _len2, _ref2, _ref3, block, code, condition, conditions, exprs, idt, pair; + var _i, _j, _len, _len2, _ref2, _ref3, block, code, condition, conditions, exprs, idt, pair; idt = (o.indent = this.idt(2)); o.top = true; code = ("" + (this.tab) + "switch (" + (this.subject.compile(o)) + ") {"); @@ -1806,8 +1806,8 @@ pair = _ref2[_i]; conditions = pair[0], block = pair[1]; exprs = block.expressions; - for (_k = 0, _len2 = (_ref3 = flatten([conditions])).length; _k < _len2; _k++) { - condition = _ref3[_k]; + for (_j = 0, _len2 = (_ref3 = flatten([conditions])).length; _j < _len2; _j++) { + condition = _ref3[_j]; if (this.tags.subjectless) { condition = new Op('!!', new Parens(condition)); } diff --git a/lib/optparse.js b/lib/optparse.js index 0f4a6dac..4a9ae283 100755 --- a/lib/optparse.js +++ b/lib/optparse.js @@ -10,7 +10,7 @@ return OptionParser; })(); OptionParser.prototype.parse = function(args) { - var _i, _j, _k, _len, _len2, _ref, arg, i, isOption, matchedRule, options, rule, value; + var _i, _len, _len2, _ref, arg, i, isOption, matchedRule, options, rule, value; options = { arguments: [] }; @@ -19,8 +19,8 @@ arg = args[i]; isOption = !!(arg.match(LONG_FLAG) || arg.match(SHORT_FLAG)); matchedRule = false; - for (_j = 0, _len2 = (_ref = this.rules).length; _j < _len2; _j++) { - rule = _ref[_j]; + for (_i = 0, _len2 = (_ref = this.rules).length; _i < _len2; _i++) { + rule = _ref[_i]; if (rule.shortFlag === arg || rule.longFlag === arg) { value = rule.hasArgument ? args[i += 1] : true; options[rule.name] = rule.isList ? (options[rule.name] || []).concat(value) : value; @@ -39,7 +39,7 @@ return options; }; OptionParser.prototype.help = function() { - var _i, _j, _len, _ref, letPart, lines, rule, spaces; + var _i, _len, _ref, letPart, lines, rule, spaces; lines = ['Available options:']; if (this.banner) { lines.unshift("" + (this.banner) + "\n"); @@ -60,7 +60,7 @@ MULTI_FLAG = /^-(\w{2,})/; OPTIONAL = /\[(\w+(\*?))\]/; buildRules = function(rules) { - var _i, _j, _len, _result, tuple; + var _i, _len, _result, tuple; _result = []; for (_i = 0, _len = rules.length; _i < _len; _i++) { tuple = rules[_i]; @@ -88,14 +88,14 @@ }; }; normalizeArguments = function(args) { - var _i, _j, _k, _l, _len, _len2, _ref, arg, l, match, result; + var _i, _j, _len, _len2, _ref, arg, l, match, result; args = args.slice(0); result = []; for (_i = 0, _len = args.length; _i < _len; _i++) { arg = args[_i]; if (match = arg.match(MULTI_FLAG)) { - for (_k = 0, _len2 = (_ref = match[1].split('')).length; _k < _len2; _k++) { - l = _ref[_k]; + for (_j = 0, _len2 = (_ref = match[1].split('')).length; _j < _len2; _j++) { + l = _ref[_j]; result.push('-' + l); } } else { diff --git a/lib/rewriter.js b/lib/rewriter.js index 2833f782..cb571dcb 100644 --- a/lib/rewriter.js +++ b/lib/rewriter.js @@ -1,5 +1,5 @@ (function() { - var BALANCED_PAIRS, EXPRESSION_CLOSE, EXPRESSION_END, EXPRESSION_START, IMPLICIT_BLOCK, IMPLICIT_CALL, IMPLICIT_END, IMPLICIT_FUNC, INVERSES, LINEBREAKS, SINGLE_CLOSERS, SINGLE_LINERS, _i, _j, _len, _ref, include, left, rite; + var BALANCED_PAIRS, EXPRESSION_CLOSE, EXPRESSION_END, EXPRESSION_START, IMPLICIT_BLOCK, IMPLICIT_CALL, IMPLICIT_END, IMPLICIT_FUNC, INVERSES, LINEBREAKS, SINGLE_CLOSERS, SINGLE_LINERS, _i, _len, _ref, include, left, rite; include = require('./helpers').include; exports.Rewriter = (function() { function Rewriter() { @@ -83,7 +83,7 @@ }); }; exports.Rewriter.prototype.removeLeadingNewlines = function() { - var _i, _len, _ref, i, tag; + var _len, _ref, i, tag; for (i = 0, _len = (_ref = this.tokens).length; i < _len; i++) { tag = _ref[i][0]; if (tag !== 'TERMINATOR') { @@ -275,11 +275,11 @@ }); }; exports.Rewriter.prototype.ensureBalance = function(pairs) { - var _i, _result, key, levels, open, openLine, unclosed, value; + var _result, key, levels, open, openLine, unclosed, value; levels = {}; openLine = {}; this.scanTokens(function(token, i) { - var _i, _j, _len, _ref, _ref2, close, open, tag; + var _i, _len, _ref, _ref2, close, open, tag; tag = token[0]; for (_i = 0, _len = (_ref = pairs).length; _i < _len; _i++) { _ref2 = _ref[_i], open = _ref2[0], close = _ref2[1]; diff --git a/lib/scope.js b/lib/scope.js index 9b086b53..b0f2a648 100644 --- a/lib/scope.js +++ b/lib/scope.js @@ -26,7 +26,7 @@ return this.garbage.push([]); }; Scope.prototype.endLevel = function() { - var _i, _j, _len, _ref2, _result, name, vars; + var _i, _len, _ref2, _result, name, vars; vars = this.variables; _result = []; for (_i = 0, _len = (_ref2 = this.garbage.pop()).length; _i < _len; _i++) { @@ -45,7 +45,7 @@ return false; }; Scope.prototype.any = function(fn) { - var _i, _ref2, k, v; + var _ref2, k, v; for (v in _ref2 = this.variables) { if (!__hasProp.call(_ref2, v)) continue; k = _ref2[v]; @@ -98,7 +98,7 @@ }); }; Scope.prototype.declaredVariables = function() { - var _i, _ref2, _result, key, val; + var _ref2, _result, key, val; return (function() { _result = []; for (key in _ref2 = this.variables) { @@ -112,7 +112,7 @@ }).call(this).sort(); }; Scope.prototype.assignedVariables = function() { - var _i, _ref2, _result, key, val; + var _ref2, _result, key, val; _result = []; for (key in _ref2 = this.variables) { if (!__hasProp.call(_ref2, key)) continue; diff --git a/src/nodes.coffee b/src/nodes.coffee index d377620b..c2561aa6 100644 --- a/src/nodes.coffee +++ b/src/nodes.coffee @@ -1425,7 +1425,7 @@ exports.For = class For extends Base rvar = scope.freeVariable 'result' unless topLevel ivar = if range then name else index ivar = scope.freeVariable 'i' if not ivar or codeInBody - nvar = scope.freeVariable 'i' if name and not range + nvar = scope.freeVariable 'i' if name and not range and codeInBody varPart = '' guardPart = '' body = Expressions.wrap([@body])