コード例 #1
0
ファイル: DynamicDataTracer.cs プロジェクト: simcoster/Dopple
        private static void ActOnCurrentNode(InstructionNode currentNode, Dictionary <InstructionNode, MergeNodeTraceData> mergingNodesData, InstructionNode lastNode, StateProviderCollection stateProviders, out bool reachedMergeNodeNotLast)
        {
            if (currentNode.BranchProperties.MergingNodeProperties.IsMergingNode)
            {
                lock (mergingNodesData)
                {
                    mergingNodesData[currentNode].ReachedNodes.Add(lastNode);
                    mergingNodesData[currentNode].AccumelatedStateProviders.AddNewProviders(stateProviders);
                    bool allBranchesReached = !currentNode.ProgramFlowBackRoutes.Except(mergingNodesData[currentNode].ReachedNodes).Any();
                    if (allBranchesReached)
                    {
                        mergingNodesData[currentNode].AllBranchesReached = true;
                        mergingNodesData[currentNode].AccumelatedStateProviders.MergeBranches(currentNode);
                        stateProviders.AddNewProviders(mergingNodesData[currentNode].AccumelatedStateProviders);
                    }
                    else
                    {
                        reachedMergeNodeNotLast = true;
                        return;
                    }
                }
            }
            var newStoreState = StoreDynamicDataStateProvider.GetMatchingStateProvider(currentNode);

            if (newStoreState != null)
            {
                stateProviders.AddNewProvider(newStoreState);
            }
            IDynamicDataLoadNode loadNode = currentNode as IDynamicDataLoadNode;

            if (loadNode != null)
            {
                foreach (var storeNode in stateProviders.MatchLoadToStore(currentNode))
                {
                    currentNode.DataFlowBackRelated.AddTwoWay(storeNode, loadNode.DataFlowDataProdivderIndex);
                }
            }
            reachedMergeNodeNotLast = false;
        }
コード例 #2
0
ファイル: TraceManager.cs プロジェクト: simcoster/Dopple
        private static void ActOnCurrentNode(InstructionNode currentNode, Dictionary <InstructionNode, MergeNodeTraceData> mergingNodesData, InstructionNode lastNode, ref StateProviderCollection stateProviders, out bool reachedMergeNodeNotLast)
        {
            if (currentNode.BranchProperties.MergingNodeProperties.IsMergingNode)
            {
                lock (mergingNodesData)
                {
                    mergingNodesData[currentNode].ReachedNodes.Add(lastNode);
                    BranchID emptyBranchToMe = null;
                    IEnumerable <BranchID> nonEmptyBranchesToMe = null;
                    if ((lastNode is ConditionalJumpNode))
                    {
                        emptyBranchToMe = ((ConditionalJumpNode)lastNode).CreatedBranches.FirstOrDefault(x => x.BranchNodes.SequenceEqual(new[] { currentNode }));
                    }
                    if (emptyBranchToMe == null)
                    {
                        nonEmptyBranchesToMe = lastNode.BranchProperties.Branches.Intersect(currentNode.BranchProperties.MergingNodeProperties.MergedBranches);
                    }
                    if (emptyBranchToMe != null || nonEmptyBranchesToMe.Any())
                    {
                        mergingNodesData[currentNode].AccumelatedStateProviders.AddRange(stateProviders.ToList());
                        var  mergedBrachesNonEmpty    = currentNode.ProgramFlowBackRoutes.Where(x => x.BranchProperties.Branches.Any(y => currentNode.BranchProperties.MergingNodeProperties.MergedBranches.Contains(y)));
                        var  mergedBrachesEmpty       = currentNode.ProgramFlowBackRoutes.Where(x => x is ConditionalJumpNode).Cast <ConditionalJumpNode>().Where(x => x.CreatedBranches.Intersect(currentNode.BranchProperties.MergingNodeProperties.MergedBranches).Any());
                        var  splitMergeMergedBranches = mergedBrachesEmpty.Concat(mergedBrachesNonEmpty).ToList();
                        bool allBranchesReached       = !splitMergeMergedBranches.Except(mergingNodesData[currentNode].ReachedNodes).Any();
                        if (allBranchesReached)
                        {
                            stateProviders = new StateProviderCollection(mergingNodesData[currentNode].AccumelatedStateProviders);
                            mergingNodesData[currentNode].AccumelatedStateProviders.Clear();
                            //prepare for next run (for loops)
                            mergingNodesData[currentNode].ReachedNodes.Clear();
                        }
                        else
                        {
                            reachedMergeNodeNotLast = true;
                            return;
                        }
                    }
                    else
                    {
                    }
                }
            }
            var newStoreStateProviders = StoreDynamicDataStateProvider.GetMatchingStateProvider(currentNode);

            if (newStoreStateProviders != null)
            {
                foreach (var newStateProvider in newStoreStateProviders)
                {
                    stateProviders.AddNewProvider(newStateProvider);
                }
            }
            IDynamicDataLoadNode loadNode = currentNode as IDynamicDataLoadNode;

            if (loadNode != null)
            {
                foreach (var stateProvider in stateProviders.MatchLoadToStore(currentNode))
                {
                    stateProvider.ConnectToLoadNode((InstructionNode)loadNode);
                    //have to change this to abstract
                }
            }
            reachedMergeNodeNotLast = false;
        }