当前位置: 首页>>代码示例>>C#>>正文


C# InterpretedFrame.SaveTraceToException方法代码示例

本文整理汇总了C#中Microsoft.Scripting.Interpreter.InterpretedFrame.SaveTraceToException方法的典型用法代码示例。如果您正苦于以下问题:C# InterpretedFrame.SaveTraceToException方法的具体用法?C# InterpretedFrame.SaveTraceToException怎么用?C# InterpretedFrame.SaveTraceToException使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Scripting.Interpreter.InterpretedFrame的用法示例。


在下文中一共展示了InterpretedFrame.SaveTraceToException方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Run

        public void Run(InterpretedFrame frame) {
            while (true) {
                try {
                    var instructions = _instructions.Instructions;
                    int index = frame.InstructionIndex;
                    while (index < instructions.Length) {
                        index += instructions[index].Run(frame);
                        frame.InstructionIndex = index;
                    }
                    return;
                } catch (Exception exception) {
                    frame.SaveTraceToException(exception);
                    frame.FaultingInstruction = frame.InstructionIndex;
                    ExceptionHandler handler;
                    frame.InstructionIndex += GotoHandler(frame, exception, out handler);

                    if (handler == null || handler.IsFault) {
                        // run finally/fault blocks:
                        Run(frame);

                        // a finally block can throw an exception caught by a handler, which cancels the previous exception:
                        if (frame.InstructionIndex == RethrowOnReturn) {
                            throw;
                        }
                        return;
                    }

                    // stay in the current catch so that ThreadAbortException is not rethrown by CLR:
                    var abort = exception as ThreadAbortException;
                    if (abort != null) {
                        _anyAbortException = abort;
                        frame.CurrentAbortHandler = handler;
                        Run(frame);
                        return;
                    }
                    exception = null;
                }
            }
        }
开发者ID:kevinkeeney,项目名称:ironruby,代码行数:39,代码来源:Interpreter.cs

示例2: HandleException

        private ExceptionHandlingResult HandleException(InterpretedFrame frame, Exception exception) {
            frame.SaveTraceToException(exception);
            ExceptionHandler handler;
            frame.InstructionIndex += GotoHandler(frame, exception, out handler);

            if (handler == null || handler.IsFault) {
                // run finally/fault blocks:
                Run(frame);

                // a finally block can throw an exception caught by a handler, which cancels the previous exception:
                if (frame.InstructionIndex == RethrowOnReturn) {
                    return ExceptionHandlingResult.Rethrow;
                }
                return ExceptionHandlingResult.Return;
            }

#if FEATURE_THREAD
            // stay in the current catch so that ThreadAbortException is not rethrown by CLR:
            var abort = exception as ThreadAbortException;
            if (abort != null) {
                _anyAbortException = abort;
                frame.CurrentAbortHandler = handler;
            }
#endif
            while (true) {
                try {
                    var instructions = _instructions.Instructions;
                    int index = frame.InstructionIndex;

                    while (index < instructions.Length) {
                        var curInstr = instructions[index];                        

                        index += curInstr.Run(frame);
                        frame.InstructionIndex = index;
                        
                        if (curInstr is LeaveExceptionHandlerInstruction) {
                            // we've completed handling of this exception
                            return ExceptionHandlingResult.Continue;
                        }
                    }

                    if (frame.InstructionIndex == RethrowOnReturn) {
                        return ExceptionHandlingResult.Rethrow;
                    }

                    return ExceptionHandlingResult.Return;
                } catch (Exception nestedException) {                    
                    switch (HandleException(frame, nestedException)) {
                        case ExceptionHandlingResult.Rethrow: throw;
                        case ExceptionHandlingResult.Continue: continue;
                        case ExceptionHandlingResult.Return: return ExceptionHandlingResult.Return;
                        default: throw Assert.Unreachable;
                    }
                }
            }
        }
开发者ID:Jaykul,项目名称:IronLangs,代码行数:56,代码来源:Interpreter.cs


注:本文中的Microsoft.Scripting.Interpreter.InterpretedFrame.SaveTraceToException方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。