perm filename CONST.SAI[NEW,AIL] blob
sn#065942 filedate 1979-01-08 generic text, type T, neo UTF8
ENTRY LCONST,SCONST,RCONST,ICONST,STCONS;
BEGIN "CONST"
INTEGER ITEMP;
LIST LTEMP;
DEFINE ARRSIZE="16";COMMENT SHOULD BE POWER OF 2;
LIST ARRAY LHASH,SHASH,IHASH,RHASH,STHASH[0:ARRSIZE-1];
SIMPLE PROCEDURE INIT;
FOR ITEMP← 0 STEP 1 UNTIL ARRSIZE-1 DO
LHASH[ITEMP]←SHASH[ITEMP]←RHASH[ITEMP]←
IHASH[ITEMP]←STHASH[ITEMP]←NIL;
REQUIRE INIT INITIALIZATION;
INTERNAL STRING ITEMVAR PROCEDURE STCONS(STRING Y);
BEGIN "STCONS"
STRING ITEMVAR STIV;
IF ITEMP←LENGTH(Y) THEN
ITEMP←(ITEMP XOR Y) LAND (ARRSIZE-1);
LTEMP←STHASH[ITEMP];
WHILE (LENGTH(LTEMP)) DO
IF EQU(DATUM(STIV←LOP(LTEMP)),Y) THEN
RETURN(STIV);
PUT (STIV←NEW(Y)) IN STHASH[ITEMP] BEFORE 1;
RETURN(STIV);
END "STCONS";
INTERNAL LIST ITEMVAR PROCEDURE LCONST(LIST Y);
BEGIN "LCONST"
LIST ITEMVAR LIV;
IF (ITEMP←LENGTH(Y)) THEN
ITEMP ←(ITEMP XOR CVN(COP(Y))) LAND (ARRSIZE-1);
LTEMP ← LHASH[ITEMP];
WHILE (LENGTH(LTEMP)) DO
IF (DATUM(LIV←LOP(LTEMP)) = Y) THEN
RETURN(LIV);
PUT (LIV←NEW(Y)) IN LHASH[ITEMP] BEFORE 1;
RETURN(LIV);
END "LCONST";
INTERNAL SET ITEMVAR PROCEDURE SCONST(SET Y);
BEGIN "SCONST"
SET ITEMVAR SIV;
IF (ITEMP←LENGTH(Y)) THEN
ITEMP←(ITEMP XOR CVN(COP(Y))) LAND (ARRSIZE-1);
LTEMP ← SHASH[ITEMP];
WHILE (LENGTH(LTEMP)) DO
IF DATUM(SIV←LOP(LTEMP))= Y THEN
RETURN (SIV);
PUT (SIV←NEW(Y)) IN SHASH[ITEMP] BEFORE 1;
RETURN(SIV);
END "SCONST";
INTERNAL REAL ITEMVAR PROCEDURE RCONST(REAL Y);
BEGIN "RCONST"
REAL ITEMVAR RIV;
ITEMP←Y LAND (ARRSIZE-1);
LTEMP← RHASH[ITEMP];
WHILE (LENGTH(LTEMP)) DO
IF (DATUM(RIV←LOP(LTEMP))= Y) THEN
RETURN(RIV);
PUT (RIV←NEW(Y)) IN RHASH[ITEMP] BEFORE 1;
RETURN(RIV);
END "RCONST";
INTERNAL INTEGER ITEMVAR PROCEDURE ICONST(INTEGER Y);
BEGIN "ICONST"
INTEGER ITEMVAR IIV;
ITEMP← Y LAND (ARRSIZE-1);
LTEMP ← IHASH[ITEMP];
WHILE (LENGTH(LTEMP)) DO
IF (DATUM(IIV←LOP(LTEMP))=Y) THEN
RETURN(IIV);
PUT (IIV ← NEW(Y)) IN IHASH[ITEMP] BEFORE 1;
RETURN(IIV);
END "ICONST";
END "CONST"