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)); } }
/// <summary> /// Determines the tabularity of signatures with computed return types. /// </summary> public void ComputeTabularity(GlobalState globals) { if (this.ReturnKind != ReturnTypeKind.Custom || _tabularity != Tabularity.Unknown) { return; } var type = Binding.Binder.GetComputedReturnType(this, globals); if (this._tabularity == Tabularity.Unknown && type != null) { if (type.IsTabular) { this._tabularity = Tabularity.Tabular; } else if (type.IsScalar) { this._tabularity = Tabularity.Scalar; } } }
public Signature(string body, Tabularity tabularity, params Parameter[] parameters) : this(ReturnTypeKind.Computed, null, body, null, null, tabularity, parameters) { }
public Signature(string body, Tabularity tabularity, IReadOnlyList <Parameter> parameters) : this(ReturnTypeKind.Computed, null, body, null, null, tabularity, parameters) { }
public Signature(CustomReturnTypeShort customReturnType, Tabularity tabularity, params Parameter[] parameters) : this((table, args, signature) => customReturnType(table, args), tabularity, parameters) { }
public Signature(CustomReturnTypeShort customReturnType, Tabularity tabularity, IReadOnlyList <Parameter> parameters) : this((table, args, signature) => customReturnType(table, args), tabularity, parameters) { }
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; } }
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; }
public FunctionSymbol(string name, string body, Tabularity tabularity, params Parameter[] parameters) : this(name, new[] { new Signature(body, tabularity, parameters) }) { }
public FunctionSymbol(string name, string body, Tabularity tabularity, IReadOnlyList <Parameter> parameters) : this(name, new[] { new Signature(body, tabularity, parameters) }) { }
public FunctionSymbol(string name, CustomReturnTypeShort customReturnType, Tabularity tabularity, params Parameter[] parameters) : this(name, (table, args, signature) => customReturnType(table, args), tabularity, parameters) { }
public FunctionSymbol(string name, CustomReturnType customReturnType, Tabularity tabularity, params Parameter[] parameters) : this(name, new[] { new Signature(customReturnType, tabularity, parameters) }) { }