diff --git a/documentation/js/array_comprehensions.js b/documentation/js/array_comprehensions.js
index cdf1e8e2..f32d5b3b 100644
--- a/documentation/js/array_comprehensions.js
+++ b/documentation/js/array_comprehensions.js
@@ -1,21 +1,21 @@
(function(){
- var _a, _b, _c, _d, _e, _f, _g, food, lunch, roid, roid2;
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, food, lunch, roid, roid2;
// Eat lunch.
lunch = (function() {
_a = []; _b = ['toast', 'cheese', 'wine'];
- for (_c = 0; _c < _b.length; _c++) {
+ for (_c = 0, _d = _b.length; _c < _d; _c++) {
food = _b[_c];
_a.push(eat(food));
}
return _a;
}).call(this);
// Naive collision detection.
- _d = asteroids;
- for (_e = 0; _e < _d.length; _e++) {
- roid = _d[_e];
- _f = asteroids;
- for (_g = 0; _g < _f.length; _g++) {
- roid2 = _f[_g];
+ _e = asteroids;
+ for (_f = 0, _g = _e.length; _f < _g; _f++) {
+ roid = _e[_f];
+ _h = asteroids;
+ for (_i = 0, _j = _h.length; _i < _j; _i++) {
+ roid2 = _h[_i];
if (roid !== roid2) {
if (roid.overlaps(roid2)) {
roid.explode();
diff --git a/documentation/js/cake_tasks.js b/documentation/js/cake_tasks.js
index ab96a5b9..07d1b62d 100644
--- a/documentation/js/cake_tasks.js
+++ b/documentation/js/cake_tasks.js
@@ -1,9 +1,9 @@
(function(){
process.mixin(require('assert'));
task('test', 'run each of the unit tests', function() {
- var _a, _b, _c, test;
+ var _a, _b, _c, _d, test;
_a = []; _b = test_files;
- for (_c = 0; _c < _b.length; _c++) {
+ for (_c = 0, _d = _b.length; _c < _d; _c++) {
test = _b[_c];
_a.push(fs.readFile(test, function(err, code) {
return eval(coffee.compile(code));
diff --git a/documentation/js/overview.js b/documentation/js/overview.js
index 7f8c01a6..6164287d 100644
--- a/documentation/js/overview.js
+++ b/documentation/js/overview.js
@@ -1,5 +1,5 @@
(function(){
- var _a, _b, _c, cubed_list, list, math, num, number, opposite_day, race, square;
+ var _a, _b, _c, _d, cubed_list, list, math, num, number, opposite_day, race, square;
// Assignment:
number = 42;
opposite_day = true;
@@ -34,7 +34,7 @@
// Array comprehensions:
cubed_list = (function() {
_a = []; _b = list;
- for (_c = 0; _c < _b.length; _c++) {
+ for (_c = 0, _d = _b.length; _c < _d; _c++) {
num = _b[_c];
_a.push(math.cube(num));
}
diff --git a/documentation/js/range_comprehensions.js b/documentation/js/range_comprehensions.js
index 848f63fe..9ec8bb4a 100644
--- a/documentation/js/range_comprehensions.js
+++ b/documentation/js/range_comprehensions.js
@@ -2,7 +2,7 @@
var _a, _b, _c, _d, _e, countdown, egg_delivery, num;
countdown = (function() {
_a = []; _d = 10; _e = 1;
- for (_c = 0, num=_d; (_d <= _e ? num <= _e : num >= _e); (_d <= _e ? num += 1 : num -= 1), _c++) {
+ for (_c = 0, num = _d; (_d <= _e ? num <= _e : num >= _e); (_d <= _e ? num += 1 : num -= 1), _c++) {
_a.push(num);
}
return _a;
@@ -10,7 +10,7 @@
egg_delivery = function egg_delivery() {
var _f, _g, _h, _i, _j, dozen_eggs, i;
_f = []; _i = 0; _j = eggs.length;
- for (_h = 0, i=_i; (_i <= _j ? i < _j : i > _j); (_i <= _j ? i += 12 : i -= 12), _h++) {
+ for (_h = 0, i = _i; (_i <= _j ? i < _j : i > _j); (_i <= _j ? i += 12 : i -= 12), _h++) {
_f.push((function() {
dozen_eggs = eggs.slice(i, i + 12);
return deliver(new egg_carton(dozen));
diff --git a/index.html b/index.html
index 370d7933..d49b61a7 100644
--- a/index.html
+++ b/index.html
@@ -133,7 +133,7 @@ alert "I knew it!# Array comprehensions:
cubed_list: math.cube num for num in list
-var _a, _b, _c, cubed_list, list, math, num, number, opposite_day, race, square;
+var _a, _b, _c, _d, cubed_list, list, math, num, number, opposite_day, race, square;
// Assignment:
number = 42;
opposite_day = true;
@@ -168,13 +168,13 @@ race = function // Array comprehensions:
cubed_list = (function() {
_a = []; _b = list;
- for (_c = 0; _c < _b.length; _c++) {
+ for (_c = 0, _d = _b.length; _c < _d; _c++) {
num = _b[_c];
_a.push(math.cube(num));
}
return _a;
}).call(this);
-
roid in asteroids
for roid2 in asteroids when roid isnt roid2
roid.explode() if roid.overlaps roid2
-
var _a, _b, _c, _d, _e, _f, _g, food, lunch, roid, roid2;
+var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, food, lunch, roid, roid2; // Eat lunch. lunch = (function() { _a = []; _b = ['toast', 'cheese', 'wine']; - for (_c = 0; _c < _b.length; _c++) { + for (_c = 0, _d = _b.length; _c < _d; _c++) { food = _b[_c]; _a.push(eat(food)); } return _a; }).call(this); // Naive collision detection. -_d = asteroids; -for (_e = 0; _e < _d.length; _e++) { - roid = _d[_e]; - _f = asteroids; - for (_g = 0; _g < _f.length; _g++) { - roid2 = _f[_g]; +_e = asteroids; +for (_f = 0, _g = _e.length; _f < _g; _f++) { + roid = _e[_f]; + _h = asteroids; + for (_i = 0, _j = _h.length; _i < _j; _i++) { + roid2 = _h[_i]; if (roid !== roid2) { if (roid.overlaps(roid2)) { roid.explode(); @@ -863,7 +863,7 @@ _d = asteroids;
var _a, _b, _c, _d, _e, countdown, egg_delivery, num; countdown = (function() { _a = []; _d = 10; _e = 1; - for (_c = 0, num=_d; (_d <= _e ? num <= _e : num >= _e); (_d <= _e ? num += 1 : num -= 1), _c++) { + for (_c = 0, num = _d; (_d <= _e ? num <= _e : num >= _e); (_d <= _e ? num += 1 : num -= 1), _c++) { _a.push(num); } return _a; @@ -871,7 +871,7 @@ countdown = (function( egg_delivery = function egg_delivery() { var _f, _g, _h, _i, _j, dozen_eggs, i; _f = []; _i = 0; _j = eggs.length; - for (_h = 0, i=_i; (_i <= _j ? i < _j : i > _j); (_i <= _j ? i += 12 : i -= 12), _h++) { + for (_h = 0, i = _i; (_i <= _j ? i < _j : i > _j); (_i <= _j ? i += 12 : i -= 12), _h++) { _f.push((function() { dozen_eggs = eggs.slice(i, i + 12); return deliver(new egg_carton(dozen)); @@ -882,7 +882,7 @@ egg_delivery = function
process.mixin(require('assert')); task('test', 'run each of the unit tests', function() { - var _a, _b, _c, test; + var _a, _b, _c, _d, test; _a = []; _b = test_files; - for (_c = 0; _c < _b.length; _c++) { + for (_c = 0, _d = _b.length; _c < _d; _c++) { test = _b[_c]; _a.push(fs.readFile(test, function(err, code) { return eval(coffee.compile(code)); diff --git a/lib/cake.js b/lib/cake.js index 5b603111..94a7f761 100755 --- a/lib/cake.js +++ b/lib/cake.js @@ -38,7 +38,7 @@ // prints them out, with no arguments. exports.run = function run() { return path.exists('Cakefile', function(exists) { - var _a, _b, _c, arg, args; + var _a, _b, _c, _d, arg, args; if (!(exists)) { throw new Error('Cakefile not found in ' + process.cwd()); } @@ -50,7 +50,7 @@ } options = oparse.parse(args); _a = []; _b = options.arguments; - for (_c = 0; _c < _b.length; _c++) { + for (_c = 0, _d = _b.length; _c < _d; _c++) { arg = _b[_c]; _a.push(invoke(arg)); } @@ -67,7 +67,7 @@ spaces = 20 - name.length; spaces = spaces > 0 ? (function() { _b = []; _e = 0; _f = spaces; - for (_d = 0, i=_e; (_e <= _f ? i <= _f : i >= _f); (_e <= _f ? i += 1 : i -= 1), _d++) { + for (_d = 0, i = _e; (_e <= _f ? i <= _f : i >= _f); (_e <= _f ? i += 1 : i -= 1), _d++) { _b.push(' '); } return _b; diff --git a/lib/coffee-script.js b/lib/coffee-script.js index 663fb159..ae88aeaf 100644 --- a/lib/coffee-script.js +++ b/lib/coffee-script.js @@ -49,9 +49,9 @@ // all script tags with a content-type of text/coffeescript. if ((typeof document !== "undefined" && document !== null) && document.getElementsByTagName) { process_scripts = function process_scripts() { - var _a, _b, _c, tag; + var _a, _b, _c, _d, tag; _a = []; _b = document.getElementsByTagName('script'); - for (_c = 0; _c < _b.length; _c++) { + for (_c = 0, _d = _b.length; _c < _d; _c++) { tag = _b[_c]; if (tag.type === 'text/coffeescript') { _a.push(eval(exports.compile(tag.innerHTML))); diff --git a/lib/command_line.js b/lib/command_line.js index 74cd66a1..9695c043 100644 --- a/lib/command_line.js +++ b/lib/command_line.js @@ -57,7 +57,7 @@ // Compiles the source CoffeeScript, returning the desired JavaScript, tokens, // or JSLint results. compile_scripts = function compile_scripts() { - var _a, _b, _c, compile, source; + var _a, _b, _c, _d, compile, source; compile = function compile(source) { return path.exists(source, function(exists) { if (!(exists)) { @@ -69,7 +69,7 @@ }); }; _a = []; _b = sources; - for (_c = 0; _c < _b.length; _c++) { + for (_c = 0, _d = _b.length; _c < _d; _c++) { source = _b[_c]; _a.push(compile(source)); } @@ -122,7 +122,7 @@ // Watch a list of source CoffeeScript files, recompiling them every time the // files are updated. watch_scripts = function watch_scripts() { - var _a, _b, _c, source, watch; + var _a, _b, _c, _d, source, watch; watch = function watch(source) { return process.watchFile(source, { persistent: true, @@ -137,7 +137,7 @@ }); }; _a = []; _b = sources; - for (_c = 0; _c < _b.length; _c++) { + for (_c = 0, _d = _b.length; _c < _d; _c++) { source = _b[_c]; _a.push(watch(source)); } @@ -170,10 +170,10 @@ }; // Pretty-print a token stream. print_tokens = function print_tokens(tokens) { - var _a, _b, _c, strings, token; + var _a, _b, _c, _d, strings, token; strings = (function() { _a = []; _b = tokens; - for (_c = 0; _c < _b.length; _c++) { + for (_c = 0, _d = _b.length; _c < _d; _c++) { token = _b[_c]; _a.push('[' + token[0] + ' ' + token[1].toString().replace(/\n/, '\\n') + ']'); } diff --git a/lib/grammar.js b/lib/grammar.js index 6adef6db..35c9a0f3 100644 --- a/lib/grammar.js +++ b/lib/grammar.js @@ -1,5 +1,5 @@ (function(){ - var Parser, _a, _b, _c, _d, _e, _f, bnf, grammar, name, non_terminal, o, operators, option, part, tokens, unwrap; + var Parser, _a, _b, _c, _d, _e, _f, _g, _h, bnf, grammar, name, non_terminal, o, operators, option, part, tokens, unwrap; var __hasProp = Object.prototype.hasOwnProperty; Parser = require('jison').Parser; // DSL =================================================================== @@ -537,12 +537,12 @@ non_terminal = _a[name]; bnf[name] = (function() { _b = []; _c = non_terminal; - for (_d = 0; _d < _c.length; _d++) { + for (_d = 0, _e = _c.length; _d < _e; _d++) { option = _c[_d]; _b.push((function() { - _e = option[0].split(" "); - for (_f = 0; _f < _e.length; _f++) { - part = _e[_f]; + _f = option[0].split(" "); + for (_g = 0, _h = _f.length; _g < _h; _g++) { + part = _f[_g]; !grammar[part] ? tokens.push(part) : null; } name === "Root" ? (option[1] = "return " + option[1]) : null; diff --git a/lib/nodes.js b/lib/nodes.js index 8172d196..51b22bfe 100644 --- a/lib/nodes.js +++ b/lib/nodes.js @@ -28,9 +28,9 @@ }; // Trim out all falsy values from an array. compact = function compact(array) { - var _a, _b, _c, item; + var _a, _b, _c, _d, item; _a = []; _b = array; - for (_c = 0; _c < _b.length; _c++) { + for (_c = 0, _d = _b.length; _c < _d; _c++) { item = _b[_c]; if (item) { _a.push(item); @@ -40,10 +40,10 @@ }; // Return a completely flattened version of an array. flatten = function flatten(array) { - var _a, _b, item, memo; + var _a, _b, _c, item, memo; memo = []; _a = array; - for (_b = 0; _b < _a.length; _b++) { + for (_b = 0, _c = _a.length; _b < _c; _b++) { item = _a[_b]; item instanceof Array ? (memo = memo.concat(item)) : memo.push(item); } @@ -128,16 +128,16 @@ var _a, _b, _c, _d, i, idt; idt = (this.indent || ''); _c = 0; _d = (tabs || 0); - for (_b = 0, i=_c; (_c <= _d ? i < _d : i > _d); (_c <= _d ? i += 1 : i -= 1), _b++) { + for (_b = 0, i = _c; (_c <= _d ? i < _d : i > _d); (_c <= _d ? i += 1 : i -= 1), _b++) { idt += TAB; } return idt; }; // Does this node, or any of its children, contain a node of a certain kind? BaseNode.prototype.contains = function contains(block) { - var _a, _b, node; + var _a, _b, _c, node; _a = this.children; - for (_b = 0; _b < _a.length; _b++) { + for (_b = 0, _c = _a.length; _b < _c; _b++) { node = _a[_b]; if (block(node)) { return true; @@ -150,11 +150,11 @@ }; // toString representation of the node, for inspecting the parse tree. BaseNode.prototype.toString = function toString(idt) { - var _a, _b, _c, child; + var _a, _b, _c, _d, child; idt = idt || ''; return '\n' + idt + this.type + (function() { _a = []; _b = this.children; - for (_c = 0; _c < _b.length; _c++) { + for (_c = 0, _d = _b.length; _c < _d; _c++) { child = _b[_c]; _a.push(child.toString(idt + TAB)); } @@ -216,10 +216,10 @@ }, // Compile each expression in the Expressions body. compile_node: function compile_node(o) { - var _a, _b, _c, node; + var _a, _b, _c, _d, node; return (function() { _a = []; _b = this.expressions; - for (_c = 0; _c < _b.length; _c++) { + for (_c = 0, _d = _b.length; _c < _d; _c++) { node = _b[_c]; _a.push(this.compile_expression(node, merge(o))); } @@ -365,7 +365,7 @@ return this.base.is_statement && this.base.is_statement() && !this.has_properties(); }, compile_node: function compile_node(o) { - var _a, _b, baseline, complete, only, op, part, prop, props, soaked, temp; + var _a, _b, _c, baseline, complete, only, op, part, prop, props, soaked, temp; soaked = false; only = del(o, 'only_first'); op = del(o, 'operation'); @@ -376,7 +376,7 @@ } complete = (this.last = baseline); _a = props; - for (_b = 0; _b < _a.length; _b++) { + for (_b = 0, _c = _a.length; _b < _c; _b++) { prop = _a[_b]; this.source = baseline; if (prop.soak_node) { @@ -430,13 +430,13 @@ }, // Compile a vanilla function call. compile_node: function compile_node(o) { - var _a, _b, _c, arg, args; + var _a, _b, _c, _d, arg, args; if (this.args[this.args.length - 1] instanceof SplatNode) { return this.compile_splat(o); } args = (function() { _a = []; _b = this.args; - for (_c = 0; _c < _b.length; _c++) { + for (_c = 0, _d = _b.length; _c < _d; _c++) { arg = _b[_c]; _a.push(arg.compile(o)); } @@ -457,12 +457,12 @@ }, // Compile a function call being passed variable arguments. compile_splat: function compile_splat(o) { - var _a, _b, arg, args, code, i, meth, obj; + var _a, _b, _c, arg, args, code, i, meth, obj; meth = this.variable.compile(o); obj = this.variable.source || 'this'; args = (function() { _a = []; _b = this.args; - for (i = 0; i < _b.length; i++) { + for (i = 0, _c = _b.length; i < _c; i++) { arg = _b[i]; _a.push((function() { code = arg.compile(o); @@ -552,7 +552,7 @@ } idx = del(o, 'index'); step = del(o, 'step'); - vars = idx + '=' + this.from_var; + vars = idx + ' = ' + this.from_var; step = step ? step.compile(o) : '1'; equals = this.exclusive ? '' : '='; intro = '(' + this.from_var + ' <= ' + this.to_var + ' ? ' + idx; @@ -602,11 +602,11 @@ // AssignNodes get interleaved correctly, with no trailing commas or // commas affixed to comments. TODO: Extract this and add it to ArrayNode. compile_node: function compile_node(o) { - var _a, _b, _c, _d, _e, i, indent, inner, join, last_noncom, non_comments, prop, props; + var _a, _b, _c, _d, _e, _f, _g, i, indent, inner, join, last_noncom, non_comments, prop, props; o.indent = this.idt(1); non_comments = (function() { _a = []; _b = this.properties; - for (_c = 0; _c < _b.length; _c++) { + for (_c = 0, _d = _b.length; _c < _d; _c++) { prop = _b[_c]; if (!(prop instanceof CommentNode)) { _a.push(prop); @@ -616,10 +616,10 @@ }).call(this); last_noncom = non_comments[non_comments.length - 1]; props = (function() { - _d = []; _e = this.properties; - for (i = 0; i < _e.length; i++) { - prop = _e[i]; - _d.push((function() { + _e = []; _f = this.properties; + for (i = 0, _g = _f.length; i < _g; i++) { + prop = _f[i]; + _e.push((function() { join = ",\n"; if ((prop === last_noncom) || (prop instanceof CommentNode)) { join = "\n"; @@ -631,7 +631,7 @@ return indent + prop.compile(o) + join; }).call(this)); } - return _d; + return _e; }).call(this); props = props.join(''); inner = props ? '\n' + props + '\n' + this.idt() : ''; @@ -646,11 +646,11 @@ return this; }, compile_node: function compile_node(o) { - var _a, _b, code, ending, i, obj, objects; + var _a, _b, _c, code, ending, i, obj, objects; o.indent = this.idt(1); objects = (function() { _a = []; _b = this.objects; - for (i = 0; i < _b.length; i++) { + for (i = 0, _c = _b.length; i < _c; i++) { obj = _b[i]; _a.push((function() { code = obj.compile(o); @@ -756,20 +756,20 @@ // object literals to a value. Peeks at their properties to assign inner names. // See: http://wiki.ecmascript.org/doku.php?id=harmony:destructuring compile_pattern_match: function compile_pattern_match(o) { - var _a, _b, access_class, assigns, code, i, idx, obj, val, val_var, value; + var _a, _b, _c, access_class, assigns, code, i, idx, obj, val, val_var, value; val_var = o.scope.free_variable(); value = this.value.is_statement() ? ClosureNode.wrap(this.value) : this.value; assigns = [this.idt() + val_var + ' = ' + value.compile(o) + ';']; o.top = true; o.as_statement = true; _a = this.variable.base.objects; - for (i = 0; i < _a.length; i++) { + for (i = 0, _b = _a.length; i < _b; i++) { obj = _a[i]; idx = i; if (this.variable.is_object()) { - _b = [obj.value, obj.variable.base]; - obj = _b[0]; - idx = _b[1]; + _c = [obj.value, obj.variable.base]; + obj = _c[0]; + idx = _c[1]; } access_class = this.variable.is_array() ? IndexNode : AccessorNode; if (obj instanceof SplatNode) { @@ -812,7 +812,7 @@ return this; }, compile_node: function compile_node(o) { - var _a, _b, _c, _d, _e, code, func, inner, name_part, param, params, shared_scope, splat, top; + var _a, _b, _c, _d, _e, _f, _g, code, func, inner, name_part, param, params, shared_scope, splat, top; shared_scope = del(o, 'shared_scope'); top = del(o, 'top'); o.scope = shared_scope || new Scope(o.scope, this.body, this); @@ -828,15 +828,15 @@ } params = (function() { _a = []; _b = this.params; - for (_c = 0; _c < _b.length; _c++) { + for (_c = 0, _d = _b.length; _c < _d; _c++) { param = _b[_c]; _a.push(param.compile(o)); } return _a; }).call(this); - _d = params; - for (_e = 0; _e < _d.length; _e++) { - param = _d[_e]; + _e = params; + for (_f = 0, _g = _e.length; _f < _g; _f++) { + param = _e[_f]; (o.scope.parameter(param)); } code = this.body.expressions.length ? '\n' + this.body.compile_with_declarations(o) + '\n' : ''; @@ -855,12 +855,12 @@ return true; }, toString: function toString(idt) { - var _a, _b, _c, child, children; + var _a, _b, _c, _d, child, children; idt = idt || ''; children = flatten([this.params, this.body.expressions]); return '\n' + idt + this.type + (function() { _a = []; _b = children; - for (_c = 0; _c < _b.length; _c++) { + for (_c = 0, _d = _b.length; _c < _d; _c++) { child = _b[_c]; _a.push(child.toString(idt + TAB)); } @@ -1129,7 +1129,7 @@ return true; }, compile_node: function compile_node(o) { - var body, body_dent, close, for_part, index, index_found, index_var, ivar, name, name_found, range, return_result, rvar, scope, set_result, source, source_part, step_part, svar, top_level, var_part, vars; + var body, body_dent, close, for_part, index, index_found, index_var, ivar, lvar, name, name_found, range, return_result, rvar, scope, set_result, source, source_part, step_part, svar, top_level, var_part, vars; top_level = del(o, 'top') && !o.returns; range = this.source instanceof ValueNode && this.source.base instanceof RangeNode && !this.source.properties.length; source = range ? this.source.base : this.source; @@ -1156,11 +1156,14 @@ } else { index_var = null; source_part = svar + ' = ' + this.source.compile(o) + ';\n' + this.idt(); - step_part = this.step ? ivar + ' += ' + this.step.compile(o) : ivar + '++'; - for_part = ivar + ' = 0; ' + ivar + ' < ' + svar + '.length; ' + step_part; if (name) { var_part = body_dent + name + ' = ' + svar + '[' + ivar + '];\n'; } + if (!this.object) { + lvar = scope.free_variable(); + step_part = this.step ? ivar + ' += ' + this.step.compile(o) : ivar + '++'; + for_part = ivar + ' = 0, ' + lvar + ' = ' + svar + '.length; ' + ivar + ' < ' + lvar + '; ' + step_part; + } } set_result = rvar ? this.idt() + rvar + ' = []; ' : this.idt(); return_result = rvar || ''; @@ -1237,7 +1240,7 @@ }, // Rewrite a chain of IfNodes with their switch condition for equality. rewrite_switch: function rewrite_switch(o) { - var _a, _b, assigner, cond, i, variable; + var _a, _b, _c, assigner, cond, i, variable; assigner = this.switcher; if (!(this.switcher.unwrap() instanceof LiteralNode)) { variable = new LiteralNode(o.scope.free_variable()); @@ -1247,7 +1250,7 @@ this.condition = (function() { if (this.multiple) { _a = []; _b = this.condition; - for (i = 0; i < _b.length; i++) { + for (i = 0, _c = _b.length; i < _c; i++) { cond = _b[i]; _a.push(new OpNode('is', (i === 0 ? assigner : this.switcher), cond)); } @@ -1283,10 +1286,10 @@ return this.statement = this.statement || !!(this.comment || this.tags.statement || this.body.is_statement() || (this.else_body && this.else_body.is_statement())); }, compile_condition: function compile_condition(o) { - var _a, _b, _c, cond; + var _a, _b, _c, _d, cond; return (function() { _a = []; _b = flatten([this.condition]); - for (_c = 0; _c < _b.length; _c++) { + for (_c = 0, _d = _b.length; _c < _d; _c++) { cond = _b[_c]; _a.push(cond.compile(o)); } diff --git a/lib/optparse.js b/lib/optparse.js index afdb665e..7656dd02 100755 --- a/lib/optparse.js +++ b/lib/optparse.js @@ -12,7 +12,7 @@ // specified options, and returning it. options.arguments will be an array // containing the remaning non-option arguments. op.prototype.parse = function parse(args) { - var _a, _b, arg, is_option, matched_rule, options, rule; + var _a, _b, _c, arg, is_option, matched_rule, options, rule; arguments = Array.prototype.slice.call(arguments, 0); options = { arguments: [] @@ -22,7 +22,7 @@ is_option = !!(arg.match(LONG_FLAG) || arg.match(SHORT_FLAG)); matched_rule = false; _a = this.rules; - for (_b = 0; _b < _a.length; _b++) { + for (_b = 0, _c = _a.length; _b < _c; _b++) { rule = _a[_b]; if (rule.letter === arg || rule.flag === arg) { options[rule.name] = rule.has_argument ? args.shift() : true; @@ -41,21 +41,21 @@ }; // Return the help text for this OptionParser, for --help and such. op.prototype.help = function help() { - var _a, _b, _c, _d, _e, _f, _g, i, let_part, lines, rule, spaces; + var _a, _b, _c, _d, _e, _f, _g, _h, i, let_part, lines, rule, spaces; lines = ['Available options:']; if (this.banner) { lines.unshift(this.banner + '\n'); } _a = this.rules; - for (_b = 0; _b < _a.length; _b++) { + for (_b = 0, _c = _a.length; _b < _c; _b++) { rule = _a[_b]; spaces = 15 - rule.flag.length; 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(' '); + _d = []; _g = 0; _h = spaces; + for (_f = 0, i = _g; (_g <= _h ? i <= _h : i >= _h); (_g <= _h ? i += 1 : i -= 1), _f++) { + _d.push(' '); } - return _c; + return _d; }).call(this).join('') : ''; let_part = rule.letter ? rule.letter + ', ' : ' '; lines.push(' ' + let_part + rule.flag + spaces + rule.description); @@ -70,9 +70,9 @@ // Build rules from a list of valid switch tuples in the form: // [letter-flag, long-flag, help], or [long-flag, help]. build_rules = function build_rules(rules) { - var _a, _b, _c, tuple; + var _a, _b, _c, _d, tuple; _a = []; _b = rules; - for (_c = 0; _c < _b.length; _c++) { + for (_c = 0, _d = _b.length; _c < _d; _c++) { tuple = _b[_c]; _a.push((function() { if (tuple.length < 3) { @@ -98,16 +98,16 @@ }; // Normalize arguments by expanding merged flags into multiple flags. normalize_arguments = function normalize_arguments(args) { - var _a, _b, _c, _d, arg, l, match, result; + var _a, _b, _c, _d, _e, _f, arg, l, match, result; args = args.slice(0); result = []; _a = args; - for (_b = 0; _b < _a.length; _b++) { + for (_b = 0, _c = _a.length; _b < _c; _b++) { arg = _a[_b]; if ((match = arg.match(MULTI_FLAG))) { - _c = match[1].split(''); - for (_d = 0; _d < _c.length; _d++) { - l = _c[_d]; + _d = match[1].split(''); + for (_e = 0, _f = _d.length; _e < _f; _e++) { + l = _d[_e]; result.push('-' + l); } } else { diff --git a/lib/rewriter.js b/lib/rewriter.js index ca9c76a9..5a6cc4e1 100644 --- a/lib/rewriter.js +++ b/lib/rewriter.js @@ -1,5 +1,5 @@ (function(){ - var BALANCED_PAIRS, EXPRESSION_CLOSE, EXPRESSION_START, EXPRESSION_TAIL, IMPLICIT_BLOCK, IMPLICIT_CALL, IMPLICIT_END, IMPLICIT_FUNC, INVERSES, SINGLE_CLOSERS, SINGLE_LINERS, _a, _b, _c, _d, _e, _f, _g, _h, pair, re; + var BALANCED_PAIRS, EXPRESSION_CLOSE, EXPRESSION_START, EXPRESSION_TAIL, IMPLICIT_BLOCK, IMPLICIT_CALL, IMPLICIT_END, IMPLICIT_FUNC, INVERSES, SINGLE_CLOSERS, SINGLE_LINERS, _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, pair, re; var __hasProp = Object.prototype.hasOwnProperty; if (!((typeof process !== "undefined" && process !== null))) { this.exports = this; @@ -13,7 +13,7 @@ // Tokens that signal the start of a balanced pair. EXPRESSION_START = (function() { _a = []; _b = BALANCED_PAIRS; - for (_c = 0; _c < _b.length; _c++) { + for (_c = 0, _d = _b.length; _c < _d; _c++) { pair = _b[_c]; _a.push(pair[0]); } @@ -21,12 +21,12 @@ }).call(this); // Tokens that signal the end of a balanced pair. EXPRESSION_TAIL = (function() { - _d = []; _e = BALANCED_PAIRS; - for (_f = 0; _f < _e.length; _f++) { - pair = _e[_f]; - _d.push(pair[1]); + _e = []; _f = BALANCED_PAIRS; + for (_g = 0, _h = _f.length; _g < _h; _g++) { + pair = _f[_g]; + _e.push(pair[1]); } - return _d; + return _e; }).call(this); // Tokens that indicate the close of a clause of an expression. EXPRESSION_CLOSE = ['CATCH', 'WHEN', 'ELSE', 'FINALLY'].concat(EXPRESSION_TAIL); @@ -37,9 +37,9 @@ IMPLICIT_CALL = ['IDENTIFIER', 'NUMBER', 'STRING', 'JS', 'REGEX', 'NEW', 'PARAM_START', 'TRY', 'DELETE', 'TYPEOF', 'SWITCH', 'TRUE', 'FALSE', 'YES', 'NO', 'ON', 'OFF', '!', '!!', 'NOT', '@', '->', '=>', '[', '(', '{']; // The inverse mappings of token pairs we're trying to fix up. INVERSES = {}; - _g = BALANCED_PAIRS; - for (_h = 0; _h < _g.length; _h++) { - pair = _g[_h]; + _i = BALANCED_PAIRS; + for (_j = 0, _k = _i.length; _j < _k; _j++) { + pair = _i[_j]; INVERSES[pair[0]] = pair[1]; INVERSES[pair[1]] = pair[0]; } @@ -156,23 +156,23 @@ brackets = [0]; return this.scan_tokens((function(__this) { var __func = function(prev, token, post, i) { - var _i; - if ((_i = token[0]) === 'CALL_START') { + var _l; + if ((_l = token[0]) === 'CALL_START') { parens.push(0); - } else if (_i === 'INDEX_START') { + } else if (_l === 'INDEX_START') { brackets.push(0); - } else if (_i === '(') { + } else if (_l === '(') { parens[parens.length - 1] += 1; - } else if (_i === '[') { + } else if (_l === '[') { brackets[brackets.length - 1] += 1; - } else if (_i === ')') { + } else if (_l === ')') { if (parens[parens.length - 1] === 0) { parens.pop(); token[0] = 'CALL_END'; } else { parens[parens.length - 1] -= 1; } - } else if (_i === ']') { + } else if (_l === ']') { if (brackets[brackets.length - 1] === 0) { brackets.pop(); token[0] = 'INDEX_END'; @@ -195,7 +195,7 @@ stack = [0]; return this.scan_tokens((function(__this) { var __func = function(prev, token, post, i) { - var _i, _j, _k, _l, idx, last, size, stack_pointer, tag, tmp; + var _l, _m, _n, _o, idx, last, size, stack_pointer, tag, tmp; tag = token[0]; if (tag === 'INDENT') { stack.push(0); @@ -211,8 +211,8 @@ if (stack[stack.length - 1] > 0 || tag === 'INDENT') { idx = tag === 'OUTDENT' ? i + 1 : i; stack_pointer = tag === 'INDENT' ? 2 : 1; - _k = 0; _l = stack[stack.length - stack_pointer]; - for (_j = 0, tmp=_k; (_k <= _l ? tmp < _l : tmp > _l); (_k <= _l ? tmp += 1 : tmp -= 1), _j++) { + _n = 0; _o = stack[stack.length - stack_pointer]; + for (_m = 0, tmp = _n; (_n <= _o ? tmp < _o : tmp > _o); (_n <= _o ? tmp += 1 : tmp -= 1), _m++) { this.tokens.splice(idx, 0, ['CALL_END', ')', token[2]]); } size = stack[stack.length - stack_pointer] + 1; @@ -276,17 +276,17 @@ // Ensure that all listed pairs of tokens are correctly balanced throughout // the course of the token stream. re.prototype.ensure_balance = function ensure_balance(pairs) { - var _i, _j, key, levels, unclosed, value; + var _l, _m, key, levels, unclosed, value; levels = {}; this.scan_tokens((function(__this) { var __func = function(prev, token, post, i) { - var _i, _j, _k, close, open; - _i = pairs; - for (_j = 0; _j < _i.length; _j++) { - pair = _i[_j]; - _k = pair; - open = _k[0]; - close = _k[1]; + var _l, _m, _n, _o, close, open; + _l = pairs; + for (_m = 0, _n = _l.length; _m < _n; _m++) { + pair = _l[_m]; + _o = pair; + open = _o[0]; + close = _o[1]; levels[open] = levels[open] || 0; if (token[0] === open) { levels[open] += 1; @@ -305,14 +305,14 @@ }); })(this)); unclosed = (function() { - _i = []; _j = levels; - for (key in _j) { if (__hasProp.call(_j, key)) { - value = _j[key]; + _l = []; _m = levels; + for (key in _m) { if (__hasProp.call(_m, key)) { + value = _m[key]; if (value > 0) { - _i.push(key); + _l.push(key); } }} - return _i; + return _l; }).call(this); if (unclosed.length) { throw new Error("unclosed " + unclosed[0]); @@ -332,12 +332,12 @@ // up balanced in the end. // re.prototype.rewrite_closing_parens = function rewrite_closing_parens() { - var _i, debt, key, stack, val; + var _l, debt, key, stack, val; stack = []; debt = {}; - _i = INVERSES; - for (key in _i) { if (__hasProp.call(_i, key)) { - val = _i[key]; + _l = INVERSES; + for (key in _l) { if (__hasProp.call(_l, key)) { + val = _l[key]; ((debt[key] = 0)); }} return this.scan_tokens((function(__this) { diff --git a/src/nodes.coffee b/src/nodes.coffee index 87425ead..6a813355 100644 --- a/src/nodes.coffee +++ b/src/nodes.coffee @@ -447,7 +447,7 @@ RangeNode: exports.RangeNode: inherit BaseNode, { return @compile_array(o) unless o.index idx: del o, 'index' step: del o, 'step' - vars: idx + '=' + @from_var + vars: idx + ' = ' + @from_var step: if step then step.compile(o) else '1' equals: if @exclusive then '' else '=' intro: '(' + @from_var + ' <= ' + @to_var + ' ? ' + idx @@ -922,9 +922,11 @@ ForNode: exports.ForNode: inherit BaseNode, { else index_var: null source_part: svar + ' = ' + @source.compile(o) + ';\n' + @idt() - step_part: if @step then ivar + ' += ' + @step.compile(o) else ivar + '++' - for_part: ivar + ' = 0; ' + ivar + ' < ' + svar + '.length; ' + step_part var_part: body_dent + name + ' = ' + svar + '[' + ivar + '];\n' if name + if not @object + lvar: scope.free_variable() + step_part: if @step then ivar + ' += ' + @step.compile(o) else ivar + '++' + for_part: ivar + ' = 0, ' + lvar + ' = ' + svar + '.length; ' + ivar + ' < ' + lvar + '; ' + step_part set_result: if rvar then @idt() + rvar + ' = []; ' else @idt() return_result: rvar or '' body: ClosureNode.wrap(body, true) if top_level and @contains (n) -> n instanceof CodeNode