destructuring assignment no longer uses a temporary variable for simple LHS

This commit is contained in:
satyr
2010-10-11 09:17:31 +09:00
parent 2642fde0f8
commit e5fe145f80
3 changed files with 102 additions and 48 deletions

View File

@@ -30,11 +30,11 @@
return (new Rewriter).rewrite(this.tokens);
};
Lexer.prototype.identifierToken = function() {
var _ref2, colon, forcedIdentifier, id, input, match, tag;
var colon, forcedIdentifier, id, input, match, tag;
if (!(match = IDENTIFIER.exec(this.chunk))) {
return false;
}
_ref2 = match, input = _ref2[0], id = _ref2[1], colon = _ref2[2];
input = match[0], id = match[1], colon = match[2];
this.i += input.length;
if (id === 'all' && this.tag() === 'FOR') {
this.token('ALL', id);
@@ -153,11 +153,11 @@
return true;
};
Lexer.prototype.commentToken = function() {
var _ref2, comment, here, match;
var comment, here, match;
if (!(match = this.chunk.match(COMMENT))) {
return false;
}
_ref2 = match, comment = _ref2[0], here = _ref2[1];
comment = match[0], here = match[1];
this.line += count(comment, '\n');
this.i += comment.length;
if (here) {
@@ -197,8 +197,8 @@
return true;
};
Lexer.prototype.heregexToken = function(match) {
var _i, _len, _ref2, _ref3, _ref4, _ref5, _this, body, flags, heregex, re, tag, tokens, value;
_ref2 = match, heregex = _ref2[0], body = _ref2[1], flags = _ref2[2];
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('#{')) {
re = body.replace(HEREGEX_OMIT, '').replace(/\//g, '\\/');
@@ -208,10 +208,10 @@
this.token('IDENTIFIER', 'RegExp');
this.tokens.push(['CALL_START', '(']);
tokens = [];
for (_i = 0, _len = (_ref3 = this.interpolateString(body, {
for (_i = 0, _len = (_ref2 = this.interpolateString(body, {
regex: true
})).length; _i < _len; _i++) {
_ref4 = _ref3[_i], tag = _ref4[0], value = _ref4[1];
_ref3 = _ref2[_i], tag = _ref3[0], value = _ref3[1];
if (tag === 'TOKENS') {
tokens.push.apply(tokens, value);
} else {
@@ -224,7 +224,7 @@
tokens.push(['+', '+']);
}
tokens.pop();
if ((((_ref5 = tokens[0]) != null) ? _ref5[0] : undefined) !== 'STRING') {
if ((((_ref4 = tokens[0]) != null) ? _ref4[0] : undefined) !== 'STRING') {
this.tokens.push(['STRING', '""'], ['+', '+']);
}
(_this = this.tokens).push.apply(_this, tokens);
@@ -399,15 +399,15 @@
return true;
};
Lexer.prototype.sanitizeHeredoc = function(doc, options) {
var _ref2, _ref3, attempt, herecomment, indent, match;
_ref2 = options, indent = _ref2.indent, herecomment = _ref2.herecomment;
var _ref2, attempt, herecomment, indent, match;
indent = options.indent, herecomment = options.herecomment;
if (herecomment && 0 > doc.indexOf('\n')) {
return doc;
}
if (!herecomment) {
while (match = HEREDOC_INDENT.exec(doc)) {
attempt = match[1];
if (indent === null || (0 < (_ref3 = attempt.length)) && (_ref3 < indent.length)) {
if (indent === null || (0 < (_ref2 = attempt.length)) && (_ref2 < indent.length)) {
indent = attempt;
}
}
@@ -452,7 +452,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, _len, _ref2, close, i, levels, open, pair, slen;
var _i, _len, close, i, levels, open, pair, slen;
options || (options = {});
levels = [];
i = 0;
@@ -463,7 +463,7 @@
} else {
for (_i = 0, _len = delimited.length; _i < _len; _i++) {
pair = delimited[_i];
_ref2 = pair, open = _ref2[0], close = _ref2[1];
open = pair[0], close = pair[1];
if (levels.length && starts(str, close, i) && last(levels) === pair) {
levels.pop();
i += close.length - 1;