Ingvar Stepanyan 4c318166e1 Added complete TCO (tail call optimization).
Works across functions and generates simpler and faster code than #701.
Works even across files when used in conjunction with `runtime` option.

Closes #256.
2015-02-07 22:22:38 +02:00

12 lines
330 B
JavaScript

"use strict";
(function f(_x, /* should be undefined after first pass */m) {
var n = arguments[0] === undefined ? getDefaultValue() : arguments[0];
if (n <= 0) {
return "foo";
}
// Should be clean (undefined) on each pass
var local;
return to5Runtime.tailCall(f, [n - 1]);
})(1000000, true) === "foo";