Search in sources :

Example 6 with Intrinsics

use of com.github.anba.es6draft.runtime.types.Intrinsics in project es6draft by anba.

the class AsyncGeneratorFunctionConstructor method CreateDynamicFunction.

/**
     * 19.2.1.1.1 RuntimeSemantics: CreateDynamicFunction(constructor, newTarget, kind, args)
     * 
     * @param callerContext
     *            the caller execution context
     * @param cx
     *            the execution context
     * @param newTarget
     *            the newTarget constructor function
     * @param args
     *            the function arguments
     * @return the new async generator function object
     */
private static FunctionObject CreateDynamicFunction(ExecutionContext callerContext, ExecutionContext cx, Constructor newTarget, Object... args) {
    /* step 1 (not applicable) */
    /* step 2 (not applicable) */
    /* step 3 */
    Intrinsics fallbackProto = Intrinsics.AsyncGenerator;
    /* steps 4-10 */
    String[] sourceText = functionSourceText(cx, args);
    String parameters = sourceText[0], bodyText = sourceText[1];
    /* steps 11, 13-20 */
    Source source = functionSource(SourceKind.AsyncGenerator, cx.getRealm(), callerContext);
    RuntimeInfo.Function function;
    try {
        ScriptLoader scriptLoader = cx.getRealm().getScriptLoader();
        function = scriptLoader.asyncGenerator(source, parameters, bodyText).getFunction();
    } catch (ParserException | CompilationException e) {
        throw e.toScriptException(cx);
    }
    /* step 12 */
    boolean strict = function.isStrict();
    /* steps 21-22 */
    ScriptObject proto = GetPrototypeFromConstructor(cx, newTarget, fallbackProto);
    /* step 23 */
    OrdinaryAsyncGenerator f = FunctionAllocate(cx, proto, strict, FunctionKind.Normal);
    /* steps 24-25 */
    LexicalEnvironment<GlobalEnvironmentRecord> scope = f.getRealm().getGlobalEnv();
    /* step 26 */
    FunctionInitialize(f, FunctionKind.Normal, function, scope, newFunctionExecutable(source));
    /* step 27 */
    OrdinaryObject prototype = ObjectCreate(cx, Intrinsics.AsyncGeneratorPrototype);
    f.infallibleDefineOwnProperty("prototype", new Property(prototype, true, false, false));
    /* step 28 (not applicable) */
    /* step 29 */
    SetFunctionName(f, "anonymous");
    /* step 30 */
    return f;
}
Also used : ParserException(com.github.anba.es6draft.parser.ParserException) CompilationException(com.github.anba.es6draft.compiler.CompilationException) ScriptObject(com.github.anba.es6draft.runtime.types.ScriptObject) RuntimeInfo(com.github.anba.es6draft.runtime.internal.RuntimeInfo) GlobalEnvironmentRecord(com.github.anba.es6draft.runtime.GlobalEnvironmentRecord) FunctionConstructor.functionSource(com.github.anba.es6draft.runtime.objects.FunctionConstructor.functionSource) Source(com.github.anba.es6draft.runtime.internal.Source) OrdinaryAsyncGenerator(com.github.anba.es6draft.runtime.types.builtins.OrdinaryAsyncGenerator) Intrinsics(com.github.anba.es6draft.runtime.types.Intrinsics) OrdinaryObject(com.github.anba.es6draft.runtime.types.builtins.OrdinaryObject) Property(com.github.anba.es6draft.runtime.types.Property) ScriptLoader(com.github.anba.es6draft.runtime.internal.ScriptLoader)

Example 7 with Intrinsics

use of com.github.anba.es6draft.runtime.types.Intrinsics in project es6draft by anba.

the class Realm method initializeBinaryModule.

/**
     * <h1>22.2 TypedArray Objects, 24.1 ArrayBuffer Objects, 24.2 DataView Objects</h1>
     * 
     * @param realm
     *            the realm instance
     */
private static void initializeBinaryModule(Realm realm) {
    EnumMap<Intrinsics, OrdinaryObject> intrinsics = realm.intrinsics;
    // allocation phase
    ArrayBufferConstructor arrayBufferConstructor = new ArrayBufferConstructor(realm);
    ArrayBufferPrototype arrayBufferPrototype = new ArrayBufferPrototype(realm);
    TypedArrayConstructorPrototype typedArrayConstructor = new TypedArrayConstructorPrototype(realm);
    TypedArrayPrototypePrototype typedArrayPrototype = new TypedArrayPrototypePrototype(realm);
    TypedArrayConstructor int8ArrayConstructor = new TypedArrayConstructor(realm, ElementType.Int8);
    TypedArrayPrototype int8ArrayPrototype = new TypedArrayPrototype(realm, ElementType.Int8);
    TypedArrayConstructor uint8ArrayConstructor = new TypedArrayConstructor(realm, ElementType.Uint8);
    TypedArrayPrototype uint8ArrayPrototype = new TypedArrayPrototype(realm, ElementType.Uint8);
    TypedArrayConstructor uint8CArrayConstructor = new TypedArrayConstructor(realm, ElementType.Uint8C);
    TypedArrayPrototype uint8CArrayPrototype = new TypedArrayPrototype(realm, ElementType.Uint8C);
    TypedArrayConstructor int16ArrayConstructor = new TypedArrayConstructor(realm, ElementType.Int16);
    TypedArrayPrototype int16ArrayPrototype = new TypedArrayPrototype(realm, ElementType.Int16);
    TypedArrayConstructor uint16ArrayConstructor = new TypedArrayConstructor(realm, ElementType.Uint16);
    TypedArrayPrototype uint16ArrayPrototype = new TypedArrayPrototype(realm, ElementType.Uint16);
    TypedArrayConstructor int32ArrayConstructor = new TypedArrayConstructor(realm, ElementType.Int32);
    TypedArrayPrototype int32ArrayPrototype = new TypedArrayPrototype(realm, ElementType.Int32);
    TypedArrayConstructor uint32ArrayConstructor = new TypedArrayConstructor(realm, ElementType.Uint32);
    TypedArrayPrototype uint32ArrayPrototype = new TypedArrayPrototype(realm, ElementType.Uint32);
    TypedArrayConstructor float32ArrayConstructor = new TypedArrayConstructor(realm, ElementType.Float32);
    TypedArrayPrototype float32ArrayPrototype = new TypedArrayPrototype(realm, ElementType.Float32);
    TypedArrayConstructor float64ArrayConstructor = new TypedArrayConstructor(realm, ElementType.Float64);
    TypedArrayPrototype float64ArrayPrototype = new TypedArrayPrototype(realm, ElementType.Float64);
    DataViewConstructor dataViewConstructor = new DataViewConstructor(realm);
    DataViewPrototype dataViewPrototype = new DataViewPrototype(realm);
    // registration phase
    intrinsics.put(Intrinsics.ArrayBuffer, arrayBufferConstructor);
    intrinsics.put(Intrinsics.ArrayBufferPrototype, arrayBufferPrototype);
    intrinsics.put(Intrinsics.TypedArray, typedArrayConstructor);
    intrinsics.put(Intrinsics.TypedArrayPrototype, typedArrayPrototype);
    intrinsics.put(Intrinsics.Int8Array, int8ArrayConstructor);
    intrinsics.put(Intrinsics.Int8ArrayPrototype, int8ArrayPrototype);
    intrinsics.put(Intrinsics.Uint8Array, uint8ArrayConstructor);
    intrinsics.put(Intrinsics.Uint8ArrayPrototype, uint8ArrayPrototype);
    intrinsics.put(Intrinsics.Uint8ClampedArray, uint8CArrayConstructor);
    intrinsics.put(Intrinsics.Uint8ClampedArrayPrototype, uint8CArrayPrototype);
    intrinsics.put(Intrinsics.Int16Array, int16ArrayConstructor);
    intrinsics.put(Intrinsics.Int16ArrayPrototype, int16ArrayPrototype);
    intrinsics.put(Intrinsics.Uint16Array, uint16ArrayConstructor);
    intrinsics.put(Intrinsics.Uint16ArrayPrototype, uint16ArrayPrototype);
    intrinsics.put(Intrinsics.Int32Array, int32ArrayConstructor);
    intrinsics.put(Intrinsics.Int32ArrayPrototype, int32ArrayPrototype);
    intrinsics.put(Intrinsics.Uint32Array, uint32ArrayConstructor);
    intrinsics.put(Intrinsics.Uint32ArrayPrototype, uint32ArrayPrototype);
    intrinsics.put(Intrinsics.Float32Array, float32ArrayConstructor);
    intrinsics.put(Intrinsics.Float32ArrayPrototype, float32ArrayPrototype);
    intrinsics.put(Intrinsics.Float64Array, float64ArrayConstructor);
    intrinsics.put(Intrinsics.Float64ArrayPrototype, float64ArrayPrototype);
    intrinsics.put(Intrinsics.DataView, dataViewConstructor);
    intrinsics.put(Intrinsics.DataViewPrototype, dataViewPrototype);
    // initialization phase
    arrayBufferConstructor.initialize(realm);
    arrayBufferPrototype.initialize(realm);
    typedArrayConstructor.initialize(realm);
    typedArrayPrototype.initialize(realm);
    int8ArrayConstructor.initialize(realm);
    int8ArrayPrototype.initialize(realm);
    uint8ArrayConstructor.initialize(realm);
    uint8ArrayPrototype.initialize(realm);
    uint8CArrayConstructor.initialize(realm);
    uint8CArrayPrototype.initialize(realm);
    int16ArrayConstructor.initialize(realm);
    int16ArrayPrototype.initialize(realm);
    uint16ArrayConstructor.initialize(realm);
    uint16ArrayPrototype.initialize(realm);
    int32ArrayConstructor.initialize(realm);
    int32ArrayPrototype.initialize(realm);
    uint32ArrayConstructor.initialize(realm);
    uint32ArrayPrototype.initialize(realm);
    float32ArrayConstructor.initialize(realm);
    float32ArrayPrototype.initialize(realm);
    float64ArrayConstructor.initialize(realm);
    float64ArrayPrototype.initialize(realm);
    dataViewConstructor.initialize(realm);
    dataViewPrototype.initialize(realm);
}
Also used : TypedArrayPrototype(com.github.anba.es6draft.runtime.objects.binary.TypedArrayPrototype) SharedArrayBufferConstructor(com.github.anba.es6draft.runtime.objects.atomics.SharedArrayBufferConstructor) ArrayBufferConstructor(com.github.anba.es6draft.runtime.objects.binary.ArrayBufferConstructor) TypedArrayConstructor(com.github.anba.es6draft.runtime.objects.binary.TypedArrayConstructor) Intrinsics(com.github.anba.es6draft.runtime.types.Intrinsics) OrdinaryObject(com.github.anba.es6draft.runtime.types.builtins.OrdinaryObject) TypedArrayConstructorPrototype(com.github.anba.es6draft.runtime.objects.binary.TypedArrayConstructorPrototype) DataViewPrototype(com.github.anba.es6draft.runtime.objects.binary.DataViewPrototype) TypedArrayPrototypePrototype(com.github.anba.es6draft.runtime.objects.binary.TypedArrayPrototypePrototype) SharedArrayBufferPrototype(com.github.anba.es6draft.runtime.objects.atomics.SharedArrayBufferPrototype) ArrayBufferPrototype(com.github.anba.es6draft.runtime.objects.binary.ArrayBufferPrototype) DataViewConstructor(com.github.anba.es6draft.runtime.objects.binary.DataViewConstructor)

Example 8 with Intrinsics

use of com.github.anba.es6draft.runtime.types.Intrinsics in project es6draft by anba.

the class Realm method initializeAsyncModule.

/**
     * <h1>Extension: Async Function Declaration</h1>
     * 
     * @param realm
     *            the realm instance
     */
private static void initializeAsyncModule(Realm realm) {
    EnumMap<Intrinsics, OrdinaryObject> intrinsics = realm.intrinsics;
    // allocation phase
    AsyncFunctionConstructor asyncFunctionConstructor = new AsyncFunctionConstructor(realm);
    AsyncFunctionPrototype asyncFunctionPrototype = new AsyncFunctionPrototype(realm);
    // registration phase
    intrinsics.put(Intrinsics.AsyncFunction, asyncFunctionConstructor);
    intrinsics.put(Intrinsics.AsyncFunctionPrototype, asyncFunctionPrototype);
    // initialization phase
    asyncFunctionConstructor.initialize(realm);
    asyncFunctionPrototype.initialize(realm);
}
Also used : Intrinsics(com.github.anba.es6draft.runtime.types.Intrinsics) AsyncFunctionConstructor(com.github.anba.es6draft.runtime.objects.async.AsyncFunctionConstructor) AsyncFunctionPrototype(com.github.anba.es6draft.runtime.objects.async.AsyncFunctionPrototype) OrdinaryObject(com.github.anba.es6draft.runtime.types.builtins.OrdinaryObject)

Example 9 with Intrinsics

use of com.github.anba.es6draft.runtime.types.Intrinsics in project es6draft by anba.

the class Realm method initializeInternationalisation.

/**
     * <h1>Internationalisation API (ECMA-402)</h1><br>
     * <h2>8 The Intl Object - 12 DateTimeFormat Objects</h2>
     * 
     * Additional built-in objects from the Internationalisation API
     * 
     * @param realm
     *            the realm instance
     */
private static void initializeInternationalisation(Realm realm) {
    EnumMap<Intrinsics, OrdinaryObject> intrinsics = realm.intrinsics;
    // allocation phase
    IntlObject intlObject = new IntlObject(realm);
    CollatorConstructor collatorConstructor = new CollatorConstructor(realm);
    CollatorPrototype collatorPrototype = new CollatorPrototype(realm);
    NumberFormatConstructor numberFormatConstructor = new NumberFormatConstructor(realm);
    NumberFormatPrototype numberFormatPrototype = new NumberFormatPrototype(realm);
    DateTimeFormatConstructor dateTimeFormatConstructor = new DateTimeFormatConstructor(realm);
    DateTimeFormatPrototype dateTimeFormatPrototype = new DateTimeFormatPrototype(realm);
    PluralRulesConstructor pluralRulesConstructor = null;
    PluralRulesPrototype pluralRulesPrototype = null;
    if (realm.isEnabled(CompatibilityOption.PluralRules)) {
        pluralRulesConstructor = new PluralRulesConstructor(realm);
        pluralRulesPrototype = new PluralRulesPrototype(realm);
    }
    // registration phase
    intrinsics.put(Intrinsics.Intl, intlObject);
    intrinsics.put(Intrinsics.Intl_Collator, collatorConstructor);
    intrinsics.put(Intrinsics.Intl_CollatorPrototype, collatorPrototype);
    intrinsics.put(Intrinsics.Intl_NumberFormat, numberFormatConstructor);
    intrinsics.put(Intrinsics.Intl_NumberFormatPrototype, numberFormatPrototype);
    intrinsics.put(Intrinsics.Intl_DateTimeFormat, dateTimeFormatConstructor);
    intrinsics.put(Intrinsics.Intl_DateTimeFormatPrototype, dateTimeFormatPrototype);
    if (pluralRulesConstructor != null) {
        intrinsics.put(Intrinsics.Intl_PluralRules, pluralRulesConstructor);
        intrinsics.put(Intrinsics.Intl_PluralRulesPrototype, pluralRulesPrototype);
    }
    // initialization phase
    intlObject.initialize(realm);
    collatorConstructor.initialize(realm);
    collatorPrototype.initialize(realm);
    numberFormatConstructor.initialize(realm);
    numberFormatPrototype.initialize(realm);
    dateTimeFormatConstructor.initialize(realm);
    dateTimeFormatPrototype.initialize(realm);
    if (pluralRulesConstructor != null) {
        pluralRulesConstructor.initialize(realm);
        pluralRulesPrototype.initialize(realm);
    }
}
Also used : DateTimeFormatConstructor(com.github.anba.es6draft.runtime.objects.intl.DateTimeFormatConstructor) PluralRulesConstructor(com.github.anba.es6draft.runtime.objects.intl.PluralRulesConstructor) DateTimeFormatPrototype(com.github.anba.es6draft.runtime.objects.intl.DateTimeFormatPrototype) Intrinsics(com.github.anba.es6draft.runtime.types.Intrinsics) OrdinaryObject(com.github.anba.es6draft.runtime.types.builtins.OrdinaryObject) NumberFormatPrototype(com.github.anba.es6draft.runtime.objects.intl.NumberFormatPrototype) CollatorPrototype(com.github.anba.es6draft.runtime.objects.intl.CollatorPrototype) IntlObject(com.github.anba.es6draft.runtime.objects.intl.IntlObject) PluralRulesPrototype(com.github.anba.es6draft.runtime.objects.intl.PluralRulesPrototype) CollatorConstructor(com.github.anba.es6draft.runtime.objects.intl.CollatorConstructor) NumberFormatConstructor(com.github.anba.es6draft.runtime.objects.intl.NumberFormatConstructor)

Example 10 with Intrinsics

use of com.github.anba.es6draft.runtime.types.Intrinsics in project es6draft by anba.

the class Realm method initializeAsyncIterationModule.

/**
     * <h1>Extension: Async Generator Function Declaration</h1>
     * 
     * @param realm
     *            the realm instance
     */
private static void initializeAsyncIterationModule(Realm realm) {
    EnumMap<Intrinsics, OrdinaryObject> intrinsics = realm.intrinsics;
    // allocation phase
    AsyncGeneratorFunctionConstructor asyncGenFunctionConstructor = new AsyncGeneratorFunctionConstructor(realm);
    AsyncGeneratorPrototype asyncGeneratorPrototype = new AsyncGeneratorPrototype(realm);
    AsyncGeneratorFunctionPrototype asyncGenerator = new AsyncGeneratorFunctionPrototype(realm);
    AsyncIteratorPrototype asyncIteratorPrototype = new AsyncIteratorPrototype(realm);
    // registration phase
    intrinsics.put(Intrinsics.AsyncGeneratorFunction, asyncGenFunctionConstructor);
    intrinsics.put(Intrinsics.AsyncGeneratorPrototype, asyncGeneratorPrototype);
    intrinsics.put(Intrinsics.AsyncGenerator, asyncGenerator);
    intrinsics.put(Intrinsics.AsyncIteratorPrototype, asyncIteratorPrototype);
    // initialization phase
    asyncGenFunctionConstructor.initialize(realm);
    asyncGeneratorPrototype.initialize(realm);
    asyncGenerator.initialize(realm);
    asyncIteratorPrototype.initialize(realm);
}
Also used : AsyncIteratorPrototype(com.github.anba.es6draft.runtime.objects.async.iteration.AsyncIteratorPrototype) Intrinsics(com.github.anba.es6draft.runtime.types.Intrinsics) AsyncGeneratorFunctionConstructor(com.github.anba.es6draft.runtime.objects.async.iteration.AsyncGeneratorFunctionConstructor) OrdinaryObject(com.github.anba.es6draft.runtime.types.builtins.OrdinaryObject) AsyncGeneratorFunctionPrototype(com.github.anba.es6draft.runtime.objects.async.iteration.AsyncGeneratorFunctionPrototype) AsyncGeneratorPrototype(com.github.anba.es6draft.runtime.objects.async.iteration.AsyncGeneratorPrototype)

Aggregations

Intrinsics (com.github.anba.es6draft.runtime.types.Intrinsics)19 OrdinaryObject (com.github.anba.es6draft.runtime.types.builtins.OrdinaryObject)14 ScriptObject (com.github.anba.es6draft.runtime.types.ScriptObject)6 CompilationException (com.github.anba.es6draft.compiler.CompilationException)5 ParserException (com.github.anba.es6draft.parser.ParserException)5 RuntimeInfo (com.github.anba.es6draft.runtime.internal.RuntimeInfo)5 ScriptLoader (com.github.anba.es6draft.runtime.internal.ScriptLoader)5 Source (com.github.anba.es6draft.runtime.internal.Source)5 GlobalEnvironmentRecord (com.github.anba.es6draft.runtime.GlobalEnvironmentRecord)4 FunctionConstructor.functionSource (com.github.anba.es6draft.runtime.objects.FunctionConstructor.functionSource)4 AsyncGeneratorFunctionConstructor (com.github.anba.es6draft.runtime.objects.async.iteration.AsyncGeneratorFunctionConstructor)3 AsyncGeneratorFunctionPrototype (com.github.anba.es6draft.runtime.objects.async.iteration.AsyncGeneratorFunctionPrototype)3 AtomicsObject (com.github.anba.es6draft.runtime.objects.atomics.AtomicsObject)3 ArrayBufferConstructor (com.github.anba.es6draft.runtime.objects.binary.ArrayBufferConstructor)3 IntlObject (com.github.anba.es6draft.runtime.objects.intl.IntlObject)3 SpeciesConstructor (com.github.anba.es6draft.runtime.AbstractOperations.SpeciesConstructor)2 AsyncFunctionConstructor (com.github.anba.es6draft.runtime.objects.async.AsyncFunctionConstructor)2 AsyncFunctionPrototype (com.github.anba.es6draft.runtime.objects.async.AsyncFunctionPrototype)2 AsyncGeneratorPrototype (com.github.anba.es6draft.runtime.objects.async.iteration.AsyncGeneratorPrototype)2 AsyncIteratorPrototype (com.github.anba.es6draft.runtime.objects.async.iteration.AsyncIteratorPrototype)2