コード例 #1
0
ファイル: PCond2e.cs プロジェクト: NotJRM/jrm-code-project
        public override bool EvalStep(out object answer, ref Control expression, ref Environment environment)
        {
            #if DEBUG
            Warm ("PCond2A.EvalStep");
            #endif
            object ev1;
            Control unev = this.rand1;
            Environment env = environment;
            while (unev.EvalStep (out ev1, ref unev, ref env)) { };
            if (ev1 == Interpreter.UnwindStack) {
                throw new NotImplementedException();
            }

            #if DEBUG
            Primitive.hotPrimitives.Note (this.procedure);
            #endif
            if (this.method (out answer, environment.ArgumentValue (this.rand0Offset), ev1)) {
                TailCallInterpreter tci = answer as TailCallInterpreter;
                if (tci != null) {
                    answer = null; // dispose of the evidence
                    // set up the interpreter for a tail call
                    Control cExpression = tci.Expression;
                    Environment cEnvironment = tci.Environment;
                    while (cExpression.EvalStep (out answer, ref cExpression, ref cEnvironment)) { };
                }
            }

            if ((answer is bool) && (bool) answer == false) {
            #if DEBUG
                noteCalls (this.alternative);
            #endif
                expression = this.alternative;
                return true;
            }
            else {
            #if DEBUG
                noteCalls (this.consequent);
            #endif
                expression = this.consequent;
                return true;
            }
        }
コード例 #2
0
 public override bool EvalStep(out object answer, ref Control expression, ref Environment environment)
 {
     #if DEBUG
     Warm ("PCondIsFixnumA1AQ.EvalStep");
     #endif
     if ((int) environment.Argument1Value == (int) environment.ArgumentValue (this.rand1Offset)) {
         answer = this.consequentValue;
         return false;
     }
     else {
     #if DEBUG
         noteCalls (this.alternative);
         alternativeTypeHistogram.Note (this.alternativeType);
     #endif
         expression = this.alternative;
         answer = null;
         return true;
     }
 }
コード例 #3
0
 public override bool EvalStep(out object answer, ref Control expression, ref Environment environment)
 {
     #if DEBUG
     Warm ("PCondIsNullAS");
     #endif
     if (environment.ArgumentValue(this.predicateArgumentOffset) == null) {
         if (environment.StaticValue (out answer, this.consequentName, this.consequentOffset))
             throw new NotImplementedException ();
         return false;
     }
     else {
     #if DEBUG
         SCode.location = "-";
         NoteCalls (this.alternative);
         alternativeTypeHistogram.Note (this.alternativeType);
         SCode.location = "PCondIsNullAS";
     #endif
         expression = this.alternative;
         answer = null; // keep c# compiler happy
         return true;
     }
 }
コード例 #4
0
        public override bool EvalStep(out object answer, ref Control expression, ref Environment environment)
        {
            #if DEBUG
            Warm ("-");
            NoteCalls (this.arg1);
            NoteCalls (this.arg2);
            rand1TypeHistogram.Note (this.rand1Type);
            rand2TypeHistogram.Note (this.rand2Type);
            SCode.location = "PrimitiveStringSetA";
            #endif
            object ev2;
            Environment env = environment;
            Control unev = this.arg2;
            while (unev.EvalStep (out ev2, ref unev, ref env)) { };
            #if DEBUG
            SCode.location = "PrimitiveStringSetA";
            #endif
            if (ev2 == Interpreter.UnwindStack) {
                ((UnwinderState) env).AddFrame (new PrimitiveCombination3Frame0 (this, environment));
                answer = Interpreter.UnwindStack;
                environment = env;
                return false;
            }

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

            object ev0 = environment.ArgumentValue (this.rand0Offset);
            answer = ((char []) ev0) [(int) ev1];
            ((char []) ev0) [(int) ev1] = (char) ev2;
            return false;
        }
コード例 #5
0
        public override bool EvalStep(out object answer, ref Control expression, ref Environment environment)
        {
            #region EvalStepBody
            #if DEBUG
            Warm ();

            #endif
            object ev0 = environment.ArgumentValue (this.predicateOffset);

            if (!(ev0 is Symbol)) {
            #if DEBUG
                noteCalls (this.alternative);

            #endif
                expression = this.alternative;
                answer = null;
                return true;
            }
            else {
                if (environment.FastLexicalRef (out answer, this.consequentName, this.consequentDepth, this.consequentOffset))
                    throw new NotImplementedException ();
                return false;
            }
            #endregion
        }
コード例 #6
0
 public override bool EvalStep(out object answer, ref Control expression, ref Environment environment)
 {
     #if DEBUG
     Warm ("PCondIsObjectEqAQQx.EvalStep");
     #endif
     object arg = environment.ArgumentValue (this.rand0Offset);
     answer = (arg == this.rand1Value) ? consequentValue : arg;
     return false;
 }
コード例 #7
0
 public override bool EvalStep(out object answer, ref Control expression, ref Environment environment)
 {
     #if DEBUG
     Warm ("-");
     SCode.location = "PCondIsObjectEqQA";
     #endif
     if (this.rand0Value == environment.ArgumentValue(this.rand1Offset)) {
     #if DEBUG
         noteCalls (this.consequent);
         consequentTypeHistogram.Note (this.consequentType);
     #endif
         expression = this.consequent;
         answer = null;
         return true;
     }
     else {
     #if DEBUG
         noteCalls (this.alternative);
         alternativeTypeHistogram.Note (this.alternativeType);
     #endif
         expression = this.alternative;
         answer = null;
         return true;
     }
 }
コード例 #8
0
        public override bool EvalStep(out object answer, ref Control expression, ref Environment environment)
        {
            #if DEBUG
            Warm ("PCondIsObjectEqAQSx.EvalStep");
            #endif
            object arg = environment.ArgumentValue (this.rand0Offset);

            if (arg == this.rand1Value) {
            #if DEBUG
                noteCalls (this.consequent);
                consequentTypeHistogram.Note (this.consequentType);
            #endif
                expression = this.consequent;
                answer = null;
                return true;
            }
            else {
                answer = arg;
                return false;
            }
        }
コード例 #9
0
ファイル: PCond2f.cs プロジェクト: NotJRM/jrm-code-project
        public override bool EvalStep(out object answer, ref Control expression, ref Environment environment)
        {
            #if DEBUG
            Warm ("-");
            SCode.location = "PCond2A0L1L1A.EvalStep";
            #endif
            object ev1;
            if (environment.FastLexicalRef1 (out ev1, this.rand1Name, this.rand1Offset))
                throw new NotImplementedException ();

            #if DEBUG
            Primitive.hotPrimitives.Note (this.procedure);
            #endif
            if (this.method (out answer, environment.Argument0Value, ev1)) {
                TailCallInterpreter tci = answer as TailCallInterpreter;
                if (tci != null) {
                    answer = null; // dispose of the evidence
                    // set up the interpreter for a tail call
                    Control cExpression = tci.Expression;
                    Environment cEnvironment = tci.Environment;
                    while (cExpression.EvalStep (out answer, ref cExpression, ref cEnvironment)) { };
                }
            }

            if ((answer is bool) && (bool) answer == false) {
                answer = environment.ArgumentValue(this.alternativeOffset);
                return false;
            }
            else {
                if (environment.FastLexicalRef1 (out answer, this.consequentName, this.consequentOffset))
                    throw new NotImplementedException ();
                return false;
            }
        }
コード例 #10
0
ファイル: PCond2f.cs プロジェクト: NotJRM/jrm-code-project
        public override bool EvalStep(out object answer, ref Control expression, ref Environment environment)
        {
            #if DEBUG
            Warm ("-");
            SCode.location = "PCond2A0ASQ.EvalStep";
            Primitive.hotPrimitives.Note (this.procedure);
            #endif
            if (this.method (out answer, environment.Argument0Value, environment.ArgumentValue (this.rand1Offset))) {
                TailCallInterpreter tci = answer as TailCallInterpreter;
                if (tci != null) {
                    answer = null; // dispose of the evidence
                    // set up the interpreter for a tail call
                    Control cExpression = tci.Expression;
                    Environment cEnvironment = tci.Environment;
                    while (cExpression.EvalStep (out answer, ref cExpression, ref cEnvironment)) { };
                }
            }

            if ((answer is bool) && (bool) answer == false) {
                answer = this.alternativeValue;
                return false;
            }
            else {
            #if DEBUG
                noteCalls (this.consequent);
            #endif
                expression = this.consequent;
                return true;
            }
        }
コード例 #11
0
 public override bool EvalStep(out object answer, ref Control expression, ref Environment environment)
 {
     #if DEBUG
     Warm ("PrimitiveIsObjectEqAQ.EvalStep");
     #endif
     answer = (environment.ArgumentValue(this.rand0Offset) == this.rand1Value) ? Constant.sharpT : Constant.sharpF;
     return false;
 }
コード例 #12
0
ファイル: PCond1.cs プロジェクト: NotJRM/jrm-code-project
        public override bool EvalStep(out object answer, ref Control expression, ref Environment environment)
        {
            #if DEBUG
            Warm ("-");
            procedureHistogram.Note (this.procedure);
            SCode.location = "PCond1A0XA";
            #endif
            object ev0 = environment.Argument0Value;

            #if DEBUG
            SCode.location = this.procedure.Name.ToString();
            Primitive.hotPrimitives.Note(this.procedure);
            #endif
            // It is expensive to bounce down to invoke the procedure
            // we invoke it directly and pass along the ref args.
            if (this.method (out answer, ev0)) {
                TailCallInterpreter tci = answer as TailCallInterpreter;
                if (tci != null) {
                    answer = null; // dispose of the evidence
                    // set up the interpreter for a tail call
                    Control cExpression = tci.Expression;
                    Environment cEnvironment = tci.Environment;
                    while (cExpression.EvalStep (out answer, ref cExpression, ref cEnvironment)) { };
                }
            }
            #if DEBUG
            SCode.location = "PCond1A0XA";
            #endif

            if ((answer is bool) && (bool) answer == false) {
                answer = environment.ArgumentValue (this.alternativeOffset);
                return false;
            }
            else {
            #if DEBUG
                SCode.location = "-";
                NoteCalls (this.consequent);
                consequentTypeHistogram.Note (this.consequentType);
                SCode.location = "PCond1A0XA";
            #endif
                expression = this.consequent;
                return true;
            }
        }
コード例 #13
0
ファイル: PCond1.cs プロジェクト: NotJRM/jrm-code-project
        public override bool EvalStep(out object answer, ref Control expression, ref Environment environment)
        {
            #if DEBUG
            Warm ("-");
            NoteCalls (this.arg0);
            procedureHistogram.Note (this.procedure);
            arg0TypeHistogram.Note (this.arg0Type);
            SCode.location = "PCond1XXA";
            #endif
            Control unev0 = this.arg0;
            Environment env = environment;
            object ev0;
            while (unev0.EvalStep (out ev0, ref unev0, ref env)) { };
            #if DEBUG
            SCode.location = "PCond1XXA";
            #endif
            if (ev0 == Interpreter.UnwindStack) {
                throw new NotImplementedException ();
                //((UnwinderState) env).AddFrame (new PrimitiveCombination1Frame0 (this, closureEnvironment));
                //answer = Interpreter.Unwind;
                //closureEnvironment = env;
                //return false;
            }

            #if DEBUG
            SCode.location = this.procedure.Name.ToString();
            Primitive.hotPrimitives.Note(this.procedure);
            #endif
            // It is expensive to bounce down to invoke the procedure
            // we invoke it directly and pass along the ref args.
            if (this.method (out answer, ev0)) {
                TailCallInterpreter tci = answer as TailCallInterpreter;
                if (tci != null) {
                    answer = null; // dispose of the evidence
                    // set up the interpreter for a tail call
                    Control cExpression = tci.Expression;
                    Environment cEnvironment = tci.Environment;
                    while (cExpression.EvalStep (out answer, ref cExpression, ref cEnvironment)) { };
                }
            }
            #if DEBUG
            SCode.location = "PCond1XXA";
            #endif
            if ((answer is bool) && (bool) answer == false) {
                answer = environment.ArgumentValue (this.alternativeOffset);
                return false;
            }
            else {
            #if DEBUG
                SCode.location = "-";
                NoteCalls (this.consequent);
                consequentTypeHistogram.Note (this.consequentType);
                SCode.location = "PCond1XXA";
            #endif
                expression = this.consequent;
                return true;
            }
        }
コード例 #14
0
ファイル: PCond2g.cs プロジェクト: NotJRM/jrm-code-project
        public override bool EvalStep(out object answer, ref Control expression, ref Environment environment)
        {
            #if DEBUG
            Warm ("-");
            SCode.location = "PCond2A1QQQ.EvalStep";
            Primitive.hotPrimitives.Note (this.procedure);
            SCode.location = this.procedure.Name.ToString();
            #endif
            object predValue;

            if (this.method (out predValue, environment.ArgumentValue (this.rand0Offset), this.rand1Value)) {
                TailCallInterpreter tci = predValue as TailCallInterpreter;
                if (tci != null) {
                    answer = null;
                    expression = tci.Expression;
                    environment = tci.Environment;
                    return true;
                }
                else
                    throw new NotImplementedException ();
            }

            if (predValue is bool && (bool) predValue == false) {
                answer = this.alternativeValue;
                return false;
            }
            else {
            #if DEBUG
                noteCalls (this.consequent);
            #endif
                expression = this.consequent;
                answer = null;
                return true;
            }
        }
コード例 #15
0
        public override bool EvalStep(out object answer, ref Control expression, ref Environment environment)
        {
            #if DEBUG
            Warm ("PCondIsFixnumEqualAL");
            #endif
            object ev1;
            if (environment.FastLexicalRef (out ev1, this.rand1Name, this.rand1Depth, this.rand1Offset))
                throw new NotImplementedException ();

            object ev0 = environment.ArgumentValue (this.rand0Offset);

            if ((int) ev0 == (int) ev1) {
            #if DEBUG
                noteCalls (this.consequent);
                consequentTypeHistogram.Note (this.consequentType);
            #endif
                expression = this.consequent;
                answer = null;
                return true;
            }
            else {
            #if DEBUG
                noteCalls (this.alternative);
                alternativeTypeHistogram.Note (this.alternativeType);
            #endif
                expression = this.alternative;
                answer = null;
                return true;
            }
        }
コード例 #16
0
        public override bool EvalStep(out object answer, ref Control expression, ref Environment environment)
        {
            #if DEBUG
            Warm ("PrimitivePlusFixnumAQ.EvalStep");
            #endif
            // Eval argument1
            int ev1 = this.rand1Value;

            // Eval argument0
            object ev0 = environment.ArgumentValue(this.rand0Offset);

            // Compute answer
            answer = (int) ev0 + ev1;
            return false;
        }
コード例 #17
0
        public override bool EvalStep(out object answer, ref Control expression, ref Environment environment)
        {
            #if DEBUG
            Warm ("-");
            noteCalls (this.rand1);
            SCode.location = "PrimitivePlusFixnumA.EvalStep";
            #endif
            // Eval argument1
            object ev1;

            Control unev = this.rand1;
            Environment env = environment;
            while (unev.EvalStep (out ev1, ref unev, ref env)) { };
            #if DEBUG
                        SCode.location = "PrimitivePlusFixnumA.EvalStep.1";
            #endif
            if (ev1 == Interpreter.UnwindStack) {
                throw new NotImplementedException ();
                //((UnwinderState) env).AddFrame (new PrimitiveCombination2Frame0 (this, environment));
                //answer = Interpreter.UnwindStack;
                //environment = env;
                //return false;
            }

            // Eval argument0
            object ev0 = environment.ArgumentValue (this.rand0Offset);

            // Compute answer
            answer = (int) ev0 + (int) ev1;
            return false;
        }
コード例 #18
0
 public override bool EvalStep(out object answer, ref Control expression, ref Environment environment)
 {
     #if DEBUG
     Warm ("PrimitiveIsFixnumEqualAL.EvalStep");
     #endif
     object ev1;
     if (environment.FastLexicalRef (out ev1, this.rand1Name, this.rand1Depth, this.rand1Offset))
         throw new NotImplementedException ();
     object ev0 = environment.ArgumentValue (this.rand0Offset);
     answer = ((int) ev0 == (int) ev1) ? Constant.sharpT : Constant.sharpF;
     return false;
 }
コード例 #19
0
        public override bool EvalStep(out object answer, ref Control expression, ref Environment environment)
        {
            #if DEBUG
            Warm ("-");
            noteCalls (this.rand1);
            rand1TypeHistogram.Note (this.rand1Type);
            SCode.location = "PCondIsObjectEqA";
            #endif
            Control unev = this.rand1;
            Environment env = environment;
            object ev1;
            while (unev.EvalStep (out ev1, ref unev, ref env)) { };
            if (ev1 == Interpreter.UnwindStack) {
                throw new NotImplementedException ();
            }

            object ev0 = environment.ArgumentValue (this.rand0Offset);

            if (ev0 == ev1) {
            #if DEBUG
                noteCalls (this.consequent);
                consequentTypeHistogram.Note (this.consequentType);
            #endif
                expression = this.consequent;
                answer = null;
                return true;
            }
            else {
            #if DEBUG
                noteCalls (this.alternative);
                alternativeTypeHistogram.Note (this.alternativeType);
            #endif
                expression = this.alternative;
                answer = null;
                return true;
            }
        }
コード例 #20
0
        public override bool EvalStep(out object answer, ref Control expression, ref Environment environment)
        {
            #if DEBUG
            Warm ();
            #endif
            // Eval argument1
            int ev1 = this.rand1Value;

            // Eval argument0
            object ev0 = environment.ArgumentValue (this.rand0Offset);

            // Greater-than-fixnum?
            answer = (int) ev0 == ev1 ? Constant.sharpT : Constant.sharpF;
            return false;
        }
コード例 #21
0
 public override bool EvalStep(out object answer, ref Control expression, ref Environment environment)
 {
     Unimplemented ();
     #if DEBUG
     Warm ("PCondIsObjectEqQA0QQ.EvalStep");
     #endif
     answer = (this.rand0Value == environment.ArgumentValue (this.rand1Offset)) ?
         this.consequentValue :
         this.alternativeValue;
     return false;
 }
コード例 #22
0
        public override bool EvalStep(out object answer, ref Control expression, ref Environment environment)
        {
            #region EvalStepBody
            #if DEBUG
            Warm ();
            noteCalls (this.arg0);
            #endif
            object ev0 = environment.ArgumentValue (this.predicateOffset);

            if (!(ev0 is Complex)) {
            #if DEBUG
                noteCalls (this.alternative);
            #endif
                expression = this.alternative;
                answer = null;
                return true;
            }
            else {
                answer = this.consequentValue;
                return false;
            }
            #endregion
        }
コード例 #23
0
 public override bool EvalStep(out object answer, ref Control expression, ref Environment environment)
 {
     Unimplemented ();
     #if DEBUG
     Warm ("PCondIsObjectEqAQ.EvalStep");
     #endif
     if (environment.ArgumentValue (this.rand0Offset) == this.rand1Value) {
     #if DEBUG
         noteCalls (this.consequent);
         consequentTypeHistogram.Note (this.consequentType);
     #endif
         expression = this.consequent;
         answer = null;
         return true;
     }
     else {
     #if DEBUG
         noteCalls (this.alternative);
     #endif
         expression = this.alternative;
         answer = null;
         return true;
     }
 }
コード例 #24
0
        public override bool EvalStep(out object answer, ref Control expression, ref Environment environment)
        {
            #if DEBUG
            Warm ("-");
            NoteCalls (this.rand1);
            rand1TypeHistogram.Note (this.rand1Type);
            SCode.location = "PrimitiveGreaterThanFixnumA";
            #endif
            // Eval argument1
            object ev1;

            Control unev = this.rand1;
            Environment env = environment;
            while (unev.EvalStep (out ev1, ref unev, ref env)) { };
            #if DEBUG
            SCode.location = "PrimitiveGreaterThanFixnumA";
            #endif
            if (ev1 == Interpreter.UnwindStack) {
                throw new NotImplementedException ();
                //((UnwinderState) env).AddFrame (new PrimitiveCombination2Frame0 (this, environment));
                //answer = Interpreter.UnwindStack;
                //environment = env;
                //return false;
            }

            // Eval argument0
            object ev0 = environment.ArgumentValue (this.rand0Offset);

            // Greater-than-fixnum?
            answer = (int) ev0 > (int) ev1 ? Constant.sharpT : Constant.sharpF;
            return false;
        }
コード例 #25
0
        public override bool EvalStep(out object answer, ref Control expression, ref Environment environment)
        {
            #if DEBUG
            Warm ();
            #endif
            object ev0 = environment.ArgumentValue (predicateOffset);

            if (!(ev0 is Symbol)) {

                answer = this.alternativeValue;
                return false;
            }
            else {
            #if DEBUG
                noteCalls (this.consequent);
            #endif
                expression = this.consequent;
                answer = null;
                return true;
            }
        }
コード例 #26
0
        public override bool EvalStep(out object answer, ref Control expression, ref Environment environment)
        {
            #if DEBUG
            Warm ("-");
            SCode.location = "PrimitiveGreaterThanFixnumQA";
            #endif
            // Eval argument1
            object ev1 = environment.ArgumentValue (this.rand1Offset);

            // Greater-than-fixnum?
            answer = this.rand0Value > (int) ev1 ? Constant.sharpT : Constant.sharpF;
            return false;
        }
コード例 #27
0
        public override bool EvalStep(out object answer, ref Control expression, ref Environment environment)
        {
            #if DEBUG
            Warm ("-");
            NoteCalls (this.arg0);
            arg0TypeHistogram.Note (this.arg0Type);
            SCode.location = "PCondIsNullXXA";
            #endif
            Control unev0 = this.arg0;
            Environment env = environment;
            object ev0;
            while (unev0.EvalStep (out ev0, ref unev0, ref env)) { };
            #if DEBUG
            SCode.location = "PCondIsNullXXA";
            #endif
            if (ev0 == Interpreter.UnwindStack) {
                throw new NotImplementedException ();
                //((UnwinderState) env).AddFrame (new PrimitiveIsNullFrame0 (this, closureEnvironment));
                //answer = Interpreter.Unwind;
                //closureEnvironment = env;
                //return false;
            }

            if (ev0 == null) {
            #if DEBUG
                SCode.location = "-";
                NoteCalls (this.consequent);
                consequentTypeHistogram.Note (this.consequentType);
                SCode.location = "PCondIsNullXXA";
            #endif
                expression = this.consequent;
                answer = null; // keep c# compiler happy
                return true;
            }
            else {
                answer = environment.ArgumentValue (this.alternativeOffset);
                return false;
            }
        }
コード例 #28
0
 public override bool EvalStep(out object answer, ref Control expression, ref Environment environment)
 {
     #if DEBUG
     Warm ("PrimitiveIsCharEqQA.EvalStep");
     #endif
     object ev1 = environment.ArgumentValue (this.rand1Offset);
     answer = (ev1 is char && ((char) ev1 == this.rand0Value)) ? Constant.sharpT : Constant.sharpF;
     return false;
 }
コード例 #29
0
        public override bool EvalStep(out object answer, ref Control expression, ref Environment environment)
        {
            #if DEBUG
            Warm ("PCondIsNullAXQ");
            #endif
            if (environment.ArgumentValue (this.predicateArgumentOffset) == null) {
            #if DEBUG
                SCode.location = "-";
                NoteCalls (this.consequent);
                consequentTypeHistogram.Note (this.consequentType);
                SCode.location = "PCondIsNullAXQ";
            #endif
                expression = this.consequent;
                answer = null; // keep c# compiler happy
                return true;
            }
            else {
                answer = this.alternativeValue;
                return false;

            }
        }
コード例 #30
0
 public override bool EvalStep(out object answer, ref Control expression, ref Environment environment)
 {
     #if DEBUG
     Warm ("PrimitivePlusFixnumA1A.EvalStep");
     #endif
     answer = (int) environment.Argument1Value + (int) environment.ArgumentValue (this.rand1Offset);
     return false;
 }