internal Interpreter(LambdaExpression lambda, bool[] localIsBoxed, int maxStackDepth, InstructionArray instructions, ExceptionHandler[] handlers, DebugInfo[] debugInfos, int compilationThreshold) { _lambda = lambda; _numberOfLocals = localIsBoxed.Length; if (Array.IndexOf(localIsBoxed, true) != -1) { _localIsBoxed = localIsBoxed; } else { _localIsBoxed = null; } _maxStackDepth = maxStackDepth; _instructions = instructions; _objects = instructions.Objects; _handlers = handlers; _debugInfos = debugInfos; _onlyFaultHandlers = true; foreach (var handler in handlers) { if (!handler.IsFinallyOrFault) { _onlyFaultHandlers = false; break; } } _compilationThreshold = compilationThreshold; }
internal Interpreter(LambdaExpression lambda, LocalVariables locals, Dictionary<LabelTarget, BranchLabel> labelMapping, InstructionArray instructions, ExceptionHandler[] handlers, DebugInfo[] debugInfos, int compilationThreshold) { _lambda = lambda; _locals = locals; _boxedLocals = locals.GetBoxed(); _instructions = instructions; _objects = instructions.Objects; _labels = instructions.Labels; _labelMapping = labelMapping; _handlers = handlers; _debugInfos = debugInfos; _compilationThreshold = compilationThreshold; }
internal Interpreter(string name, LocalVariables locals, HybridReferenceDictionary<LabelTarget, BranchLabel> labelMapping, InstructionArray instructions, ExceptionHandler[] handlers, DebugInfo[] debugInfos, int compilationThreshold) { _name = name; _localCount = locals.LocalCount; _closureVariables = locals.ClosureVariables; _instructions = instructions; _objects = instructions.Objects; _labels = instructions.Labels; _labelMapping = labelMapping; _handlers = handlers; _debugInfos = debugInfos; _compilationThreshold = compilationThreshold; }
public bool IsBetterThan(ExceptionHandler other) { if (other == null) return true; if (StartIndex == other.StartIndex && EndIndex == other.EndIndex) { return JumpToIndex < other.JumpToIndex; } if (StartIndex > other.StartIndex) { Debug.Assert(EndIndex <= other.EndIndex); return true; } else if (EndIndex < other.EndIndex) { Debug.Assert(StartIndex == other.StartIndex); return true; } else { return false; } }
internal Interpreter(LambdaExpression lambda, bool[] localIsBoxed, int maxStackDepth, Instruction[] instructions, ExceptionHandler[] handlers) { this._lambda = lambda; this._numberOfLocals = localIsBoxed.Length; if (AnyBoxedLocals(localIsBoxed)) { _localIsBoxed = localIsBoxed; } else { _localIsBoxed = null; } this._maxStackDepth = maxStackDepth; this._instructions = instructions; this._handlers = handlers; _onlyFaultHandlers = true; foreach (var handler in handlers) { if (!handler.IsFault) { _onlyFaultHandlers = false; break; } } }
private ExceptionHandler AddHandler(Type exceptionType, ParameterExpression exceptionParameter, int start, int end) { var handler = new ExceptionHandler() { ExceptionType = exceptionType, PushException = exceptionParameter != null, StartIndex = start, EndIndex = end, JumpToIndex = _instructions.Count }; _handlers.Add(handler); return handler; }
internal int GotoHandler(InterpretedFrame frame, object exception, out ExceptionHandler handler) { handler = GetBestHandler(frame.InstructionIndex, exception.GetType()); if (handler == null) { return frame.Goto(ReturnAndRethrowLabelIndex, Interpreter.NoValue); } else { return frame.Goto(handler.LabelIndex, exception); } }