Exemplo n.º 1
0
        /// <inheritdoc />
        public void AssignAlias(Snapshot snapshot, MemoryPath targetPath, MemoryPath sourcePath)
        {
            if (snapshot.AssignInfo == null)
            {
                snapshot.AssignInfo = new AssignInfo();
            }

            // Collects memory location of alias sources
            TreeIndexCollector aliasSourcesCollector = new TreeIndexCollector(snapshot);

            aliasSourcesCollector.ProcessPath(sourcePath);

            // Creates missing source locations and collect source data
            AliasWorker aliasWorker = new AliasWorker(Factories, snapshot, aliasSourcesCollector, snapshot.AssignInfo.AliasAssignModifications);

            aliasWorker.CollectAliases();

            // Collects target locations
            TreeIndexCollector aliasTargetCollector = new TreeIndexCollector(snapshot);

            aliasTargetCollector.ProcessPath(targetPath);

            // Creates missing target locations, create aliases and assign source data
            AssignWorker assignWorker = new AssignWorker(Factories, snapshot, aliasWorker.EntryCollector, aliasTargetCollector, snapshot.AssignInfo.AliasAssignModifications);

            assignWorker.AssignAliasesIntoCollectedIndexes = true;
            assignWorker.Assign();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Process given access path and collects all matching indexes. This is an entry point
        /// of the computation.
        /// </summary>
        /// <param name="path">The path.</param>
        public void ProcessPath(MemoryPath path)
        {
            currentPath = path;

            foreach (var segment in path.PathSegments)
            {
                processAliases();

                var swap = currentNodes;
                currentNodes       = nextIterationNodes;
                nextIterationNodes = swap;
                nextIterationNodes.Clear();

                segment.Accept(this);
            }

            if (PostProcessAliases)
            {
                processAliases();
            }
            currentNodes = nextIterationNodes;

            foreach (CollectorNode node in currentNodes)
            {
                node.IsCollected = true;
            }
        }
Exemplo n.º 3
0
        /// <inheritdoc />
        public void Assign(Snapshot snapshot, MemoryPath path, MemoryEntry value, bool forceStrongWrite)
        {
            if (snapshot.AssignInfo == null)
            {
                snapshot.AssignInfo = new AssignInfo();
            }
            MemoryIndexModificationList pathModifications = snapshot.AssignInfo.GetOrCreatePathModification(path);

            // Collecting all sources of the data
            MemoryEntryCollector entryCollector = new MemoryEntryCollector(snapshot);

            entryCollector.ProcessRootMemoryEntry(value);

            // Collecting all locations where to assign into
            TreeIndexCollector treeCollector = new TreeIndexCollector(snapshot);

            treeCollector.PostProcessAliases = true;
            treeCollector.ProcessPath(path);

            // Provides an assign operation
            AssignWorker worker = new AssignWorker(Factories, snapshot, entryCollector, treeCollector, pathModifications);

            worker.ForceStrongWrite = forceStrongWrite;
            worker.Assign();
        }
Exemplo n.º 4
0
        /// <inheritdoc />
        public bool IsDefined(Snapshot snapshot, MemoryPath path)
        {
            ReadCollector collector = new ReadCollector(snapshot);

            collector.ProcessPath(path);

            return(collector.IsDefined);
        }
Exemplo n.º 5
0
        /// <inheritdoc />
        public MemoryEntry Read(Snapshot snapshot, MemoryPath path)
        {
            ReadCollector collector = new ReadCollector(snapshot);

            collector.ProcessPath(path);

            ReadWorker worker = new ReadWorker(snapshot);

            return(worker.ReadValue(collector));
        }
Exemplo n.º 6
0
        /// <inheritdoc />
        public void WriteWithoutCopy(Snapshot snapshot, MemoryPath path, MemoryEntry value)
        {
            AssignCollector collector = new AssignCollector(snapshot);

            collector.ProcessPath(path);

            Weverca.MemoryModels.ModularCopyMemoryModel.Implementation.Algorithm.CopyAlgorithms.MemoryWorkers.AssignWithoutCopyWorker worker
                = new Weverca.MemoryModels.ModularCopyMemoryModel.Implementation.Algorithm.CopyAlgorithms.MemoryWorkers.AssignWithoutCopyWorker(Factories, snapshot);
            worker.Assign(collector, value);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Processes the given access path.
        /// </summary>
        /// <param name="path">The path.</param>
        public void ProcessPath(MemoryPath path)
        {
            Global    = path.Global;
            CallLevel = path.CallLevel;

            foreach (PathSegment segment in path.PathSegments)
            {
                Next(segment);
            }

            FinishPath();
        }
        private bool IsTestCasePresentInFilesOrMemoryTree()
        {
            MemoryPath = TestCasesListOperations.IsPresentInTheTestCasesTree(ContentName.Text,
                                                                             FilesAndFolderStructure.ConcatFileNameToFolder(OutputFile.Text, FolderType.Tests),
                                                                             null);

            if (!MemoryPath.Equals(""))
            {
                ContentName.ForeColor = Color.Red;
                return(true);
            }
            return(false);
        }
Exemplo n.º 9
0
        private bool IsTestCasePresentInFilesOrMemoryTree()
        {
            MemoryPath = TestCasesListOperations.IsPresentInTheTestCasesTree(TestCaseName.Text,
                                                                             FilesAndFolderStructure.ConcatFileNameToFolder(OutputFile.Text, FolderType.Tests),
                                                                             RobotAutomationHelper.TestCases[ImplementationIndexFromTheParent]);

            if (!MemoryPath.Equals(""))
            {
                TestCaseName.ForeColor = Color.Red;
                return(true);
            }
            return(false);
        }
        private bool IsKeywordPresentInFilesOrMemoryTree()
        {
            MemoryPath = TestCasesListOperations.IsPresentInTheKeywordTree(KeywordName.Text,
                                                                           FilesAndFolderStructure.ConcatFileNameToFolder(OutputFile.Text, FolderType.Resources),
                                                                           _parentKeywords[ImplementationIndexFromTheParent]);

            if (MemoryPath.Equals(""))
            {
                return(false);
            }
            KeywordName.ForeColor = Color.DarkOrange;
            return(true);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Creates the snapshot entry for the given variable name.
        /// </summary>
        /// <param name="variable">The variable name.</param>
        /// <param name="global">Determines whether variable is global or local.</param>
        /// <param name="callLevel">The call level.</param>
        internal static ReadWriteSnapshotEntryBase CreateVariableEntry(AnalysisFramework.VariableIdentifier variable, GlobalContext global, int callLevel)
        {
            MemoryPath path;

            if (variable.IsUnknown)
            {
                path = MemoryPath.MakePathAnyVariable(global, callLevel);
            }
            else
            {
                var names = from name in variable.PossibleNames select name.Value;
                path = MemoryPath.MakePathVariable(names, global, callLevel);
            }

            return(new SnapshotEntry(path, variable));
        }
Exemplo n.º 12
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();
                temporaryLocation = new SnapshotEntry(MemoryPath.MakePathTemporary(temporaryIndex));

                snapshot.Factories.Benchmark.StartAlgorithm(snapshot, AlgorithmType.MERGE_TO_TEMPORARY);
                snapshot.Algorithms.MergeAlgorithm.MergeMemoryEntry(snapshot, temporaryIndex, dataEntry);
                snapshot.Factories.Benchmark.FinishAlgorithm(snapshot, AlgorithmType.MERGE_TO_TEMPORARY);
            }

            return(temporaryLocation);
        }
Exemplo n.º 13
0
        /// <summary>
        /// Read memory represented by given field identifier resolved on current
        /// snapshot entry (resulting snapshot entry can encapsulate merging, alias resolving and
        /// other stuff based on nondeterminism of identifier and current snapshot entry)
        /// </summary>
        /// <param name="context">Context snapshot where operation is proceeded</param>
        /// <param name="field">Identifier of an field</param>
        /// <returns>
        /// Snapshot entry representing field resolving on current entry
        /// </returns>
        protected override ReadWriteSnapshotEntryBase readField(SnapshotBase context, AnalysisFramework.VariableIdentifier field)
        {
            MemoryPath newPath;

            if (field.IsUnknown)
            {
                newPath = MemoryPath.MakePathAnyField(path);
            }
            else
            {
                var names = from name in field.PossibleNames select name.Value;
                newPath = MemoryPath.MakePathField(path, names);
            }

            return(new SnapshotEntry(newPath, variableId));
        }
Exemplo n.º 14
0
        /// <inheritdoc />
        public void Assign(Snapshot snapshot, MemoryPath path, MemoryEntry value, bool forceStrongWrite)
        {
            if (snapshot.AssignInfo == null)
            {
                snapshot.AssignInfo = new AssignInfo();
            }
            MemoryIndexModificationList pathModifications = snapshot.AssignInfo.GetOrCreatePathModification(path);

            List <Tuple <MemoryIndex, HashSet <Value> > > valuesToAssign = new List <Tuple <MemoryIndex, HashSet <Value> > >();

            // Prepares locations and values to assign
            foreach (var item in pathModifications.Modifications)
            {
                MemoryIndex             index             = item.Key;
                MemoryIndexModification indexModification = item.Value;

                HashSet <Value> values = new HashSet <Value>();
                valuesToAssign.Add(new Tuple <MemoryIndex, HashSet <Value> >(index, values));

                if (indexModification.IsCollectedIndex)
                {
                    CollectionMemoryUtils.AddAll(values, value.PossibleValues);
                }

                // Loads all other datasources where to get additional values to assign - unknown indexes.
                foreach (var datasource in indexModification.Datasources)
                {
                    MemoryEntry entry;
                    if (datasource.SourceSnapshot.Infos.Readonly.TryGetMemoryEntry(datasource.SourceIndex, out entry))
                    {
                        CollectionMemoryUtils.AddAll(values, entry.PossibleValues);
                    }
                }
            }

            // Assigns values to locations
            foreach (var item in valuesToAssign)
            {
                MemoryIndex     index  = item.Item1;
                HashSet <Value> values = item.Item2;

                MemoryEntry entry = new MemoryEntry(values);
                snapshot.Infos.Writeable.SetMemoryEntry(index, entry);
            }
        }
Exemplo n.º 15
0
        /// <summary>
        /// Read memory represented by given index identifier resolved on current
        /// snapshot entry (resulting snapshot entry can encapsulate merging, alias resolving and
        /// other stuff based on nondeterminism of identifier and current snapshot entry)
        /// </summary>
        /// <param name="context">Context snapshot where operation is proceeded</param>
        /// <param name="index">Identifier of an index</param>
        /// <returns>
        /// Snapshot entry representing index resolving on current entry
        /// </returns>
        protected override ReadWriteSnapshotEntryBase readIndex(SnapshotBase context, MemberIdentifier index)
        {
            MemoryPath newPath;

            if (index.IsAny)
            {
                newPath = MemoryPath.MakePathAnyIndex(path);
            }
            else if (index.IsUnknown)
            {
                newPath = MemoryPath.MakePathUnknownIndex(path);
            }
            else
            {
                newPath = MemoryPath.MakePathIndex(path, index.PossibleNames);
            }

            return(new SnapshotEntry(newPath, variableId));
        }
Exemplo n.º 16
0
 void Start()
 {
     script = gameObject.transform.parent.GetComponent <MemoryPath>();
     color  = gameObject.GetComponent <ObjectColor>();
 }
Exemplo n.º 17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SnapshotEntry"/> class.
 /// </summary>
 /// <param name="path">The variable acces path.</param>
 /// <param name="variableId">The variable unique identifier.</param>
 private SnapshotEntry(MemoryPath path, AnalysisFramework.VariableIdentifier variableId)
 {
     this.path       = path;
     this.variableId = variableId;
 }
Exemplo n.º 18
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SnapshotEntry"/> class.
        /// </summary>
        /// <param name="path">The variable acces path.</param>
        internal SnapshotEntry(MemoryPath path)
        {
            this.path = path;

            this.variableId = null;
        }
Exemplo n.º 19
0
        /// <summary>
        /// Creates the snapshot entry for the given variable name.
        /// </summary>
        /// <param name="name">The name of control variable.</param>
        /// <param name="global">Determines whether variable is global or local.</param>
        /// <param name="callLevel">The call level.</param>
        /// <returns>New snapshot entry for the given variable name.</returns>
        internal static ReadWriteSnapshotEntryBase CreateControlEntry(VariableName name, GlobalContext global, int callLevel)
        {
            MemoryPath path = MemoryPath.MakePathControl(new string[] { name.ToString() }, global, callLevel);

            return(new SnapshotEntry(path));
        }
Exemplo n.º 20
0
 /// <inheritdoc />
 public void AssignAlias(Snapshot snapshot, MemoryPath targetPath, MemoryPath sourcePath)
 {
     // Do nothing - Alias cannot be assigned in info mode
 }