Esempio n. 1
0
        private IBoundExpression ResolveProcedureNamespace()
        {
            /*  Namespace tier 1:
             *  Procedure namespace: A local variable, reference parameter binding or constant whose implicit
             *  or explicit definition precedes this expression in an enclosing procedure.
             */
            if (!_parent.DeclarationType.HasFlag(DeclarationType.Function) && !_parent.DeclarationType.HasFlag(DeclarationType.Procedure))
            {
                return(null);
            }
            var parameter = _declarationFinder.FindMemberEnclosingProcedure(_parent, _name, DeclarationType.Parameter);

            if (IsValidMatch(parameter, _name))
            {
                return(new SimpleNameExpression(parameter, ExpressionClassification.Variable, _context));
            }
            var localVariable = _declarationFinder.FindMemberEnclosingProcedure(_parent, _name, DeclarationType.Variable)
                                ?? _declarationFinder.FindMemberEnclosingProcedure(_parent, _name, DeclarationType.Variable)
            ;

            if (IsValidMatch(localVariable, _name))
            {
                return(new SimpleNameExpression(localVariable, ExpressionClassification.Variable, _context));
            }
            var constant = _declarationFinder.FindMemberEnclosingProcedure(_parent, _name, DeclarationType.Constant);

            if (IsValidMatch(constant, _name))
            {
                return(new SimpleNameExpression(constant, ExpressionClassification.Value, _context));
            }

            return(null);
        }