Esempio n. 1
0
        /// <summary>
        /// Sets the PHP object descriptor which contains defined fields and informations about object.
        /// </summary>
        /// <param name="objectValue">The object value.</param>
        /// <param name="descriptor">The descriptor.</param>
        internal void SetDescriptor(ObjectValue objectValue, ObjectDescriptor descriptor)
        {
            lockedTest();

            ObjectDescriptors[objectValue] = descriptor;
        }
Esempio n. 2
0
        /// <summary>
        /// Processes the field - traverse thru all containing objects. When there is possibility undefined
        /// value in location new object is created.
        /// </summary>
        /// <param name="segment">The segment.</param>
        /// <param name="parentIndex">Index of the parent.</param>
        /// <param name="visitor">The visitor to process scalar values.</param>
        /// <param name="isMust">if set to <c>true</c> [is must].</param>
        private void processField(PathSegment segment, MemoryIndex parentIndex, FieldLocationVisitor visitor, bool isMust)
        {
            bool        processOtherValues = false;
            MemoryEntry entry;

            if (snapshot.Structure.TryGetMemoryEntry(parentIndex, out entry))
            {
                ObjectValueContainer objects = snapshot.Structure.GetObjects(parentIndex);
                if (objects.Count > 0)
                {
                    processOtherValues = entry.Count > objects.Count;
                }
                else if (entry.Count > 0)
                {
                    processOtherValues = true;
                }
                else
                {
                    entry = snapshot.Data.EmptyEntry;
                    processOtherValues = true;
                }
            }
            else
            {
                entry = snapshot.Data.EmptyEntry;
                processOtherValues = true;
            }

            if (processOtherValues)
            {
                if (entry.Count > 1)
                {
                    isMust = false;
                }

                visitor.ProcessValues(parentIndex, entry.PossibleValues, isMust);
                ReadFieldVisitor valueVisitor    = visitor.LastValueVisitor;
                bool             removeUndefined = isMust;

                if (valueVisitor.ContainsDefinedValue || valueVisitor.ContainsAnyValue)
                {
                    isMust = false;
                }

                if (valueVisitor.ContainsUndefinedValue && snapshot.CurrentMode == SnapshotMode.MemoryLevel)
                {
                    ObjectValue objectValue = snapshot.CreateObject(parentIndex, isMust, removeUndefined);
                }
            }

            ObjectValueContainer objectValues = snapshot.Structure.GetObjects(parentIndex);

            if (objectValues.Count == 1 && snapshot.HasMustReference(parentIndex))
            {
                ObjectDescriptor descriptor = snapshot.Structure.GetDescriptor(objectValues.First());
                creatorVisitor.ObjectValue = objectValues.First();
                processSegment(segment, descriptor, isMust);
            }
            else
            {
                foreach (ObjectValue value in objectValues)
                {
                    ObjectDescriptor descriptor = snapshot.Structure.GetDescriptor(value);
                    creatorVisitor.ObjectValue = value;
                    processSegment(segment, descriptor, false);
                }
            }
        }
Esempio n. 3
0
 /// <summary>
 /// Tries to get the PHP object descriptor which contains defined fields and informations about object.
 /// </summary>
 /// <param name="objectValue">The object value.</param>
 /// <param name="descriptor">The descriptor.</param>
 /// <returns>True whether structure contains PHP object descriptor which contains defined fields and informations about object.</returns>
 internal bool TryGetDescriptor(ObjectValue objectValue, out ObjectDescriptor descriptor)
 {
     return(ObjectDescriptors.TryGetValue(objectValue, out descriptor));
 }