Exemple #1
0
            private static bool RequiresControlFlowUpdate(
                TerminatorValue oldTerminator,
                TerminatorValue newTerminator)
            {
                if (oldTerminator == newTerminator)
                {
                    return(false);
                }
                if (oldTerminator == null || newTerminator == null)
                {
                    return(true);
                }

                // Check whether the new terminator has the identical list of
                // successors. In theory we could check whether both lists contain
                // the same blocks without paying attention to the order; however,
                // this is very unlikely and expensive to verify.
                var oldSuccessors = oldTerminator.Targets;
                var newSuccessors = newTerminator.Targets;

                if (oldSuccessors.Length != newSuccessors.Length)
                {
                    return(true);
                }
                for (int i = 0, e = oldSuccessors.Length; i < e; ++i)
                {
                    if (oldSuccessors[i] != newSuccessors[i])
                    {
                        return(true);
                    }
                }
                return(false);
            }
Exemple #2
0
 /// <summary>
 /// Schedules control-flow updates if the successor relation has been
 /// changed by setting a new terminator.
 /// </summary>
 public void ScheduleControlFlowUpdate(
     TerminatorValue oldTerminator,
     TerminatorValue newTerminator)
 {
     if (RequiresControlFlowUpdate(oldTerminator, newTerminator))
     {
         ScheduleControlFlowUpdate();
     }
 }
Exemple #3
0
 /// <summary>
 /// Compacts the terminator.
 /// </summary>
 /// <returns></returns>
 private TerminatorValue CompactTerminator() =>
 Terminator = Terminator?.ResolveAs <TerminatorValue>();
Exemple #4
0
 /// <summary>
 /// Creates an instantiated terminator.
 /// </summary>
 /// <param name="node">The terminator to create.</param>
 /// <returns>The created node.</returns>
 protected abstract TerminatorValue CreateTerminator(TerminatorValue node);