Esempio n. 1
0
        public SignatureLookupResult TryFindMatch(string name, FunctionTypeSignature typeSignature)
        {
            SignatureLookupResult result = new SignatureLookupResult();
            var checks = GetChecks(typeSignature);

            Dictionary <FunctionTypeSignature, FunctionInfo> userOptions;

            if (_userFunctionsLookup.TryGetOptions(name, out userOptions))
            {
                var searchResult = SignatureSearcher.Search(userOptions, checks, x => x);
                if (searchResult.Success)
                {
                    result.Success      = true;
                    result.Ambiguous    = searchResult.Ambiguous;
                    result.FunctionInfo = searchResult.Value;

                    return(result);
                }
            }

            Dictionary <FunctionTypeSignature, Func <Op> > opOptions;

            if (_functionBindingLookup.TryGetOptions(name, out opOptions))
            {
                var searchResult = SignatureSearcher.Search(opOptions, checks, x => x);
                if (searchResult.Success)
                {
                    result.Success      = true;
                    result.Ambiguous    = searchResult.Ambiguous;
                    result.FunctionInfo = new FunctionInfo(new FunctionSignature(null, null, searchResult.Key), null);
                    result.OpBuilder    = searchResult.Value;

                    return(result);
                }
            }

            Dictionary <FunctionTypeSignature, BuiltInFunction> builtinOptions;

            if (_builtinFunctionsLookup.TryGetOptions(name, out builtinOptions))
            {
                var searchResult = SignatureSearcher.Search(builtinOptions, checks, x => x);
                if (searchResult.Success)
                {
                    result.Success         = true;
                    result.Ambiguous       = searchResult.Ambiguous;
                    result.FunctionInfo    = searchResult.Value.Info;
                    result.BuiltInFunction = searchResult.Value;

                    return(result);
                }
            }

            return(result);
        }
Esempio n. 2
0
        public SignatureLookupResult TryFindMatch(ConversionTypeSignature signature)
        {
            SignatureLookupResult result = new SignatureLookupResult();

            if (_conversionBindingLookup.TryGetValue(signature, out Func <Op> value))
            {
                result.Success   = true;
                result.OpBuilder = value;
            }
            else if (_builtinConversionLookup.TryGetValue(signature, out BuiltInFunction builtIn))
            {
                result.Success         = true;
                result.BuiltInFunction = builtIn;
                result.FunctionInfo    = builtIn.Info;
            }

            return(result);
        }
Esempio n. 3
0
        public SignatureLookupResult TryFindMatch(string name, OperatorTypeSignature typeSignature)
        {
            SignatureLookupResult result = new SignatureLookupResult();
            var checks = GetChecks(typeSignature);

            Dictionary <OperatorTypeSignature, Func <Op> > opOptions;

            if (_operatorBindingLookup.TryGetOptions(name, out opOptions))
            {
                var searchResult = SignatureSearcher.Search(opOptions, checks, x => x);
                if (searchResult.Success)
                {
                    result.Success   = true;
                    result.Ambiguous = searchResult.Ambiguous;
                    result.OpBuilder = searchResult.Value;

                    return(result);
                }
            }

            Dictionary <OperatorTypeSignature, BuiltInFunction> builtinOptions;

            if (_builtInOperatorLookup.TryGetOptions(name, out builtinOptions))
            {
                var searchResult = SignatureSearcher.Search(builtinOptions, checks, x => x);
                if (searchResult.Success)
                {
                    result.Success         = true;
                    result.Ambiguous       = searchResult.Ambiguous;
                    result.FunctionInfo    = searchResult.Value.Info;
                    result.BuiltInFunction = searchResult.Value;

                    return(result);
                }
            }

            return(result);
        }