Search in sources :

Example 86 with Property

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

the class OrdinaryObject method ordinaryGet.

/**
 * 9.1.8.1 OrdinaryGet (O, P, Receiver)
 *
 * @param cx
 *            the execution context
 * @param propertyKey
 *            the property key
 * @param receiver
 *            the receiver object
 * @return the property value
 */
protected final Object ordinaryGet(ExecutionContext cx, long propertyKey, Object receiver) {
    /* step 1 (implicit) */
    /* step 2 */
    Property desc = getOwnProperty(cx, propertyKey);
    /* step 3 */
    if (desc == null) {
        ScriptObject parent = getPrototypeOf(cx);
        if (parent == null) {
            return UNDEFINED;
        }
        return parent.get(cx, propertyKey, receiver);
    }
    /* step 4 */
    if (desc.isDataDescriptor()) {
        return desc.getValue();
    }
    /* step 5 */
    assert desc.isAccessorDescriptor();
    /* step 6 */
    Callable getter = desc.getGetter();
    /* step 7 */
    if (getter == null) {
        return UNDEFINED;
    }
    /* step 8 */
    return getter.call(cx, receiver, EMPTY_ARRAY);
}
Also used : ScriptObject(com.github.anba.es6draft.runtime.types.ScriptObject) Property(com.github.anba.es6draft.runtime.types.Property) Callable(com.github.anba.es6draft.runtime.types.Callable)

Example 87 with Property

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

the class OrdinaryObject method ordinaryGet.

/**
 * 9.1.8.1 OrdinaryGet (O, P, Receiver)
 *
 * @param cx
 *            the execution context
 * @param propertyKey
 *            the property key
 * @param receiver
 *            the receiver object
 * @return the property value
 */
protected final Object ordinaryGet(ExecutionContext cx, String propertyKey, Object receiver) {
    /* step 1 (implicit) */
    /* step 2 */
    Property desc = getOwnProperty(cx, propertyKey);
    /* step 3 */
    if (desc == null) {
        ScriptObject parent = getPrototypeOf(cx);
        if (parent == null) {
            return UNDEFINED;
        }
        return parent.get(cx, propertyKey, receiver);
    }
    /* step 4 */
    if (desc.isDataDescriptor()) {
        return desc.getValue();
    }
    /* step 5 */
    assert desc.isAccessorDescriptor();
    /* step 6 */
    Callable getter = desc.getGetter();
    /* step 7 */
    if (getter == null) {
        return UNDEFINED;
    }
    /* step 8 */
    return getter.call(cx, receiver, EMPTY_ARRAY);
}
Also used : ScriptObject(com.github.anba.es6draft.runtime.types.ScriptObject) Property(com.github.anba.es6draft.runtime.types.Property) Callable(com.github.anba.es6draft.runtime.types.Callable)

Example 88 with Property

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

the class OrdinaryObject method isEnumerableOwnProperty.

/**
 * Subclasses can override this method if they have virtual properties.
 *
 * @param cx
 *            the execution context
 * @param propertyKey
 *            the property key
 * @return the property enumerable status
 */
@Override
public Enumerability isEnumerableOwnProperty(ExecutionContext cx, String propertyKey) {
    Property prop;
    long index = IndexedMap.toIndex(propertyKey);
    if (IndexedMap.isIndex(index)) {
        prop = getOwnProperty(cx, index);
    } else {
        prop = getOwnProperty(cx, propertyKey);
    }
    if (prop == null) {
        return Enumerability.Deleted;
    }
    return Enumerability.isEnumerable(prop.isEnumerable());
}
Also used : Property(com.github.anba.es6draft.runtime.types.Property)

Example 89 with Property

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

the class OrdinaryObject method ordinaryDefineOwnProperty.

/**
 * 9.1.6.1 OrdinaryDefineOwnProperty (O, P, Desc)
 *
 * @param cx
 *            the execution context
 * @param propertyKey
 *            the property key
 * @param desc
 *            the property descriptor
 * @return {@code true} on success
 */
protected final boolean ordinaryDefineOwnProperty(ExecutionContext cx, String propertyKey, PropertyDescriptor desc) {
    assert !IndexedMap.isIndex(propertyKey);
    /* step 1 */
    Property current = getOwnProperty(cx, propertyKey);
    /* step 2 */
    boolean extensible = isExtensible();
    /* step 3 */
    return validateAndApplyPropertyDescriptor(properties, propertyKey, extensible, desc, current);
}
Also used : Property(com.github.anba.es6draft.runtime.types.Property)

Example 90 with Property

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

the class ModuleNamespaceObject method ModuleNamespaceCreate.

/**
 * 9.4.6.11 ModuleNamespaceCreate (module, exports)
 *
 * @param cx
 *            the execution context
 * @param module
 *            the module record
 * @param exports
 *            the exported bindings
 * @return the new module namespace object
 */
public static ModuleNamespaceObject ModuleNamespaceCreate(ExecutionContext cx, ModuleRecord module, Set<String> exports) {
    /* step 2 */
    assert module.getNamespace() == null;
    /* step 3 (not applicable) */
    /* steps 4-8 */
    ModuleNamespaceObject m = new ModuleNamespaceObject(cx.getRealm(), module, exports);
    /* step 9 */
    // 26.3.1 @@toStringTag
    m.infallibleDefineOwnProperty(BuiltinSymbol.toStringTag.get(), new Property("Module", false, false, false));
    // TODO: spec issue - add [[Extensible]] and set to false.
    m.setExtensible(false);
    /* step 10 */
    module.setNamespace(m);
    /* step 11 */
    return m;
}
Also used : Property(com.github.anba.es6draft.runtime.types.Property)

Aggregations

Property (com.github.anba.es6draft.runtime.types.Property)93 ScriptObject (com.github.anba.es6draft.runtime.types.ScriptObject)54 Callable (com.github.anba.es6draft.runtime.types.Callable)44 OrdinaryObject (com.github.anba.es6draft.runtime.types.builtins.OrdinaryObject)19 PropertyDescriptor (com.github.anba.es6draft.runtime.types.PropertyDescriptor)18 OrdinaryGenerator (com.github.anba.es6draft.runtime.types.builtins.OrdinaryGenerator)6 OrdinaryAsyncGenerator (com.github.anba.es6draft.runtime.types.builtins.OrdinaryAsyncGenerator)5 PrivateName (com.github.anba.es6draft.runtime.types.PrivateName)4 ArrayObject (com.github.anba.es6draft.runtime.types.builtins.ArrayObject)4 FunctionObject (com.github.anba.es6draft.runtime.types.builtins.FunctionObject)4 CreateDataProperty (com.github.anba.es6draft.runtime.AbstractOperations.CreateDataProperty)3 IsCallable (com.github.anba.es6draft.runtime.AbstractOperations.IsCallable)3 GlobalEnvironmentRecord (com.github.anba.es6draft.runtime.GlobalEnvironmentRecord)3 RuntimeInfo (com.github.anba.es6draft.runtime.internal.RuntimeInfo)3 OrdinaryFunction (com.github.anba.es6draft.runtime.types.builtins.OrdinaryFunction)3 ArrayList (java.util.ArrayList)3 CompilationException (com.github.anba.es6draft.compiler.CompilationException)2 ParserException (com.github.anba.es6draft.parser.ParserException)2 DeclarativeEnvironmentRecord (com.github.anba.es6draft.runtime.DeclarativeEnvironmentRecord)2 ScriptLoader (com.github.anba.es6draft.runtime.internal.ScriptLoader)2