本文整理汇总了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);
}
示例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;
}
示例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;
}