Search in sources :

Example 1 with GeneratorObject

use of com.github.anba.es6draft.runtime.objects.iteration.GeneratorObject in project es6draft by anba.

the class ScriptRuntime method EvaluateConstructorGeneratorComprehension.

/**
     * 12.2.? Generator Comprehensions
     * <p>
     * 12.2.?.2 Runtime Semantics: Evaluation
     * 
     * @param fd
     *            the function runtime info object
     * @param cx
     *            the execution context
     * @return the generator object
     */
public static GeneratorObject EvaluateConstructorGeneratorComprehension(RuntimeInfo.Function fd, ExecutionContext cx) {
    /* step 1 (omitted) */
    /* step 2 */
    LexicalEnvironment<?> scope = cx.getLexicalEnvironment();
    /* steps 3-4 (not applicable) */
    /* step 5 */
    OrdinaryConstructorGenerator closure = ConstructorGeneratorFunctionCreate(cx, FunctionKind.Arrow, fd, scope);
    /* step 6 */
    OrdinaryObject prototype = ObjectCreate(cx, Intrinsics.GeneratorPrototype);
    /* step 7 */
    MakeConstructor(closure, true, prototype);
    /* step 8 */
    GeneratorObject iterator = (GeneratorObject) closure.call(cx, UNDEFINED);
    /* step 9 */
    return iterator;
}
Also used : GeneratorObject(com.github.anba.es6draft.runtime.objects.iteration.GeneratorObject)

Example 2 with GeneratorObject

use of com.github.anba.es6draft.runtime.objects.iteration.GeneratorObject in project es6draft by anba.

the class ScriptRuntime method EvaluateLegacyGeneratorComprehension.

/**
     * 12.2.? Generator Comprehensions
     * <p>
     * Runtime Semantics: Evaluation
     * 
     * @param fd
     *            the function runtime info object
     * @param cx
     *            the execution context
     * @return the generator object
     */
public static GeneratorObject EvaluateLegacyGeneratorComprehension(RuntimeInfo.Function fd, ExecutionContext cx) {
    /* step 1 (omitted) */
    /* step 2 */
    LexicalEnvironment<?> scope = cx.getLexicalEnvironment();
    /* steps 3-4 (not applicable) */
    /* step 5 */
    OrdinaryConstructorGenerator closure = ConstructorGeneratorFunctionCreate(cx, FunctionKind.Arrow, fd, scope);
    /* step 6 */
    OrdinaryObject prototype = ObjectCreate(cx, Intrinsics.LegacyGeneratorPrototype);
    /* step 7 */
    MakeConstructor(closure, true, prototype);
    /* step 8 */
    GeneratorObject iterator = (GeneratorObject) closure.call(cx, UNDEFINED);
    /* step 9 */
    return iterator;
}
Also used : GeneratorObject(com.github.anba.es6draft.runtime.objects.iteration.GeneratorObject)

Example 3 with GeneratorObject

use of com.github.anba.es6draft.runtime.objects.iteration.GeneratorObject in project es6draft by anba.

the class ScriptRuntime method EvaluateGeneratorComprehension.

/**
     * 12.2.? Generator Comprehensions
     * <p>
     * 12.2.?.2 Runtime Semantics: Evaluation
     * 
     * @param fd
     *            the function runtime info object
     * @param cx
     *            the execution context
     * @return the generator object
     */
public static GeneratorObject EvaluateGeneratorComprehension(RuntimeInfo.Function fd, ExecutionContext cx) {
    /* step 1 (omitted) */
    /* step 2 */
    LexicalEnvironment<?> scope = cx.getLexicalEnvironment();
    /* steps 3-4 (not applicable) */
    /* step 5 */
    OrdinaryGenerator closure = GeneratorFunctionCreate(cx, FunctionKind.Arrow, fd, scope);
    /* step 6 */
    OrdinaryObject prototype = ObjectCreate(cx, Intrinsics.GeneratorPrototype);
    /* step 7 */
    closure.infallibleDefineOwnProperty("prototype", new Property(prototype, true, false, false));
    /* step 8 */
    GeneratorObject iterator = (GeneratorObject) closure.call(cx, UNDEFINED);
    /* step 9 */
    return iterator;
}
Also used : GeneratorObject(com.github.anba.es6draft.runtime.objects.iteration.GeneratorObject)

Example 4 with GeneratorObject

use of com.github.anba.es6draft.runtime.objects.iteration.GeneratorObject in project es6draft by anba.

the class OrdinaryConstructorGenerator method EvaluateBody.

/**
     * 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;
}
Also used : GeneratorObject(com.github.anba.es6draft.runtime.objects.iteration.GeneratorObject)

Example 5 with GeneratorObject

use of com.github.anba.es6draft.runtime.objects.iteration.GeneratorObject in project es6draft by anba.

the class OrdinaryGenerator method EvaluateBody.

/**
     * 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, OrdinaryGenerator functionObject) {
    /* steps 1-2 */
    GeneratorObject gen = OrdinaryCreateFromConstructor(cx, functionObject, Intrinsics.GeneratorPrototype, GeneratorObject::new);
    /* step 3 */
    GeneratorStart(cx, gen, functionObject.getCode());
    /* step 4 */
    return gen;
}
Also used : GeneratorObject(com.github.anba.es6draft.runtime.objects.iteration.GeneratorObject)

Aggregations

GeneratorObject (com.github.anba.es6draft.runtime.objects.iteration.GeneratorObject)5