当前位置: 首页>>代码示例>>Java>>正文


Java Global.newAccessorDescriptor方法代码示例

本文整理汇总了Java中jdk.nashorn.internal.objects.Global.newAccessorDescriptor方法的典型用法代码示例。如果您正苦于以下问题:Java Global.newAccessorDescriptor方法的具体用法?Java Global.newAccessorDescriptor怎么用?Java Global.newAccessorDescriptor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在jdk.nashorn.internal.objects.Global的用法示例。


在下文中一共展示了Global.newAccessorDescriptor方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: toPropertyDescriptor

import jdk.nashorn.internal.objects.Global; //导入方法依赖的package包/类
/**
  * 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);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:28,代码来源:ScriptObject.java

示例2: getOwnPropertyDescriptor

import jdk.nashorn.internal.objects.Global; //导入方法依赖的package包/类
/**
 * 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;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:46,代码来源:ScriptObject.java

示例3: getOwnPropertyDescriptor

import jdk.nashorn.internal.objects.Global; //导入方法依赖的package包/类
/**
 * 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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:46,代码来源:ScriptObject.java


注:本文中的jdk.nashorn.internal.objects.Global.newAccessorDescriptor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。