/// <summary> /// Creates a new <see cref="Signature"/> just like this one, but with a custom function that /// builds a list of parameter associated with each argument. /// </summary> public Signature WithArgumentParametersBuilder(CustomArgumentParametersBuilder customBuilder) { return(new Signature(this.ReturnKind, this._returnType, this._body, this.Declaration, this.CustomReturnType, this._tabularity, this.Parameters, customBuilder, this.IsHidden)); }
private Signature( ReturnTypeKind returnKind, TypeSymbol returnType, string body, FunctionDeclaration declaration, CustomReturnType customReturnType, Tabularity tabularity, IReadOnlyList <Parameter> parameters, CustomArgumentParametersBuilder customParameterListBuilder = null, bool isHidden = false) { if (returnKind == ReturnTypeKind.Declared && returnType == null) { throw new ArgumentNullException(nameof(returnType)); } if (returnKind == ReturnTypeKind.Computed && !(body != null | declaration != null)) { throw new ArgumentNullException(nameof(body)); } if (returnKind == ReturnTypeKind.Custom && customReturnType == null) { throw new ArgumentNullException(nameof(customReturnType)); } this.ReturnKind = returnKind; this._returnType = returnType; this._body = body; this.Declaration = declaration; this.CustomReturnType = customReturnType; this._tabularity = tabularity; this.Parameters = parameters.ToReadOnly(); this.CustomArgumentParametersBuilder = customParameterListBuilder; this.IsHidden = isHidden; if (returnKind == ReturnTypeKind.Computed && returnType != null && tabularity == Tabularity.Unknown) { this._tabularity = returnType.Tabularity; } this._firstRepeatableParameter = -1; this._lastRepeatableParameter = -1; int minArgumentCount = 0; int maxArgumentCount = 0; for (sbyte i = 0, n = (sbyte)this.Parameters.Count; i < n; i++) { var p = parameters[i]; if (p.IsRepeatable) { if (this._firstRepeatableParameter == -1) { this._firstRepeatableParameter = i; } this._lastRepeatableParameter = i; } if (p.IsOptional) { this.HasOptionalParameters = true; } if (p.ArgumentKind == ArgumentKind.Aggregate) { this.HasAggregateParameters = true; } minArgumentCount += p.MinOccurring; maxArgumentCount += p.MaxOccurring; } this.MinArgumentCount = minArgumentCount; this.MaxArgumentCount = maxArgumentCount; }