コード例 #1
0
 private static UnifiedExpression CreateEnsure(XElement node)
 {
     Contract.Requires(node != null);
     Contract.Requires(node.Name() == "ensure");
     return(UnifiedTry.Create(
                CreateSmartBlock(node.FirstElement()), null, null,
                CreateSmartBlock(node.LastElement())));
 }
コード例 #2
0
        private static UnifiedExpression CreateRescue(XElement node)
        {
            Contract.Requires(node != null);
            Contract.Requires(node.Name() == "rescue");
            var lastNode  = node.LastElement();
            var elseBlock = lastNode.Name() != "resbody"
                                    ? CreateSmartBlock(lastNode)
                                    : null;

            return(UnifiedTry.Create(
                       CreateSmartBlock(node.FirstElement()),
                       node.Elements("resbody").Select(CreateResbody).ToSet(
                           ),
                       elseBlock));
        }
コード例 #3
0
        public UnifiedElement VisitTryCatchStatement(TryCatchStatement tryCatchStatement, object data)
        {
            var uTry    = tryCatchStatement.TryBlock.TryAcceptForExpression(this).ToBlock();
            var uCatchs = tryCatchStatement
                          .CatchClauses
                          .Select(c => c.AcceptVisitor(this, data))
                          .Cast <UnifiedCatch>()
                          .ToSet();
            var nFinally = tryCatchStatement.FinallyBlock;
            var uFinally = nFinally == null
                                                                   ? null
                                                                   : nFinally.TryAcceptForExpression(this).ToBlock();

            return(UnifiedTry.Create(uTry, uCatchs, /* else */ null, uFinally));
        }