示例#1
0
        /// <summary>
        /// Deeply copies the specified source index into target index.
        /// </summary>
        /// <param name="sourceIndex">Index of the source.</param>
        /// <param name="targetIndex">Index of the target.</param>
        public void Copy(MemoryIndex sourceIndex, MemoryIndex targetIndex)
        {
            if (!sourceIndex.IsPrefixOf(targetIndex) && !targetIndex.IsPrefixOf(sourceIndex))
            {
                MemoryEntry entry = snapshot.Structure.GetMemoryEntry(sourceIndex);

                CopyWithinSnapshotVisitor visitor = new CopyWithinSnapshotVisitor(this, targetIndex);
                visitor.VisitMemoryEntry(entry);

                if (isMust && visitor.GetValuesCount() == 1 && objectValues.Count == 1)
                {
                    ObjectValueContainerBuilder objectsValues = snapshot.Structure.GetObjects(targetIndex).Builder();

                    ObjectValue value = objectValues.First();
                    objectsValues.Add(value);
                    snapshot.Structure.SetObjects(targetIndex, objectsValues.Build());
                }
                else if (objectValues.Count > 0)
                {
                    ObjectValueContainerBuilder objectsValues = snapshot.Structure.GetObjects(targetIndex).Builder();
                    foreach (ObjectValue value in objectValues)
                    {
                        objectsValues.Add(value);
                    }
                    snapshot.Structure.SetObjects(targetIndex, objectsValues.Build());
                }

                if (!isMust)
                {
                    visitor.AddValue(snapshot.UndefinedValue);
                }

                snapshot.CopyAliases(sourceIndex, targetIndex, isMust);

                snapshot.Structure.SetMemoryEntry(targetIndex, visitor.GetCopiedEntry());
            }
        }
示例#2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ObjectValueContainer"/> class.
 /// </summary>
 /// <param name="builder">The builder.</param>
 public ObjectValueContainer(ObjectValueContainerBuilder builder)
 {
     values = new HashSet <ObjectValue>(builder.Values);
 }