Exemple #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);
        }
Exemple #2
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);
        }