private bool canBeDifferent(MemoryEntry left, MemoryEntry right) { if (containsAnyValue(left) || containsAnyValue(right)) { return(true); } if (left.PossibleValues.Count() > 1 || left.PossibleValues.Count() > 1) { return(true); } return(!left.Equals(right)); }
/// <summary> /// Simplify data of single memory index if exceeds given simplify limit and compares it with the data inside given data container. /// </summary> /// <param name="oldData">The old data.</param> /// <param name="index">The index.</param> /// <param name="simplifyLimit">The simplify limit.</param> /// <param name="assistant">The assistant.</param> /// <returns>True whether compared data are the same.</returns> public bool DataEqualsAndSimplify(SnapshotData oldData, MemoryIndex index, int simplifyLimit, MemoryAssistantBase assistant) { MemoryEntry newEntry = null; if (!this.IndexData.TryGetValue(index, out newEntry)) { newEntry = EmptyEntry; } MemoryEntry oldEntry = null; if (!oldData.IndexData.TryGetValue(index, out oldEntry)) { oldEntry = EmptyEntry; } if (oldEntry.Equals(newEntry)) { return(true); } else if (newEntry.Count > simplifyLimit) { MemoryIndex testIndex = ControlIndex.Create(".return", 6); if (testIndex.Equals(index)) { } MemoryEntry simplifiedEntry = assistant.Simplify(newEntry); SetMemoryEntry(index, simplifiedEntry); return(oldEntry.Equals(simplifiedEntry)); } else { return(false); } }
/// <summary> /// Widens the data of given memory index in this data container. /// </summary> /// <param name="oldData">The old data.</param> /// <param name="index">The index.</param> /// <param name="assistant">The assistant.</param> public void DataWiden(SnapshotData oldData, MemoryIndex index, MemoryAssistantBase assistant) { MemoryEntry newEntry = null; if (!this.IndexData.TryGetValue(index, out newEntry)) { newEntry = EmptyEntry; } MemoryEntry oldEntry = null; if (!oldData.IndexData.TryGetValue(index, out oldEntry)) { oldEntry = EmptyEntry; } MemoryIndex testIndex = ControlIndex.Create(".return", 6); if (testIndex.Equals(index)) { } if (!oldEntry.Equals(newEntry)) { MemoryEntry widenedEntry = assistant.Widen(oldEntry, newEntry); CollectComposedValuesVisitor newVisitor = new CollectComposedValuesVisitor(); newVisitor.VisitMemoryEntry(newEntry); CollectComposedValuesVisitor widenedVisitor = new CollectComposedValuesVisitor(); widenedVisitor.VisitMemoryEntry(widenedEntry); if (newVisitor.Arrays.Count != widenedVisitor.Arrays.Count) { snapshot.DestroyArray(index); } if (newVisitor.Objects.Count != widenedVisitor.Objects.Count) { snapshot.Structure.SetObjects(index, null); } SetMemoryEntry(index, assistant.Widen(oldEntry, new MemoryEntry(widenedVisitor.Values))); } }
/// <summary> /// Compares data of single memory index within this and given data container. /// </summary> /// <param name="oldData">The old data.</param> /// <param name="index">The index.</param> /// <returns>True whether compared data are the same.</returns> public bool DataEquals(SnapshotData oldData, MemoryIndex index) { MemoryEntry newEntry = null; if (!this.IndexData.TryGetValue(index, out newEntry)) { newEntry = EmptyEntry; } MemoryEntry oldEntry = null; if (!oldData.IndexData.TryGetValue(index, out oldEntry)) { oldEntry = EmptyEntry; } return(oldEntry.Equals(newEntry)); }