This patchset causes the bytecode emitter to yield boxed return values
in ES6 generators, of the form { value: foo, done: bool }.
If the generator function does not end in a return, the compiler inserts
the equivalent of a "return { value: undefined, done:true }" statement
at the end.
When an ES6 generator finishes, it does so with {done:true} instead of
throwing a StopIteration.
This patch also ports lib/asserts.js to "default version" JS, and ports
ecma_6/Generators to use it.
This patch makes legacy (JS 1.7) and star (ES6) generators have
different classes, avoiding the need to poke through to the frame's
script to see which kind they are. This steps around a failure to get
a frame's script after GC, when the script was thrown away, while also
preparing for bug 907744.
To detect errors in the future, also make accesses to gen->fp->script()
cause a null pointer deref in debug mode. This caught another bug in
generator_close_impl(), in which with GGC it could be possible to
reference a return value from the recently dead frame. This was easily
fixed because that value is always undefined.
Add a Generator constructor, like the Function constructor.
Define the GeneratorFunctionPrototype, GeneratorFunction, and
GeneratorObjectPrototype meta-objects.
When cloning or creating a star generator, give it
GeneratorFunctionPrototype as its prototype.
Each star generator function has a ".prototype" property, which has
GeneratorObjectPrototype as its prototype. That prototype does not have
a ".constructor" link.
If Function.prototype.toSource is called on a non-function, chain up to
Object.prototype.toSource instead.
Prototypes of generator objects are no longer made with
GeneratorObject::class_. This allows us to elide some "null" checks
from bug 352885. Instead calling a generator on a method now signals a
typeerror.
Make the "send" generator method a simple alias to "next".
Add a GeneratorKind enumeration, and use it in the parser and runtime to
indicate whether a function is a non-generator, a legacy generator, or a
star generator.
Always parse "yield" as TOK_YIELD, regardless of the version. Add
TokenStream::currentName() to retrieve the current token's name, which
works for TOK_NAME or TOK_YIELD. The parser should check the validity
of "yield" as a name, if needed, using checkYieldNameValidity().
Parse "function*" as the StarGenerator GeneratorKind, and allow star
generators to be lazily parsed.
Separate parsing of return statements from yield expressions.