/// <inheritdoc /> public void Assign(Snapshot snapshot, MemoryPath path, MemoryEntry value, bool forceStrongWrite) { if (snapshot.AssignInfo == null) { snapshot.AssignInfo = new AssignInfo(); } MemoryIndexModificationList pathModifications = snapshot.AssignInfo.GetOrCreatePathModification(path); List <Tuple <MemoryIndex, HashSet <Value> > > valuesToAssign = new List <Tuple <MemoryIndex, HashSet <Value> > >(); // Prepares locations and values to assign foreach (var item in pathModifications.Modifications) { MemoryIndex index = item.Key; MemoryIndexModification indexModification = item.Value; HashSet <Value> values = new HashSet <Value>(); valuesToAssign.Add(new Tuple <MemoryIndex, HashSet <Value> >(index, values)); if (indexModification.IsCollectedIndex) { CollectionMemoryUtils.AddAll(values, value.PossibleValues); } // Loads all other datasources where to get additional values to assign - unknown indexes. foreach (var datasource in indexModification.Datasources) { MemoryEntry entry; if (datasource.SourceSnapshot.Infos.Readonly.TryGetMemoryEntry(datasource.SourceIndex, out entry)) { CollectionMemoryUtils.AddAll(values, entry.PossibleValues); } } } // Assigns values to locations foreach (var item in valuesToAssign) { MemoryIndex index = item.Item1; HashSet <Value> values = item.Item2; MemoryEntry entry = new MemoryEntry(values); snapshot.Infos.Writeable.SetMemoryEntry(index, entry); } }
protected override void collectValueNode(ValueCollectorNode node) { MemoryIndexModification modification = PathModifications.GetOrCreateModification(node.TargetIndex); if (node.IsMust || ForceStrongWrite) { modification.SetCollectedIndex(); valueLocationVisitor.IsMust = true; node.ValueLocation.ContainingIndex = node.TargetIndex; node.ValueLocation.Accept(valueLocationVisitor); } else { modification.SetCollectedIndex(); valueLocationVisitor.IsMust = false; node.ValueLocation.ContainingIndex = node.TargetIndex; node.ValueLocation.Accept(valueLocationVisitor); } }