コード例 #1
0
ファイル: Lambda.cs プロジェクト: NotJRM/jrm-code-project
        public override bool EvalStep(out object answer, ref Control expression, ref Environment environment)
        {
            #if DEBUG
            Warm ("SimpleLambda");
            if (this.staticMapping == null)
                throw new NotImplementedException("Static mapping should not be null.");
            #endif
            this.closeCount += 1;
            object [] cells = environment.GetValueCells (this.staticMapping);
            #if DEBUG
            SCode.location = "SimpleLambda";
            #endif
            // Use the base environment for lookup.
            answer = new SimpleClosure (this, environment.BaseEnvironment, cells);

            return false;
        }
コード例 #2
0
ファイル: Let2.cs プロジェクト: NotJRM/jrm-code-project
        public override bool EvalStep(out object answer, ref Control expression, ref Environment environment)
        {
            #if DEBUG
            Warm ("-");
            NoteCalls (this.rator);
            SCode.location = "StaticLet2QQ";
            #endif
            object ev1 = this.rand1Value;
            object ev0 = this.rand0Value;

            object [] cells = environment.GetValueCells (this.lambda.StaticMapping);
            #if DEBUG
            SCode.location = "StaticLet2QQ";
            #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;
        }
コード例 #3
0
ファイル: Lambda.cs プロジェクト: NotJRM/jrm-code-project
 public override bool EvalStep(out object answer, ref Control expression, ref Environment environment)
 {
     #if DEBUG
     Warm ("StaticLambda");
     #endif
     this.closeCount += 1;
     object [] cells = environment.GetValueCells (this.staticMapping);
     #if DEBUG
     SCode.location = "StaticLambda";
     #endif
     answer = new StaticClosure (this, environment.BaseEnvironment, cells);
     return false;
 }
コード例 #4
0
ファイル: Let2.cs プロジェクト: NotJRM/jrm-code-project
        public override bool EvalStep(out object answer, ref Control expression, ref Environment environment)
        {
            #if DEBUG
            Warm ("-");
            NoteCalls (this.rator);
            NoteCalls (this.rand1);
            rand1TypeHistogram.Note (this.rand1Type);
            SCode.location = "StaticLet2Q";
            #endif
            object ev1;
            Environment env = environment;
            Control unev = this.rand1;
            while (unev.EvalStep (out ev1, ref unev, ref env)) { };
            #if DEBUG
            SCode.location = "StaticLet2Q";
            #endif
            if (ev1 == Interpreter.UnwindStack) {
                ((UnwinderState) env).AddFrame (new Combination2Frame0 (this, environment));
                environment = env;
                answer = Interpreter.UnwindStack;
                return false;
            }

            object ev0 = this.rand0Value;

            object [] cells = environment.GetValueCells (this.lambda.StaticMapping);
            #if DEBUG
            SCode.location = "StaticLet2Q";
            #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;
        }