예제 #1
0
        /// <summary>
        /// Compares this structure object with given copy of old data and applies simplify limit when new memory entry is bigger than given simplify limit.
        /// </summary>
        /// <param name="oldValue">The old value.</param>
        /// <param name="simplifyLimit">The simplify limit.</param>
        /// <param name="assistant">The assistant.</param>
        /// <returns><c>true</c> if the data are same; otherwise, <c>false</c>.</returns>
        private bool compareDataAndSimplify(SnapshotStructure oldValue, int simplifyLimit, MemoryAssistantBase assistant)
        {
            HashSet <MemoryIndex> usedIndexes = new HashSet <MemoryIndex>();

            HashSetTools.AddAll(usedIndexes, this.IndexData.Keys);
            HashSetTools.AddAll(usedIndexes, oldValue.IndexData.Keys);

            IndexData emptyStructure = new CopyMemoryModel.IndexData(null, null, null);

            bool areEqual = true;

            foreach (MemoryIndex index in usedIndexes)
            {
                if (index is TemporaryIndex)
                {
                    continue;
                }
                IndexData newStructure = getDataOrUndefined(index, this, emptyStructure);
                IndexData oldStructure = getDataOrUndefined(index, oldValue, emptyStructure);

                if (!newStructure.DataEquals(oldStructure))
                {
                    areEqual = false;
                }

                if (!Data.DataEqualsAndSimplify(oldValue.Data, index, simplifyLimit, assistant))
                {
                    areEqual = false;
                }
            }

            return(areEqual);
        }
예제 #2
0
        /// <summary>
        /// Compares this structure object with given copy of old data and applies widening operation on memory entry which differs.
        /// </summary>
        /// <param name="oldValue">The old value.</param>
        /// <param name="simplifyLimit">The simplify limit.</param>
        /// <param name="assistant">The assistant.</param>
        /// <returns><c>true</c> if the data are same; otherwise, <c>false</c>.</returns>
        private bool widenNotEqualData(SnapshotStructure oldValue, int simplifyLimit, MemoryAssistantBase assistant)
        {
            HashSet <MemoryIndex> indexes = new HashSet <MemoryIndex>();

            HashSetTools.AddAll(indexes, this.IndexData.Keys);
            HashSetTools.AddAll(indexes, oldValue.IndexData.Keys);

            IndexData emptyData = new CopyMemoryModel.IndexData(null, null, null);

            bool areEqual = true;

            foreach (MemoryIndex index in indexes)
            {
                if (index is TemporaryIndex)
                {
                    continue;
                }

                IndexData newData = getDataOrUndefined(index, this, emptyData);
                IndexData oldData = getDataOrUndefined(index, oldValue, emptyData);

                Data.DataWiden(oldValue.Data, index, assistant);

                if (!Data.DataEqualsAndSimplify(oldValue.Data, index, simplifyLimit, assistant))
                {
                    areEqual = false;
                }
            }

            return(areEqual);
        }
예제 #3
0
        /// <summary>
        /// Compares this structure object with given copy of old data.
        /// </summary>
        /// <param name="oldValue">The old value.</param>
        /// <returns><c>true</c> if the data are same; otherwise, <c>false</c>.</returns>
        private bool compareData(SnapshotStructure oldValue)
        {
            HashSet <MemoryIndex> usedIndexes = new HashSet <MemoryIndex>();

            HashSetTools.AddAll(usedIndexes, this.IndexData.Keys);
            HashSetTools.AddAll(usedIndexes, oldValue.IndexData.Keys);

            IndexData emptyStructure = new CopyMemoryModel.IndexData(null, null, null);

            foreach (MemoryIndex index in usedIndexes)
            {
                if (index is TemporaryIndex)
                {
                    continue;
                }
                IndexData newStructure = getDataOrUndefined(index, this, emptyStructure);
                IndexData oldStructure = getDataOrUndefined(index, oldValue, emptyStructure);

                if (!newStructure.DataEquals(oldStructure))
                {
                    return(false);
                }

                if (!Data.DataEquals(oldValue.Data, index))
                {
                    return(false);
                }
            }

            return(true);
        }