public Signature(CustomReturnType customReturnType, Tabularity tabularity, params Parameter[] parameters) : this(ReturnTypeKind.Custom, null, null, null, customReturnType, tabularity, parameters) { if (customReturnType == null) { throw new ArgumentNullException(nameof(customReturnType)); } }
private Signature( ReturnTypeKind returnKind, TypeSymbol returnType, string body, FunctionDeclaration declaration, CustomReturnType customReturnType, Tabularity tabularity, IReadOnlyList <Parameter> parameters, 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.IsHidden = isHidden; if (returnKind == ReturnTypeKind.Computed && returnType != null && tabularity == Tabularity.Unknown) { this._tabularity = returnType.Tabularity; } this.ReturnTypeDependsOnArguments = returnKind != ReturnTypeKind.Declared && this.Parameters.Count > 0 && this.Parameters.Any(p => p.TypeDependsOnArguments); 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; } minArgumentCount += p.MinOccurring; maxArgumentCount += p.MaxOccurring; } this.MinArgumentCount = minArgumentCount; this.MaxArgumentCount = maxArgumentCount; }
private Signature( ReturnTypeKind returnKind, TypeSymbol returnType, string body, FunctionDeclaration declaration, CustomReturnType customReturnType, Tabularity tabularity, IReadOnlyList <Parameter> parameters, ParameterLayout layout = 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.IsHidden = isHidden; if (returnKind == ReturnTypeKind.Computed && returnType != null && tabularity == Tabularity.Unknown) { this._tabularity = returnType.Tabularity; } int minArgumentCount = 0; int maxArgumentCount = 0; foreach (var p in this.Parameters) { if (p.IsRepeatable) { this.HasRepeatableParameters = true; } 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; if (layout != null) { this.Layout = layout; } else if (this.HasRepeatableParameters) { this.Layout = ParameterLayouts.Repeating; } else { this.Layout = ParameterLayouts.Fixed; } }
public FunctionSymbol(string name, CustomReturnType customReturnType, Tabularity tabularity, params Parameter[] parameters) : this(name, new[] { new Signature(customReturnType, tabularity, parameters) }) { }