Beispiel #1
0
        /// <summary>
        /// Replaces all inner "return" statements of the given statement with "goto" statements to the function
        /// exit point.
        /// </summary>
        /// <param name="stmt">top-level statement</param>
        /// <param name="returnVariable">out parameter to receive a newly created local variable for the function
        /// return value (if applicable)</param>
        /// <returns>re-written statement with removed "return" statements</returns>
        public static Statement RemoveRets(this Statement stmt, out Variable returnVariable)
        {
            Statement work = stmt.Clone;

            work.RemoveNops();
            RetRemover rr     = new RetRemover(work);
            Function   result = rr.GetAlgorithm();

            returnVariable = rr.ReturnVariable;
            return(result.Body);
        }
Beispiel #2
0
 /// <summary>
 /// Replaces all inner "return" statements of the given statement with "goto" statements to the function
 /// exit point.
 /// </summary>
 /// <param name="stmt">top-level statement</param>
 /// <param name="returnVariable">out parameter to receive a newly created local variable for the function
 /// return value (if applicable)</param>
 /// <returns>re-written statement with removed "return" statements</returns>
 public static Statement RemoveRets(this Statement stmt, out Variable returnVariable)
 {
     Statement work = stmt.Clone;
     work.RemoveNops();
     RetRemover rr = new RetRemover(work);
     Function result = rr.GetAlgorithm();
     returnVariable = rr.ReturnVariable;
     return result.Body;
 }