Exemple #1
0
        public static bool CompareFromDifferentCore(DSArray array1, DSArray array2, RuntimeCore rtCore1, RuntimeCore rtCore2, Context context = null)
        {
            if (array1.Count != array2.Count)
            {
                return(false);
            }

            var dict1 = array1.ToDictionary();

            for (int i = 0; i < array1.Count; i++)
            {
                if (!StackUtils.CompareStackValues(array1.GetValueAt(i), array2.GetValueAt(i), rtCore1, rtCore2, context))
                {
                    return(false);
                }
            }

            foreach (var key in array1.Dict.Keys)
            {
                StackValue value1 = array1.Dict[key];
                StackValue value2 = StackValue.Null;
                if (!array2.Dict.TryGetValue(key, out value2))
                {
                    return(false);
                }

                if (!StackUtils.CompareStackValues(value1, value2, rtCore1, rtCore2))
                {
                    return(false);
                }
            }

            return(true);
        }
Exemple #2
0
        /// <summary>
        /// Mark all items in the array.
        /// </summary>
        /// <param name="array">Array</param>
        /// <returns>Return the size of memory that referenced by the array</returns>
        private int TraverseArray(DSArray array)
        {
            var dict = array.ToDictionary();
            int size = array.MemorySize;

            foreach (var pair in array.ToDictionary())
            {
                var key = pair.Key;
                if (key.IsReferenceType)
                    size += RecursiveMark(key);

                var value = pair.Value;
                if (value.IsReferenceType)
                    size += RecursiveMark(value);
            }

            return size;
        }
Exemple #3
0
        public static bool CompareFromDifferentCore(DSArray array1, DSArray array2, RuntimeCore rtCore1, RuntimeCore rtCore2, Context context = null)
        {
            if (array1.VisibleSize != array2.VisibleSize)
            {
                return false;
            }

            var dict1 = array1.ToDictionary();
            for (int i = 0; i < array1.VisibleSize; i++)
            {
                if (!StackUtils.CompareStackValues(array1.GetItemAt(i), array2.GetItemAt(i), rtCore1, rtCore2, context))
                {
                    return false;
                }
            }

            foreach (var key in array1.Dict.Keys)
            {
                StackValue value1 = array1.Dict[key];
                StackValue value2 = StackValue.Null;
                if (!array2.Dict.TryGetValue(key, out value2))
                {
                    return false;
                }

                if (!StackUtils.CompareStackValues(value1, value2, rtCore1, rtCore2))
                {
                    return false;
                }
            }

            return true;
        }