Beispiel #1
0
        private void PushIsInstanceScope(Node node, KeyValuePair <NameExpression, Expression>[] isInstanceNames, SuiteStatement effectiveSuite)
        {
            InterpreterScope scope;

            if (!_curUnit.InterpreterScope.TryGetNodeScope(node, out scope))
            {
                // find our parent scope, it may not be just the last entry in _scopes
                // because that can be a StatementScope and we would start a new range.
                var declScope = _scope.EnumerateTowardsGlobal.FirstOrDefault(s => !(s is StatementScope));

                scope = new IsInstanceScope(node.StartIndex, effectiveSuite, declScope);

                declScope.Children.Add(scope);
                declScope.AddNodeScope(node, scope);
                _scope = scope;
            }
        }
Beispiel #2
0
        public override bool Walk(SuiteStatement node)
        {
            var prevSuite = _curSuite;

            _curSuite = node;

            // recursively walk the statements in the suite
            if (node.Statements != null)
            {
                foreach (var innerNode in node.Statements)
                {
                    innerNode.Walk(this);
                }
            }

            _curSuite = prevSuite;

            // then check if we encountered an assert which added an isinstance scope.
            IsInstanceScope isInstanceScope = _scope as IsInstanceScope;

            if (isInstanceScope != null && isInstanceScope._effectiveSuite == node)
            {
                // pop the isinstance scope
                _scope = _scope.OuterScope;
                // transform back into a line number and start the new statement scope on the line
                // after the suite statement.
                var lineNo = _tree.IndexToLocation(node.EndIndex).Line;

                int offset;
                if (_tree.NewLineLocations.Length == 0)
                {
                    // single line input
                    offset = 0;
                }
                else
                {
                    offset = lineNo < _tree.NewLineLocations.Length
                        ? _tree.NewLineLocations[lineNo].EndIndex
                        : _tree.NewLineLocations[_tree.NewLineLocations.Length - 1].EndIndex;
                }
                var closingScope = new StatementScope(offset, _scope);
                _scope.Children.Add(closingScope);
                _scope = closingScope;
            }
            return(false);
        }
Beispiel #3
0
        private void PushIsInstanceScope(Node node, KeyValuePair<NameExpression, Expression>[] isInstanceNames, SuiteStatement effectiveSuite) {
            InterpreterScope scope;
            if (!_curUnit.Scope.TryGetNodeScope(node, out scope)) {
                // find our parent scope, it may not be just the last entry in _scopes
                // because that can be a StatementScope and we would start a new range.
                var declScope = _scope.EnumerateTowardsGlobal.FirstOrDefault(s => !(s is StatementScope));

                scope = new IsInstanceScope(node.StartIndex, effectiveSuite, declScope);

                declScope.Children.Add(scope);
                declScope.AddNodeScope(node, scope);
                _scope = scope;
            }
        }