Ejemplo n.º 1
0
        /// <summary>
        /// If the exception can be handled in current scope, return true and
        /// set pc which is where the executive will jump to. Otherwise return
        /// false.
        /// </summary>
        /// <param name="pc">New pc value</param>
        /// <returns></returns>
        public bool CanHandleIt(ref int pc)
        {
            if (!IsStackUnwinding || TargetHandler == null || Context == null)
            {
                return(false);
            }

            // Note there is always an instance of ExceptionRegistration
            // associated with a scope -- either function defintion or a language
            // block -- and that instance of ExceptionRegistration associated
            // with current scope is called CurrentActiveRegistration which is
            // dynamically upated when switching scopes.
            if (TargetHandler.Registration == CurrentActiveRegistration)
            {
                CatchHandler catchHandler = TargetHandler.GetCatchHandler(Context.typeUID);
                if (catchHandler != null)
                {
                    pc = catchHandler.Entry;
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            return(false);
        }