/** * 9.2.3 FunctionAllocate (functionPrototype, strict [,functionKind] ) * * @param cx the execution context * @param functionPrototype the function prototype * @param strict the strict mode flag * @param kind the function kind * @return the new generator function object */ public static OrdinaryConstructorGenerator FunctionAllocate( ExecutionContext cx, ScriptObject functionPrototype, boolean strict, FunctionKind kind) { assert kind != FunctionKind.ClassConstructor; Realm realm = cx.getRealm(); /* steps 1-5 (implicit) */ /* steps 6-9 */ OrdinaryConstructorGenerator f = new OrdinaryConstructorGenerator(realm); /* steps 10-14 */ f.allocate(realm, functionPrototype, strict, kind, ConstructorKind.Derived); /* step 15 */ return f; }
/** * 14.4 Generator Function Definitions * * <p>14.4.14 Runtime Semantics: EvaluateBody * * <pre> * GeneratorBody : FunctionBody * </pre> * * @param cx the execution context * @param functionObject the generator function object * @return the generator result value */ public static GeneratorObject EvaluateBody( ExecutionContext cx, OrdinaryConstructorGenerator functionObject) { /* steps 1-2 */ GeneratorObject gen = OrdinaryCreateFromConstructor( cx, functionObject, Intrinsics.GeneratorPrototype, GeneratorObject::new); /* step 3 */ GeneratorStart(cx, gen, functionObject.getCode()); /* step 4 */ return gen; }