clean up tail call transformer
This commit is contained in:
@@ -1,27 +1,29 @@
|
||||
"use strict";
|
||||
|
||||
(function f(n) {
|
||||
var _arguments = arguments,
|
||||
_this = this,
|
||||
_shouldContinue,
|
||||
_result;
|
||||
do {
|
||||
_shouldContinue = false;
|
||||
_result = (function (n) {
|
||||
if (n <= 0) {
|
||||
console.log(this, arguments);
|
||||
return "foo";
|
||||
}
|
||||
if (Math.random() > 0.5) {
|
||||
_arguments = [n - 1];
|
||||
_this = this;
|
||||
return _shouldContinue = true;
|
||||
} else {
|
||||
_arguments = [n - 1];
|
||||
_this = this;
|
||||
return _shouldContinue = true;
|
||||
}
|
||||
}).apply(_this, _arguments);
|
||||
} while (_shouldContinue);
|
||||
return _result;
|
||||
})(1000000) === "foo";
|
||||
"use strict";
|
||||
|
||||
(function f(n) {
|
||||
var _arguments = arguments,
|
||||
_this = this,
|
||||
_shouldContinue,
|
||||
_result;
|
||||
var _callee = function (n) {
|
||||
if (n <= 0) {
|
||||
console.log(this, arguments);
|
||||
return "foo";
|
||||
}
|
||||
if (Math.random() > 0.5) {
|
||||
_arguments = [n - 1];
|
||||
_this = this;
|
||||
return _shouldContinue = true;
|
||||
} else {
|
||||
_arguments = [n - 1];
|
||||
_this = this;
|
||||
return _shouldContinue = true;
|
||||
}
|
||||
};
|
||||
|
||||
do {
|
||||
_shouldContinue = false;
|
||||
_result = _callee.apply(_this, _arguments);
|
||||
} while (_shouldContinue);
|
||||
return _result;
|
||||
})(1000000) === "foo";
|
||||
@@ -1,30 +1,32 @@
|
||||
"use strict";
|
||||
|
||||
(function f(n) {
|
||||
var _arguments = arguments,
|
||||
_this = this,
|
||||
_shouldContinue,
|
||||
_result;
|
||||
do {
|
||||
_shouldContinue = false;
|
||||
_result = (function (n) {
|
||||
var _left;
|
||||
if (n <= 0) {
|
||||
return "foo";
|
||||
} else {
|
||||
doSmth();
|
||||
|
||||
if (!(_left = getTrueValue())) {
|
||||
return _left;
|
||||
}
|
||||
if (_left = getFalseValue()) {
|
||||
return _left;
|
||||
}
|
||||
_arguments = [n - 1];
|
||||
_this = undefined;
|
||||
return _shouldContinue = true;
|
||||
}
|
||||
}).apply(_this, _arguments);
|
||||
} while (_shouldContinue);
|
||||
return _result;
|
||||
})(1000000, true) === "foo";
|
||||
"use strict";
|
||||
|
||||
(function f(n) {
|
||||
var _arguments = arguments,
|
||||
_this = this,
|
||||
_shouldContinue,
|
||||
_result;
|
||||
var _callee = function (n) {
|
||||
var _left;
|
||||
if (n <= 0) {
|
||||
return "foo";
|
||||
} else {
|
||||
doSmth();
|
||||
|
||||
if (!(_left = getTrueValue())) {
|
||||
return _left;
|
||||
}
|
||||
if (_left = getFalseValue()) {
|
||||
return _left;
|
||||
}
|
||||
_arguments = [n - 1];
|
||||
_this = undefined;
|
||||
return _shouldContinue = true;
|
||||
}
|
||||
};
|
||||
|
||||
do {
|
||||
_shouldContinue = false;
|
||||
_result = _callee.apply(_this, _arguments);
|
||||
} while (_shouldContinue);
|
||||
return _result;
|
||||
})(1000000, true) === "foo";
|
||||
@@ -1,23 +1,25 @@
|
||||
"use strict";
|
||||
|
||||
(function f(_x, /* should be undefined after first pass */m) {
|
||||
var _arguments = arguments,
|
||||
_this = this,
|
||||
_shouldContinue,
|
||||
_result;
|
||||
do {
|
||||
_shouldContinue = false;
|
||||
_result = (function (_x, m) {
|
||||
var n = arguments[0] === undefined ? getDefaultValue() : arguments[0];
|
||||
if (n <= 0) {
|
||||
return "foo";
|
||||
}
|
||||
// Should be clean (undefined) on each pass
|
||||
var local;
|
||||
_arguments = [n - 1];
|
||||
_this = undefined;
|
||||
return _shouldContinue = true;
|
||||
}).apply(_this, _arguments);
|
||||
} while (_shouldContinue);
|
||||
return _result;
|
||||
})(1000000, true) === "foo";
|
||||
"use strict";
|
||||
|
||||
(function f(_x, /* should be undefined after first pass */m) {
|
||||
var _arguments = arguments,
|
||||
_this = this,
|
||||
_shouldContinue,
|
||||
_result;
|
||||
var _callee = function (_x, m) {
|
||||
var n = arguments[0] === undefined ? getDefaultValue() : arguments[0];
|
||||
if (n <= 0) {
|
||||
return "foo";
|
||||
}
|
||||
// Should be clean (undefined) on each pass
|
||||
var local;
|
||||
_arguments = [n - 1];
|
||||
_this = undefined;
|
||||
return _shouldContinue = true;
|
||||
};
|
||||
|
||||
do {
|
||||
_shouldContinue = false;
|
||||
_result = _callee.apply(_this, _arguments);
|
||||
} while (_shouldContinue);
|
||||
return _result;
|
||||
})(1000000, true) === "foo";
|
||||
@@ -1,65 +1,69 @@
|
||||
"use strict";
|
||||
|
||||
(function f(n) {
|
||||
if (n <= 0) {
|
||||
return "foo";
|
||||
}
|
||||
try {
|
||||
return f(n - 1);
|
||||
} catch (e) {}
|
||||
})(1000000) === "foo";
|
||||
|
||||
(function f(n) {
|
||||
var _arguments = arguments,
|
||||
_this = this,
|
||||
_shouldContinue,
|
||||
_result;
|
||||
do {
|
||||
_shouldContinue = false;
|
||||
_result = (function (n) {
|
||||
if (n <= 0) {
|
||||
return "foo";
|
||||
}
|
||||
try {
|
||||
throw new Error();
|
||||
} catch (e) {
|
||||
_arguments = [n - 1];
|
||||
_this = undefined;
|
||||
return _shouldContinue = true;
|
||||
}
|
||||
}).apply(_this, _arguments);
|
||||
} while (_shouldContinue);
|
||||
return _result;
|
||||
})(1000000) === "foo";
|
||||
|
||||
(function f(n) {
|
||||
if (n <= 0) {
|
||||
return "foo";
|
||||
}
|
||||
try {
|
||||
throw new Error();
|
||||
} catch (e) {
|
||||
return f(n - 1);
|
||||
} finally {}
|
||||
})(1000000) === "foo";
|
||||
|
||||
(function f(n) {
|
||||
var _arguments = arguments,
|
||||
_this = this,
|
||||
_shouldContinue,
|
||||
_result;
|
||||
do {
|
||||
_shouldContinue = false;
|
||||
_result = (function (n) {
|
||||
if (n <= 0) {
|
||||
return "foo";
|
||||
}
|
||||
try {} finally {
|
||||
_arguments = [n - 1];
|
||||
_this = undefined;
|
||||
return _shouldContinue = true;
|
||||
}
|
||||
}).apply(_this, _arguments);
|
||||
} while (_shouldContinue);
|
||||
return _result;
|
||||
})(1000000) === "foo";
|
||||
"use strict";
|
||||
|
||||
(function f(n) {
|
||||
if (n <= 0) {
|
||||
return "foo";
|
||||
}
|
||||
try {
|
||||
return f(n - 1);
|
||||
} catch (e) {}
|
||||
})(1000000) === "foo";
|
||||
|
||||
(function f(n) {
|
||||
var _arguments = arguments,
|
||||
_this = this,
|
||||
_shouldContinue,
|
||||
_result;
|
||||
var _callee = function (n) {
|
||||
if (n <= 0) {
|
||||
return "foo";
|
||||
}
|
||||
try {
|
||||
throw new Error();
|
||||
} catch (e) {
|
||||
_arguments = [n - 1];
|
||||
_this = undefined;
|
||||
return _shouldContinue = true;
|
||||
}
|
||||
};
|
||||
|
||||
do {
|
||||
_shouldContinue = false;
|
||||
_result = _callee.apply(_this, _arguments);
|
||||
} while (_shouldContinue);
|
||||
return _result;
|
||||
})(1000000) === "foo";
|
||||
|
||||
(function f(n) {
|
||||
if (n <= 0) {
|
||||
return "foo";
|
||||
}
|
||||
try {
|
||||
throw new Error();
|
||||
} catch (e) {
|
||||
return f(n - 1);
|
||||
} finally {}
|
||||
})(1000000) === "foo";
|
||||
|
||||
(function f(n) {
|
||||
var _arguments = arguments,
|
||||
_this = this,
|
||||
_shouldContinue,
|
||||
_result;
|
||||
var _callee = function (n) {
|
||||
if (n <= 0) {
|
||||
return "foo";
|
||||
}
|
||||
try {} finally {
|
||||
_arguments = [n - 1];
|
||||
_this = undefined;
|
||||
return _shouldContinue = true;
|
||||
}
|
||||
};
|
||||
|
||||
do {
|
||||
_shouldContinue = false;
|
||||
_result = _callee.apply(_this, _arguments);
|
||||
} while (_shouldContinue);
|
||||
return _result;
|
||||
})(1000000) === "foo";
|
||||
Reference in New Issue
Block a user