private ImmutableArray <BoundVariableDeclaration> BindParameters(ParameterListSyntax parameterList, Binder invocableBinder, InvocableSymbol invocableSymbol) { var boundParameters = new List <BoundVariableDeclaration>(); foreach (var parameterSyntax in parameterList.Parameters) { var parameterValueType = Bind(parameterSyntax.Type, x => BindType(x, null)); var parameterDirection = SyntaxFacts.GetParameterDirection(parameterSyntax.Modifiers); boundParameters.Add(invocableBinder.Bind(parameterSyntax.Declarator, x => invocableBinder.BindVariableDeclarator(x, parameterValueType.TypeSymbol, (d, t) => new SourceParameterSymbol( parameterSyntax, invocableSymbol, t, parameterDirection)))); } invocableSymbol.ClearParameters(); foreach (var parameter in invocableBinder.LocalSymbols.Values.SelectMany(x => x)) { invocableSymbol.AddParameter((ParameterSymbol)parameter); } return(boundParameters.ToImmutableArray()); }
private void BindFunctionDeclaration(FunctionDeclarationSyntax declaration) { var returnType = _symbolSet.ResolveType(declaration.ReturnType, null, null); Func <FunctionSymbol, IEnumerable <ParameterSymbol> > lazyParameterSymbols = fd => { var parameterSymbols = new List <ParameterSymbol>(); foreach (var parameterSyntax in declaration.ParameterList.Parameters) { var parameterValueType = _symbolSet.ResolveType(parameterSyntax.Type, null, null); var parameterDirection = SyntaxFacts.GetParameterDirection(parameterSyntax.Modifiers); parameterSymbols.Add(new SourceParameterSymbol( parameterSyntax, fd, parameterValueType, parameterDirection)); } return(parameterSymbols); }; var symbol = new SourceFunctionDeclarationSymbol(declaration, returnType, lazyParameterSymbols); _bindingResult.AddSymbol(declaration, symbol); _symbolSet.AddGlobal(symbol); }