예제 #1
0
        private IExpressionBinding VisitUnaryOp(Declaration module, Declaration parent, ParserRuleContext context, VBAParser.ExpressionContext expr, IBoundExpression withBlockVariable)
        {
            var exprBinding        = Visit(module, parent, expr, withBlockVariable, StatementResolutionContext.Undefined);
            var letCoercionBinding = new LetCoercionDefaultBinding(expr, exprBinding);

            return(new UnaryOpDefaultBinding(context, letCoercionBinding));
        }
예제 #2
0
        private IExpressionBinding Visit(Declaration module, Declaration parent, VBAParser.ParenthesizedExprContext expression, IBoundExpression withBlockVariable)
        {
            var expressionParens   = expression.expression();
            var expressionBinding  = Visit(module, parent, expressionParens, withBlockVariable, StatementResolutionContext.Undefined);
            var letCoercionBinding = new LetCoercionDefaultBinding(expressionParens, expressionBinding);

            return(new ParenthesizedDefaultBinding(expression, letCoercionBinding));
        }
예제 #3
0
        private IExpressionBinding VisitBinaryOp(Declaration module, Declaration parent, ParserRuleContext context, VBAParser.ExpressionContext left, VBAParser.ExpressionContext right, IBoundExpression withBlockVariable, bool isIsRelation = false)
        {
            var leftBinding  = Visit(module, parent, left, withBlockVariable, StatementResolutionContext.Undefined);
            var rightBinding = Visit(module, parent, right, withBlockVariable, StatementResolutionContext.Undefined);

            if (!isIsRelation)
            {
                //All but the Is relation require value type arguments.
                leftBinding  = new LetCoercionDefaultBinding(left, leftBinding);
                rightBinding = new LetCoercionDefaultBinding(right, rightBinding);
            }

            return(new BinaryOpDefaultBinding(context, leftBinding, rightBinding));
        }
예제 #4
0
        public void Resolve(Declaration calledProcedure, int parameterIndex, bool isArrayAccess = false)
        {
            ArgumentPosition = parameterIndex;

            var binding = _binding;

            if (calledProcedure != null)
            {
                NamedArgumentExpression = _namedArgumentExpressionCreator(calledProcedure);
                ReferencedParameter     = ResolveReferencedParameter(calledProcedure, parameterIndex);

                if (!_isAddressOfArgument &&
                    !(Context is VBAParser.MissingArgumentContext) &&
                    (isArrayAccess ||
                     ReferencedParameter != null &&
                     !CanBeObject(ReferencedParameter)))
                {
                    binding = new LetCoercionDefaultBinding(Context, binding);
                }
            }

            Expression = binding.Resolve();
        }