INTERFACECompile Juno expressions, predicates, functions, and procedures.JunoCompile ;
   Each of the compilation procedures in this interface takes a JunoAST.T to
   compile and a JunoScope.T scope that is used to resolve free variables.
   Each has the side-effect of decorating its argument AST, and each raises
   Error in the event of a compilation error.
   Compiling a Juno predicate, function, or procedure is a two-step process.
   Clients must first call NewPred, NewFunc, or NewProc to transform the
   declaration AST into a JunoScope.Entity. They should then pass that
   entity to PredDecl, FuncDecl, or ProcDecl, respectively, to install a
   bytestream in the run-time code table.
These procedures are re-entrant; they use an internal mutex to guarantee serialization.
IMPORT JunoAST, JunoScope, JunoRT;
FROM JunoCompileErr IMPORT Error;
IMPORT Wr, Rd;
PROCEDURE Expr(
    expr: JunoAST.Expr;
    scp: JunoScope.T;
    nm: JunoAST.Id;
    VAR (*OUT*) val_slot: CARDINAL;
    pure := FALSE):
    JunoRT.ByteStream RAISES {Error};
Setsval_slotand returns the bytestream of a command compiled underscpthat, when executed, stores the value of the expressionexprinJunoRT.value_tbl[val_slot].nmis printed in debugging output for this compilation. IfpureisTRUEandexprreferences a global variable or procedure, then raisesError.
PROCEDURE PredDecl(nm: JunoAST.Id; pred: JunoScope.Pred; scp: JunoScope.T)
    RAISES {Error};
Compile the predicate with signature and body determined frompredusingscpto resolve all its free variables, and place the resulting code inJunoRT.code_tbl[pred.index].nmis printed in debugging output for this compilation.By
compiling a predicate, we mean: 1) installing the normal form for the predicate body in theJunoScope.Predentity corresponding tonminscp, and 2) compiling the query(body)?()-- wherebodyis the predicate body -- with all IN arguments to the predicate assumed to be known variables.
PROCEDURE FuncDecl(nm: JunoAST.Id; func: JunoScope.Func; scp: JunoScope.T)
    RAISES {Error};
Compile the function with signature and body determined fromfuncusingscpto resolve all its free variables, and place the resulting code inJunoRT.code_tbl[func.index].nmis printed in debugging output for this compilation.By
compiling a function, we mean: 1) installing the normal form for the function body in theJunoScope.Funcentity corresponding tonminscp, and 2) compiling the query(body)?(res)-- wherebodyis the function body andresis its single OUT parameter -- with all IN arguments to the function assumed to be known variables.
PROCEDURE ProcDecl(nm: JunoAST.Id; proc: JunoScope.Proc; scp: JunoScope.T):
    JunoAST.Cmd RAISES {Error};
Compile the procedure with signature and body determined fromprocusingscpto resolve all its free variables, and place the resulting code inJunoRT.code_tbl[proc.index].nmis printed in debugging output for this compilation. Return the command produced by the front-end of the compiler that is to be fed into the back-end (assembler).
PROCEDURE SaveSlots(wr: Wr.T);
Write towrthe indexes of any internalJunoRTslots that are stored in the compiler or assembler.
PROCEDURE RestoreSlots(rd: Rd.T);
Read fromwrthe indexs stored bySaveSlots, and set the internal slots to the values read.
END JunoCompile.