コード例 #1
0
ファイル: AstRewriter.cs プロジェクト: clorton/IDM-CMS
        // SwitchStatement
        private Statement Rewrite(SwitchStatement node)
        {
            Expression test = RewriteExpressionFreeTemps(node.TestValue);
            ReadOnlyCollection <SwitchCase> cases = node.Cases;

            SwitchCase[] clone = null;

            for (int i = 0; i < cases.Count; i++)
            {
                SwitchCase @case = cases[i];
                SwitchCase rcase = Rewrite(@case);

                if (((object)rcase != (object)@case) && (clone == null))
                {
                    clone = Clone(cases, i);
                }

                if (clone != null)
                {
                    clone[i] = rcase;
                }
            }

            if (clone != null)
            {
                return(Ast.Switch(node.Span, node.Header, test, clone));
            }
            else if ((object)test != (object)node.TestValue)
            {
                return(Ast.Switch(node.Span, node.Header, test, ArrayUtils.ToArray(node.Cases)));
            }
            else
            {
                return(node);
            }
        }
コード例 #2
0
 public Statement ToStatement() {
     Contract.Requires(_test != null);
     return Ast.Switch(_span, _header, _test, _cases.ToArray());
 }