/// <summary> /// Assigns the given memory entry into all collected indexes in the collector. /// Must indexes are strongly updated may indexes weakly. /// </summary> /// <param name="collector">The collector.</param> /// <param name="value">The value.</param> internal void Assign(AssignCollector collector, AnalysisFramework.Memory.MemoryEntry value) { CollectComposedValuesVisitor composedValues = new CollectComposedValuesVisitor(); composedValues.VisitMemoryEntry(value); foreach (MemoryIndex mustIndex in collector.MustIndexes) { assignMust(mustIndex, composedValues); } foreach (MemoryIndex mayIndex in collector.MayIndexes) { assignMay(mayIndex, composedValues); } if (snapshot.CurrentMode == SnapshotMode.InfoLevel) { InfoLocationVisitor mustVisitor = new InfoLocationVisitor(snapshot, value, true); foreach (ValueLocation mustLocation in collector.MustLocation) { mustLocation.Accept(mustVisitor); } InfoLocationVisitor mayVisitor = new InfoLocationVisitor(snapshot, value, false); foreach (ValueLocation mustLocation in collector.MayLocaton) { mustLocation.Accept(mayVisitor); } } }
/// <summary> /// Reads the values from locations specified by given collector. /// </summary> /// <param name="collector">The collector.</param> /// <returns>Memory entry with values from locations specified by given collector.</returns> public MemoryEntry ReadValue(IIndexCollector collector) { if (collector.MustIndexesCount == 1 && collector.IsDefined) { MemoryIndex index = collector.MustIndexes.First(); return(snapshot.Structure.GetMemoryEntry(index)); } else { HashSet <Value> values = new HashSet <Value>(); if (!collector.IsDefined) { values.Add(snapshot.UndefinedValue); } foreach (MemoryIndex index in collector.MustIndexes) { MemoryEntry entry = snapshot.Structure.GetMemoryEntry(index); HashSetTools.AddAll(values, entry.PossibleValues); } foreach (ValueLocation location in collector.MustLocation) { if (snapshot.CurrentMode == SnapshotMode.MemoryLevel) { HashSetTools.AddAll(values, location.ReadValues(snapshot.MemoryAssistant)); } else { InfoLocationVisitor visitor = new InfoLocationVisitor(snapshot); location.Accept(visitor); HashSetTools.AddAll(values, visitor.Value); } } return(new MemoryEntry(values)); } }