コード例 #1
0
        /// <summary>
        /// Read memory represented by current snapshot entry
        /// </summary>
        /// <param name="context">Context snapshot where operation is proceeded</param>
        /// <returns>
        /// Memory represented by current snapshot entry
        /// </returns>
        /// <exception cref="System.NotSupportedException">Current mode:  + snapshot.CurrentMode</exception>
        protected override MemoryEntry readMemory(SnapshotBase context)
        {
            SnapshotLogger.append(context, "read memory - " + this.ToString());

            if (isTemporarySet(context))
            {
                SnapshotLogger.append(context, "read from temporary location - " + this.ToString());
                return(temporaryLocation.ReadMemory(context));
            }
            else
            {
                SnapshotLogger.append(context, "read just value - " + this.ToString());
                Snapshot snapshot = SnapshotEntry.ToSnapshot(context);
                switch (snapshot.CurrentMode)
                {
                case SnapshotMode.MemoryLevel:
                    return(dataEntry);

                case SnapshotMode.InfoLevel:
                    return(infoEntry);

                default:
                    throw new NotSupportedException("Current mode: " + snapshot.CurrentMode);
                }
            }
        }
コード例 #2
0
        public static void append(SnapshotBase snapshotBase, String message)
        {
#if COPY_SNAPSHOT_LOG
            Snapshot snapshot = SnapshotEntry.ToSnapshot(snapshotBase);
            append(snapshot, message);
#endif
        }
コード例 #3
0
        /// <summary>
        /// Write given value at memory represented by snapshot entry
        /// </summary>
        /// <param name="context">Context snapshot where operation is proceeded</param>
        /// <param name="value">Written value</param>
        /// <param name="forceStrongWrite">Determine that current write should be processed as strong</param>
        /// <exception cref="System.NotSupportedException">Current mode:  + snapshot.CurrentMode</exception>
        protected override void writeMemory(SnapshotBase context, MemoryEntry value, bool forceStrongWrite)
        {
            SnapshotLogger.append(context, "write memory - " + this.ToString());
            Snapshot snapshot = SnapshotEntry.ToSnapshot(context);

            switch (snapshot.CurrentMode)
            {
            case SnapshotMode.MemoryLevel:
                getTemporary(context).WriteMemory(context, value, forceStrongWrite);
                break;

            case SnapshotMode.InfoLevel:
                if (isTemporarySet(context))
                {
                    getTemporary(context).WriteMemory(context, value, forceStrongWrite);
                }
                else
                {
                    infoEntry = value;
                }
                break;

            default:
                throw new NotSupportedException("Current mode: " + snapshot.CurrentMode);
            }
        }
コード例 #4
0
        /// <summary>
        /// Iterates the indexes of PHP array in entry.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="snapshotEntry">The snapshot entry.</param>
        /// <returns>The list of indexes in the given snapshot entry.</returns>
        public static IEnumerable <MemberIdentifier> IterateIndexes(SnapshotBase context, ICopyModelSnapshotEntry snapshotEntry)
        {
            Snapshot    snapshot = SnapshotEntry.ToSnapshot(context);
            MemoryEntry entry    = snapshotEntry.ReadMemory(snapshot);

            CollectComposedValuesVisitor visitor = new CollectComposedValuesVisitor();

            visitor.VisitMemoryEntry(entry);

            return(visitor.CollectIndexes(snapshot));
        }
コード例 #5
0
        /// <summary>
        /// Resolves the type of PHP objects in the entry.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="snapshotEntry">The snapshot entry.</param>
        /// <returns>The list of types in the given snapshot entry.</returns>
        public static IEnumerable <TypeValue> ResolveType(SnapshotBase context, ICopyModelSnapshotEntry snapshotEntry)
        {
            Snapshot    snapshot = SnapshotEntry.ToSnapshot(context);
            MemoryEntry entry    = snapshotEntry.ReadMemory(snapshot);

            CollectComposedValuesVisitor visitor = new CollectComposedValuesVisitor();

            visitor.VisitMemoryEntry(entry);

            return(visitor.ResolveObjectsTypes(snapshot));
        }
コード例 #6
0
        /// <summary>
        /// Resolve method on current snapshot entry with given methodName
        /// </summary>
        /// <param name="context">Context where methods are resolved</param>
        /// <param name="methodName">Name of resolved method</param>
        /// <returns>
        /// Resolved methods
        /// </returns>
        protected override IEnumerable <FunctionValue> resolveMethod(SnapshotBase context, PHP.Core.QualifiedName methodName)
        {
            SnapshotLogger.append(context, "resolve method - " + this.ToString() + " method: " + methodName);

            if (isTemporarySet(context))
            {
                return(temporaryLocation.ResolveMethod(context, methodName));
            }
            else
            {
                Snapshot snapshot = SnapshotEntry.ToSnapshot(context);
                return(snapshot.resolveMethod(dataEntry, methodName));
            }
        }
コード例 #7
0
        /// <summary>
        /// Gets the snapshot entry of temporary index associated with this memory entry.
        /// </summary>
        /// <param name="context">The context.</param>
        private SnapshotEntry getTemporary(SnapshotBase context)
        {
            Snapshot snapshot = SnapshotEntry.ToSnapshot(context);

            if (temporaryLocation == null)
            {
                temporaryIndex = snapshot.CreateTemporary();
                MergeWithinSnapshotWorker mergeWorker = new MergeWithinSnapshotWorker(snapshot);
                mergeWorker.MergeMemoryEntry(temporaryIndex, dataEntry);

                temporaryLocation = new SnapshotEntry(MemoryPath.MakePathTemporary(temporaryIndex));
            }

            return(temporaryLocation);
        }
コード例 #8
0
        /// <summary>
        /// Write given value at memory represented by snapshot entry and doesn't process any
        /// array copy. Is needed for correct increment/decrement semantic.
        /// </summary>
        /// <param name="context">Context snapshot where operation is proceeded</param>
        /// <param name="value">Written value</param>
        /// <exception cref="System.NotImplementedException"></exception>
        protected override void writeMemoryWithoutCopy(SnapshotBase context, MemoryEntry value)
        {
            if (isTemporarySet(context))
            {
                getTemporary(context).WriteMemoryWithoutCopy(context, value);
            }
            else
            {
                Snapshot snapshot = SnapshotEntry.ToSnapshot(context);
                switch (snapshot.CurrentMode)
                {
                case SnapshotMode.MemoryLevel:
                    dataEntry = value;
                    break;

                case SnapshotMode.InfoLevel:
                    infoEntry = value;
                    break;

                default:
                    throw new NotSupportedException("Current mode: " + snapshot.CurrentMode);
                }
            }
        }
コード例 #9
0
        /// <summary>
        /// Determines whether there is associated temporary index with memory entry in the specified context.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <returns>True whether there is associated temporary index with memory entry in the specified context.</returns>
        private bool isTemporarySet(SnapshotBase context)
        {
            Snapshot snapshot = SnapshotEntry.ToSnapshot(context);

            return(temporaryIndex != null && snapshot.IsTemporarySet(temporaryIndex));
        }