Beispiel #1
0
        // saveContext: saves numbered registers and Reg.implicitContinuation to frame
        //   will restore registers and return to Reg.implicitContinuation of Reg.Register0
        //   clears Reg.implicitContinuation
        //   Also saves Result and flag whether to restore Result
        public static void saveContext(bool full)
        {
            // Save current context: Create frame described below, before RestoreContextCode
            Instructions.save(1 + Reg.LASTREG + 2);
            ContinuationFrame frame = Cont.cont;

            frame.saveRegisters(RestoreContextCode.singletonProcedure, full);
//            frame.setSlot(0, RestoreContextCode.singletonProcedure);
//            frame.returnIndex = Reg.implicitContinuation;
//            for (int i = 0; i <= Reg.LASTREG; ++i) {
//                frame.setSlot(i + 1, Reg.getRegister(i));
//            }
//            frame.setSlot(Reg.LASTREG + 2, Reg.Result);
//            frame.setSlot(Reg.LASTREG + 3, full ? Factory.True : Factory.False);
            Reg.implicitContinuation = -1;
        }
Beispiel #2
0
        public override CodeAddress call(int jumpIndex)
        {
            ContinuationFrame frame = Cont.cont;

            for (int i = 0; i < Reg.NREGS; ++i)
            {
                Reg.setRegister(i, frame.getSlot(i + 1));
            }
            if (frame.getSlot(Reg.LASTREG + 3) == Factory.True)
            {
                Reg.Result = frame.getSlot(Reg.LASTREG + 2);
            }
            Procedure p0 = Reg.ProcRegister0;

            Cont.cont.checkPop(Reg.NREGS + 2, singletonProcedure);
            Cont.pop();
            return(Call.call(p0.entrypoint, jumpIndex));
        }