當前位置: 首頁>>代碼示例>>C#>>正文


C# StackValue.TryGetArrayKey方法代碼示例

本文整理匯總了C#中ProtoCore.DSASM.StackValue.TryGetArrayKey方法的典型用法代碼示例。如果您正苦於以下問題:C# StackValue.TryGetArrayKey方法的具體用法?C# StackValue.TryGetArrayKey怎麽用?C# StackValue.TryGetArrayKey使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ProtoCore.DSASM.StackValue的用法示例。


在下文中一共展示了StackValue.TryGetArrayKey方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: GetValueAtIndex

 public StackValue GetValueAtIndex(StackValue index, RuntimeCore runtimeCore)
 {
     int pos = Constants.kInvalidIndex;
     if (index.IsNumeric)
     {
         pos = (int)index.ToInteger().IntegerValue;
         return GetValueAtIndex(pos, runtimeCore);
     }
     else if (index.IsArrayKey)
     {
         StackValue array;
         index.TryGetArrayKey(out array, out pos);
         return GetValueAtIndex(pos, runtimeCore);
     }
     else
     {
         if (runtimeCore != null)
             runtimeCore.RuntimeStatus.LogWarning(WarningID.InvalidIndexing, Resources.kInvalidArguments);
         return StackValue.Null;
     }
 }
開發者ID:sh4nnongoh,項目名稱:Dynamo,代碼行數:21,代碼來源:HeapObjects.cs

示例2: GetNextKey

        /// <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;
        }
開發者ID:jbenoit44,項目名稱:Dynamo,代碼行數:25,代碼來源:ArrayUtils.cs

示例3: GetValueFromIndex

        /// <summary>
        /// = array[index].
        /// 
        /// Note this function doesn't support the replication of array indexing.
        /// </summary>
        /// <param name="index"></param>
        /// <param name="core"></param>
        /// <returns></returns>
        public StackValue GetValueFromIndex(StackValue index, RuntimeCore runtimeCore)
        {
            if (index.IsNumeric)
            {
                index = index.ToInteger();
                return GetValueFromIndex((int)index.IntegerValue, runtimeCore);
            }
            else if (index.IsArrayKey)
            {
                int fullIndex = Constants.kInvalidIndex;
                StackValue array;
                index.TryGetArrayKey(out array, out fullIndex);

                if (Count > fullIndex)
                {
                    return GetValueFromIndex(fullIndex, runtimeCore);
                }
                else
                {
                    fullIndex = fullIndex - Count;
                    if (Dict != null && Dict.Count > fullIndex)
                    {
                        int count = 0;
                        foreach (var key in Dict.Keys)
                        {
                            if (count == fullIndex)
                            {
                                return Dict[key];
                            }
                            count = count + 1;
                        }
                    }
                }

                return StackValue.Null;
            }
            else
            {
                StackValue value = StackValue.Null;
                if (Dict.TryGetValue(index, out value))
                {
                    return value;
                }
                else
                {
                    return StackValue.Null;
                }
            }
        }
開發者ID:sh4nnongoh,項目名稱:Dynamo,代碼行數:57,代碼來源:HeapObjects.cs

示例4: GetNextKey

        /// <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);
        }
開發者ID:junmendoza,項目名稱:Dynamo,代碼行數:33,代碼來源:ArrayUtils.cs


注:本文中的ProtoCore.DSASM.StackValue.TryGetArrayKey方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。