Java Code Examples for jdk.nashorn.internal.runtime.PropertyDescriptor#ACCESSOR
The following examples show how to use
jdk.nashorn.internal.runtime.PropertyDescriptor#ACCESSOR .
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: NativeArguments.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * 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); }
Example 2
Source File: NativeArguments.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * 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); }
Example 3
Source File: NativeArguments.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * 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); }
Example 4
Source File: NativeArguments.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * 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); }
Example 5
Source File: NativeArguments.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * 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); }
Example 6
Source File: NativeArguments.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * 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); }
Example 7
Source File: NativeArguments.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * 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); }
Example 8
Source File: NativeArguments.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * 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); }
Example 9
Source File: NativeArguments.java From jdk8u_nashorn with GNU General Public License v2.0 | 5 votes |
/** * 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); }
Example 10
Source File: NativeArguments.java From nashorn with GNU General Public License v2.0 | 5 votes |
/** * 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); }