void ChangeEdgeStatus(ControlFlowEdge edge, DefiniteAssignmentStatus newStatus)
        {
            DefiniteAssignmentStatus oldStatus = edgeStatus[edge];

            if (oldStatus == newStatus)
            {
                return;
            }
            // Ensure that status can cannot change back to CodeUnreachable after it once was reachable.
            // Also, don't ever use AssignedAfter... for statements.
            if (newStatus == DefiniteAssignmentStatus.CodeUnreachable ||
                newStatus == DefiniteAssignmentStatus.AssignedAfterFalseExpression ||
                newStatus == DefiniteAssignmentStatus.AssignedAfterTrueExpression)
            {
                throw new InvalidOperationException();
            }
            // Note that the status can change from DefinitelyAssigned
            // back to PotentiallyAssigned as unreachable input edges are
            // discovered to be reachable.

            edgeStatus[edge] = newStatus;
            DefiniteAssignmentNode targetNode = (DefiniteAssignmentNode)edge.To;

            if (analyzedRangeStart <= targetNode.Index && targetNode.Index <= analyzedRangeEnd)
            {
                // TODO: potential optimization: visit previously unreachable nodes with higher priority
                // (e.g. use Deque and enqueue previously unreachable nodes at the front, but
                // other nodes at the end)
                nodesWithModifiedInput.Enqueue(targetNode);
            }
        }
Ejemplo n.º 2
0
            internal ControlFlowEdge Connect(ControlFlowNode from, ControlFlowNode to, ControlFlowEdgeType type = ControlFlowEdgeType.Normal)
            {
                if (from == null || to == null)
                {
                    return(null);
                }
                ControlFlowEdge edge = builder.CreateEdge(from, to, type);

                from.Outgoing.Add(edge);
                to.Incoming.Add(edge);
                return(edge);
            }