/// <summary> /// Tests the and create implicit object. /// </summary> /// <param name="node">The node.</param> /// <param name="values">The values.</param> private void testAndCreateImplicitObject(MemoryCollectorNode node, HashSet <Value> values) { if (node.HasNewImplicitObject) { ObjectValue value = Snapshot.MemoryAssistant.CreateImplicitObject(); values.Add(value); IObjectValueContainerBuilder objectValues = Structure.GetObjects(node.TargetIndex).Builder(Structure); objectValues.Add(value); Structure.SetObjects(node.TargetIndex, objectValues.Build(Structure)); IObjectDescriptor oldDescriptor = Structure.GetDescriptor(value); IObjectDescriptorBuilder builder = oldDescriptor.Builder(Structure); foreach (var newChild in node.ImplicitObjectNode.UndefinedChildren) { string childName = newChild.Item1; MemoryCollectorNode childNode = newChild.Item2; MemoryIndex index = ObjectIndex.Create(value, childName); childNode.TargetIndex = index; builder.AddIndex(childName, index); } IObjectDescriptor newDescriptor = builder.Build(Structure); Structure.SetDescriptor(value, newDescriptor); enqueueChildNodes(node.ImplicitObjectNode); } }
/// <summary> /// Creates the merge operation for all fields of specified object. /// </summary> /// <param name="objectValue">The object value.</param> private void mergeObject(ObjectValue objectValue) { IObjectDescriptorBuilder builder = Factories.StructuralContainersFactories.ObjectDescriptorFactory.CreateObjectDescriptor(writeableStrucure, objectValue, null, ObjectIndex.CreateUnknown(objectValue)) .Builder(writeableStrucure); ContainerOperations collectVariables = new ContainerOperations(this, builder, builder.UnknownIndex, builder.UnknownIndex); foreach (Snapshot snapshot in sourceSnapshots) { IObjectDescriptor descriptor; if (snapshot.Structure.Readonly.TryGetDescriptor(objectValue, out descriptor)) { collectVariables.CollectIndexes(snapshot, builder.UnknownIndex, descriptor); builder.SetType(descriptor.Type); } else { collectVariables.SetUndefined(); } } collectVariables.MergeContainers(); writeableStrucure.SetDescriptor(objectValue, builder.Build(writeableStrucure)); }
/// <summary> /// Gets the current descriptor. /// </summary> /// <returns>Descriptor</returns> public IObjectDescriptor getCurrentDescriptor() { if (builder == null) { return(objectDescriptor); } else { return(builder.Build(structure)); } }
/// <summary> /// Processes the object. /// </summary> /// <param name="objectValue">The object value.</param> /// <param name="node">The node.</param> private void processObject(ObjectValue objectValue, ContainerCollectorNode node) { if (node.HasUndefinedChildren) { IObjectDescriptor oldDescriptor = Structure.GetDescriptor(objectValue); IObjectDescriptorBuilder builder = oldDescriptor.Builder(Structure); foreach (var newChild in node.UndefinedChildren) { string childName = newChild.Item1; MemoryCollectorNode childNode = newChild.Item2; MemoryIndex index = ObjectIndex.Create(objectValue, childName); childNode.TargetIndex = index; builder.AddIndex(childName, index); } IObjectDescriptor newDescriptor = builder.Build(Structure); Structure.SetDescriptor(objectValue, newDescriptor); } enqueueChildNodes(node); }