Bug 776314 - Stub out genexp toSource. r=luke

This commit is contained in:
Benjamin Peterson 2012-07-24 11:19:18 -07:00
parent 82a0c3817c
commit a810a5ad27
2 changed files with 15 additions and 0 deletions

View File

@ -0,0 +1,7 @@
function getgen() {
gen = getgen.caller;
}
var gen;
(getgen() for (x of [1])).next();
assertEq(gen.toSource(), "function genexp() {\n [generator expression]\n}");
assertEq(decompileBody(gen), "\n [generator expression]\n");

View File

@ -577,6 +577,14 @@ JSFunction::toString(JSContext *cx, bool bodyOnly, bool lambdaParen)
{
StringBuffer out(cx);
if (isInterpreted() && script()->isGeneratorExp) {
if ((!bodyOnly && !out.append("function genexp() {")) ||
!out.append("\n [generator expression]\n") ||
(!bodyOnly && !out.append("}"))) {
return NULL;
}
return out.finishString();
}
if (!bodyOnly) {
// If we're not in pretty mode, put parentheses around lambda functions.
if (isInterpreted() && !lambdaParen && (flags & JSFUN_LAMBDA)) {