Esempio n. 1
0
        /// <summary>
        /// Get an array's next key
        /// </summary>
        /// <param name="key"></param>
        /// <param name="core"></param>
        /// <returns></returns>
        public static StackValue GetNextKey(StackValue key, RuntimeCore runtimeCore)
        {
            StackValue array;
            int        index;

            if (!key.TryGetArrayKey(out array, out index))
            {
                return(StackValue.Null);
            }

            int nextIndex = Constants.kInvalidIndex;

            if (array.IsString)
            {
                var str = runtimeCore.Heap.GetString(array);
                if (str.Length > index + 1)
                {
                    nextIndex = index + 1;
                }
            }
            else
            {
                HeapElement he = GetHeapElement(array, runtimeCore);
                if ((he.VisibleSize > index + 1) ||
                    (he.Dict != null && he.Dict.Count + he.VisibleSize > index + 1))
                {
                    nextIndex = index + 1;
                }
            }

            return(nextIndex == Constants.kInvalidIndex ? StackValue.Null : StackValue.BuildArrayKey(array, nextIndex));
        }
Esempio n. 2
0
        /// <summary>
        /// Get an array's next key
        /// </summary>
        /// <param name="key"></param>
        /// <param name="core"></param>
        /// <returns></returns>
        public static StackValue GetNextKey(StackValue key, Core core)
        {
            StackValue array;
            int        index;

            if (!key.TryGetArrayKey(out array, out index))
            {
                return(StackValue.Null);
            }

            HeapElement he = GetHeapElement(array, core);

            if ((he.VisibleSize > index + 1) ||
                (he.Dict != null && he.Dict.Count + he.VisibleSize > index + 1))
            {
                return(StackValue.BuildArrayKey(array, index + 1));
            }

            return(StackValue.Null);
        }