Beispiel #1
0
        public override bool Continue(out object answer, ref Control expression, ref Environment environment, object ev1)
        {
            object      ev0;
            Environment env    = environment;
            Control     unevop = this.expression.Components [1];

            while (unevop.EvalStep(out ev0, ref unevop, ref env))
            {
            }
            ;
#if DEBUG
            SCode.location = "Combination3";
#endif
            if (ev0 == Interpreter.UnwindStack)
            {
                throw new NotImplementedException();
            }

            object evop;
            env    = environment;
            unevop = this.expression.Operator;
            while (unevop.EvalStep(out evop, ref unevop, ref env))
            {
            }
            ;
#if DEBUG
            SCode.location = "Combination3";
#endif
            if (evop == Interpreter.UnwindStack)
            {
                throw new NotImplementedException();
            }

            return(Interpreter.Call(out answer, ref expression, ref environment, evop, ev0, ev1, this.ev2));
        }
Beispiel #2
0
        public bool Call(out object answer, ref Control expression, ref Environment environment)
        {
#if DEBUG
            Entity.applicationCount += 1;
#endif
            return(Interpreter.Call(out answer, ref expression, ref environment, this.first, this));
        }
Beispiel #3
0
        public override bool EvalStep(out object answer, ref Control expression, ref Environment environment)
        {
#if DEBUG
            Warm("Combination0A0");
#endif
            return(Interpreter.Call(out answer, ref expression, ref environment, environment.Argument0Value));
        }
Beispiel #4
0
        public bool Call(out object answer, ref Control expression, ref Environment environment, object arg0, object arg1, object arg2)
        {
#if DEBUG
            Entity.applicationCount += 1;
            SCode.location           = "Entity.Call3";
#endif
            return(Interpreter.Call(out answer, ref expression, ref environment, this.first, this, arg0, arg1, arg2));
        }
Beispiel #5
0
        public override bool EvalStep(out object answer, ref Control expression, ref Environment environment)
        {
#if DEBUG
            Warm("Combination0S");
#endif
            object evop;
            if (environment.StaticValue(out evop, this.ratorName, this.ratorOffset))
            {
                throw new NotImplementedException();
            }

            return(Interpreter.Call(out answer, ref expression, ref environment, evop));
        }
Beispiel #6
0
        public override bool Continue(out object answer, ref Control expression, ref Environment environment, object value)
        {
            object      evop   = null;
            Control     unevop = this.expression.Operator;
            Environment env    = this.environment;

            while (unevop.EvalStep(out evop, ref unevop, ref env))
            {
            }
            ;
            if (evop == Interpreter.UnwindStack)
            {
                throw new NotImplementedException();
            }

            return(Interpreter.Call(out answer, ref expression, ref environment, evop, value));
        }
Beispiel #7
0
        public override bool EvalStep(out object answer, ref Control expression, ref Environment environment)
        {
#if DEBUG
            Warm("Combination0");
            NoteCalls(this.rator);
#endif
            object      evop   = null;
            Control     unevop = this.rator;
            Environment env    = environment;
            while (unevop.EvalStep(out evop, ref unevop, ref env))
            {
            }
            ;
            if (evop == Interpreter.UnwindStack)
            {
                ((UnwinderState)env).AddFrame(new Combination0Frame0(this, environment));
                answer      = Interpreter.UnwindStack;
                environment = env;
                return(false);
            }

            return(Interpreter.Call(out answer, ref expression, ref environment, evop));
        }
Beispiel #8
0
        public override bool EvalStep(out object answer, ref Control expression, ref Environment environment)
        {
#if DEBUG
            Warm("-");
            NoteCalls(this.components [0]);
            NoteCalls(this.components [1]);
            NoteCalls(this.components [2]);
            NoteCalls(this.components [3]);
            c0TypeHistogram.Note(this.c0Type);
            c1TypeHistogram.Note(this.c1Type);
            c2TypeHistogram.Note(this.c2Type);
            c3TypeHistogram.Note(this.c3Type);
            SCode.location = "Combination3";
#endif
            object      ev2;
            Environment env  = environment;
            Control     unev = this.components [3];
            while (unev.EvalStep(out ev2, ref unev, ref env))
            {
            }
            ;
#if DEBUG
            SCode.location = "Combination3";
#endif
            if (ev2 == Interpreter.UnwindStack)
            {
                ((UnwinderState)env).AddFrame(new Combination3Frame0(this, environment));
                environment = env;
                answer      = Interpreter.UnwindStack;
                return(false);
            }

            object ev1;
            env  = environment;
            unev = this.components [2];
            while (unev.EvalStep(out ev1, ref unev, ref env))
            {
            }
            ;
#if DEBUG
            SCode.location = "Combination3";
#endif
            if (ev1 == Interpreter.UnwindStack)
            {
                ((UnwinderState)env).AddFrame(new Combination3Frame1(this, environment, ev2));
                environment = env;
                answer      = Interpreter.UnwindStack;
                return(false);
            }

            object ev0;
            env  = environment;
            unev = this.components [1];
            while (unev.EvalStep(out ev0, ref unev, ref env))
            {
            }
            ;
#if DEBUG
            SCode.location = "Combination3";
#endif
            if (ev0 == Interpreter.UnwindStack)
            {
                ((UnwinderState)env).AddFrame(new Combination3Frame2(this, environment, ev1, ev2));
                environment = env;
                answer      = Interpreter.UnwindStack;
                return(false);
            }

            object evop;
            env  = environment;
            unev = this.components [0];
            while (unev.EvalStep(out evop, ref unev, ref env))
            {
            }
            ;
#if DEBUG
            SCode.location = "Combination3";
#endif
            if (evop == Interpreter.UnwindStack)
            {
                throw new NotImplementedException();
                //((UnwinderState) env).AddFrame (new Combination3Frame3 (this, environment, ev0, ev1, ev2));
                //environment = env;
                //answer = Interpreter.UnwindStack;
                //return false;
            }

            return(Interpreter.Call(out answer, ref expression, ref environment, evop, ev0, ev1, ev2));
        }
Beispiel #9
0
 public override bool Continue(out object answer, ref Control expression, ref Environment environment, object value)
 {
     return(Interpreter.Call(out answer, ref expression, ref environment, value, this.ev0, this.ev1, this.ev2));
 }
Beispiel #10
0
        public override bool EvalStep(out object answer, ref Control expression, ref Environment environment)
        {
#if DEBUG
            Warm("-");
            NoteCalls(this.rator);
            NoteCalls(this.rand0);
            NoteCalls(this.rand1);
            ratorTypeHistogram.Note(this.ratorType);
            rand0TypeHistogram.Note(this.rand0Type);
            rand1TypeHistogram.Note(this.rand1Type);
            SCode.location = "Let2";
#endif
            object      ev1;
            Environment env  = environment;
            Control     unev = this.rand1;
            while (unev.EvalStep(out ev1, ref unev, ref env))
            {
            }
            ;
#if DEBUG
            SCode.location = "Let2";
#endif
            if (ev1 == Interpreter.UnwindStack)
            {
                ((UnwinderState)env).AddFrame(new Combination2Frame0(this, environment));
                environment = env;
                answer      = Interpreter.UnwindStack;
                return(false);
            }

            object ev0;
            env  = environment;
            unev = this.rand0;
            while (unev.EvalStep(out ev0, ref unev, ref env))
            {
            }
            ;
#if DEBUG
            SCode.location = "Let2";
#endif
            if (ev0 == Interpreter.UnwindStack)
            {
                ((UnwinderState)env).AddFrame(new Combination2Frame1(this, environment, ev1));
                environment = env;
                answer      = Interpreter.UnwindStack;
                return(false);
            }

            object evop;
            env  = environment;
            unev = this.rator;
            while (unev.EvalStep(out evop, ref unev, ref env))
            {
            }
            ;
#if DEBUG
            SCode.location = "Let2";
#endif
            if (evop == Interpreter.UnwindStack)
            {
                ((UnwinderState)env).AddFrame(new Combination2Frame2(this, environment, ev0, ev1));
                environment = env;
                answer      = Interpreter.UnwindStack;
                return(false);
            }

            return(Interpreter.Call(out answer, ref expression, ref environment, evop, ev0, ev1));
        }
Beispiel #11
0
        public override bool EvalStep(out object answer, ref Control expression, ref Environment environment)
        {
#if DEBUG
            Warm("-");
            histogram.Note(this.histogramKey);
            combinationSizeHistogram.Note(this.components.Length);
            SCode.location = "Combination";
#endif
            object    rator     = null;
            object [] evaluated = new object [this.components.Length - 1];
            int       counter   = this.components.Length - 1;
            while (counter > -1)
            {
                object      ev;
                Environment env  = environment;
                Control     expr = components [counter];
#if DEBUG
                NoteCalls((SCode)expr);
#endif
                while (expr.EvalStep(out ev, ref expr, ref env))
                {
                }
                ;
#if DEBUG
                SCode.location = "Combination";
#endif
                if (ev == Interpreter.UnwindStack)
                {
                    ((UnwinderState)env).AddFrame(new CombinationFrame(this, environment, evaluated, counter));
                    environment = env;
                    answer      = Interpreter.UnwindStack;
                    return(false);
                }
                if (counter == 0)
                {
                    rator = ev;
                    break;
                }
                else
                {
                    evaluated [--counter] = ev;
                }
            }
            switch (evaluated.Length)
            {
            case 0:
                return(Interpreter.Call(out answer, ref expression, ref environment, rator));

            case 1:
                Debugger.Break();
                return(Interpreter.Call(out answer, ref expression, ref environment, rator, evaluated [0]));

            case 2:
                Debugger.Break();
                return(Interpreter.Call(out answer, ref expression, ref environment, rator, evaluated [0], evaluated [1]));

            case 3:
                return(Interpreter.Call(out answer, ref expression, ref environment, rator, evaluated [0], evaluated [1], evaluated [2]));

            default:
                return(Interpreter.Apply(out answer, ref expression, ref environment, rator, evaluated));
            }
        }