INTERFACEJunoAssemble ; IMPORT JunoRT, JunoScope, JunoCompileRep; TYPE CmdType = { Pred, Func, Proc }; PROCEDURE Cmd( cmd: JunoCompileRep.Result; scp: JunoScope.T; temp_cnt: CARDINAL; type: CmdType): JunoRT.ByteStream;
Returns the byte-code program produced by assembling the compilation resultcmdunder the scopescp. The first instruction in the resulting stream increments the stack pointer bytemp_cntlocations in order to make space for temporary (local) variables.The
typereflects the kind of declaration in which this command is being compiled. Each type makes certain assumptions about the input commandcmd, and handles run-time errors and the state of the machine on return differently. In particular:
type = CmdType.PredORtype = CmdType.Func=>Cmdmay be a partial command, but it is required not to abort. Execution of the resulting bytestream is guaranteed to terminate with the machine's condition bit set iffGrd(cmd) # FALSE.
type = CmdType.Proc, => Requires thatcmdbe a total command. Ifcmdaborts, the resulting bytestream will execute the run-time bytecodeJunoByteCode.ERRORwith the appropriate argument (encounteredABORT,IF..FIfailure, or undefined term).This procedure has the side-effect of setting the
startandendfields of every AST node of the ASTcmd.cmd. Each nodenis annotated such that the half-open interval[n.start, n.end)is the largest interval containing the PC locations corresponding the assembly instructions forn.
END JunoAssemble.