Exemple #1
0
        public static IToken Acquire(IToken arg0, IToken arg1, IToken arg2 = null)
        {
            var key = Tuple.Create(arg0, arg1, arg2);

            if (Cache.TryGetValue(key, out var cached))
            {
                return(cached);
            }

            IToken x;

            if (arg1 == null)
            {
                x = new ConsOperator(arg0, arg1);
            }
            else if (arg2 == null)
            {
                var a0 = AlienMessageParser.Reduce(arg0);
                var a1 = AlienMessageParser.Reduce(arg1);
                x = new ConsOperator(a0, a1);
            }
            else
            {
                x = ApOperator.Acquire(ApOperator.Acquire(arg2, arg0), arg1);
            }

            Cache[key] = x;
            return(x);
        }
Exemple #2
0
        public static IToken Acquire(IToken arg0, IToken arg1)
        {
            var key = Tuple.Create(arg0, arg1);

            if (Cache.TryGetValue(key, out var cached))
            {
                return(cached);
            }

            var x = new ApOperator(arg0, arg1);

            Cache[key] = x;
            return(x);
        }
Exemple #3
0
        private static IToken Acquire(IToken arg0, IToken arg1, IToken arg2)
        {
            var key = Tuple.Create(arg0, arg1, arg2);

            if (Cache.TryGetValue(key, out var cached))
            {
                return(cached);
            }

            IToken x;

            if (arg2 == null)
            {
                x = new CComb(arg0, arg1);
            }
            else
            {
                x = AlienMessageParser.Reduce(ApOperator.Acquire(ApOperator.Acquire(arg0, arg2), arg1));
            }

            Cache[key] = x;
            return(x);
        }