Search in sources :

Example 66 with OrdinaryObject

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

the class JSONParser method jsonObject.

/**
     * <pre>
     * JSONObject :
     *      { }
     *      { JSONMemberList }
     * JSONMemberList :
     *      JSONMember 
     *      JSONMemberList , JSONMember
     * JSONMember :
     *      JSONString : JSONValue
     * </pre>
     * 
     * @return the script object represented by the JSON object
     */
private OrdinaryObject jsonObject() {
    OrdinaryObject object = ObjectCreate(cx, Intrinsics.ObjectPrototype);
    consume(Token.LC);
    if (token() != Token.RC) {
        for (; ; ) {
            consume(Token.STRING);
            String name = ts.getString();
            consume(Token.COLON);
            Object value = jsonValue();
            object.defineOwnProperty(cx, name, new PropertyDescriptor(value, true, true, true));
            if (token() == Token.RC) {
                break;
            }
            consume(Token.COMMA);
        }
    }
    consume(Token.RC);
    return object;
}
Also used : PropertyDescriptor(com.github.anba.es6draft.runtime.types.PropertyDescriptor) OrdinaryObject(com.github.anba.es6draft.runtime.types.builtins.OrdinaryObject) OrdinaryObject(com.github.anba.es6draft.runtime.types.builtins.OrdinaryObject) ArrayObject(com.github.anba.es6draft.runtime.types.builtins.ArrayObject)

Example 67 with OrdinaryObject

use of com.github.anba.es6draft.runtime.types.builtins.OrdinaryObject 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 68 with OrdinaryObject

use of com.github.anba.es6draft.runtime.types.builtins.OrdinaryObject 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 69 with OrdinaryObject

use of com.github.anba.es6draft.runtime.types.builtins.OrdinaryObject 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 70 with OrdinaryObject

use of com.github.anba.es6draft.runtime.types.builtins.OrdinaryObject 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

OrdinaryObject (com.github.anba.es6draft.runtime.types.builtins.OrdinaryObject)141 ArrayObject (com.github.anba.es6draft.runtime.types.builtins.ArrayObject)102 ScriptObject (com.github.anba.es6draft.runtime.types.ScriptObject)98 RegExpObject (com.github.anba.es6draft.runtime.objects.text.RegExpObject)84 Intrinsics (com.github.anba.es6draft.runtime.types.Intrinsics)14 Property (com.github.anba.es6draft.runtime.types.Property)5 CompilationException (com.github.anba.es6draft.compiler.CompilationException)3 ParserException (com.github.anba.es6draft.parser.ParserException)3 GlobalEnvironmentRecord (com.github.anba.es6draft.runtime.GlobalEnvironmentRecord)3 RuntimeInfo (com.github.anba.es6draft.runtime.internal.RuntimeInfo)3 ScriptLoader (com.github.anba.es6draft.runtime.internal.ScriptLoader)3 Source (com.github.anba.es6draft.runtime.internal.Source)3 FunctionConstructor.functionSource (com.github.anba.es6draft.runtime.objects.FunctionConstructor.functionSource)3 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 IntlObject (com.github.anba.es6draft.runtime.objects.intl.IntlObject)3 ArrayList (java.util.ArrayList)3 MethodCode (com.github.anba.es6draft.compiler.assembler.Code.MethodCode)2 MethodName (com.github.anba.es6draft.compiler.assembler.MethodName)2