Java Code Examples for jdk.nashorn.internal.objects.Global#newAccessorDescriptor()

The following examples show how to use jdk.nashorn.internal.objects.Global#newAccessorDescriptor() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ScriptObject.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
  * ECMA 8.10.5 ToPropertyDescriptor ( Obj )
  *
  * @return property descriptor
  */
public final PropertyDescriptor toPropertyDescriptor() {
    final Global global = Context.getGlobal();

    final PropertyDescriptor desc;
    if (isDataDescriptor()) {
        if (has(SET) || has(GET)) {
            throw typeError(global, "inconsistent.property.descriptor");
        }

        desc = global.newDataDescriptor(UNDEFINED, false, false, false);
    } else if (isAccessorDescriptor()) {
        if (has(VALUE) || has(WRITABLE)) {
            throw typeError(global, "inconsistent.property.descriptor");
        }

        desc = global.newAccessorDescriptor(UNDEFINED, UNDEFINED, false, false);
    } else {
        desc = global.newGenericDescriptor(false, false);
    }

    return desc.fillFrom(this);
}
 
Example 2
Source File: ScriptObject.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
  * ECMA 8.10.5 ToPropertyDescriptor ( Obj )
  *
  * @return property descriptor
  */
public final PropertyDescriptor toPropertyDescriptor() {
    final Global global = Context.getGlobal();

    final PropertyDescriptor desc;
    if (isDataDescriptor()) {
        if (has(SET) || has(GET)) {
            throw typeError(global, "inconsistent.property.descriptor");
        }

        desc = global.newDataDescriptor(UNDEFINED, false, false, false);
    } else if (isAccessorDescriptor()) {
        if (has(VALUE) || has(WRITABLE)) {
            throw typeError(global, "inconsistent.property.descriptor");
        }

        desc = global.newAccessorDescriptor(UNDEFINED, UNDEFINED, false, false);
    } else {
        desc = global.newGenericDescriptor(false, false);
    }

    return desc.fillFrom(this);
}
 
Example 3
Source File: ScriptObject.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
  * ECMA 8.10.5 ToPropertyDescriptor ( Obj )
  *
  * @return property descriptor
  */
public final PropertyDescriptor toPropertyDescriptor() {
    final Global global = Context.getGlobal();

    final PropertyDescriptor desc;
    if (isDataDescriptor()) {
        if (has(SET) || has(GET)) {
            throw typeError(global, "inconsistent.property.descriptor");
        }

        desc = global.newDataDescriptor(UNDEFINED, false, false, false);
    } else if (isAccessorDescriptor()) {
        if (has(VALUE) || has(WRITABLE)) {
            throw typeError(global, "inconsistent.property.descriptor");
        }

        desc = global.newAccessorDescriptor(UNDEFINED, UNDEFINED, false, false);
    } else {
        desc = global.newGenericDescriptor(false, false);
    }

    return desc.fillFrom(this);
}
 
Example 4
Source File: ScriptObject.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
  * ECMA 8.10.5 ToPropertyDescriptor ( Obj )
  *
  * @return property descriptor
  */
public final PropertyDescriptor toPropertyDescriptor() {
    final Global global = Context.getGlobal();

    final PropertyDescriptor desc;
    if (isDataDescriptor()) {
        if (has(SET) || has(GET)) {
            throw typeError(global, "inconsistent.property.descriptor");
        }

        desc = global.newDataDescriptor(UNDEFINED, false, false, false);
    } else if (isAccessorDescriptor()) {
        if (has(VALUE) || has(WRITABLE)) {
            throw typeError(global, "inconsistent.property.descriptor");
        }

        desc = global.newAccessorDescriptor(UNDEFINED, UNDEFINED, false, false);
    } else {
        desc = global.newGenericDescriptor(false, false);
    }

    return desc.fillFrom(this);
}
 
Example 5
Source File: ScriptObject.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
  * ECMA 8.10.5 ToPropertyDescriptor ( Obj )
  *
  * @return property descriptor
  */
public final PropertyDescriptor toPropertyDescriptor() {
    final Global global = Context.getGlobal();

    final PropertyDescriptor desc;
    if (isDataDescriptor()) {
        if (has(SET) || has(GET)) {
            throw typeError(global, "inconsistent.property.descriptor");
        }

        desc = global.newDataDescriptor(UNDEFINED, false, false, false);
    } else if (isAccessorDescriptor()) {
        if (has(VALUE) || has(WRITABLE)) {
            throw typeError(global, "inconsistent.property.descriptor");
        }

        desc = global.newAccessorDescriptor(UNDEFINED, UNDEFINED, false, false);
    } else {
        desc = global.newGenericDescriptor(false, false);
    }

    return desc.fillFrom(this);
}
 
Example 6
Source File: ScriptObject.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
  * ECMA 8.10.5 ToPropertyDescriptor ( Obj )
  *
  * @return property descriptor
  */
public final PropertyDescriptor toPropertyDescriptor() {
    final Global global = Context.getGlobal();

    final PropertyDescriptor desc;
    if (isDataDescriptor()) {
        if (has(SET) || has(GET)) {
            throw typeError(global, "inconsistent.property.descriptor");
        }

        desc = global.newDataDescriptor(UNDEFINED, false, false, false);
    } else if (isAccessorDescriptor()) {
        if (has(VALUE) || has(WRITABLE)) {
            throw typeError(global, "inconsistent.property.descriptor");
        }

        desc = global.newAccessorDescriptor(UNDEFINED, UNDEFINED, false, false);
    } else {
        desc = global.newGenericDescriptor(false, false);
    }

    return desc.fillFrom(this);
}
 
Example 7
Source File: ScriptObject.java    From jdk8u_nashorn with GNU General Public License v2.0 6 votes vote down vote up
/**
  * ECMA 8.10.5 ToPropertyDescriptor ( Obj )
  *
  * @return property descriptor
  */
public final PropertyDescriptor toPropertyDescriptor() {
    final Global global = Context.getGlobal();

    final PropertyDescriptor desc;
    if (isDataDescriptor()) {
        if (has(SET) || has(GET)) {
            throw typeError(global, "inconsistent.property.descriptor");
        }

        desc = global.newDataDescriptor(UNDEFINED, false, false, false);
    } else if (isAccessorDescriptor()) {
        if (has(VALUE) || has(WRITABLE)) {
            throw typeError(global, "inconsistent.property.descriptor");
        }

        desc = global.newAccessorDescriptor(UNDEFINED, UNDEFINED, false, false);
    } else {
        desc = global.newGenericDescriptor(false, false);
    }

    return desc.fillFrom(this);
}
 
Example 8
Source File: ScriptObject.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * ECMA 8.12.1 [[GetOwnProperty]] (P)
 *
 * @param key property key
 *
 * @return Returns the Property Descriptor of the named own property of this
 * object, or undefined if absent.
 */
public Object getOwnPropertyDescriptor(final String key) {
    final Property property = getMap().findProperty(key);

    final Global global = Context.getGlobal();

    if (property != null) {
        final ScriptFunction get   = property.getGetterFunction(this);
        final ScriptFunction set   = property.getSetterFunction(this);

        final boolean configurable = property.isConfigurable();
        final boolean enumerable   = property.isEnumerable();
        final boolean writable     = property.isWritable();

        if (property instanceof UserAccessorProperty) {
            return global.newAccessorDescriptor(
                get != null ?
                    get :
                    UNDEFINED,
                set != null ?
                    set :
                    UNDEFINED,
                configurable,
                enumerable);
        }

        return global.newDataDescriptor(getWithProperty(property), configurable, enumerable, writable);
    }

    final int index = getArrayIndex(key);
    final ArrayData array = getArray();

    if (array.has(index)) {
        return array.getDescriptor(global, index);
    }

    return UNDEFINED;
}
 
Example 9
Source File: ScriptObject.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * ECMA 8.12.1 [[GetOwnProperty]] (P)
 *
 * @param key property key
 *
 * @return Returns the Property Descriptor of the named own property of this
 * object, or undefined if absent.
 */
public Object getOwnPropertyDescriptor(final String key) {
    final Property property = getMap().findProperty(key);

    final Global global = Context.getGlobal();

    if (property != null) {
        final ScriptFunction get   = property.getGetterFunction(this);
        final ScriptFunction set   = property.getSetterFunction(this);

        final boolean configurable = property.isConfigurable();
        final boolean enumerable   = property.isEnumerable();
        final boolean writable     = property.isWritable();

        if (property instanceof UserAccessorProperty) {
            return global.newAccessorDescriptor(
                get != null ?
                    get :
                    UNDEFINED,
                set != null ?
                    set :
                    UNDEFINED,
                configurable,
                enumerable);
        }

        return global.newDataDescriptor(getWithProperty(property), configurable, enumerable, writable);
    }

    final int index = getArrayIndex(key);
    final ArrayData array = getArray();

    if (array.has(index)) {
        return array.getDescriptor(global, index);
    }

    return UNDEFINED;
}
 
Example 10
Source File: ScriptObject.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * ECMA 8.12.1 [[GetOwnProperty]] (P)
 *
 * @param key property key
 *
 * @return Returns the Property Descriptor of the named own property of this
 * object, or undefined if absent.
 */
public Object getOwnPropertyDescriptor(final String key) {
    final Property property = getMap().findProperty(key);

    final Global global = Context.getGlobal();

    if (property != null) {
        final ScriptFunction get   = property.getGetterFunction(this);
        final ScriptFunction set   = property.getSetterFunction(this);

        final boolean configurable = property.isConfigurable();
        final boolean enumerable   = property.isEnumerable();
        final boolean writable     = property.isWritable();

        if (property instanceof UserAccessorProperty) {
            return global.newAccessorDescriptor(
                get != null ?
                    get :
                    UNDEFINED,
                set != null ?
                    set :
                    UNDEFINED,
                configurable,
                enumerable);
        }

        return global.newDataDescriptor(getWithProperty(property), configurable, enumerable, writable);
    }

    final int index = getArrayIndex(key);
    final ArrayData array = getArray();

    if (array.has(index)) {
        return array.getDescriptor(global, index);
    }

    return UNDEFINED;
}
 
Example 11
Source File: ScriptObject.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * ECMA 8.12.1 [[GetOwnProperty]] (P)
 *
 * @param key property key
 *
 * @return Returns the Property Descriptor of the named own property of this
 * object, or undefined if absent.
 */
public Object getOwnPropertyDescriptor(final String key) {
    final Property property = getMap().findProperty(key);

    final Global global = Context.getGlobal();

    if (property != null) {
        final ScriptFunction get   = property.getGetterFunction(this);
        final ScriptFunction set   = property.getSetterFunction(this);

        final boolean configurable = property.isConfigurable();
        final boolean enumerable   = property.isEnumerable();
        final boolean writable     = property.isWritable();

        if (property instanceof UserAccessorProperty) {
            return global.newAccessorDescriptor(
                get != null ?
                    get :
                    UNDEFINED,
                set != null ?
                    set :
                    UNDEFINED,
                configurable,
                enumerable);
        }

        return global.newDataDescriptor(getWithProperty(property), configurable, enumerable, writable);
    }

    final int index = getArrayIndex(key);
    final ArrayData array = getArray();

    if (array.has(index)) {
        return array.getDescriptor(global, index);
    }

    return UNDEFINED;
}
 
Example 12
Source File: ScriptObject.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * ECMA 8.12.1 [[GetOwnProperty]] (P)
 *
 * @param key property key
 *
 * @return Returns the Property Descriptor of the named own property of this
 * object, or undefined if absent.
 */
public Object getOwnPropertyDescriptor(final Object key) {
    final Property property = getMap().findProperty(key);

    final Global global = Context.getGlobal();

    if (property != null) {
        final ScriptFunction get   = property.getGetterFunction(this);
        final ScriptFunction set   = property.getSetterFunction(this);

        final boolean configurable = property.isConfigurable();
        final boolean enumerable   = property.isEnumerable();
        final boolean writable     = property.isWritable();

        if (property.isAccessorProperty()) {
            return global.newAccessorDescriptor(
                get != null ?
                    get :
                    UNDEFINED,
                set != null ?
                    set :
                    UNDEFINED,
                configurable,
                enumerable);
        }

        return global.newDataDescriptor(getWithProperty(property), configurable, enumerable, writable);
    }

    final int index = getArrayIndex(key);
    final ArrayData array = getArray();

    if (array.has(index)) {
        return array.getDescriptor(global, index);
    }

    return UNDEFINED;
}
 
Example 13
Source File: ScriptObject.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * ECMA 8.12.1 [[GetOwnProperty]] (P)
 *
 * @param key property key
 *
 * @return Returns the Property Descriptor of the named own property of this
 * object, or undefined if absent.
 */
public Object getOwnPropertyDescriptor(final String key) {
    final Property property = getMap().findProperty(key);

    final Global global = Context.getGlobal();

    if (property != null) {
        final ScriptFunction get   = property.getGetterFunction(this);
        final ScriptFunction set   = property.getSetterFunction(this);

        final boolean configurable = property.isConfigurable();
        final boolean enumerable   = property.isEnumerable();
        final boolean writable     = property.isWritable();

        if (property instanceof UserAccessorProperty) {
            return global.newAccessorDescriptor(
                get != null ?
                    get :
                    UNDEFINED,
                set != null ?
                    set :
                    UNDEFINED,
                configurable,
                enumerable);
        }

        return global.newDataDescriptor(getWithProperty(property), configurable, enumerable, writable);
    }

    final int index = getArrayIndex(key);
    final ArrayData array = getArray();

    if (array.has(index)) {
        return array.getDescriptor(global, index);
    }

    return UNDEFINED;
}
 
Example 14
Source File: ScriptObject.java    From jdk8u_nashorn with GNU General Public License v2.0 5 votes vote down vote up
/**
 * ECMA 8.12.1 [[GetOwnProperty]] (P)
 *
 * @param key property key
 *
 * @return Returns the Property Descriptor of the named own property of this
 * object, or undefined if absent.
 */
public Object getOwnPropertyDescriptor(final String key) {
    final Property property = getMap().findProperty(key);

    final Global global = Context.getGlobal();

    if (property != null) {
        final ScriptFunction get   = property.getGetterFunction(this);
        final ScriptFunction set   = property.getSetterFunction(this);

        final boolean configurable = property.isConfigurable();
        final boolean enumerable   = property.isEnumerable();
        final boolean writable     = property.isWritable();

        if (property instanceof UserAccessorProperty) {
            return global.newAccessorDescriptor(
                get != null ?
                    get :
                    UNDEFINED,
                set != null ?
                    set :
                    UNDEFINED,
                configurable,
                enumerable);
        }

        return global.newDataDescriptor(getWithProperty(property), configurable, enumerable, writable);
    }

    final int index = getArrayIndex(key);
    final ArrayData array = getArray();

    if (array.has(index)) {
        return array.getDescriptor(global, index);
    }

    return UNDEFINED;
}