Search in sources :

Example 51 with Callable

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

the class ProxyObject method hasProperty.

/**
     * 9.5.7 [[HasProperty]] (P)
     */
@Override
public boolean hasProperty(ExecutionContext cx, Symbol 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 booleanTrapResult = ToBoolean(trap.call(cx, handler, target, propertyKey));
    /* step 11 */
    if (!booleanTrapResult) {
        /* steps 11.a-11.b */
        Property targetDesc = target.getOwnProperty(cx, propertyKey);
        /* step 11.c */
        validateHasProperty(cx, target, targetDesc);
    }
    /* step 12 */
    return booleanTrapResult;
}
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 52 with Callable

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

the class ProxyObject method delete.

/**
     * 9.5.10 [[Delete]] (P)
     */
@Override
public boolean delete(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, "deleteProperty");
    /* step 8 */
    if (trap == null) {
        return target.delete(cx, propertyKey);
    }
    /* steps 9-10 */
    boolean trapResult = ToBoolean(trap.call(cx, handler, target, propertyKey));
    /* step 11 */
    if (!trapResult) {
        return false;
    }
    /* steps 12-13 */
    Property targetDesc = target.getOwnProperty(cx, propertyKey);
    /* steps 14-16 */
    return validateDelete(cx, targetDesc);
}
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 53 with Callable

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

the class ProxyObject method get.

/**
     * 9.5.8 [[Get]] (P, Receiver)
     */
@Override
public Object get(ExecutionContext cx, String propertyKey, Object receiver) {
    /* step 1 (implicit) */
    /* steps 2-4 */
    ScriptObject handler = getProxyHandler(cx);
    /* step 5 */
    ScriptObject target = getProxyTarget();
    /* steps 6-7 */
    Callable trap = GetMethod(cx, handler, "get");
    /* step 8 */
    if (trap == null) {
        return target.get(cx, propertyKey, receiver);
    }
    /* steps 9-10 */
    Object trapResult = trap.call(cx, handler, target, propertyKey, receiver);
    /* steps 11-12 */
    Property targetDesc = target.getOwnProperty(cx, propertyKey);
    /* steps 13-14 */
    return validateGet(cx, trapResult, 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 54 with Callable

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

the class ProxyObject method get.

/**
     * 9.5.8 [[Get]] (P, Receiver)
     */
@Override
public Object get(ExecutionContext cx, Symbol propertyKey, Object receiver) {
    /* step 1 (implicit) */
    /* steps 2-4 */
    ScriptObject handler = getProxyHandler(cx);
    /* step 5 */
    ScriptObject target = getProxyTarget();
    /* steps 6-7 */
    Callable trap = GetMethod(cx, handler, "get");
    /* step 8 */
    if (trap == null) {
        return target.get(cx, propertyKey, receiver);
    }
    /* steps 9-10 */
    Object trapResult = trap.call(cx, handler, target, propertyKey, receiver);
    /* steps 11-12 */
    Property targetDesc = target.getOwnProperty(cx, propertyKey);
    /* steps 13-14 */
    return validateGet(cx, trapResult, 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 55 with Callable

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

the class OrdinaryObject method getValue.

/**
     * 9.1.8 [[Get]] (P, Receiver)
     *
     * @param cx
     *            the execution context
     * @param propertyKey
     *            the property key
     * @param receiver
     *            the receiver object
     * @return the property value
     */
protected Object getValue(ExecutionContext cx, long propertyKey, Object receiver) {
    /* step 1 (implicit) */
    /* steps 2-3 */
    Property desc = getProperty(cx, propertyKey);
    /* step 4 */
    if (desc == null) {
        ScriptObject parent = getPrototypeOf(cx);
        if (parent == null) {
            return UNDEFINED;
        }
        return parent.get(cx, propertyKey, receiver);
    }
    /* step 5 */
    if (desc.isDataDescriptor()) {
        return desc.getValue();
    }
    assert desc.isAccessorDescriptor();
    /* step 6 */
    Callable getter = desc.getGetter();
    /* step 7 */
    if (getter == null) {
        return UNDEFINED;
    }
    /* step 8 */
    return getter.call(cx, receiver, EMPTY_GETTER_ARGS);
}
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)

Aggregations

Callable (com.github.anba.es6draft.runtime.types.Callable)59 ScriptObject (com.github.anba.es6draft.runtime.types.ScriptObject)49 Property (com.github.anba.es6draft.runtime.types.Property)26 ExecutionContext (com.github.anba.es6draft.runtime.ExecutionContext)10 IsCallable (com.github.anba.es6draft.runtime.AbstractOperations.IsCallable)7 ScriptException (com.github.anba.es6draft.runtime.internal.ScriptException)7 PropertyDescriptor (com.github.anba.es6draft.runtime.types.PropertyDescriptor)6 ArrayObject (com.github.anba.es6draft.runtime.types.builtins.ArrayObject)3 OrdinaryObject (com.github.anba.es6draft.runtime.types.builtins.OrdinaryObject)3 ArrayList (java.util.ArrayList)3 Jump (com.github.anba.es6draft.compiler.assembler.Jump)2 Realm (com.github.anba.es6draft.runtime.Realm)2 PromiseObject (com.github.anba.es6draft.runtime.objects.promise.PromiseObject)2 com.github.anba.es6draft.ast (com.github.anba.es6draft.ast)1 Abrupt (com.github.anba.es6draft.ast.AbruptNode.Abrupt)1 BlockScope (com.github.anba.es6draft.ast.scope.BlockScope)1 ModuleScope (com.github.anba.es6draft.ast.scope.ModuleScope)1 Name (com.github.anba.es6draft.ast.scope.Name)1 Scope (com.github.anba.es6draft.ast.scope.Scope)1 ScriptScope (com.github.anba.es6draft.ast.scope.ScriptScope)1