private IExpressionBinding Visit(Declaration module, Declaration parent, VBAParser.CallStmtContext expression, IBoundExpression withBlockVariable, StatementResolutionContext statementContext) { // Call statements always have an argument list. // One of the reasons we're doing this is that an empty argument list could represent a call to a default member, // which requires us to use an IndexDefaultBinding. if (expression.CALL() == null) { dynamic lexpr = expression.lExpression(); var lexprBinding = Visit(module, parent, lexpr, withBlockVariable, StatementResolutionContext.Undefined); var argList = VisitArgumentList(module, parent, expression.argumentList(), withBlockVariable, StatementResolutionContext.Undefined); SetLeftMatch(lexprBinding, argList.Arguments.Count); return(new IndexDefaultBinding(_declarationFinder, Declaration.GetProjectParent(parent), module, parent, expression.lExpression(), lexprBinding, argList)); } else { var lexprBinding = Visit(module, parent, (dynamic)expression.lExpression(), withBlockVariable, StatementResolutionContext.Undefined); if (!(lexprBinding is IndexDefaultBinding)) { return(new IndexDefaultBinding(_declarationFinder, Declaration.GetProjectParent(parent), module, parent, expression.lExpression(), lexprBinding, new ArgumentList())); } else { return(lexprBinding); } } }
private IExpressionBinding Visit(Declaration module, Declaration parent, VBAParser.CallStmtContext expression, IBoundExpression withBlockVariable) { var lExpression = expression.lExpression(); var lExpressionBinding = Visit(module, parent, lExpression, withBlockVariable, StatementResolutionContext.Undefined); if (expression.CALL() == null) { var argList = VisitArgumentList(module, parent, expression.argumentList(), withBlockVariable); SetLeftMatch(lExpressionBinding, argList.Arguments.Count); if (argList.HasArguments) { return(new IndexDefaultBinding(expression.lExpression(), lExpressionBinding, argList, parent)); } return(new ProcedureCoercionDefaultBinding(expression.lExpression(), lExpressionBinding, false, parent)); } return(new ProcedureCoercionDefaultBinding(expression.lExpression(), lExpressionBinding, true, parent)); }
public static VBAParser.ArgumentListContext GetArgumentList(VBAParser.CallStmtContext callStmt) { VBAParser.ArgumentListContext argList = null; if (callStmt.CALL() != null) { var lExpr = callStmt.lExpression(); if (lExpr is VBAParser.IndexExprContext) { var indexExpr = (VBAParser.IndexExprContext)lExpr; argList = indexExpr.argumentList(); } else if (lExpr is VBAParser.WhitespaceIndexExprContext) { var indexExpr = (VBAParser.WhitespaceIndexExprContext)lExpr; argList = indexExpr.argumentList(); } } else { argList = callStmt.argumentList(); } return(argList); }