本文整理汇总了Java中jdk.nashorn.internal.runtime.PropertyDescriptor.type方法的典型用法代码示例。如果您正苦于以下问题:Java PropertyDescriptor.type方法的具体用法?Java PropertyDescriptor.type怎么用?Java PropertyDescriptor.type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jdk.nashorn.internal.runtime.PropertyDescriptor
的用法示例。
在下文中一共展示了PropertyDescriptor.type方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: defineOwnProperty
import jdk.nashorn.internal.runtime.PropertyDescriptor; //导入方法依赖的package包/类
/**
* ECMA 15.4.5.1 [[DefineOwnProperty]] ( P, Desc, Throw ) as specialized in
* ECMA 10.6 for Arguments object.
*/
@Override
public boolean defineOwnProperty(final String key, final Object propertyDesc, final boolean reject) {
final int index = ArrayIndex.getArrayIndex(key);
if (index >= 0) {
final boolean isMapped = isMapped(index);
final Object oldValue = isMapped ? getArray().getObject(index) : null;
if (!super.defineOwnProperty(key, propertyDesc, false)) {
if (reject) {
throw typeError("cant.redefine.property", key, ScriptRuntime.safeToString(this));
}
return false;
}
if (isMapped) {
// When mapped argument is redefined, if new descriptor is accessor property
// or data-non-writable property, we have to "unmap" (unlink).
final PropertyDescriptor desc = toPropertyDescriptor(Global.instance(), propertyDesc);
if (desc.type() == PropertyDescriptor.ACCESSOR) {
setDeleted(index, oldValue);
} else if (desc.has(PropertyDescriptor.WRITABLE) && !desc.isWritable()) {
// delete and set value from new descriptor if it has one, otherwise use old value
setDeleted(index, desc.has(PropertyDescriptor.VALUE) ? desc.getValue() : oldValue);
} else if (desc.has(PropertyDescriptor.VALUE)) {
setArray(getArray().set(index, desc.getValue(), false));
}
}
return true;
}
return super.defineOwnProperty(key, propertyDesc, reject);
}
示例2: defineOwnProperty
import jdk.nashorn.internal.runtime.PropertyDescriptor; //导入方法依赖的package包/类
/**
* ECMA 15.4.5.1 [[DefineOwnProperty]] ( P, Desc, Throw ) as specialized in
* ECMA 10.6 for Arguments object.
*/
@Override
public boolean defineOwnProperty(final Object key, final Object propertyDesc, final boolean reject) {
final int index = ArrayIndex.getArrayIndex(key);
if (index >= 0) {
final boolean isMapped = isMapped(index);
final Object oldValue = isMapped ? getArray().getObject(index) : null;
if (!super.defineOwnProperty(key, propertyDesc, false)) {
if (reject) {
throw typeError("cant.redefine.property", key.toString(), ScriptRuntime.safeToString(this));
}
return false;
}
if (isMapped) {
// When mapped argument is redefined, if new descriptor is accessor property
// or data-non-writable property, we have to "unmap" (unlink).
final PropertyDescriptor desc = toPropertyDescriptor(Global.instance(), propertyDesc);
if (desc.type() == PropertyDescriptor.ACCESSOR) {
setDeleted(index, oldValue);
} else if (desc.has(PropertyDescriptor.WRITABLE) && !desc.isWritable()) {
// delete and set value from new descriptor if it has one, otherwise use old value
setDeleted(index, desc.has(PropertyDescriptor.VALUE) ? desc.getValue() : oldValue);
} else if (desc.has(PropertyDescriptor.VALUE)) {
setArray(getArray().set(index, desc.getValue(), false));
}
}
return true;
}
return super.defineOwnProperty(key, propertyDesc, reject);
}