示例#1
0
        public static Expression AnalyzeBreakExpr(SymplBreakExpr expr,
                                                  AnalysisScope scope)
        {
            var loopscope = _findFirstLoop(scope);

            if (loopscope == null)
            {
                throw new InvalidOperationException(
                          "Call to Break not inside loop.");
            }
            Expression value;

            if (expr.Value == null)
            {
                value = Expression.Constant(null, typeof(object));
            }
            else
            {
                // Ok if value jumps to break label.
                value = AnalyzeExpr(expr.Value, loopscope);
            }
            // Need final type=object arg because the Goto is in a value returning
            // position, and the Break factory doesn't set the GotoExpr.Type property
            // to the type of the LoopBreak label target's type.  For example, removing
            // this would cause the Convert to object for an If branch to throw because
            // the Goto is void without this last arg.
            return(Expression.Break(loopscope.LoopBreak, value, typeof(object)));
        }
示例#2
0
 public static Expression AnalyzeBreakExpr (SymplBreakExpr expr,
                                 AnalysisScope scope) {
     var loopscope = _findFirstLoop(scope);
     if (loopscope == null)
         throw new InvalidOperationException(
                        "Call to Break not inside loop.");
     Expression value;
     if (expr.Value == null)
         value = Expression.Constant(null, typeof(object));
     else
         // Ok if value jumps to break label.
         value = AnalyzeExpr(expr.Value, loopscope);
     // Need final type=object arg because the Goto is in a value returning
     // position, and the Break factory doesn't set the GotoExpr.Type property
     // to the type of the LoopBreak label target's type.  For example, removing
     // this would cause the Convert to object for an If branch to throw because
     // the Goto is void without this last arg.
     return Expression.Break(loopscope.LoopBreak, value, typeof(object));
 }