private ArgumentList VisitArgumentList(Declaration module, Declaration parent, VBAParser.ArgumentListContext argumentList, IBoundExpression withBlockVariable, StatementResolutionContext statementContext) { var convertedList = new ArgumentList(); if (argumentList == null) { return(convertedList); } var list = argumentList; // TODO: positionalArgumentOrMissing is there as preparation for argument compatibility checking. if (list.argument() != null) { foreach (var expr in list.argument()) { if (expr.positionalArgument() != null) { convertedList.AddArgument(new ArgumentListArgument( VisitArgumentBinding(module, parent, expr.positionalArgument().argumentExpression(), withBlockVariable, StatementResolutionContext.Undefined), ArgumentListArgumentType.Positional)); } else if (expr.namedArgument() != null) { convertedList.AddArgument(new ArgumentListArgument( VisitArgumentBinding(module, parent, expr.namedArgument().argumentExpression(), withBlockVariable, StatementResolutionContext.Undefined), ArgumentListArgumentType.Named, CreateNamedArgumentExpressionCreator(expr.namedArgument().unrestrictedIdentifier().GetText(), expr.namedArgument().unrestrictedIdentifier()))); } } } return(convertedList); }
private ArgumentList VisitArgumentList(Declaration module, Declaration parent, VBAParser.ArgumentListContext argumentList, IBoundExpression withBlockVariable) { var convertedList = new ArgumentList(); if (argumentList == null) { return(convertedList); } var list = argumentList; // TODO: positionalArgumentOrMissing is there as preparation for argument compatibility checking. if (list.argument() != null) { foreach (var expr in list.argument()) { if (expr.positionalArgument() != null) { var(binding, context, isAddressOfArgument) = VisitArgumentBinding(module, parent, expr.positionalArgument().argumentExpression(), withBlockVariable); convertedList.AddArgument(new ArgumentListArgument( binding, context, argumentList, ArgumentListArgumentType.Positional, isAddressOfArgument)); } else if (expr.namedArgument() != null) { var(binding, context, isAddressOfArgument) = VisitArgumentBinding(module, parent, expr.namedArgument().argumentExpression(), withBlockVariable); convertedList.AddArgument(new ArgumentListArgument( binding, context, argumentList, ArgumentListArgumentType.Named, CreateNamedArgumentExpressionCreator(expr.namedArgument().unrestrictedIdentifier().GetText(), expr.namedArgument().unrestrictedIdentifier()), isAddressOfArgument)); } else if (expr.missingArgument() != null) { var missingArgumentContext = expr.missingArgument(); var binding = new MissingArgumentBinding(missingArgumentContext); convertedList.AddArgument(new ArgumentListArgument( binding, missingArgumentContext, argumentList, ArgumentListArgumentType.Missing, false)); } } } return(convertedList); }
private IExpressionBinding VisitDictionaryAccessExpression(Declaration module, Declaration parent, ParserRuleContext expression, ParserRuleContext nameContext, IBoundExpression lExpression, StatementResolutionContext statementContext) { /* * A dictionary access expression is syntactically translated into an index expression with the same * expression for <l-expression> and an argument list with a single positional argument with a * declared type of String and a value equal to the name value of <unrestricted-name>. */ var fakeArgList = new ArgumentList(); fakeArgList.AddArgument(new ArgumentListArgument(new LiteralDefaultBinding(nameContext), ArgumentListArgumentType.Positional)); return(new IndexDefaultBinding(_declarationFinder, Declaration.GetProjectParent(parent), module, parent, expression, lExpression, fakeArgList)); }
private IExpressionBinding VisitDictionaryAccessExpression(ParserRuleContext expression, ParserRuleContext nameContext, IBoundExpression lExpression) { /* * A dictionary access expression is syntactically translated into an index expression with the same * expression for <l-expression> and an argument list with a single positional argument with a * declared type of String and a value equal to the name value of <unrestricted-name>. * * Still, we have a specific binding for it in order to attach a reference to the called default member to the exclamation mark. */ var fakeArgList = new ArgumentList(); fakeArgList.AddArgument(new ArgumentListArgument(new LiteralDefaultBinding(nameContext), nameContext, null, ArgumentListArgumentType.Positional)); return(new DictionaryAccessDefaultBinding(expression, lExpression, fakeArgList)); }