Search in sources :

Example 1 with CompletePropertyDescriptor

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

the class ProxyObject method validateGetOwnProperty.

private Property validateGetOwnProperty(ExecutionContext cx, ScriptObject target, Object trapResultObj, Property targetDesc) {
    /* step 14 */
    if (Type.isUndefined(trapResultObj)) {
        if (targetDesc == null) {
            return null;
        }
        if (!targetDesc.isConfigurable()) {
            throw newTypeError(cx, Messages.Key.ProxyNotConfigurable);
        }
        boolean extensibleTarget = IsExtensible(cx, target);
        if (!extensibleTarget) {
            throw newTypeError(cx, Messages.Key.ProxyNotExtensible);
        }
        return null;
    }
    if (targetDesc != null) {
        // need copy because of possible side-effects in IsExtensible()
        targetDesc = targetDesc.clone();
    }
    /* steps 15-16 */
    boolean extensibleTarget = IsExtensible(cx, target);
    /* steps 17-18 */
    PropertyDescriptor resultDesc = ToPropertyDescriptor(cx, trapResultObj);
    /* step 19 */
    CompletePropertyDescriptor(resultDesc);
    /* step 20 */
    boolean valid = IsCompatiblePropertyDescriptor(extensibleTarget, resultDesc, targetDesc);
    /* step 21 */
    if (!valid) {
        throw newTypeError(cx, Messages.Key.ProxyIncompatibleDescriptor);
    }
    /* step 22 */
    if (!resultDesc.isConfigurable()) {
        if (targetDesc == null || targetDesc.isConfigurable()) {
            throw newTypeError(cx, Messages.Key.ProxyAbsentOrConfigurable);
        }
    }
    /* step 23 */
    return resultDesc.toProperty();
}
Also used : CompletePropertyDescriptor(com.github.anba.es6draft.runtime.types.PropertyDescriptor.CompletePropertyDescriptor) ToPropertyDescriptor(com.github.anba.es6draft.runtime.types.PropertyDescriptor.ToPropertyDescriptor) PropertyDescriptor(com.github.anba.es6draft.runtime.types.PropertyDescriptor) FromPropertyDescriptor(com.github.anba.es6draft.runtime.types.PropertyDescriptor.FromPropertyDescriptor) IsCompatiblePropertyDescriptor(com.github.anba.es6draft.runtime.types.builtins.OrdinaryObject.IsCompatiblePropertyDescriptor)

Aggregations

PropertyDescriptor (com.github.anba.es6draft.runtime.types.PropertyDescriptor)1 CompletePropertyDescriptor (com.github.anba.es6draft.runtime.types.PropertyDescriptor.CompletePropertyDescriptor)1 FromPropertyDescriptor (com.github.anba.es6draft.runtime.types.PropertyDescriptor.FromPropertyDescriptor)1 ToPropertyDescriptor (com.github.anba.es6draft.runtime.types.PropertyDescriptor.ToPropertyDescriptor)1 IsCompatiblePropertyDescriptor (com.github.anba.es6draft.runtime.types.builtins.OrdinaryObject.IsCompatiblePropertyDescriptor)1