コード例 #1
0
 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));
     }
 }
コード例 #2
0
        /// <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;
                }
            }
        }
コード例 #3
0
 public Signature(string body, Tabularity tabularity, params Parameter[] parameters)
     : this(ReturnTypeKind.Computed, null, body, null, null, tabularity, parameters)
 {
 }
コード例 #4
0
 public Signature(string body, Tabularity tabularity, IReadOnlyList <Parameter> parameters)
     : this(ReturnTypeKind.Computed, null, body, null, null, tabularity, parameters)
 {
 }
コード例 #5
0
 public Signature(CustomReturnTypeShort customReturnType, Tabularity tabularity, params Parameter[] parameters)
     : this((table, args, signature) => customReturnType(table, args), tabularity, parameters)
 {
 }
コード例 #6
0
 public Signature(CustomReturnTypeShort customReturnType, Tabularity tabularity, IReadOnlyList <Parameter> parameters)
     : this((table, args, signature) => customReturnType(table, args), tabularity, parameters)
 {
 }
コード例 #7
0
        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;
            }
        }
コード例 #8
0
        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;
        }
コード例 #9
0
 public FunctionSymbol(string name, string body, Tabularity tabularity, params Parameter[] parameters)
     : this(name, new[] { new Signature(body, tabularity, parameters) })
 {
 }
コード例 #10
0
 public FunctionSymbol(string name, string body, Tabularity tabularity, IReadOnlyList <Parameter> parameters)
     : this(name, new[] { new Signature(body, tabularity, parameters) })
 {
 }
コード例 #11
0
 public FunctionSymbol(string name, CustomReturnTypeShort customReturnType, Tabularity tabularity, params Parameter[] parameters)
     : this(name, (table, args, signature) => customReturnType(table, args), tabularity, parameters)
 {
 }
コード例 #12
0
 public FunctionSymbol(string name, CustomReturnType customReturnType, Tabularity tabularity, params Parameter[] parameters)
     : this(name, new[] { new Signature(customReturnType, tabularity, parameters) })
 {
 }