Bug 666399 - New Harmony syntax for generators. r=Waldo
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.
This commit is contained in:
@@ -1475,6 +1475,13 @@ js_NewGenerator(JSContext *cx, const FrameRegs &stackRegs)
|
||||
JS_ASSERT(stackRegs.stackDepth() == 0);
|
||||
StackFrame *stackfp = stackRegs.fp();
|
||||
|
||||
JS_ASSERT(stackfp->script()->isGenerator());
|
||||
|
||||
if (stackfp->script()->isStarGenerator()) {
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_ES6_UNIMPLEMENTED);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Rooted<GlobalObject*> global(cx, &stackfp->global());
|
||||
RootedObject obj(cx);
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user