Ejemplo n.º 1
0
 public static bool Add(out object answer, object left, object right)
 {
     if (left is int && right is int)
     {
         answer = (int)left + (int)right;
         return(false);
     }
     answer = new TailCallInterpreter(CallFromPrimitive.Make((IApplicable)FixedObjectsVector.GenericAdd, left, right), null);
     return(true);
 }
Ejemplo n.º 2
0
 public static bool IsLess(out object answer, object left, object right)
 {
     // Shortcut for fixnums
     if (left is int && right is int)
     {
         answer = ((int)left < (int)right) ? Constant.sharpT : Constant.sharpF;
         return(false);
     }
     else
     {
         answer = new TailCallInterpreter(CallFromPrimitive.Make((IApplicable)FixedObjectsVector.GenericLessP, left, right), null);
     }
     return(true);
 }
Ejemplo n.º 3
0
 public static bool Remainder(out object answer, object left, object right)
 {
     answer = new TailCallInterpreter(CallFromPrimitive.Make((IApplicable)FixedObjectsVector.GenericRemainder, left, right), null);
     return(true);
 }
Ejemplo n.º 4
0
 public static bool IsPositive(out object answer, object arg)
 {
     answer = new TailCallInterpreter(CallFromPrimitive.Make((IApplicable)FixedObjectsVector.GenericPositiveP, arg), null);
     return(true);
 }
Ejemplo n.º 5
0
        public override bool EvalStep(out object answer, ref Control expression, ref Environment environment)
        {
#if DEBUG
            Warm("-");
            NoteCalls(this.rand0);
            rand0TypeHistogram.Note(this.rand0Type);
            NoteCalls(this.rand1);
            rand1TypeHistogram.Note(this.rand1Type);
            SCode.location = "PrimitiveLessThan";
#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 = "PrimitiveLessThan";
#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;

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

            // less-than-fixnum?
            // Shortcut for fixnums
            if (ev0 is int && ev1 is int)
            {
                answer = ((int)ev0 < (int)ev1) ? Constant.sharpT : Constant.sharpF;
                return(false);
            }
            else
            {
                answer = new TailCallInterpreter(CallFromPrimitive.Make((IApplicable)FixedObjectsVector.GenericLessP, ev0, ev1), null);
            }
            return(true);
        }