-- CoreSchemeCode.mesa
-- Tidbit compiler output for Core.scheme

DIRECTORY Scheme, SchemePrivate;

CoreSchemeCode: CEDAR PROGRAM
IMPORTS Scheme, SchemePrivate
~ BEGIN
    OPEN Scheme, SchemePrivate;
    
    Code0: PROC [a: Activation] ~ {
        g: PairSeq ~ a.code.globalBindings;
        env: Environment ~ a.env;
        c: SimpleVector ~ a.code.literals;
        s: Stack ~ a.s;
        temp: Any ← NIL;
        pc: INTEGER ← a.pc;
        bottom: INTEGER ← 0;
        n: INTEGER ← 2;
        
        DO
            a.pc ← pc;
            pc ← pc + 1;
            SELECT a.pc FROM
                1 => {
                    s[0] ← unspecified;
                    GOTO returnExit;
                    };
                0 => {
                    s[0] ← g[0].cdr;
                    s[1] ← c[0];
                    };
                ENDCASE => ERROR;
            a.pc ← pc;
            a.n ← n;
            a.bottom ← bottom;
            RETURN;
            
            REPEAT
                returnExit => { a.pc ← -1; a.n ← 0; };
            ENDLOOP;
        };
    
    Register: PROC [env: Environment] ~ {
        startProc: TidbitProcedure;
        literals: SimpleVector ~ ReadRopeVector["#\001\022\001\021\012CoreMXCode"];
        
        
        {
            startProc ← NEW[TidbitProcedureRep ← [env: NIL, code:
                MakeTidbitCode[
                    "\"Core\" () (reinstall)",
                    env, 0, Code0,
                    SV1[
                        literals[0]
                        ],
                    0, "No documentation", NIL]
                ]];
            };
        [] ← Apply[startProc, NIL];
        };
    
    RegisterInit[Register];
END.