예제 #1
0
        private bool TryResolveOwnShortMethod(BRAQParser.Short_callContext context, out OwnMethodInfo ownMethodInfo)
        {
            IToken name = context.calee;

            //найдём аргумент
            List <Type> args;
            Type        argument_type;

            argument_type = context.arg.Accept(this);

            args = new List <Type>(new[] { argument_type });

            try
            {
                var handle = user_functions
                             .First(x => x.name == name.Text &&
                                    x.arguments.Count == args.Count &&
                                    x.arguments.Select(r => r.b).Zip(args, (r, w) => new Pair <Type, Type>(r, w))
                                    .All(rec => rec.a == rec.b)
                                    );
                ownMethodInfo = handle;

                return(true);
            }
            catch (InvalidOperationException)
            {
                ownMethodInfo = null;
                return(false);
            }
        }
예제 #2
0
        private bool TryResolveOwnMethod(BRAQParser.CallContext context, out OwnMethodInfo ownMethodInfo)
        {
            IToken      name = context.calee;
            List <Type> args = context.expr().Select(x => type_dict[x]).ToList();

            try
            {
                var handle = user_functions
                             .First(x => x.name == name.Text &&
                                    x.arguments.Count == args.Count &&
                                    x.arguments.Select(r => r.b).Zip(args, (r, w) => new Pair <Type, Type>(r, w))
                                    .All(rec => rec.a == rec.b)
                                    );
                ownMethodInfo = handle;

                return(true);
            }
            catch (InvalidOperationException)
            {
                ownMethodInfo = null;
                return(false);
            }
        }