Beispiel #1
0
        private bool BpTest(Statement statement, BreakPoint breakpoint)
        {
            bool afterStart, beforeEnd;

            afterStart = (breakpoint.Line == statement.Location.Start.Line &&
                          breakpoint.Char >= statement.Location.Start.Column);

            if (!afterStart)
            {
                return(false);
            }

            beforeEnd = breakpoint.Line < statement.Location.End.Line ||
                        (breakpoint.Line == statement.Location.End.Line &&
                         breakpoint.Char <= statement.Location.End.Column);

            if (!beforeEnd)
            {
                return(false);
            }

            if (!string.IsNullOrEmpty(breakpoint.Condition))
            {
                return(_engine.Execute(breakpoint.Condition).GetCompletionValue().AsBoolean());
            }

            return(true);
        }
Beispiel #2
0
        internal void OnStep(Statement statement)
        {
            var old = _stepMode;

            if (statement == null)
            {
                return;
            }

            BreakPoint breakpoint      = _engine.BreakPoints.FirstOrDefault(breakPoint => BpTest(statement, breakPoint));
            bool       breakpointFound = false;

            if (breakpoint != null)
            {
                DebugInformation info = CreateDebugInformation(statement);
                var result            = _engine.InvokeBreakEvent(info);
                if (result.HasValue)
                {
                    _stepMode       = result.Value;
                    breakpointFound = true;
                }
            }

            if (breakpointFound == false && _stepMode == StepMode.Into)
            {
                DebugInformation info = CreateDebugInformation(statement);
                var result            = _engine.InvokeStepEvent(info);
                if (result.HasValue)
                {
                    _stepMode = result.Value;
                }
            }

            if (old == StepMode.Into && _stepMode == StepMode.Out)
            {
                _callBackStepOverDepth = _debugCallStack.Count;
            }
            else if (old == StepMode.Into && _stepMode == StepMode.Over)
            {
                var expressionStatement = statement as ExpressionStatement;
                if (expressionStatement != null && expressionStatement.Expression is CallExpression)
                {
                    _callBackStepOverDepth = _debugCallStack.Count;
                }
                else
                {
                    _stepMode = StepMode.Into;
                }
            }
        }