예제 #1
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);
            rand0TypeHistogram.Note(this.rand0Type);
            rand1TypeHistogram.Note(this.rand1Type);
            SCode.location = "StaticLet2";
#endif
            object      ev1;
            Environment env  = environment;
            Control     unev = this.rand1;
            while (unev.EvalStep(out ev1, ref unev, ref env))
            {
            }
            ;
#if DEBUG
            SCode.location = "StaticLet2";
#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 = "StaticLet2";
#endif
            if (ev0 == Interpreter.UnwindStack)
            {
                ((UnwinderState)env).AddFrame(new Combination2Frame1(this, environment, ev1));
                environment = env;
                answer      = Interpreter.UnwindStack;
                return(false);
            }

            object [] cells = environment.GetValueCells(this.lambda.StaticMapping);
#if DEBUG
            SCode.location = "StaticLet2";
#endif
            // StaticClosure cl = new StaticClosure ((StaticLambda) this.rator, environment);
            StaticClosure cl = new StaticClosure(this.lambda, environment.BaseEnvironment, cells);

            expression  = this.body;
            environment = new StaticEnvironment(cl, new object [] { ev0, ev1 });
            answer      = null;
            return(true);
        }
예제 #2
0
        public override bool Continue(out object answer, ref Control expression, ref Environment environment, object value)
        {
            StaticClosure cl = new StaticClosure(this.expression.lambda, environment.BaseEnvironment, environment.GetValueCells(this.expression.staticMapping));

            expression  = this.expression.body;
            environment = new StaticEnvironment(cl, new object [] { value });
            answer      = null;
            return(true);
        }
예제 #3
0
        public override bool EvalStep(out object answer, ref Control expression, ref Environment environment)
        {
#if DEBUG
            Warm("-");
            NoteCalls(this.body);
            bodyTypeHistogram.Note(this.bodyType);
            SCode.location = "StaticLet1Q";
#endif
            // StaticClosure cl = new StaticClosure ((StaticLambda) this.rator, environment);
            object [] valueCells = environment.GetValueCells(this.lambda.StaticMapping);
#if DEBUG
            SCode.location = "StaticLet1Q";
#endif
            StaticClosure cl = new StaticClosure(this.lambda, environment.BaseEnvironment, valueCells);

            expression  = this.body;
            environment = new StaticEnvironment(cl, new object [] { this.rand0Value });
            answer      = null;
            return(true);
        }