Beispiel #1
0
        // Gets the overloads for SortByColumns function for the specified arity.
        private IEnumerable <TexlStrings.StringGetter[]> GetOverloadsSortByColumns(int arity)
        {
            Contracts.Assert(3 < arity);

            const int OverloadCount = 2;

            var overloads = new List <TexlStrings.StringGetter[]>(OverloadCount);

            // Limit the argCount avoiding potential OOM
            int argCount = arity > SignatureConstraint.RepeatTopLength ? SignatureConstraint.RepeatTopLength : arity;

            for (int ioverload = 0; ioverload < OverloadCount; ioverload++)
            {
                int iArgCount = argCount + ioverload;
                var overload  = new TexlStrings.StringGetter[iArgCount];
                overload[0] = TexlStrings.SortByColumnsArg1;
                for (int iarg = 1; iarg < iArgCount; iarg += 2)
                {
                    overload[iarg] = TexlStrings.SortByColumnsArg2;

                    if (iarg < iArgCount - 1)
                    {
                        overload[iarg + 1] = TexlStrings.SortByColumnsArg3;
                    }
                }
                overloads.Add(overload);
            }

            return(new ReadOnlyCollection <TexlStrings.StringGetter[]>(overloads));
        }
Beispiel #2
0
 public ExtractDateTimeFunctionBase(string name, TexlStrings.StringGetter description, FunctionCategories fc, DType returnType, BigInteger maskLambdas, int arityMin, int arityMax, params DType[] paramTypes)
     : base(name, description, fc, returnType, maskLambdas, arityMin, arityMax, paramTypes)
 {
     Contracts.Assert(arityMin == 1);
     Contracts.Assert(arityMax == 1);
     Contracts.Assert(paramTypes[0] == DType.DateTime);
 }
Beispiel #3
0
        // Gets the overloads for the AddColumns function for the specified arity.
        private IEnumerable <TexlStrings.StringGetter[]> GetOverloadsAddColumns(int arity)
        {
            Contracts.Assert(4 <= arity);

            const int OverloadCount = 2;

            // REVIEW ragru: cache these and enumerate from the cache...

            var overloads = new List <TexlStrings.StringGetter[]>(OverloadCount);
            // Limit the argCount avoiding potential OOM
            int argCount = arity > SignatureConstraint.RepeatTopLength ? SignatureConstraint.RepeatTopLength : arity;

            for (int ioverload = 0; ioverload < OverloadCount; ioverload++)
            {
                int iArgCount = (argCount | 1) + ioverload * 2;
                var overload  = new TexlStrings.StringGetter[iArgCount];
                overload[0] = TexlStrings.AddColumnsArg1;
                for (int iarg = 1; iarg < iArgCount; iarg += 2)
                {
                    overload[iarg]     = TexlStrings.AddColumnsArg2;
                    overload[iarg + 1] = TexlStrings.AddColumnsArg3;
                }
                overloads.Add(overload);
            }

            return(new ReadOnlyCollection <TexlStrings.StringGetter[]>(overloads));
        }
Beispiel #4
0
        // Gets the overloads for the If function for the specified arity.
        // If is special because it doesn't have a small number of overloads
        // since its max arity is int.MaxSize.
        private IEnumerable <TexlStrings.StringGetter[]> GetOverloadsIf(int arity)
        {
            Contracts.Assert(3 <= arity);

            // REVIEW ragru: What should be the number of overloads for functions like these?
            // Once we decide should we just hardcode the number instead of having the outer loop?
            const int OverloadCount = 3;

            var overloads = new List <TexlStrings.StringGetter[]>(OverloadCount);
            // Limit the argCount avoiding potential OOM
            int argCount = arity > SignatureConstraint.RepeatTopLength ? SignatureConstraint.RepeatTopLength + (arity & 1) : arity;

            for (int ioverload = 0; ioverload < OverloadCount; ioverload++)
            {
                var  signature = new TexlStrings.StringGetter[argCount];
                bool fOdd      = (argCount & 1) != 0;
                int  cargCur   = fOdd ? argCount - 1 : argCount;

                for (int iarg = 0; iarg < cargCur; iarg += 2)
                {
                    signature[iarg]     = TexlStrings.IfArgCond;
                    signature[iarg + 1] = TexlStrings.IfArgTrueValue;
                }

                if (fOdd)
                {
                    signature[cargCur] = TexlStrings.IfArgElseValue;
                }

                argCount++;
                overloads.Add(signature);
            }

            return(new ReadOnlyCollection <TexlStrings.StringGetter[]>(overloads));
        }
Beispiel #5
0
        // Return all signatures for switch function with at most 'arity' parameters.
        public override IEnumerable<TexlStrings.StringGetter[]> GetSignatures(int arity)
        {
            if (arity < 5)
            {
                return base.GetSignatures(arity);
            }

            // Limit the argCount avoiding potential OOM
            int argCount = arity > SignatureConstraint.RepeatTopLength ? SignatureConstraint.RepeatTopLength + (arity & 1 ^ 1) : arity;
            var signature = new TexlStrings.StringGetter[argCount];
            bool fEven = (argCount & 1) == 0;
            int cargCur = fEven ? argCount - 1 : argCount;
            signature[0] = TexlStrings.SwitchExpression;
            for (int iarg = 1; iarg < cargCur; iarg += 2)
            {
                signature[iarg] = TexlStrings.SwitchCaseExpr;
                signature[iarg + 1] = TexlStrings.SwitchCaseArg;
            }

            if (fEven)
                signature[cargCur] = TexlStrings.SwitchDefaultReturn;

            return new ReadOnlyCollection<TexlStrings.StringGetter[]>(new[] { signature });
        }
Beispiel #6
0
 public ClockFunction(string functionInvariantName, TexlStrings.StringGetter functionDescription)
     : base(new DPath().Append(new DName(LanguageConstants.InvariantClockNamespace)), functionInvariantName, functionDescription, FunctionCategories.DateTime, DType.CreateTable(new TypedName(DType.String, new DName("Value"))), 0, 0, 0)
 {
 }
Beispiel #7
0
 public ScalarRoundingFunction(string name, TexlStrings.StringGetter description)
     : base(name, description, FunctionCategories.MathAndStat, DType.Number, 0, 2, 2, DType.Number, DType.Number)
 {
 }
Beispiel #8
0
 public IsBlankFunctionBase(string name, TexlStrings.StringGetter description, FunctionCategories functionCategories, DType returnType, BigInteger maskLambdas, int arityMin, int arityMax)
     : base(name, description, functionCategories, returnType, maskLambdas, arityMin, arityMax)
 {
 }
Beispiel #9
0
 public MathOneArgFunction(string name, TexlStrings.StringGetter description, FunctionCategories fc)
     : base(name, description, fc, DType.Number, 0, 1, 1, DType.Number)
 {
 }
Beispiel #10
0
 public MathOneArgTableFunction(string name, TexlStrings.StringGetter description, FunctionCategories fc)
     : base(name, description, fc, DType.EmptyTable, 0, 1, 1, DType.EmptyTable)
 {
 }
Beispiel #11
0
 public BuiltinFunction(DPath theNamespace, string name, TexlStrings.StringGetter description, FunctionCategories functionCategories, DType returnType, BigInteger maskLambdas, int arityMin, int arityMax, params DType[] paramTypes)
     : this(theNamespace, name, /*localeSpecificName*/ string.Empty, description, functionCategories, returnType, maskLambdas, arityMin, arityMax, paramTypes)
 {
 }
Beispiel #12
0
 public TableRoundingFunction(string name, TexlStrings.StringGetter description)
     : base(name, description, FunctionCategories.Table, DType.EmptyTable, 0, 2, 2)
 {
 }
Beispiel #13
0
 public StringOneArgFunction(string name, TexlStrings.StringGetter description, FunctionCategories functionCategories, DType returnType)
     : base(name, description, functionCategories, returnType, 0, 1, 1, DType.String)
 {
 }
Beispiel #14
0
 protected DateTimeGenericFunction(string name, TexlStrings.StringGetter description, DType returnType)
     : base(name, description, FunctionCategories.DateTime, returnType, 0, 1, 2, DType.String, DType.String)
 {
 }
 public StringTwoArgFunction(string name, TexlStrings.StringGetter description)
     : this(name, description, DType.Boolean)
 {
 }
Beispiel #16
0
 public StatisticalFunction(string name, TexlStrings.StringGetter description, FunctionCategories fc)
     : base(name, description, fc, DType.Number, 0, 1, int.MaxValue, DType.Number)
 {
 }
 public FunctionWithTableInput(string name, TexlStrings.StringGetter description, FunctionCategories fc, DType returnType, BigInteger maskLambdas, int arityMin, int arityMax, params DType[] paramTypes)
     : this(DPath.Root, name, description, fc, returnType, maskLambdas, arityMin, arityMax, paramTypes)
 {
 }
Beispiel #18
0
 public FilterFunctionBase(string name, TexlStrings.StringGetter description, FunctionCategories fc, DType returnType, BigInteger maskLambdas, int arityMin, int arityMax, params DType[] paramTypes)
     : base(name, description, fc, returnType, maskLambdas, arityMin, arityMax, paramTypes)
 {
 }
Beispiel #19
0
 public BuiltinFunction(string name, string localeSpecificName, TexlStrings.StringGetter description, FunctionCategories functionCategories, DType returnType, BigInteger maskLambdas, int arityMin, int arityMax, params DType[] paramTypes)
     : this(DPath.Root, name, localeSpecificName, description, functionCategories, returnType, maskLambdas, arityMin, arityMax, paramTypes)
 {
 }
 public StringTwoArgFunction(string name, TexlStrings.StringGetter description, DType returnType)
     : base(name, description, FunctionCategories.Text, returnType, 0, 2, 2, DType.String, DType.String)
 {
 }
 public StatisticalTableFunction(string name, TexlStrings.StringGetter description, FunctionCategories fc)
     : base(name, description, fc, DType.Number, 0x02, 2, 2, DType.EmptyTable, DType.Number)
 {
     ScopeInfo = new FunctionScopeInfo(this, usesAllFieldsInScope: false, acceptsLiteralPredicates: false);
 }