merging the range-killer to master

This commit is contained in:
Jeremy Ashkenas
2010-10-21 21:27:45 -04:00
23 changed files with 639 additions and 1035 deletions

View File

@@ -25,16 +25,16 @@
return xhr.send(null);
};
runScripts = function() {
var _i, _j, _len, _ref, script;
for (_i = 0, _len = (_ref = document.getElementsByTagName('script')).length; _i < _len; _i++) {
(function() {
var script = _ref[_i];
_j = script;
return script.type === 'text/coffeescript' ? script.src ? CoffeeScript.load(script.src) : setTimeout(function() {
return CoffeeScript.run(script.innerHTML);
}) : undefined;
})();
script = _j;
var _i, _len, _ref, script;
for (_i = 0, _len = (_ref = document.getElementsByTagName('script')).length; _i < _len; ++_i) {
script = _ref[_i];
if (script.type === 'text/coffeescript') {
if (script.src) {
CoffeeScript.load(script.src);
} else {
CoffeeScript.run(script.innerHTML);
}
}
}
return null;
};

View File

@@ -47,7 +47,7 @@
}
options = oparse.parse(args);
_result = [];
for (_i = 0, _len = (_ref = options.arguments).length; _i < _len; _i++) {
for (_i = 0, _len = (_ref = options.arguments).length; _i < _len; ++_i) {
arg = _ref[_i];
_result.push(invoke(arg));
}

View File

@@ -48,43 +48,39 @@
return compileScripts();
};
compileScripts = function() {
var _i, _j, _len, _ref2, _result, base, compile, source;
var _i, _len, _ref2, _result, base, compile, source;
_result = [];
for (_i = 0, _len = (_ref2 = sources).length; _i < _len; _i++) {
(function() {
var source = _ref2[_i];
_j = source;
return _result.push((function() {
base = path.join(source);
compile = function(source, topLevel) {
return path.exists(source, function(exists) {
if (!exists) {
throw new Error("File not found: " + source);
for (_i = 0, _len = (_ref2 = sources).length; _i < _len; ++_i) {
source = _ref2[_i];
_result.push((function() {
base = path.join(source);
compile = function(source, topLevel) {
return path.exists(source, function(exists) {
if (!exists) {
throw new Error("File not found: " + source);
}
return fs.stat(source, function(err, stats) {
if (stats.isDirectory()) {
return fs.readdir(source, function(err, files) {
var _j, _len2, _result2, file;
_result2 = [];
for (_j = 0, _len2 = files.length; _j < _len2; ++_j) {
file = files[_j];
_result2.push(compile(path.join(source, file)));
}
return _result2;
});
} else if (topLevel || path.extname(source) === '.coffee') {
fs.readFile(source, function(err, code) {
return compileScript(source, code.toString(), base);
});
return opts.watch ? watch(source, base) : undefined;
}
return fs.stat(source, function(err, stats) {
if (stats.isDirectory()) {
return fs.readdir(source, function(err, files) {
var _k, _len2, _result2, file;
_result2 = [];
for (_k = 0, _len2 = files.length; _k < _len2; _k++) {
file = files[_k];
_result2.push(compile(path.join(source, file)));
}
return _result2;
});
} else if (topLevel || path.extname(source) === '.coffee') {
fs.readFile(source, function(err, code) {
return compileScript(source, code.toString(), base);
});
return opts.watch ? watch(source, base) : undefined;
}
});
});
};
return compile(source, true);
})());
})();
source = _j;
});
};
return compile(source, true);
})());
}
return _result;
};
@@ -93,7 +89,7 @@
o = opts;
options = compileOptions(file);
if (o.require) {
for (_i = 0, _len = (_ref2 = o.require).length; _i < _len; _i++) {
for (_i = 0, _len = (_ref2 = o.require).length; _i < _len; ++_i) {
req = _ref2[_i];
require(helpers.starts(req, '.') ? fs.realpathSync(req) : req);
}
@@ -190,7 +186,7 @@
var _i, _len, _ref2, _result, strings, tag, token, value;
strings = (function() {
_result = [];
for (_i = 0, _len = tokens.length; _i < _len; _i++) {
for (_i = 0, _len = tokens.length; _i < _len; ++_i) {
token = tokens[_i];
_result.push((function() {
_ref2 = [token[0], token[1].toString().replace(/\n/, '\\n')], tag = _ref2[0], value = _ref2[1];

View File

@@ -1,6 +1,5 @@
(function() {
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*\}/;
o = function(patternString, action, options) {
@@ -11,7 +10,7 @@
}
action = (match = unwrap.exec(action)) ? match[1] : "(" + action + "())";
action = action.replace(/\bnew /g, '$&yy.');
action = action.replace(/\bExpressions\.wrap\b/g, 'yy.$&');
action = action.replace(/\b(?:Expressions\.wrap|extend)\b/g, 'yy.$&');
return [patternString, "$$ = " + action + ";", options];
};
grammar = {
@@ -78,17 +77,17 @@
})
],
AssignObj: [
o("Identifier", function() {
o('Identifier', function() {
return new Value($1);
}), o("AlphaNumeric"), o("ThisProperty"), o("Identifier : Expression", function() {
}), o('AlphaNumeric'), o('ThisProperty'), o('Identifier : Expression', function() {
return new Assign(new Value($1), $3, 'object');
}), o("AlphaNumeric : Expression", function() {
}), o('AlphaNumeric : Expression', function() {
return new Assign(new Value($1), $3, 'object');
}), o("Identifier : INDENT Expression OUTDENT", function() {
}), o('Identifier : INDENT Expression OUTDENT', function() {
return new Assign(new Value($1), $4, 'object');
}), o("AlphaNumeric : INDENT Expression OUTDENT", function() {
}), o('AlphaNumeric : INDENT Expression OUTDENT', function() {
return new Assign(new Value($1), $4, 'object');
}), o("Comment")
}), o('Comment')
],
Return: [
o("RETURN Expression", function() {
@@ -168,8 +167,6 @@
return new Value($1);
}), o("Parenthetical", function() {
return new Value($1);
}), o("Range", function() {
return new Value($1);
}), o("This")
],
Accessor: [
@@ -188,12 +185,14 @@
Index: [
o("INDEX_START Expression INDEX_END", function() {
return new Index($2);
}), o("INDEX_SOAK Index", function() {
$2.soakNode = true;
return $2;
}), o("INDEX_SOAK Index", function() {
return extend($2, {
soakNode: true
});
}), o("INDEX_PROTO Index", function() {
$2.proto = true;
return $2;
return extend($2, {
proto: true
});
})
],
Object: [
@@ -290,32 +289,11 @@
return new Value(new Literal('this'));
})
],
RangeDots: [
o("..", function() {
return 'inclusive';
}), o("...", function() {
return 'exclusive';
})
],
ThisProperty: [
o("@ Identifier", function() {
return new Value(new Literal('this'), [new Accessor($2)], 'this');
})
],
Range: [
o("[ Expression RangeDots Expression ]", function() {
return new Range($2, $4, $3);
})
],
Slice: [
o("INDEX_START Expression RangeDots Expression INDEX_END", function() {
return new Range($2, $4, $3);
}), o("INDEX_START Expression RangeDots INDEX_END", function() {
return new Range($2, null, $3);
}), o("INDEX_START RangeDots Expression INDEX_END", function() {
return new Range(null, $3, $2);
})
],
Array: [
o("[ ]", function() {
return new ArrayLiteral([]);
@@ -405,81 +383,37 @@
})
],
For: [
o("Statement ForBody", function() {
return new For($1, $2, $2.vars[0], $2.vars[1]);
}), o("Expression ForBody", function() {
return new For($1, $2, $2.vars[0], $2.vars[1]);
}), o("ForBody Block", function() {
return new For($2, $1, $1.vars[0], $1.vars[1]);
})
],
ForBody: [
o("FOR Range", function() {
return {
source: new Value($2),
vars: []
};
}), o("ForStart ForSource", function() {
$2.raw = $1.raw;
$2.vars = $1;
return $2;
})
],
ForStart: [
o("FOR ForVariables", function() {
return $2;
}), o("FOR ALL ForVariables", function() {
$3.raw = true;
return $3;
o('Statement ForBody', function() {
return new For($1, $2);
}), o('Expression ForBody', function() {
return new For($1, $2);
}), o('ForBody Block', function() {
return new For($2, $1);
})
],
ForValue: [
o("Identifier"), o("Array", function() {
o('Identifier'), o('Array', function() {
return new Value($1);
}), o("Object", function() {
}), o('Object', function() {
return new Value($1);
})
],
ForVariables: [
o("ForValue", function() {
return [$1];
}), o("ForValue , ForValue", function() {
return [$1, $3];
})
],
ForSource: [
o("FORIN Expression", function() {
ForIn: [
o('FORIN Expression', function() {
return {
source: $2
};
}), o("FOROF Expression", function() {
return {
source: $2,
object: true
};
}), o("FORIN Expression WHEN Expression", function() {
}), o('FORIN Expression WHEN Expression', function() {
return {
source: $2,
guard: $4
};
}), o("FOROF Expression WHEN Expression", function() {
return {
source: $2,
guard: $4,
object: true
};
}), o("FORIN Expression BY Expression", function() {
}), o('FORIN Expression BY Expression', function() {
return {
source: $2,
step: $4
};
}), o("FORIN Expression WHEN Expression BY Expression", function() {
return {
source: $2,
guard: $4,
step: $6
};
}), o("FORIN Expression BY Expression WHEN Expression", function() {
}), o('FORIN Expression BY Expression WHEN Expression', function() {
return {
source: $2,
step: $4,
@@ -487,6 +421,80 @@
};
})
],
ForOf: [
o('FOROF Expression', function() {
return {
object: true,
source: $2
};
}), o('FOROF Expression WHEN Expression', function() {
return {
object: true,
source: $2,
guard: $4
};
})
],
ForTo: [
o('TO Expression', function() {
return {
to: $2
};
}), o('TO Expression WHEN Expression', function() {
return {
to: $2,
guard: $4
};
}), o('TO Expression BY Expression', function() {
return {
to: $2,
step: $4
};
}), o('TO Expression BY Expression WHEN Expression', function() {
return {
to: $2,
step: $4,
guard: $6
};
})
],
ForBody: [
o('FOR ForValue ForIn', function() {
return extend($3, {
name: $2
});
}), o('FOR ForValue , Identifier ForIn', function() {
return extend($5, {
name: $2,
index: $4
});
}), o('FOR Identifier ForOf', function() {
return extend($3, {
index: $2
});
}), o('FOR ForValue , ForValue ForOf', function() {
return extend($5, {
index: $2,
name: $4
});
}), o('FOR ALL Identifier ForOf', function() {
return extend($4, {
raw: true,
index: $3
});
}), o('FOR ALL Identifier , ForValue ForOf', function() {
return extend($6, {
raw: true,
index: $3,
name: $5
});
}), o('FOR Identifier FROM Expression ForTo', function() {
return extend($5, {
index: $2,
from: $4
});
})
],
Switch: [
o("SWITCH Expression INDENT Whens OUTDENT", function() {
return new Switch($2, $4);
@@ -588,17 +596,16 @@
})
]
};
operators = [["left", 'CALL_START', 'CALL_END'], ["nonassoc", '++', '--'], ["left", '?'], ["right", 'UNARY'], ["left", 'MATH'], ["left", '+', '-'], ["left", 'SHIFT'], ["left", 'COMPARE'], ["left", 'RELATION'], ["left", '==', '!='], ["left", 'LOGIC'], ["left", '.'], ["nonassoc", 'INDENT', 'OUTDENT'], ["right", 'WHEN', 'LEADING_WHEN', 'FORIN', 'FOROF', 'BY', 'THROW'], ["right", 'IF', 'UNLESS', 'ELSE', 'FOR', 'WHILE', 'UNTIL', 'LOOP', 'SUPER', 'CLASS', 'EXTENDS'], ["right", '=', ':', 'COMPOUND_ASSIGN', 'RETURN'], ["right", '->', '=>', 'UNLESS', 'POST_IF', 'POST_UNLESS']];
operators = [["left", 'CALL_START', 'CALL_END'], ["nonassoc", '++', '--'], ["left", '?'], ["right", 'UNARY'], ["left", 'MATH'], ["left", '+', '-'], ["left", 'SHIFT'], ["left", 'COMPARE'], ["left", 'RELATION'], ["left", '==', '!='], ["left", 'LOGIC'], ["left", '.'], ["nonassoc", 'INDENT', 'OUTDENT'], ["right", 'WHEN', 'LEADING_WHEN', 'FORIN', 'FOROF', 'FROM', 'TO', 'BY', 'THROW'], ["right", 'IF', 'UNLESS', 'ELSE', 'FOR', 'WHILE', 'UNTIL', 'LOOP', 'SUPER', 'CLASS', 'EXTENDS'], ["right", '=', ':', 'COMPOUND_ASSIGN', 'RETURN'], ["right", '->', '=>', 'UNLESS', 'POST_IF', 'POST_UNLESS']];
tokens = [];
for (name in grammar) {
if (!__hasProp.call(grammar, name)) continue;
alternatives = grammar[name];
grammar[name] = (function() {
_result = [];
for (_i = 0, _len = alternatives.length; _i < _len; _i++) {
for (_i = 0, _len = alternatives.length; _i < _len; ++_i) {
alt = alternatives[_i];
_result.push((function() {
for (_j = 0, _len2 = (_ref = alt[0].split(' ')).length; _j < _len2; _j++) {
for (_j = 0, _len2 = (_ref = alt[0].split(' ')).length; _j < _len2; ++_j) {
token = _ref[_j];
if (!grammar[token]) {
tokens.push(token);

View File

@@ -11,7 +11,7 @@
exports.compact = function(array) {
var _i, _len, _result, item;
_result = [];
for (_i = 0, _len = array.length; _i < _len; _i++) {
for (_i = 0, _len = array.length; _i < _len; ++_i) {
item = array[_i];
if (item) {
_result.push(item);
@@ -41,7 +41,7 @@
exports.flatten = flatten = function(array) {
var _i, _len, element, flattened;
flattened = [];
for (_i = 0, _len = array.length; _i < _len; _i++) {
for (_i = 0, _len = array.length; _i < _len; ++_i) {
element = array[_i];
if (element instanceof Array) {
flattened = flattened.concat(flatten(element));

View File

@@ -23,9 +23,9 @@
this.indent = 0;
this.indebt = 0;
this.outdebt = 0;
this.seenFor = false;
this.indents = [];
this.tokens = [];
this.seenFor = this.seenFrom = false;
while (this.chunk = code.slice(this.i)) {
this.identifierToken() || this.commentToken() || this.whitespaceToken() || this.lineToken() || this.heredocToken() || this.stringToken() || this.numberToken() || this.regexToken() || this.jsToken() || this.literalToken();
}
@@ -46,6 +46,17 @@
this.token('ALL', id);
return true;
}
if (id === 'from' && this.tag(1) === 'FOR') {
this.seenFor = false;
this.seenFrom = true;
this.token('FROM', id);
return true;
}
if (id === 'to' && this.seenFrom) {
this.seenFrom = false;
this.token('TO', id);
return true;
}
forcedIdentifier = colon || this.tagAccessor();
tag = 'IDENTIFIER';
if (__indexOf.call(JS_KEYWORDS, id) >= 0 || !forcedIdentifier && __indexOf.call(COFFEE_KEYWORDS, id) >= 0) {
@@ -217,7 +228,7 @@
tokens = [];
for (_i = 0, _len = (_ref2 = this.interpolateString(body, {
regex: true
})).length; _i < _len; _i++) {
})).length; _i < _len; ++_i) {
_ref3 = _ref2[_i], tag = _ref3[0], value = _ref3[1];
if (tag === 'TOKENS') {
tokens.push.apply(tokens, value);
@@ -469,7 +480,7 @@
if (levels.length && str.charAt(i) === '\\') {
i += 1;
} else {
for (_i = 0, _len = delimited.length; _i < _len; _i++) {
for (_i = 0, _len = delimited.length; _i < _len; ++_i) {
pair = delimited[_i];
open = pair[0], close = pair[1];
if (levels.length && starts(str, close, i) && last(levels) === pair) {
@@ -495,7 +506,7 @@
if (levels.length) {
throw SyntaxError("Unterminated " + (levels.pop()[0]) + " starting on line " + (this.line + 1));
}
return !i ? false : str.slice(0, i);
return i && str.slice(0, i);
};
Lexer.prototype.interpolateString = function(str, options) {
var _len, _ref2, _ref3, _this, expr, heredoc, i, inner, interpolated, letter, nested, pi, regex, tag, tokens, value;
@@ -545,7 +556,7 @@
if (interpolated = tokens.length > 1) {
this.token('(', '(');
}
for (i = 0, _len = tokens.length; i < _len; i++) {
for (i = 0, _len = tokens.length; i < _len; ++i) {
_ref3 = tokens[i], tag = _ref3[0], value = _ref3[1];
if (i) {
this.token('+', '+');
@@ -611,7 +622,7 @@
IDENTIFIER = /^([$A-Za-z_][$\w]*)([^\n\S]*:(?!:))?/;
NUMBER = /^0x[\da-f]+|^(?:\d+(\.\d+)?|\.\d+)(?:e[+-]?\d+)?/i;
HEREDOC = /^("""|''')([\s\S]*?)(?:\n[ \t]*)?\1/;
OPERATOR = /^(?:-[-=>]?|\+[+=]?|\.\.\.?|[*&|\/%=<>^:!?]+)/;
OPERATOR = /^(?:-[-=>]?|\+[+=]?|\.{3}|[*&|\/%=<>^:!?]+)/;
WHITESPACE = /^[ \t]+/;
COMMENT = /^###([^#][\s\S]*?)(?:###[ \t]*\n|(?:###)?$)|^(?:\s*#(?!##[^#]).*)+/;
CODE = /^[-=]>/;
@@ -625,7 +636,7 @@
HEREDOC_INDENT = /\n+([ \t]*)/g;
ASSIGNED = /^\s*@?[$A-Za-z_][$\w]*[ \t]*?[:=][^:=>]/;
NEXT_CHARACTER = /^\s*(\S?)/;
NEXT_ELLIPSIS = /^\s*\.\.\.?/;
NEXT_ELLIPSIS = /^\s*\.{3}/;
LEADING_SPACES = /^\s+/;
TRAILING_SPACES = /\s+$/;
NO_NEWLINE = /^(?:[-+*&|\/%=<>!.\\][<>=&|]*|and|or|is(?:nt)?|n(?:ot|ew)|delete|typeof|instanceof)$/;

View File

@@ -1,5 +1,5 @@
(function() {
var Accessor, ArrayLiteral, Assign, Base, Call, Class, Closure, Code, Comment, Existence, Expressions, Extends, For, IDENTIFIER, IS_STRING, If, In, Index, Literal, NO, NUMBER, ObjectLiteral, Op, Param, Parens, Push, Range, Return, SIMPLENUM, Scope, Slice, Splat, Switch, TAB, THIS, TRAILING_WHITESPACE, Throw, Try, UTILITIES, Value, While, YES, _ref, compact, del, ends, flatten, last, merge, starts, utility;
var Accessor, ArrayLiteral, Assign, Base, Call, Class, Closure, Code, Comment, Existence, Expressions, Extends, For, IDENTIFIER, IS_STRING, If, In, Index, Literal, NO, NUMBER, ObjectLiteral, Op, Param, Parens, Push, Return, SIMPLENUM, Scope, Splat, Switch, TAB, THIS, TRAILING_WHITESPACE, Throw, Try, UTILITIES, Value, While, YES, _ref, compact, del, ends, extend, flatten, last, merge, starts, utility;
var __extends = function(child, parent) {
function ctor() { this.constructor = child; }
ctor.prototype = parent.prototype;
@@ -11,7 +11,8 @@
return -1;
};
Scope = require('./scope').Scope;
_ref = require('./helpers'), compact = _ref.compact, flatten = _ref.flatten, merge = _ref.merge, del = _ref.del, starts = _ref.starts, ends = _ref.ends, last = _ref.last;
_ref = require('./helpers'), compact = _ref.compact, flatten = _ref.flatten, extend = _ref.extend, merge = _ref.merge, del = _ref.del, starts = _ref.starts, ends = _ref.ends, last = _ref.last;
exports.extend = extend;
YES = function() {
return true;
};
@@ -57,7 +58,7 @@
}
}).call(this);
if ((options != null) ? options.precompile : undefined) {
for (i = 0, _len = pair.length; i < _len; i++) {
for (i = 0, _len = pair.length; i < _len; ++i) {
node = pair[i];
(pair[i] = node.compile(o));
}
@@ -68,6 +69,16 @@
this.parenthetical = true;
return this.compile(o);
};
Base.prototype.compileLoopReference = function(o, name) {
var src, tmp;
src = tmp = this.compile(o);
if (!(NUMBER.test(src) || IDENTIFIER.test(src) && o.scope.check(src, {
immediate: true
}))) {
src = "" + (tmp = o.scope.freeVariable(name)) + " = " + src;
}
return [src, tmp];
};
Base.prototype.idt = function(tabs) {
return (this.tab || '') + Array((tabs || 0) + 1).join(TAB);
};
@@ -103,7 +114,7 @@
idt || (idt = '');
children = (function() {
_result = [];
for (_i = 0, _len = (_ref2 = this.collectChildren()).length; _i < _len; _i++) {
for (_i = 0, _len = (_ref2 = this.collectChildren()).length; _i < _len; ++_i) {
child = _ref2[_i];
_result.push(child.toString(idt + TAB));
}
@@ -117,10 +128,10 @@
if (!this.children) {
return;
}
for (_i = 0, _len = (_ref2 = this.children).length; _i < _len; _i++) {
for (_i = 0, _len = (_ref2 = this.children).length; _i < _len; ++_i) {
attr = _ref2[_i];
if (this[attr]) {
for (_j = 0, _len2 = (_ref3 = flatten([this[attr]])).length; _j < _len2; _j++) {
for (_j = 0, _len2 = (_ref3 = flatten([this[attr]])).length; _j < _len2; ++_j) {
child = _ref3[_j];
if (func(child) === false) {
return;
@@ -205,7 +216,7 @@
var _i, _len, _ref2, _result, node;
return (function() {
_result = [];
for (_i = 0, _len = (_ref2 = this.expressions).length; _i < _len; _i++) {
for (_i = 0, _len = (_ref2 = this.expressions).length; _i < _len; ++_i) {
node = _ref2[_i];
_result.push(this.compileExpression(node, merge(o)));
}
@@ -348,15 +359,12 @@
Value.prototype.isObject = function() {
return this.base instanceof ObjectLiteral && !this.properties.length;
};
Value.prototype.isSplice = function() {
return last(this.properties) instanceof Slice;
};
Value.prototype.isComplex = function() {
return this.base.isComplex() || this.hasProperties();
};
Value.prototype.isAtomic = function() {
var _i, _len, _ref2, node;
for (_i = 0, _len = (_ref2 = this.properties.concat(this.base)).length; _i < _len; _i++) {
for (_i = 0, _len = (_ref2 = this.properties.concat(this.base)).length; _i < _len; ++_i) {
node = _ref2[_i];
if (node.soakNode || node instanceof Call) {
return false;
@@ -417,7 +425,7 @@
if (props[0] instanceof Accessor && this.isSimpleNumber()) {
code = "(" + code + ")";
}
for (_i = 0, _len = props.length; _i < _len; _i++) {
for (_i = 0, _len = props.length; _i < _len; ++_i) {
prop = props[_i];
(code += prop.compile(o));
}
@@ -429,7 +437,7 @@
Array.prototype.push.apply(ifn.body.properties, this.properties);
return ifn;
}
for (i = 0, _len = (_ref2 = this.properties).length; i < _len; i++) {
for (i = 0, _len = (_ref2 = this.properties).length; i < _len; ++i) {
prop = _ref2[i];
if (prop.soakNode) {
prop.soakNode = false;
@@ -544,7 +552,7 @@
break;
}
}
for (_i = 0, _len = (_ref3 = list.reverse()).length; _i < _len; _i++) {
for (_i = 0, _len = (_ref3 = list.reverse()).length; _i < _len; ++_i) {
call = _ref3[_i];
if (ifn) {
if (call.variable instanceof Call) {
@@ -563,7 +571,7 @@
return ifn.compile(o);
}
((_ref2 = this.variable) != null) ? _ref2.tags.front = this.tags.front : undefined;
for (_i = 0, _len = (_ref3 = this.args).length; _i < _len; _i++) {
for (_i = 0, _len = (_ref3 = this.args).length; _i < _len; ++_i) {
arg = _ref3[_i];
if (arg instanceof Splat) {
return this.compileSplat(o);
@@ -571,7 +579,7 @@
}
args = (function() {
_result = [];
for (_j = 0, _len2 = (_ref4 = this.args).length; _j < _len2; _j++) {
for (_j = 0, _len2 = (_ref4 = this.args).length; _j < _len2; ++_j) {
arg = _ref4[_j];
_result.push(arg.compileBare(o));
}
@@ -663,117 +671,6 @@
};
return Index;
})();
exports.Range = (function() {
Range = (function() {
function Range(_arg, _arg2, tag) {
this.to = _arg2;
this.from = _arg;
Range.__super__.constructor.call(this);
this.exclusive = tag === 'exclusive';
this.equals = this.exclusive ? '' : '=';
return this;
};
return Range;
})();
__extends(Range, Base);
Range.prototype.children = ['from', 'to'];
Range.prototype.compileVariables = function(o) {
var _ref2, _ref3, _ref4, parts;
o = merge(o, {
top: true
});
_ref2 = this.from.compileReference(o, {
precompile: true
}), this.from = _ref2[0], this.fromVar = _ref2[1];
_ref3 = this.to.compileReference(o, {
precompile: true
}), this.to = _ref3[0], this.toVar = _ref3[1];
_ref4 = [this.fromVar.match(SIMPLENUM), this.toVar.match(SIMPLENUM)], this.fromNum = _ref4[0], this.toNum = _ref4[1];
parts = [];
if (this.from !== this.fromVar) {
parts.push(this.from);
}
return this.to !== this.toVar ? parts.push(this.to) : undefined;
};
Range.prototype.compileNode = function(o) {
var compare, idx, incr, intro, step, stepPart, vars;
this.compileVariables(o);
if (!o.index) {
return this.compileArray(o);
}
if (this.fromNum && this.toNum) {
return this.compileSimple(o);
}
idx = del(o, 'index');
step = del(o, 'step');
vars = ("" + idx + " = " + this.from) + (this.to !== this.toVar ? ", " + this.to : '');
intro = "(" + this.fromVar + " <= " + this.toVar + " ? " + idx;
compare = "" + intro + " <" + this.equals + " " + this.toVar + " : " + idx + " >" + this.equals + " " + this.toVar + ")";
stepPart = step ? step.compile(o) : '1';
incr = step ? "" + idx + " += " + stepPart : "" + intro + " += " + stepPart + " : " + idx + " -= " + stepPart + ")";
return "" + vars + "; " + compare + "; " + incr;
};
Range.prototype.compileSimple = function(o) {
var _ref2, from, idx, step, to;
_ref2 = [+this.fromNum, +this.toNum], from = _ref2[0], to = _ref2[1];
idx = del(o, 'index');
step = del(o, 'step');
step && (step = "" + idx + " += " + (step.compile(o)));
return from <= to ? "" + idx + " = " + from + "; " + idx + " <" + this.equals + " " + to + "; " + (step || ("" + idx + "++")) : "" + idx + " = " + from + "; " + idx + " >" + this.equals + " " + to + "; " + (step || ("" + idx + "--"));
};
Range.prototype.compileArray = function(o) {
var _i, _ref2, _ref3, _result, body, clause, i, idt, post, pre, range, result, vars;
if (this.fromNum && this.toNum && Math.abs(this.fromNum - this.toNum) <= 20) {
range = (function() {
_result = [];
for (var _i = _ref2 = +this.fromNum, _ref3 = +this.toNum; _ref2 <= _ref3 ? _i <= _ref3 : _i >= _ref3; _ref2 <= _ref3 ? _i += 1 : _i -= 1){ _result.push(_i); }
return _result;
}).call(this);
if (this.exclusive) {
range.pop();
}
return "[" + (range.join(', ')) + "]";
}
idt = this.idt(1);
i = o.scope.freeVariable('i');
result = o.scope.freeVariable('result');
pre = "\n" + idt + result + " = [];";
if (this.fromNum && this.toNum) {
o.index = i;
body = this.compileSimple(o);
} else {
vars = ("" + i + " = " + this.from) + (this.to !== this.toVar ? ", " + this.to : '');
clause = "" + this.fromVar + " <= " + this.toVar + " ?";
body = "var " + vars + "; " + clause + " " + i + " <" + this.equals + " " + this.toVar + " : " + i + " >" + this.equals + " " + this.toVar + "; " + clause + " " + i + " += 1 : " + i + " -= 1";
}
post = "{ " + result + ".push(" + i + "); }\n" + idt + "return " + result + ";\n" + o.indent;
return "(function() {" + pre + "\n" + idt + "for (" + body + ")" + post + "}).call(this)";
};
return Range;
})();
exports.Slice = (function() {
Slice = (function() {
function Slice(_arg) {
this.range = _arg;
Slice.__super__.constructor.call(this);
return this;
};
return Slice;
})();
__extends(Slice, Base);
Slice.prototype.children = ['range'];
Slice.prototype.compileNode = function(o) {
var from, to;
from = this.range.from ? this.range.from.compile(o) : '0';
to = this.range.to ? this.range.to.compile(o) : '';
to += !to || this.range.exclusive ? '' : ' + 1';
if (to) {
to = ', ' + to;
}
return ".slice(" + from + to + ")";
};
return Slice;
})();
exports.ObjectLiteral = (function() {
ObjectLiteral = (function() {
function ObjectLiteral(props) {
@@ -791,7 +688,7 @@
o.indent = this.idt(1);
nonComments = (function() {
_result = [];
for (_i = 0, _len = (_ref2 = this.properties).length; _i < _len; _i++) {
for (_i = 0, _len = (_ref2 = this.properties).length; _i < _len; ++_i) {
prop = _ref2[_i];
if (!(prop instanceof Comment)) {
_result.push(prop);
@@ -802,7 +699,7 @@
lastNoncom = last(nonComments);
props = (function() {
_result = [];
for (i = 0, _len = (_ref2 = this.properties).length; i < _len; i++) {
for (i = 0, _len = (_ref2 = this.properties).length; i < _len; ++i) {
prop = _ref2[i];
_result.push((function() {
join = i === this.properties.length - 1 ? '' : prop === lastNoncom || prop instanceof Comment ? '\n' : ',\n';
@@ -823,7 +720,7 @@
};
ObjectLiteral.prototype.assigns = function(name) {
var _i, _len, _ref2, prop;
for (_i = 0, _len = (_ref2 = this.properties).length; _i < _len; _i++) {
for (_i = 0, _len = (_ref2 = this.properties).length; _i < _len; ++_i) {
prop = _ref2[_i];
if (prop.assigns(name)) {
return true;
@@ -850,14 +747,14 @@
ArrayLiteral.prototype.compileNode = function(o) {
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++) {
for (_i = 0, _len = (_ref2 = this.objects).length; _i < _len; ++_i) {
obj = _ref2[_i];
if (obj instanceof Splat) {
return this.compileSplatLiteral(o);
}
}
objects = [];
for (i = 0, _len2 = (_ref3 = this.objects).length; i < _len2; i++) {
for (i = 0, _len2 = (_ref3 = this.objects).length; i < _len2; ++i) {
obj = _ref3[i];
code = obj.compileBare(o);
objects.push(obj instanceof Comment ? "\n" + code + "\n" + o.indent : i === this.objects.length - 1 ? code : code + ', ');
@@ -867,7 +764,7 @@
};
ArrayLiteral.prototype.assigns = function(name) {
var _i, _len, _ref2, obj;
for (_i = 0, _len = (_ref2 = this.objects).length; _i < _len; _i++) {
for (_i = 0, _len = (_ref2 = this.objects).length; _i < _len; ++_i) {
obj = _ref2[_i];
if (obj.assigns(name)) {
return true;
@@ -914,7 +811,7 @@
} else {
constructor = new Code([], new Expressions([new Return(new Literal('this'))]));
}
for (_i = 0, _len = (_ref2 = this.properties).length; _i < _len; _i++) {
for (_i = 0, _len = (_ref2 = this.properties).length; _i < _len; ++_i) {
prop = _ref2[_i];
pvar = prop.variable, func = prop.value;
if (pvar && pvar.base.value === 'constructor') {
@@ -996,9 +893,6 @@
if (this.variable.isArray() || this.variable.isObject()) {
return this.compilePatternMatch(o);
}
if (this.variable.isSplice()) {
return this.compileSplice(o);
}
if (ifn = If.unfoldSoak(o, this, 'variable')) {
delete o.top;
return ifn.compile(o);
@@ -1058,7 +952,7 @@
assigns.push("" + (ref = o.scope.freeVariable('ref')) + " = " + valVar);
valVar = ref;
}
for (i = 0, _len = objects.length; i < _len; i++) {
for (i = 0, _len = objects.length; i < _len; ++i) {
obj = objects[i];
idx = i;
if (isObject) {
@@ -1089,17 +983,6 @@
code = assigns.join(', ');
return top || this.parenthetical ? code : "(" + code + ")";
};
Assign.prototype.compileSplice = function(o) {
var from, name, plus, range, ref, to, val;
range = this.variable.properties.pop().range;
name = this.variable.compile(o);
plus = range.exclusive ? '' : ' + 1';
from = range.from ? range.from.compile(o) : '0';
to = range.to ? range.to.compile(o) + ' - ' + from + plus : "" + name + ".length";
ref = o.scope.freeVariable('ref');
val = this.value.compile(o);
return "([].splice.apply(" + name + ", [" + from + ", " + to + "].concat(" + ref + " = " + val + ")), " + ref + ")";
};
Assign.prototype.compileConditional = function(o) {
var _ref2, left, rite;
_ref2 = this.variable.cacheReference(o), left = _ref2[0], rite = _ref2[1];
@@ -1140,7 +1023,7 @@
delete o.globals;
splat = undefined;
params = [];
for (i = 0, _len = (_ref2 = this.params).length; i < _len; i++) {
for (i = 0, _len = (_ref2 = this.params).length; i < _len; ++i) {
param = _ref2[i];
if (splat) {
if (param.attach) {
@@ -1168,7 +1051,7 @@
o.scope.startLevel();
params = (function() {
_result = [];
for (_i = 0, _len2 = params.length; _i < _len2; _i++) {
for (_i = 0, _len2 = params.length; _i < _len2; ++_i) {
param = params[_i];
_result.push(param.compile(o));
}
@@ -1177,7 +1060,7 @@
if (!(empty || this.noReturn)) {
this.body.makeReturn();
}
for (_i = 0, _len2 = params.length; _i < _len2; _i++) {
for (_i = 0, _len2 = params.length; _i < _len2; ++_i) {
param = params[_i];
o.scope.parameter(param);
}
@@ -1258,7 +1141,7 @@
variadic = o.scope.freeVariable('result');
o.scope.assign(variadic, len + ' >= ' + this.arglength);
end = this.trailings.length ? ", " + len + " - " + this.trailings.length : undefined;
for (idx = 0, _len = (_ref2 = this.trailings).length; idx < _len; idx++) {
for (idx = 0, _len = (_ref2 = this.trailings).length; idx < _len; ++idx) {
trailing = _ref2[idx];
if (trailing.attach) {
assign = trailing.assign;
@@ -1280,7 +1163,7 @@
var _len, arg, args, code, end, i, prev;
args = [];
end = -1;
for (i = 0, _len = list.length; i < _len; i++) {
for (i = 0, _len = list.length; i < _len; ++i) {
arg = list[i];
code = arg.compile(o);
prev = args[end];
@@ -1480,7 +1363,7 @@
_ref3 = this.negated ? [' !== ', ' && '] : [' === ', ' || '], cmp = _ref3[0], cnj = _ref3[1];
tests = (function() {
_result = [];
for (i = 0, _len = (_ref4 = this.array.base.objects).length; i < _len; i++) {
for (i = 0, _len = (_ref4 = this.array.base.objects).length; i < _len; ++i) {
item = _ref4[i];
_result.push((i ? ref : sub) + cmp + item.compile(o));
}
@@ -1616,22 +1499,16 @@
})();
exports.For = (function() {
For = (function() {
function For(_arg, source, _arg2, _arg3) {
var _ref2;
this.index = _arg3;
this.name = _arg2;
function For(_arg, head) {
this.body = _arg;
For.__super__.constructor.call(this);
this.source = source.source, this.guard = source.guard, this.step = source.step;
this.raw = !!source.raw;
this.object = !!source.object;
if (this.object) {
_ref2 = [this.index, this.name], this.name = _ref2[0], this.index = _ref2[1];
}
if (this.index instanceof Value) {
if (head.index instanceof Value) {
throw SyntaxError('index cannot be a pattern matching expression');
}
this.range = this.source instanceof Value && this.source.base instanceof Range && !this.source.properties.length;
For.__super__.constructor.call(this);
extend(this, head);
if (!this.object) {
this.step || (this.step = new Literal(1));
}
this.pattern = this.name instanceof Value;
if (this.range && this.pattern) {
throw SyntaxError('cannot pattern match a range loop');
@@ -1642,7 +1519,7 @@
return For;
})();
__extends(For, Base);
For.prototype.children = ['body', 'source', 'guard'];
For.prototype.children = ['body', 'source', 'guard', 'step', 'from', 'to'];
For.prototype.topSensitive = YES;
For.prototype.isStatement = YES;
For.prototype.makeReturn = function() {
@@ -1659,16 +1536,16 @@
return '';
};
For.prototype.compileNode = function(o) {
var body, codeInBody, forPart, guardPart, idt1, index, ivar, lastLine, lvar, name, namePart, nvar, ref, resultPart, returnResult, rvar, scope, source, sourcePart, stepPart, svar, topLevel, unstepPart, varPart, vars;
topLevel = del(o, 'top') && !this.returns;
source = this.range ? this.source.base : this.source;
codeInBody = !this.body.containsPureStatement() && this.body.contains(function(node) {
return node instanceof Code;
});
var _ref2, _ref3, _ref4, _ref5, _ref6, body, cond, forPart, guardPart, idt, index, ivar, lvar, name, namePart, pvar, resultDef, resultRet, rvar, scope, sourcePart, step, svar, tail, top, tvar, varPart, vars;
scope = o.scope;
name = this.name && this.name.compile(o);
index = this.index && this.index.compile(o);
if (name && !this.pattern && (this.range || !codeInBody)) {
top = del(o, 'top') && !this.returns;
name = !this.pattern && (((_ref2 = this.name) != null) ? _ref2.compile(o) : undefined);
index = ((_ref3 = this.index) != null) ? _ref3.compile(o) : undefined;
ivar = !index ? scope.freeVariable('i') : index;
varPart = '';
body = Expressions.wrap([this.body]);
idt = this.idt(1);
if (name) {
scope.find(name, {
immediate: true
});
@@ -1678,101 +1555,73 @@
immediate: true
});
}
if (!topLevel) {
rvar = scope.freeVariable('result');
if (this.step) {
_ref4 = this.step.compileLoopReference(o, 'step'), step = _ref4[0], pvar = _ref4[1];
}
ivar = this.range ? name : index;
if (!ivar || codeInBody) {
ivar = scope.freeVariable('i');
}
if (name && !this.range && codeInBody) {
nvar = scope.freeVariable('i');
}
varPart = '';
guardPart = '';
unstepPart = '';
body = Expressions.wrap([this.body]);
idt1 = this.idt(1);
if (this.range) {
forPart = source.compile(merge(o, {
index: ivar,
step: this.step
}));
if (this.from) {
_ref5 = this.to.compileLoopReference(o, 'to'), tail = _ref5[0], tvar = _ref5[1];
vars = "" + ivar + " = " + (this.from.compile(o));
if (tail !== tvar) {
vars += ", " + tail;
}
cond = +pvar ? "" + ivar + " " + (pvar < 0 ? '>' : '<') + "= " + tvar : "" + pvar + " < 0 ? " + ivar + " >= " + tvar + " : " + ivar + " <= " + tvar;
} else {
svar = sourcePart = this.source.compile(o);
if ((name || !this.raw) && !(IDENTIFIER.test(svar) && scope.check(svar, {
immediate: true
}))) {
sourcePart = "" + (ref = scope.freeVariable('ref')) + " = " + svar;
if (!this.object) {
if (name || !this.raw) {
_ref6 = this.source.compileLoopReference(o, 'ref'), sourcePart = _ref6[0], svar = _ref6[1];
if (!(sourcePart === svar || this.object)) {
sourcePart = "(" + sourcePart + ")";
}
svar = ref;
} else {
sourcePart = svar = this.source.compile(o);
}
namePart = this.pattern ? new Assign(this.name, new Literal("" + svar + "[" + ivar + "]")).compile(merge(o, {
top: true
})) : name ? "" + name + " = " + svar + "[" + ivar + "]" : undefined;
if (!this.object) {
lvar = scope.freeVariable('len');
stepPart = this.step ? "" + ivar + " += " + (this.step.compile(o)) : "" + ivar + "++";
forPart = "" + ivar + " = 0, " + lvar + " = " + sourcePart + ".length; " + ivar + " < " + lvar + "; " + stepPart;
if (0 > pvar && (pvar | 0) === +pvar) {
vars = "" + ivar + " = " + sourcePart + ".length - 1";
cond = "" + ivar + " >= 0";
} else {
lvar = scope.freeVariable('len');
vars = "" + ivar + " = 0, " + lvar + " = " + sourcePart + ".length";
cond = "" + ivar + " < " + lvar;
}
}
}
resultPart = rvar ? "" + this.tab + rvar + " = [];\n" : '';
returnResult = this.compileReturnValue(rvar, o);
if (!topLevel) {
if (this.object) {
forPart = "" + ivar + " in " + sourcePart;
guardPart = !this.raw && ("" + idt + "if (!" + (utility('hasProp')) + ".call(" + svar + ", " + ivar + ")) continue;\n");
} else {
if (step !== pvar) {
vars += ", " + step;
}
forPart = ("" + vars + "; " + cond + "; ") + (function() {
switch (+pvar) {
case 1:
return '++' + ivar;
case -1:
return '--' + ivar;
default:
return ivar + (pvar < 0 ? ' -= ' + pvar.slice(1) : ' += ' + pvar);
}
})();
}
if (!top) {
rvar = scope.freeVariable('result');
resultDef = "" + this.tab + rvar + " = [];\n";
resultRet = this.compileReturnValue(rvar, o);
body = Push.wrap(rvar, body);
}
if (this.guard) {
body = Expressions.wrap([new If(this.guard, body)]);
}
if (codeInBody) {
if (this.range) {
body.unshift(new Literal("var " + name + " = " + ivar));
}
if (namePart) {
body.unshift(new Literal("var " + namePart));
}
if (index) {
body.unshift(new Literal("var " + index + " = " + ivar));
}
lastLine = body.expressions.pop();
if (index) {
body.push(new Assign(new Literal(ivar), new Literal(index)));
}
if (nvar) {
body.push(new Assign(new Literal(nvar), new Literal(name)));
}
body.push(lastLine);
o.indent = this.idt(1);
body = Expressions.wrap([new Literal(body.compile(o))]);
if (index) {
body.push(new Assign(this.index, new Literal(ivar)));
}
if (name) {
body.push(new Assign(this.name, new Literal(nvar || ivar)));
}
} else {
if (namePart) {
varPart = "" + idt1 + namePart + ";\n";
}
if (forPart && name === ivar) {
unstepPart = this.step ? "" + name + " -= " + (this.step.compile(o)) + ";" : "" + name + "--;";
unstepPart = ("\n" + this.tab) + unstepPart;
}
if (namePart) {
varPart = "" + idt + namePart + ";\n";
}
if (this.object) {
forPart = "" + ivar + " in " + sourcePart;
if (!this.raw) {
guardPart = "\n" + idt1 + "if (!" + (utility('hasProp')) + ".call(" + svar + ", " + ivar + ")) continue;";
}
}
body = body.compile(merge(o, {
indent: idt1,
return "" + (resultDef || '') + this.tab + "for (" + forPart + ") {\n" + (guardPart || '') + varPart + (body.compile(merge(o, {
indent: idt,
top: true
}));
vars = this.range ? name : "" + name + ", " + ivar;
return "" + resultPart + this.tab + "for (" + forPart + ") {" + guardPart + "\n" + varPart + body + "\n" + this.tab + "}" + unstepPart + returnResult;
}))) + "\n" + this.tab + "}" + (resultRet || '');
};
return For;
})();
@@ -1792,7 +1641,7 @@
Switch.prototype.isStatement = YES;
Switch.prototype.makeReturn = function() {
var _i, _len, _ref2, pair;
for (_i = 0, _len = (_ref2 = this.cases).length; _i < _len; _i++) {
for (_i = 0, _len = (_ref2 = this.cases).length; _i < _len; ++_i) {
pair = _ref2[_i];
pair[1].makeReturn();
}
@@ -1807,9 +1656,9 @@
idt2 = o.indent = this.idt(2);
o.top = true;
code = "" + this.tab + "switch (" + ((((_ref2 = this.subject) != null) ? _ref2.compile(o) : undefined) || true) + ") {";
for (_i = 0, _len = (_ref3 = this.cases).length; _i < _len; _i++) {
for (_i = 0, _len = (_ref3 = this.cases).length; _i < _len; ++_i) {
_ref4 = _ref3[_i], conditions = _ref4[0], block = _ref4[1];
for (_j = 0, _len2 = (_ref5 = flatten([conditions])).length; _j < _len2; _j++) {
for (_j = 0, _len2 = (_ref5 = flatten([conditions])).length; _j < _len2; ++_j) {
condition = _ref5[_j];
if (!this.subject) {
condition = condition.invert().invert();
@@ -1968,7 +1817,7 @@
TAB = ' ';
TRAILING_WHITESPACE = /[ \t]+$/gm;
IDENTIFIER = /^[$A-Za-z_][$\w]*$/;
NUMBER = /^0x[\da-f]+$|^(?:\d+(\.\d+)?|\.\d+)(?:e[+-]?\d+)?$/i;
NUMBER = /^-?(?:0x[\da-f]+|(?:\d+(\.\d+)?|\.\d+)(?:e[+-]?\d+)?)$/i;
SIMPLENUM = /^[+-]?\d+$/;
IS_STRING = /^['"]/;
utility = function(name) {

View File

@@ -15,11 +15,11 @@
arguments: []
};
args = normalizeArguments(args);
for (i = 0, _len = args.length; i < _len; i++) {
for (i = 0, _len = args.length; i < _len; ++i) {
arg = args[i];
isOption = !!(arg.match(LONG_FLAG) || arg.match(SHORT_FLAG));
matchedRule = false;
for (_i = 0, _len2 = (_ref = this.rules).length; _i < _len2; _i++) {
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;
@@ -44,7 +44,7 @@
if (this.banner) {
lines.unshift("" + this.banner + "\n");
}
for (_i = 0, _len = (_ref = this.rules).length; _i < _len; _i++) {
for (_i = 0, _len = (_ref = this.rules).length; _i < _len; ++_i) {
rule = _ref[_i];
spaces = 15 - rule.longFlag.length;
spaces = spaces > 0 ? Array(spaces + 1).join(' ') : '';
@@ -62,7 +62,7 @@
buildRules = function(rules) {
var _i, _len, _result, tuple;
_result = [];
for (_i = 0, _len = rules.length; _i < _len; _i++) {
for (_i = 0, _len = rules.length; _i < _len; ++_i) {
tuple = rules[_i];
_result.push((function() {
if (tuple.length < 3) {
@@ -91,10 +91,10 @@
var _i, _j, _len, _len2, _ref, arg, l, match, result;
args = args.slice(0);
result = [];
for (_i = 0, _len = args.length; _i < _len; _i++) {
for (_i = 0, _len = args.length; _i < _len; ++_i) {
arg = args[_i];
if (match = arg.match(MULTI_FLAG)) {
for (_j = 0, _len2 = (_ref = match[1].split('')).length; _j < _len2; _j++) {
for (_j = 0, _len2 = (_ref = match[1].split('')).length; _j < _len2; ++_j) {
l = _ref[_j];
result.push('-' + l);
}

File diff suppressed because one or more lines are too long

View File

@@ -87,7 +87,7 @@
};
exports.Rewriter.prototype.removeLeadingNewlines = function() {
var _len, _ref, i, tag;
for (i = 0, _len = (_ref = this.tokens).length; i < _len; i++) {
for (i = 0, _len = (_ref = this.tokens).length; i < _len; ++i) {
tag = _ref[i][0];
if (tag !== 'TERMINATOR') {
break;
@@ -286,7 +286,7 @@
this.scanTokens(function(token, i) {
var _i, _len, _ref, _ref2, close, open, tag;
tag = token[0];
for (_i = 0, _len = (_ref = pairs).length; _i < _len; _i++) {
for (_i = 0, _len = (_ref = pairs).length; _i < _len; ++_i) {
_ref2 = _ref[_i], open = _ref2[0], close = _ref2[1];
levels[open] |= 0;
if (tag === open) {
@@ -366,7 +366,7 @@
INVERSES = {};
EXPRESSION_START = [];
EXPRESSION_END = [];
for (_i = 0, _len = BALANCED_PAIRS.length; _i < _len; _i++) {
for (_i = 0, _len = BALANCED_PAIRS.length; _i < _len; ++_i) {
_ref = BALANCED_PAIRS[_i], left = _ref[0], rite = _ref[1];
EXPRESSION_START.push(INVERSES[rite] = left);
EXPRESSION_END.push(INVERSES[left] = rite);

View File

@@ -42,7 +42,7 @@
};
Scope.prototype.endLevel = function() {
var _i, _len, _ref2, name;
for (_i = 0, _len = (_ref2 = this.garbage.pop()).length; _i < _len; _i++) {
for (_i = 0, _len = (_ref2 = this.garbage.pop()).length; _i < _len; ++_i) {
name = _ref2[_i];
if (this.type(name) === 'var') {
this.add(name, 'reuse');
@@ -59,7 +59,7 @@
};
Scope.prototype.any = function(fn) {
var _i, _len, _ref2, v;
for (_i = 0, _len = (_ref2 = this.variables).length; _i < _len; _i++) {
for (_i = 0, _len = (_ref2 = this.variables).length; _i < _len; ++_i) {
v = _ref2[_i];
if (fn(v)) {
return true;
@@ -83,7 +83,7 @@
};
Scope.prototype.type = function(name) {
var _i, _len, _ref2, v;
for (_i = 0, _len = (_ref2 = this.variables).length; _i < _len; _i++) {
for (_i = 0, _len = (_ref2 = this.variables).length; _i < _len; ++_i) {
v = _ref2[_i];
if (v.name === name) {
return v.type;
@@ -122,7 +122,7 @@
var _i, _len, _ref2, _ref3, _result, v;
return (function() {
_result = [];
for (_i = 0, _len = (_ref2 = this.variables).length; _i < _len; _i++) {
for (_i = 0, _len = (_ref2 = this.variables).length; _i < _len; ++_i) {
v = _ref2[_i];
if ((_ref3 = v.type) === 'var' || _ref3 === 'reuse') {
_result.push(v.name);
@@ -134,7 +134,7 @@
Scope.prototype.assignedVariables = function() {
var _i, _len, _ref2, _result, v;
_result = [];
for (_i = 0, _len = (_ref2 = this.variables).length; _i < _len; _i++) {
for (_i = 0, _len = (_ref2 = this.variables).length; _i < _len; ++_i) {
v = _ref2[_i];
if (v.type.assigned) {
_result.push("" + v.name + " = " + v.type.value);