MODULE; IMPORT JunoAST, JunoScope, Atom, Rd, Wr, Lex, Fmt, FloatMode, Thread; VAR close, apply := -1; PROCEDURE BuiltInSlots SlotFromName (scp: JunoScope.T; nm: TEXT): CARDINAL =
Return the index associated with the namenm
inscp
, which must be bound to a procedure.
VAR ent: JunoScope.Proc; BEGIN ent := JunoScope.Lookup(scp, Atom.FromText(nm)); RETURN ent.index END SlotFromName; PROCEDUREInit (scp: JunoScope.T) = BEGIN close := SlotFromName(scp, "CLOSE"); apply := SlotFromName(scp, "APPLY") END Init; PROCEDUREIsProcSlot (nm: JunoAST.QId; slot: INTEGER): BOOLEAN =
Return TRUE iffnm
has annotated indexslot
and the annoated type corresponding to a user-defined procedure.
BEGIN RETURN nm.index = slot AND nm.type = JunoAST.IdType.Proc END IsProcSlot; PROCEDUREIsApplySlot (slot: CARDINAL): BOOLEAN = BEGIN RETURN slot = apply END IsApplySlot; PROCEDUREIsCloseSlot (slot: CARDINAL): BOOLEAN = BEGIN RETURN slot = close END IsCloseSlot; PROCEDUREIsApplyProc (nm: JunoAST.QId): BOOLEAN = BEGIN RETURN IsProcSlot(nm, apply) END IsApplyProc; PROCEDUREIsCloseProc (nm: JunoAST.QId): BOOLEAN = BEGIN RETURN IsProcSlot(nm, close) END IsCloseProc; PROCEDURESave (wr: Wr.T) = <* FATAL Thread.Alerted, Wr.Failure *> BEGIN Wr.PutText(wr, Fmt.Int(close) & "\n"); Wr.PutText(wr, Fmt.Int(apply) & "\n") END Save; PROCEDURERestore (rd: Rd.T) = <* FATAL FloatMode.Trap, Lex.Error, Rd.Failure, Thread.Alerted *> BEGIN close := Lex.Int(rd); apply := Lex.Int(rd); <* FATAL Rd.EndOfFile *> BEGIN IF Rd.GetChar(rd) # '\n' THEN <* ASSERT FALSE *> END END END Restore; BEGIN END BuiltInSlots.