// e.g. try{...}catch(E e){...}finally{...}
 public override bool Visit(UnifiedTry element, VisitorArgument arg)
 {
     Writer.Write("try");
     element.Body.TryAccept(this, arg.Set(ForBlock));
     element.Catches.TryAccept(this, arg);
     element.FinallyBody.TryAccept(this, arg, "finally");
     return(false);
 }
Ejemplo n.º 2
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())));
 }
Ejemplo n.º 3
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));
        }
Ejemplo n.º 4
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));
        }
Ejemplo n.º 5
0
        //try文
        public override bool Visit(UnifiedTry element, VisitorArgument arg)
        {
            //tryブロック
            Writer.Write("try");
            element.Body.TryAccept(this, arg.Set(ForBlock));

            //catchブロック
            element.Catches.TryAccept(this, arg.Set(SemiColonDelimiter));

            //finallyブロック
            var finallyBlock = element.FinallyBody;

            //finallyブロックがある場合はその内容を出力
            if (finallyBlock != null)
            {
                Writer.Write("finally");
                finallyBlock.TryAccept(this, arg.Set(ForBlock));
            }
            return(false);
        }
Ejemplo n.º 6
0
        // e.g. try{...}catch(E e){...}finally{...}
        public override bool Visit(UnifiedTry element, VisitorArgument arg)
        {
            // try block
            Writer.Write("try");
            element.Body.TryAccept(this, arg);

            // catch blocks
            element.Catches.TryAccept(this, arg);

            // finally block
            var finallyBlock = element.FinallyBody;

            // how judge whether finalluBlock exists or not???
            if (finallyBlock != null)
            {
                Writer.Write("finally");
                finallyBlock.TryAccept(this, arg);
            }
            return(false);
        }
 // e.g. try{...}catch(E e){...}finally{...}
 public override bool Visit(UnifiedTry element, VisitorArgument arg)
 {
     Writer.Write("try");
     element.Body.TryAccept(this, arg.Set(ForBlock));
     element.Catches.TryAccept(this, arg);
     element.FinallyBody.TryAccept(this, arg, "finally");
     return false;
 }
        //try文
        public override bool Visit(UnifiedTry element, VisitorArgument arg)
        {
            //tryブロック
            Writer.Write("try");
            element.Body.TryAccept(this, arg.Set(ForBlock));

            //catchブロック
            element.Catches.TryAccept(this, arg.Set(SemiColonDelimiter));

            //finallyブロック
            var finallyBlock = element.FinallyBody;
            //finallyブロックがある場合はその内容を出力
            if (finallyBlock != null) {
                Writer.Write("finally");
                finallyBlock.TryAccept(this, arg.Set(ForBlock));
            }
            return false;
        }
        // e.g. try{...}catch(E e){...}finally{...}
        public override bool Visit(UnifiedTry element, VisitorArgument arg)
        {
            // try block
            Writer.Write("try");
            element.Body.TryAccept(this, arg);

            // catch blocks
            element.Catches.TryAccept(this, arg);

            // finally block
            var finallyBlock = element.FinallyBody;
            // how judge whether finalluBlock exists or not???
            if (finallyBlock != null) {
                Writer.Write("finally");
                finallyBlock.TryAccept(this, arg);
            }
            return false;
        }