示例#1
0
        /// <summary>
        /// Creates the alias to this entry and returnes data which can be used to aliasing the target.
        /// </summary>
        /// <param name="snapshot">The snapshot.</param>
        /// <returns>
        /// Alias data fro the newly created aliases.
        /// </returns>
        public AliasData CreateAliasToEntry(Snapshot snapshot)
        {
            //Collect alias indexes
            AssignCollector indexesCollector = new AssignCollector(snapshot);

            indexesCollector.ProcessPath(path);

            //Memory locations where to get data from
            ReadCollector valueCollector = new ReadCollector(snapshot);

            valueCollector.ProcessPath(path);

            //Get data from locations
            ReadWorker  worker = new ReadWorker(snapshot);
            MemoryEntry value  = worker.ReadValue(valueCollector);

            //Makes deep copy of data to prevent changes after assign alias
            TemporaryIndex            temporaryIndex = snapshot.CreateTemporary();
            MergeWithinSnapshotWorker mergeWorker    = new MergeWithinSnapshotWorker(snapshot);

            mergeWorker.MergeMemoryEntry(temporaryIndex, value);

            AliasData data = new AliasData(indexesCollector.MustIndexes, indexesCollector.MayIndexes, temporaryIndex);

            data.TemporaryIndexToRealease(temporaryIndex);

            return(data);
        }
示例#2
0
        /// <summary>
        /// Set aliases to current snapshot entry. Aliases can be set even to those entries
        /// that doesn't belongs to any variable, field,..
        /// </summary>
        /// <param name="context">Context snapshot where operation is proceeded</param>
        /// <param name="aliasedEntry">Snapshot entry which will be aliased from current entry</param>
        protected override void setAliases(SnapshotBase context, ReadSnapshotEntryBase aliasedEntry)
        {
            Snapshot snapshot = ToSnapshot(context);

            SnapshotLogger.append(context, "set alias: " + this.ToString() + " from: " + aliasedEntry.ToString());

            if (snapshot.CurrentMode == SnapshotMode.InfoLevel)
            {
                return;
            }

            ICopyModelSnapshotEntry entry = ToEntry(aliasedEntry);
            AliasData data = entry.CreateAliasToEntry(snapshot);

            AssignCollector collector = new AssignCollector(snapshot);

            collector.AliasesProcessing = AliasesProcessing.BeforeCollecting;
            collector.ProcessPath(path);

            AssignAliasWorker worker = new AssignAliasWorker(snapshot);

            worker.AssignAlias(collector, data);

            data.Release(snapshot);
        }
示例#3
0
        /// <summary>
        /// Assigns the given memory entry into all collected indexes in the collector.
        /// Must indexes are strongly updated may indexes weakly.
        /// </summary>
        /// <param name="collector">The collector.</param>
        /// <param name="value">The value.</param>
        internal void Assign(AssignCollector collector, AnalysisFramework.Memory.MemoryEntry value)
        {
            CollectComposedValuesVisitor composedValues = new CollectComposedValuesVisitor();

            composedValues.VisitMemoryEntry(value);

            foreach (MemoryIndex mustIndex in collector.MustIndexes)
            {
                assignMust(mustIndex, composedValues);
            }

            foreach (MemoryIndex mayIndex in collector.MayIndexes)
            {
                assignMay(mayIndex, composedValues);
            }

            if (snapshot.CurrentMode == SnapshotMode.InfoLevel)
            {
                InfoLocationVisitor mustVisitor = new InfoLocationVisitor(snapshot, value, true);
                foreach (ValueLocation mustLocation in collector.MustLocation)
                {
                    mustLocation.Accept(mustVisitor);
                }

                InfoLocationVisitor mayVisitor = new InfoLocationVisitor(snapshot, value, false);
                foreach (ValueLocation mustLocation in collector.MayLocaton)
                {
                    mustLocation.Accept(mayVisitor);
                }
            }
        }
示例#4
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>
        protected override void writeMemoryWithoutCopy(SnapshotBase context, MemoryEntry value)
        {
            Snapshot snapshot = ToSnapshot(context);

            SnapshotLogger.append(context, "write without copy:" + this.ToString());

            AssignCollector collector = new AssignCollector(snapshot);

            collector.ProcessPath(path);

            AssignWithoutCopyWorker worker = new AssignWithoutCopyWorker(snapshot);

            worker.Assign(collector, value);
        }
示例#5
0
        /// <summary>
        /// Writes the memory information.
        /// </summary>
        /// <param name="snapshot">The snapshot.</param>
        /// <param name="value">The value.</param>
        /// <param name="forceStrongWrite">if set to <c>true</c> [force strong write].</param>
        private void writeMemoryInfo(Snapshot snapshot, MemoryEntry value, bool forceStrongWrite)
        {
            AssignCollector collector = new AssignCollector(snapshot);

            collector.ProcessPath(path);

            if (forceStrongWrite)
            {
                collector.SetAllToMust();
            }

            AssignWithoutCopyWorker worker = new AssignWithoutCopyWorker(snapshot);

            worker.Assign(collector, value);
        }
示例#6
0
        /// <summary>
        /// Writes the memory normal.
        /// </summary>
        /// <param name="snapshot">The snapshot.</param>
        /// <param name="value">The value.</param>
        /// <param name="forceStrongWrite">if set to <c>true</c> [force strong write].</param>
        private void writeMemoryNormal(Snapshot snapshot, MemoryEntry value, bool forceStrongWrite)
        {
            TemporaryIndex            temporaryIndex = snapshot.CreateTemporary();
            MergeWithinSnapshotWorker mergeWorker    = new MergeWithinSnapshotWorker(snapshot);

            mergeWorker.MergeMemoryEntry(temporaryIndex, value);

            AssignCollector collector = new AssignCollector(snapshot);

            collector.ProcessPath(path);

            if (forceStrongWrite)
            {
                collector.SetAllToMust();
            }

            AssignWorker worker = new AssignWorker(snapshot);

            worker.Assign(collector, temporaryIndex);

            snapshot.ReleaseTemporary(temporaryIndex);
        }