示例#1
0
        public static EcmaValue Store(TypedArray array, EcmaValue index, EcmaValue value)
        {
            int pos = ValidateArrayAndIndex(array, index);

            value = value.ToInteger();
            array.SetValueInBuffer(pos, value);
            return(value);
        }
示例#2
0
 public static long GetBoundIndex(EcmaValue index, long len, long defaultValue)
 {
     if (index == default)
     {
         return(defaultValue);
     }
     index = index.ToInteger();
     return((index < 0 ? EcmaMath.Max(len + index, 0) : EcmaMath.Min(index, len)).ToInt64());
 }
示例#3
0
 public static int GetBoundIndexClamped(EcmaValue index, int len, int defaultValue)
 {
     if (index == default)
     {
         return(defaultValue);
     }
     index = index.ToInteger();
     return((index < 0 ? 0 : EcmaMath.Min(index, len)).ToInt32());
 }
示例#4
0
        public static int ToInteger(this EcmaValue thisValue, int min, int max)
        {
            EcmaValue value = thisValue.ToInteger();

            return(value > max ? max : value < min ? min : (int)value);
        }