internal override Node Bind(Binder b)
        {
            b.OpenScope();
            b.Bind(ref Key);
            Key.RequireGetAccess();
            if (Key.Datatype.IsValueType)
            {
                throw Error(ErrorCode.RequireReferenceType);
            }
            b.Bind(ref Stmt);
            b.CloseScope();

            var k = b.AddLocal(Compilation.Get(NativeType.Object));

            b.Convert(ref Key, Compilation.Get(NativeType.Object));
            var kdecl = DeclStmt.Bound(VarDecl.Bound(k, Key, b.Options.Binding));

            var l     = b.AddLocal(Compilation.Get(NativeType.Boolean));
            var ldecl = DeclStmt.Bound(VarDecl.Bound(l, LiteralExpr.Bound(Constant.Create(false)), b.Options.Binding));

            var enter = ExprStmt.Bound(MethodCallExpr.Bound(b, null, Compilation.Get(WellKnownMembers.System_Threading_Monitor_Enter), null, ArgList.Bound(IdExpr.Bound(k), IdExpr.Bound(l))));
            var exit  = IfStmt.Bound(IdExpr.Bound(l),
                                     ExprStmt.Bound(MethodCallExpr.Bound(b, null, Compilation.Get(WellKnownMembers.System_Threading_Monitor_Exit), null, ArgList.Bound(IdExpr.Bound(k)))),
                                     null);

            return(StmtBlock.Bound(kdecl, ldecl,
                                   TryStmt.Bound(b,
                                                 StmtBlock.Bound(enter, Stmt),
                                                 exit)));
        }
        internal override Node Bind(Binder b)
        {
            b.OpenScope();
            if (Expr != null)
            {
                b.Bind(ref Expr);
                Expr.RequireGetAccess();
            }
            else
            {
                b.Bind(ref Decl);
            }
            b.Bind(ref Stmt);
            b.CloseScope();

            var u     = Decl != null ? Decl.VarDecls[0].Var : b.AddLocal(Expr.Datatype);
            var udecl = Decl ?? DeclStmt.Bound(VarDecl.Bound(u, Expr, b.Options.Binding));

            Expr du = AsTypeExpr.Bound(IdExpr.Bound(u), IdExpr.Bound(Compilation.Get(WellKnownTypes.System_IDisposable)));

            b.Cache(ref du);
            var cond = BinaryExpr.Bound(du, Expr.Token, LiteralExpr.Bound(Constant.Null), BinaryOperatorKind.NotEqual, b.Options.Binding);
            var exit = IfStmt.Bound(cond,
                                    ExprStmt.Bound(MethodCallExpr.Bound(b, null, Compilation.Get(WellKnownMembers.System_IDisposable_Dispose), du, ArgList.Empty)),
                                    null);

            return(StmtBlock.Bound(udecl,
                                   TryStmt.Bound(b,
                                                 Stmt,
                                                 exit)));
        }
 internal override Node Bind(Binder b)
 {
     b.OpenScope();
     b.Bind(ref Stmt);
     Stmt = TryStmt.Bound(b,
                          StmtBlock.Bound(
                              ExprStmt.Bound(MethodCallExpr.Bound(null, Compilation.Get(WellKnownMembers.XSharp_Internal_CompilerServices_EnterBeginSequence), null, ArgList.Empty)),
                              Stmt),
                          ExprStmt.Bound(MethodCallExpr.Bound(null, Compilation.Get(WellKnownMembers.XSharp_Internal_CompilerServices_ExitBeginSequence), null, ArgList.Empty))
                          );
     b.CloseScope();
     if (Recover != null)
     {
         b.OpenScope();
         var rv = b.AddLocal(Name.Value, b.ObjectType);
         b.Bind(ref Recover);
         ExVar = b.AddLocal(Compilation.Get(WellKnownTypes.System_Exception));
         Expr rvxw   = MethodCallExpr.Bound(b, TypeCast.Bound(b, IdExpr.Bound(ExVar), Compilation.Get(WellKnownTypes.XSharp_Internal_WrappedException)), "get_Value", ArgList.Empty);
         Expr rvxe   = TypeCast.Bound(b, IdExpr.Bound(ExVar), Compilation.Get(WellKnownTypes.XSharp_Error));
         Expr rvx    = MethodCallExpr.Bound(null, Compilation.Get(WellKnownMembers.XSharp_Error_WrapRawException), null, ArgList.Bound(TypeCast.Bound(b, IdExpr.Bound(ExVar), Compilation.Get(WellKnownTypes.System_Exception))));
         var  rvInit =
             IifExpr.Bound(IsExpr.Bound(IdExpr.Bound(ExVar), IdExpr.Bound(Compilation.Get(WellKnownTypes.XSharp_Internal_WrappedException))), TypeConversion.Bound(b, rvxw, Compilation.Get(NativeType.Usual)),
                           IifExpr.Bound(IsExpr.Bound(IdExpr.Bound(ExVar), IdExpr.Bound(Compilation.Get(WellKnownTypes.XSharp_Error))), TypeConversion.Bound(b, rvxe, Compilation.Get(NativeType.Usual)),
                                         rvx,
                                         b.Options.Binding),
                           b.Options.Binding);
         var rvdecl = DeclStmt.Bound(VarDecl.Bound(rv, rvInit, b.Options.Binding));
         Recover = StmtBlock.Bound(rvdecl, Recover);
         b.CloseScope();
     }
     if (Finally != null)
     {
         bool ar = SaveAllowReturn(b);
         b.OpenScope();
         b.Bind(ref Finally);
         b.CloseScope();
         RestoreAllowReturn(b, ar);
     }
     return(TryStmt.Bound(b, Stmt, CatchBlock.Bound(ExVar, Recover), Finally));
 }