本文整理汇总了Java中jdk.nashorn.internal.runtime.arrays.ArrayIndex.toLongIndex方法的典型用法代码示例。如果您正苦于以下问题:Java ArrayIndex.toLongIndex方法的具体用法?Java ArrayIndex.toLongIndex怎么用?Java ArrayIndex.toLongIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jdk.nashorn.internal.runtime.arrays.ArrayIndex
的用法示例。
在下文中一共展示了ArrayIndex.toLongIndex方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doesNotHave
import jdk.nashorn.internal.runtime.arrays.ArrayIndex; //导入方法依赖的package包/类
private void doesNotHave(final int index, final int value, final int callSiteFlags) {
final long oldLength = getArray().length();
final long longIndex = ArrayIndex.toLongIndex(index);
if (!doesNotHaveCheckArrayKeys(longIndex, value, callSiteFlags) && !doesNotHaveEnsureLength(longIndex, oldLength, callSiteFlags)) {
final boolean strict = isStrictFlag(callSiteFlags);
setArray(getArray().set(index, value, strict));
doesNotHaveEnsureDelete(longIndex, oldLength, strict);
}
}
示例2: addArrayElement
import jdk.nashorn.internal.runtime.arrays.ArrayIndex; //导入方法依赖的package包/类
private static ArrayData addArrayElement(final ArrayData arrayData, final int index, final Object value) {
final long oldLength = arrayData.length();
final long longIndex = ArrayIndex.toLongIndex(index);
ArrayData newArrayData = arrayData;
if (longIndex >= oldLength) {
newArrayData = newArrayData.ensure(longIndex);
if (longIndex > oldLength) {
newArrayData = newArrayData.delete(oldLength, longIndex - 1);
}
}
return newArrayData.set(index, value, false);
}
示例3: doesNotHave
import jdk.nashorn.internal.runtime.arrays.ArrayIndex; //导入方法依赖的package包/类
private void doesNotHave(final int index, final int value, final int callSiteFlags) {
final long oldLength = getArray().length();
final long longIndex = ArrayIndex.toLongIndex(index);
if (!doesNotHaveCheckArrayKeys(longIndex, value, callSiteFlags) && !doesNotHaveEnsureLength(longIndex, oldLength, callSiteFlags)) {
final boolean strict = isStrictFlag(callSiteFlags);
setArray(getArray().set(index, value, strict).safeDelete(oldLength, longIndex - 1, strict));
}
}
示例4: defineOwnProperty
import jdk.nashorn.internal.runtime.arrays.ArrayIndex; //导入方法依赖的package包/类
/**
* ECMA 15.4.5.1 [[DefineOwnProperty]] ( P, Desc, Throw )
*/
@Override
public boolean defineOwnProperty(final String key, final Object propertyDesc, final boolean reject) {
final PropertyDescriptor desc = toPropertyDescriptor(Global.instance(), propertyDesc);
// never be undefined as "length" is always defined and can't be deleted for arrays
// Step 1
final PropertyDescriptor oldLenDesc = (PropertyDescriptor) super.getOwnPropertyDescriptor("length");
// Step 2
// get old length and convert to long
final long oldLen = NativeArray.validLength(oldLenDesc.getValue(), true);
// Step 3
if ("length".equals(key)) {
// check for length being made non-writable
final boolean result = defineLength(oldLen, oldLenDesc, desc, reject);
if (desc.has(WRITABLE) && !desc.isWritable()) {
setIsLengthNotWritable();
}
return result;
}
// Step 4a
final int index = ArrayIndex.getArrayIndex(key);
if (ArrayIndex.isValidArrayIndex(index)) {
final long longIndex = ArrayIndex.toLongIndex(index);
// Step 4b
// setting an element beyond current length, but 'length' is not writable
if (longIndex >= oldLen && !oldLenDesc.isWritable()) {
if (reject) {
throw typeError("property.not.writable", Long.toString(longIndex), ScriptRuntime.safeToString(this));
}
return false;
}
// Step 4c
// set the new array element
final boolean succeeded = super.defineOwnProperty(key, desc, false);
// Step 4d
if (!succeeded) {
if (reject) {
throw typeError("cant.redefine.property", key, ScriptRuntime.safeToString(this));
}
return false;
}
// Step 4e -- adjust new length based on new element index that is set
if (longIndex >= oldLen) {
oldLenDesc.setValue(longIndex + 1);
super.defineOwnProperty("length", oldLenDesc, false);
}
// Step 4f
return true;
}
// not an index property
return super.defineOwnProperty(key, desc, reject);
}
示例5: defineOwnProperty
import jdk.nashorn.internal.runtime.arrays.ArrayIndex; //导入方法依赖的package包/类
/**
* ECMA 15.4.5.1 [[DefineOwnProperty]] ( P, Desc, Throw )
*/
@Override
public boolean defineOwnProperty(final Object key, final Object propertyDesc, final boolean reject) {
final PropertyDescriptor desc = toPropertyDescriptor(Global.instance(), propertyDesc);
// never be undefined as "length" is always defined and can't be deleted for arrays
// Step 1
final PropertyDescriptor oldLenDesc = (PropertyDescriptor) super.getOwnPropertyDescriptor("length");
// Step 2
// get old length and convert to long. Always a Long/Uint32 but we take the safe road.
final long oldLen = JSType.toUint32(oldLenDesc.getValue());
// Step 3
if ("length".equals(key)) {
// check for length being made non-writable
final boolean result = defineLength(oldLen, oldLenDesc, desc, reject);
if (desc.has(WRITABLE) && !desc.isWritable()) {
setIsLengthNotWritable();
}
return result;
}
// Step 4a
final int index = ArrayIndex.getArrayIndex(key);
if (ArrayIndex.isValidArrayIndex(index)) {
final long longIndex = ArrayIndex.toLongIndex(index);
// Step 4b
// setting an element beyond current length, but 'length' is not writable
if (longIndex >= oldLen && !oldLenDesc.isWritable()) {
if (reject) {
throw typeError("property.not.writable", Long.toString(longIndex), ScriptRuntime.safeToString(this));
}
return false;
}
// Step 4c
// set the new array element
final boolean succeeded = super.defineOwnProperty(key, desc, false);
// Step 4d
if (!succeeded) {
if (reject) {
throw typeError("cant.redefine.property", key.toString(), ScriptRuntime.safeToString(this));
}
return false;
}
// Step 4e -- adjust new length based on new element index that is set
if (longIndex >= oldLen) {
oldLenDesc.setValue(longIndex + 1);
super.defineOwnProperty("length", oldLenDesc, false);
}
// Step 4f
return true;
}
// not an index property
return super.defineOwnProperty(key, desc, reject);
}
示例6: defineOwnProperty
import jdk.nashorn.internal.runtime.arrays.ArrayIndex; //导入方法依赖的package包/类
/**
* ECMA 15.4.5.1 [[DefineOwnProperty]] ( P, Desc, Throw )
*/
@Override
public boolean defineOwnProperty(final String key, final Object propertyDesc, final boolean reject) {
final PropertyDescriptor desc = toPropertyDescriptor(Global.instance(), propertyDesc);
// never be undefined as "length" is always defined and can't be deleted for arrays
// Step 1
final PropertyDescriptor oldLenDesc = (PropertyDescriptor) super.getOwnPropertyDescriptor("length");
// Step 2
// get old length and convert to long. Always a Long/Uint32 but we take the safe road.
final long oldLen = JSType.toUint32(oldLenDesc.getValue());
// Step 3
if ("length".equals(key)) {
// check for length being made non-writable
final boolean result = defineLength(oldLen, oldLenDesc, desc, reject);
if (desc.has(WRITABLE) && !desc.isWritable()) {
setIsLengthNotWritable();
}
return result;
}
// Step 4a
final int index = ArrayIndex.getArrayIndex(key);
if (ArrayIndex.isValidArrayIndex(index)) {
final long longIndex = ArrayIndex.toLongIndex(index);
// Step 4b
// setting an element beyond current length, but 'length' is not writable
if (longIndex >= oldLen && !oldLenDesc.isWritable()) {
if (reject) {
throw typeError("property.not.writable", Long.toString(longIndex), ScriptRuntime.safeToString(this));
}
return false;
}
// Step 4c
// set the new array element
final boolean succeeded = super.defineOwnProperty(key, desc, false);
// Step 4d
if (!succeeded) {
if (reject) {
throw typeError("cant.redefine.property", key, ScriptRuntime.safeToString(this));
}
return false;
}
// Step 4e -- adjust new length based on new element index that is set
if (longIndex >= oldLen) {
oldLenDesc.setValue(longIndex + 1);
super.defineOwnProperty("length", oldLenDesc, false);
}
// Step 4f
return true;
}
// not an index property
return super.defineOwnProperty(key, desc, reject);
}