private void BoxLocals(StackFrame frame) { if (_localIsBoxed != null) { for (int i = 0; i < _localIsBoxed.Length; i++) { if (_localIsBoxed[i]) { frame.Data[i] = new StrongBox<object>(frame.Data[i]); } } } }
public override int Run(StackFrame frame) { DebugInfo info = DebugInfo.GetMatchingDebugInfo(_debugInfos, frame.FaultingInstruction); if (info != null && !info.IsClear) { frame.Push(info.StartLine); }else{ frame.Push(-1); } return +1; }
public override int Run(StackFrame frame) { var targetDelegate = _targetField.GetValue(_site); object[] args = new object[_argCount]; for (int i = _argCount - 1; i >= 1; i--) { args[i] = frame.Pop(); } args[0] = _site; object ret = _target.InvokeInstance(targetDelegate, args); if (!_isVoid) frame.Push(ret); return +1; }
private void HandleFault(StackFrame frame) { UpdateStackTrace(frame); var handler = GetBestHandler(frame, null); if (handler == null) return; frame.StackIndex = _numberOfLocals; try { frame.InstructionIndex = handler.JumpToIndex; RunInstructions(_instructions, frame, handler.EndHandlerIndex); } finally { // This assumes that finally faults are propogated always frame.InstructionIndex = handler.EndHandlerIndex; HandleFault(frame); } }
private void RunFaultHandlerWithCatch(StackFrame frame, int endIndex) { while (true) { try { RunInstructions(_instructions, frame, endIndex); return; } catch (Exception exc) { ExceptionHelpers.AssociateDynamicStackFrames(exc); if (!HandleCatch(frame, exc)) { ExceptionHelpers.UpdateForRethrow(exc); throw; } } } }
private bool HandleCatch(StackFrame frame, Exception exception) { UpdateStackTrace(frame); Type exceptionType = exception.GetType(); var handler = GetBestHandler(frame, exceptionType); if (handler == null) return false; frame.StackIndex = _numberOfLocals; if (handler.IsFault) { frame.InstructionIndex = handler.JumpToIndex; //var savedFrames = ExceptionHelpers.DynamicStackFrames; //ExceptionHelpers.DynamicStackFrames = null; RunFaultHandlerWithCatch(frame, handler.EndHandlerIndex); if (frame.InstructionIndex == handler.EndHandlerIndex) { //ExceptionHelpers.DynamicStackFrames = savedFrames; frame.InstructionIndex -= 1; // push back into the right range return HandleCatch(frame, exception); } else { return true; } } else { if (handler.PushException) { frame.Push(exception); } frame.InstructionIndex = handler.JumpToIndex; return true; } }
private ExceptionHandler GetBestHandler(StackFrame frame, Type exceptionType) { ExceptionHandler best = null; foreach (var handler in _handlers) { if (handler.Matches(exceptionType, frame.InstructionIndex)) { if (handler.IsBetterThan(best)) { best = handler; } } } return best; }
private void UpdateStackTrace(StackFrame frame) { foreach (var info in _debugInfos) { if (info.Matches(frame.InstructionIndex)) { ExceptionHelpers.UpdateStackTrace(null, _runMethod, _lambda.Name, info.FileName, info.StartLine); return; } } }
public override int Run(StackFrame frame) { frame.Push(_global.CurrentValue); return +1; }
private void RunFaultHandlerWithCatch(StackFrame frame, int endIndex) { while (true) { try { RunInstructions(_instructions, frame, endIndex); return; } catch (Exception exc) { frame.FaultingInstruction = frame.InstructionIndex; if (!HandleCatch(frame, exc)) { throw; } } } }
private void UpdateStackTrace(StackFrame frame) { DebugInfo info = DebugInfo.GetMatchingDebugInfo(_debugInfos, frame.InstructionIndex); if (info != null && !info.IsClear) { string name = _lambda.Name; if (name != null) { int index = name.LastIndexOf('$'); if (index >= 0) { name = name.Substring(0, index); } } ExceptionHelpers.UpdateStackTrace(null, _runMethod, name, info.FileName, info.StartLine); } }
public override int Run(StackFrame frame) { if (_isLocal) { frame.Push(PythonOps.GetLocal((Scope)frame.Pop(), _name)); } else { frame.Push(PythonOps.GetGlobal((Scope)frame.Pop(), _name)); } return +1; }
public override int Run(StackFrame frame) { _global.CurrentValue = frame.Peek(); return +1; }
private static void RunInstructions(Instruction[] instructions, StackFrame frame) { int index = frame.InstructionIndex; while (index < instructions.Length) { index += instructions[index].Run(frame); frame.InstructionIndex = index; } }
private void HandleFault(StackFrame frame) { var handler = GetBestHandler(frame, null); if (handler == null) return; frame.StackIndex = _numberOfLocals; bool wasFault = true; try { frame.InstructionIndex = handler.JumpToIndex; RunInstructions(_instructions, frame, handler.EndHandlerIndex); wasFault = false; } finally { if (wasFault) { frame.FaultingInstruction = frame.InstructionIndex; } // This assumes that finally faults are propogated always // // Go back one so we are scoped correctly frame.InstructionIndex = handler.EndHandlerIndex - 1; HandleFault(frame); } }
internal StackFrame MakeFrame(StrongBox<object>[] closure) { var ret = new StackFrame(_numberOfLocals, _maxStackDepth); ret.Closure = closure; return ret; }
public object Run(StackFrame frame) { BoxLocals(frame); if (_onlyFaultHandlers) { bool fault = true; try { RunInstructions(_instructions, frame); fault = false; return frame.Pop(); } finally { if (fault) { frame.FaultingInstruction = frame.InstructionIndex; HandleFault(frame); } } } else { while (true) { try { RunInstructions(_instructions, frame); return frame.Pop(); } catch (Exception exc) { frame.FaultingInstruction = frame.InstructionIndex; if (!HandleCatch(frame, exc)) { throw; } else if (exc is System.Threading.ThreadAbortException) { // we can't exit the catch block here or the CLR will forcibly rethrow // the exception on us. Run(frame); } } } } }
public object Run(StackFrame frame) { BoxLocals(frame); if (_onlyFaultHandlers) { bool fault = true; try { RunInstructions(_instructions, frame); fault = false; return frame.Pop(); } finally { if (fault) { HandleFault(frame); } } } else { while (true) { try { RunInstructions(_instructions, frame); return frame.Pop(); } catch (Exception exc) { ExceptionHelpers.AssociateDynamicStackFrames(exc); if (!HandleCatch(frame, exc)) { ExceptionHelpers.UpdateForRethrow(exc); throw; } } } } }
private void UpdateStackTrace(StackFrame frame) { DebugInfo info = DebugInfo.GetMatchingDebugInfo(_debugInfos, frame.InstructionIndex); if (info != null && !info.IsClear) { ExceptionHelpers.UpdateStackTrace(null, _runMethod, _lambda.Name, info.FileName, info.StartLine); } }