Search in sources :

Example 56 with ScriptObject

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

the class ProxyObject method ownPropertyKeys.

/**
     * 9.5.12 [[OwnPropertyKeys]] ()
     */
@Override
public List<?> ownPropertyKeys(ExecutionContext cx) {
    /* steps 1-3 */
    ScriptObject handler = getProxyHandler(cx);
    /* step 4 */
    ScriptObject target = getProxyTarget();
    /* steps 5-6 */
    Callable trap = GetMethod(cx, handler, "ownKeys");
    /* step 7 */
    if (trap == null) {
        return target.ownPropertyKeys(cx);
    }
    /* step 8 */
    Object trapResultArray = trap.call(cx, handler, target);
    /* steps 9-25 */
    return validateOwnPropertyKeys(cx, target, trapResultArray);
}
Also used : ScriptObject(com.github.anba.es6draft.runtime.types.ScriptObject) ScriptObject(com.github.anba.es6draft.runtime.types.ScriptObject) Callable(com.github.anba.es6draft.runtime.types.Callable)

Example 57 with ScriptObject

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

the class ProxyObject method enumerateKeys.

/**
     * 9.5.11 [[Enumerate]] ()
     */
@Override
public ScriptIterator<?> enumerateKeys(ExecutionContext cx) {
    /* steps 1-3 */
    ScriptObject handler = getProxyHandler(cx);
    /* step 4 */
    ScriptObject target = getProxyTarget();
    /* steps 5-6 */
    Callable trap = GetMethod(cx, handler, "enumerate");
    /* step 7 */
    if (trap == null) {
        return target.enumerateKeys(cx);
    }
    /* steps 8-9 */
    Object trapResult = trap.call(cx, handler, target);
    /* step 10 */
    if (!Type.isObject(trapResult)) {
        throw newTypeError(cx, Messages.Key.ProxyNotObject);
    }
    /* step 11 */
    return ToScriptIterator(cx, Type.objectValue(trapResult));
}
Also used : ScriptObject(com.github.anba.es6draft.runtime.types.ScriptObject) ScriptObject(com.github.anba.es6draft.runtime.types.ScriptObject) Callable(com.github.anba.es6draft.runtime.types.Callable)

Example 58 with ScriptObject

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

the class ProxyObject method getOwnProperty.

/**
     * 9.5.5 [[GetOwnProperty]] (P)
     */
@Override
public Property getOwnProperty(ExecutionContext cx, String propertyKey) {
    /* step 1 (implicit) */
    /* steps 2-4 */
    ScriptObject handler = getProxyHandler(cx);
    /* step 5 */
    ScriptObject target = getProxyTarget();
    /* steps 6-7 */
    Callable trap = GetMethod(cx, handler, "getOwnPropertyDescriptor");
    /* step 8 */
    if (trap == null) {
        return target.getOwnProperty(cx, propertyKey);
    }
    /* steps 9-10 */
    Object trapResultObj = trap.call(cx, handler, target, propertyKey);
    /* step 11 */
    if (!(Type.isObject(trapResultObj) || Type.isUndefined(trapResultObj))) {
        throw newTypeError(cx, Messages.Key.ProxyNotObjectOrUndefined);
    }
    /* steps 12-13 */
    Property targetDesc = target.getOwnProperty(cx, propertyKey);
    /* steps 14-23 */
    return validateGetOwnProperty(cx, target, trapResultObj, targetDesc);
}
Also used : ScriptObject(com.github.anba.es6draft.runtime.types.ScriptObject) 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 59 with ScriptObject

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

the class ProxyObject method hasProperty.

/**
     * 9.5.7 [[HasProperty]] (P)
     */
@Override
public boolean hasProperty(ExecutionContext cx, String propertyKey) {
    /* step 1 (implicit) */
    /* steps 2-4 */
    ScriptObject handler = getProxyHandler(cx);
    /* step 5 */
    ScriptObject target = getProxyTarget();
    /* steps 6-7 */
    Callable trap = GetMethod(cx, handler, "has");
    /* step 8 */
    if (trap == null) {
        return target.hasProperty(cx, propertyKey);
    }
    /* steps 9-10 */
    boolean trapResult = ToBoolean(trap.call(cx, handler, target, propertyKey));
    /* step 11 */
    if (!trapResult) {
        /* steps 11.a-11.b */
        Property targetDesc = target.getOwnProperty(cx, propertyKey);
        /* step 11.c */
        validateHasProperty(cx, target, targetDesc);
    }
    /* step 12 */
    return trapResult;
}
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 60 with ScriptObject

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

the class ProxyObject method enumerate.

/**
     * 9.5.11 [[Enumerate]] ()
     */
@Override
public ScriptObject enumerate(ExecutionContext cx) {
    /* steps 1-3 */
    ScriptObject handler = getProxyHandler(cx);
    /* step 4 */
    ScriptObject target = getProxyTarget();
    /* steps 5-6 */
    Callable trap = GetMethod(cx, handler, "enumerate");
    /* step 7 */
    if (trap == null) {
        return target.enumerate(cx);
    }
    /* steps 8-9 */
    Object trapResult = trap.call(cx, handler, target);
    /* step 10 */
    if (!Type.isObject(trapResult)) {
        throw newTypeError(cx, Messages.Key.ProxyNotObject);
    }
    /* step 11 */
    return Type.objectValue(trapResult);
}
Also used : ScriptObject(com.github.anba.es6draft.runtime.types.ScriptObject) ScriptObject(com.github.anba.es6draft.runtime.types.ScriptObject) Callable(com.github.anba.es6draft.runtime.types.Callable)

Aggregations

ScriptObject (com.github.anba.es6draft.runtime.types.ScriptObject)129 Callable (com.github.anba.es6draft.runtime.types.Callable)43 Property (com.github.anba.es6draft.runtime.types.Property)32 OrdinaryObject (com.github.anba.es6draft.runtime.types.builtins.OrdinaryObject)26 ArrayObject (com.github.anba.es6draft.runtime.types.builtins.ArrayObject)21 ExecutionContext (com.github.anba.es6draft.runtime.ExecutionContext)16 Constructor (com.github.anba.es6draft.runtime.types.Constructor)11 Realm (com.github.anba.es6draft.runtime.Realm)9 PropertyDescriptor (com.github.anba.es6draft.runtime.types.PropertyDescriptor)9 ParserException (com.github.anba.es6draft.parser.ParserException)8 CompilationException (com.github.anba.es6draft.compiler.CompilationException)7 Source (com.github.anba.es6draft.runtime.internal.Source)7 ArrayList (java.util.ArrayList)7 FunctionObject (com.github.anba.es6draft.runtime.types.builtins.FunctionObject)6 ImmutablePrototypeObject (com.github.anba.es6draft.runtime.types.builtins.ImmutablePrototypeObject)6 OrdinaryCreateFromConstructor (com.github.anba.es6draft.runtime.types.builtins.OrdinaryObject.OrdinaryCreateFromConstructor)6 Test (org.junit.Test)6 GlobalEnvironmentRecord (com.github.anba.es6draft.runtime.GlobalEnvironmentRecord)5 IsCallable (com.github.anba.es6draft.runtime.AbstractOperations.IsCallable)4 RuntimeInfo (com.github.anba.es6draft.runtime.internal.RuntimeInfo)4