Exemple #1
0
 protected TryStatementImpl(LexicalInfo lexicalInfo, Block successBlock, Block ensureBlock) : base(lexicalInfo)
 {
     ProtectedBlock     = new Block();
     _exceptionHandlers = new ExceptionHandlerCollection(this);
     SuccessBlock       = successBlock;
     EnsureBlock        = ensureBlock;
 }
Exemple #2
0
        public MessageCollection CheckMethod(MethodDefinition methodDefinition, Runner runner)
        {
            MessageCollection messageCollection = new MessageCollection();

            if (methodDefinition.HasBody)
            {
                ExceptionHandlerCollection exceptionHandlerCollection = methodDefinition.Body.ExceptionHandlers;
                foreach (ExceptionHandler exceptionHandler in exceptionHandlerCollection)
                {
                    if (exceptionHandler.Type == ExceptionHandlerType.Catch)
                    {
                        string catchTypeName = exceptionHandler.CatchType.FullName;
                        if (IsForbiddenTypeInCatches(catchTypeName))
                        {
                            if (!ThrowsGeneralException(exceptionHandler))
                            {
                                Location location = new Location(methodDefinition.Name, methodDefinition.Name, exceptionHandler.HandlerStart.Offset);
                                Message  message  = new Message("Do not swallow errors catching nonspecific exceptions.", location, MessageType.Error);
                                messageCollection.Add(message);
                            }
                        }
                    }
                }
            }

            if (messageCollection.Count == 0)
            {
                return(null);
            }
            return(messageCollection);
        }
Exemple #3
0
 protected TryStatementImpl(Block successBlock, Block ensureBlock)
 {
     ProtectedBlock     = new Block();
     _exceptionHandlers = new ExceptionHandlerCollection(this);
     SuccessBlock       = successBlock;
     EnsureBlock        = ensureBlock;
 }
Exemple #4
0
        void CheckExceptionHandlers(ExceptionHandlerCollection handlers)
        {
            for (int i = 1; i < handlers.Count; ++i)
            {
                ExceptionHandler handler = handlers[i];
                for (int j = i - 1; j >= 0; --j)
                {
                    ExceptionHandler previous     = handlers[j];
                    IType            handlerType  = handler.Declaration.Type.Entity as IType;
                    IType            previousType = previous.Declaration.Type.Entity as IType;

                    if (null == handlerType || null == previousType)
                    {
                        continue;
                    }

                    if ((handlerType == previousType && null == previous.FilterCondition) ||
                        handlerType.IsSubclassOf(previousType))
                    {
                        Error(CompilerErrorFactory.ExceptionAlreadyHandled(
                                  handler, previous));
                        break;
                    }
                }
            }
        }
Exemple #5
0
 public void VisitExceptionHandlerCollection(ExceptionHandlerCollection seh)
 {
     foreach (ExceptionHandler eh in seh)
     {
         eh.Accept(this);
     }
 }
Exemple #6
0
 public override void VisitExceptionHandlerCollection(ExceptionHandlerCollection seh)
 {
     for (int i = 0; i < seh.Count; i++)
     {
         VisitExceptionHandler(seh[i]);
     }
 }
        void MarkBlockStarts(ExceptionHandlerCollection handlers)
        {
            for (int i = 0; i < handlers.Count; i++)
            {
                var handler = handlers [i];
                MarkBlockStart(handler.TryStart);
                MarkBlockStart(handler.HandlerStart);

                if (handler.Type == ExceptionHandlerType.Filter)
                {
                    MarkExceptionObjectPosition(handler.FilterStart);
                    MarkBlockStart(handler.FilterStart);
                }
                else if (handler.Type == ExceptionHandlerType.Catch)
                {
                    MarkExceptionObjectPosition(handler.HandlerStart);
                }
            }
        }
Exemple #8
0
        protected PlSqlBlockStatement(SerializationInfo info, StreamingContext context)
            : base(info, context)
        {
            Declarations      = new DeclarationCollection();
            ExceptionHandlers = new ExceptionHandlerCollection();

            var decls = (SqlStatement[])info.GetValue("Declarations", typeof(SqlStatement[]));

            foreach (var statement in decls)
            {
                Declarations.Add(statement);
            }

            var handlers = (ExceptionHandler[])info.GetValue("ExceptionHandlers", typeof(ExceptionHandler[]));

            foreach (var handler in handlers)
            {
                ExceptionHandlers.Add(handler);
            }
        }
Exemple #9
0
        private void MarkExceptionHandlers(ExceptionHandlerCollection exceptionHandlers)
        {
            foreach (ExceptionHandler exceptionHandler in exceptionHandlers)
            {
                AddActionAfter(exceptionHandler.TryStart, delegate
                {
                    generator.BeginExceptionBlock();
                });

                if (exceptionHandler.Type == ExceptionHandlerType.Filter)
                {
                    AddActionAfter(exceptionHandler.FilterStart, delegate
                    {
                        generator.BeginExceptFilterBlock();
                    });
                }

                AddActionAfter(exceptionHandler.HandlerStart, delegate
                {
                    switch (exceptionHandler.Type)
                    {
                    case ExceptionHandlerType.Catch:
                        generator.BeginCatchBlock(outer.ResolveType(exceptionHandler.CatchType));
                        break;

                    case ExceptionHandlerType.Fault:
                        generator.BeginFaultBlock();
                        break;

                    case ExceptionHandlerType.Finally:
                        generator.BeginFinallyBlock();
                        break;
                    }
                });

                AddActionBefore(exceptionHandler.HandlerEnd, delegate
                {
                    generator.EndExceptionBlock();
                });
            }
        }
Exemple #10
0
 public static bool Compare(this ExceptionHandlerCollection source, ExceptionHandlerCollection n, Func <ExceptionHandler, ExceptionHandler, bool> checkitem)
 {
     return(Compare <ExceptionHandler>(source, n, checkitem));
 }
Exemple #11
0
 protected TryStatementImpl()
 {
     ProtectedBlock     = new Block();
     _exceptionHandlers = new ExceptionHandlerCollection(this);
 }
        public virtual IExceptionHandlerCollection TransformExceptionHandlerCollection(IExceptionHandlerCollection value)
        {
            IExceptionHandler[] array = new IExceptionHandler[value.Count];
            for (int i = 0; i < value.Count; i++)
            {
                array[i] = this.TransformExceptionHandler(value[i]);
            }

            IExceptionHandlerCollection target = new ExceptionHandlerCollection();
            target.AddRange(array);
            return target;
        }
Exemple #13
0
 protected TryStatementImpl(LexicalInfo lexicalInfo) : base(lexicalInfo)
 {
     ProtectedBlock     = new Block();
     _exceptionHandlers = new ExceptionHandlerCollection(this);
 }
Exemple #14
0
 public static bool Compare(this ExceptionHandlerCollection source, ExceptionHandlerCollection n, Func<ExceptionHandler, ExceptionHandler, Action<string, string>, bool> checkitem, Action<string, string> errAct)
 {
     return Compare<ExceptionHandler>(source,n,checkitem,errAct);
 }
Exemple #15
0
 public static bool Compare(this ExceptionHandlerCollection source, ExceptionHandlerCollection n, Func<ExceptionHandler, ExceptionHandler, bool> checkitem)
 {
     return Compare<ExceptionHandler>(source,n,checkitem);
 }
Exemple #16
0
 public static bool Compare(this ExceptionHandlerCollection source, ExceptionHandlerCollection n)
 {
     return(Compare <ExceptionHandler>(source, n));
 }
Exemple #17
0
 public virtual void VisitExceptionHandlerCollection(ExceptionHandlerCollection seh)
 {
 }
Exemple #18
0
		public virtual void VisitExceptionHandlerCollection (ExceptionHandlerCollection seh)
		{
		}
Exemple #19
0
 public static bool Compare(this ExceptionHandlerCollection source, ExceptionHandlerCollection n, Func <ExceptionHandler, ExceptionHandler, Action <string, string>, bool> checkitem, Action <string, string> errAct)
 {
     return(Compare <ExceptionHandler>(source, n, checkitem, errAct));
 }
Exemple #20
0
 public static bool Compare(this ExceptionHandlerCollection source, ExceptionHandlerCollection n)
 {
     return Compare<ExceptionHandler>(source,n);
 }
Exemple #21
0
 public PlSqlBlockStatement()
 {
     Declarations      = new DeclarationCollection();
     ExceptionHandlers = new ExceptionHandlerCollection();
 }