Google
 

Trailing-Edge - PDP-10 Archives - decuslib20-03 - decus/20-0078/maint/tdiid.rno
There is 1 other file named tdiid.rno in the archive. Click here to see a list.
00010	.sp 1;.nonum;.lm 9;.ps 50,72
00020	.ts 1,9,17,25,33,41,49,57,65
00030	.pg;.nm appendix D
00040	.ax SIMULA FOR DEC SYSTEM 10#############TD, COMPILER
00050	.nm 1
00060	.st 780302################6###########################Claes Wihlborg
00070	.pg;.lm 9;.p -8,0,10;II.D####DETAILS OF THE HIDDEN/PROTECTED IMPLEMENTATION
00080	.s 2;The implementation details are described below as SIMULA
00090	algorithms approximating the actual assembly code and data structures.
00100	.s;The current implementation of HIDDEN/PROTECTED has the following main properties:
00110	.s;- Whether or not an entity is visible, is entirely decided by ZQU.INVISIBLE.
00120	.s;- The flag ZQU.INVISIBLE is only changed at entry/exit of class/prefixed block.
00130	.s;- Thus, the visibility of an element is not dependent on the access method,
00140	only from where access is made.
00150	.nf;.br;_;
     
00010	.s;BEGIN
00020	.S;  CLASS zqu(idno,no,hid,prot,next);
00030	    INTEGER idno; COMMENT identifier number;
00040	    BOOLEAN no,hid,prot; COMMENT not hidden protected;
00050	    REF(zqu) next;
00060	    BEGIN
00070	      BOOLEAN invisible,match,virtual__match;
00080	    END zqu ;
00090	.s
00100	  CLASS zhe;
00110	    BEGIN
00120	      REF(zqu) declarations;
00130	    END zhe;
00140	.s
00150	  zhe CLASS zhb;
00160	    COMMENT  ZHB is used for classes, procedures,
00170	             connections and prefixed blocks;
00180	    BEGIN
00190	      REF(zhb) prefix; COMMENT to this class or block;
00200	      REF(zqu) hspec; COMMENT HIDDEN specifications;
00210	    END zhb ;
00220	.s
00230	  PROCEDURE error(message);VALUE message;TEXT message;;
00240	.s
00250	.s
00260	  BEGIN COMMENT  pass 1;
00270	.s
00280	    CLASS level(head);
00290	      REF(zhe) head;
00300	      BEGIN
00310	        REF(level) environment;
00320	        REF(zqu) pspec; COMMENT  protected specifications;
00330	        environment:-c__level;
00340	      END level;
00350	.s
00360	    REF(level) c__level;
00370	.s
00380	    PROCEDURE class__entry(idno);
00390	      INTEGER idno ;
00400	      BEGIN
00410	        normal__declaration(idno);
00420	        c__level:-NEW level(NEW zhb);
00430	      END class__entry;
00440	.s
00450	    PROCEDURE class__exit;
00460	      INSPECT c__level DO BEGIN
00470	        IF pspec=/=NONE THEN BEGIN
00480	          REF(zqu) pzqu;
00490	          IF pspec.no THEN BEGIN
00500	            pzqu:-head.declarations;
00510	            WHILE pzqu=/=NONE DO BEGIN
00520	              pzqu.prot:=pzqu.invisible:=TRUE;
00530	              pzqu:-pzqu.next;
00540	            END;
00550	            WHILE pspec=/=NONE DO BEGIN
00560	              BOOLEAN found;
00570	              pzqu:-head.declarations;
00580	              WHILE pzqu=/=NONE AND NOT found DO
00590	                IF pzqu.idno=pspec.idno
00600	                THEN found:=TRUE
00610	                ELSE pzqu:-pzqu.next;
00620	              IF found THEN
00630	                pzqu.prot:=pzqu.invisible:=FALSE
00640	              ELSE error(
00650	                "Attribute XXXX not found.");
00660	              pspec:-pspec.next;
00670	            END;
00680	          END ELSE
00690	            WHILE pspec=/=NONE DO BEGIN
00700	              BOOLEAN found;
00710	              pzqu:-head.declarations;
00720	              WHILE pzqu=/=NONE AND NOT found DO
00730	                IF pzqu.idno=pspec.idno
00740	                THEN found:=TRUE
00750	                ELSE pzqu:-pzqu.next;
00760	              IF found THEN
00770	                pzqu.prot:=pzqu.invisible:=TRUE
00780	              ELSE error(
00790	                "Attribute XXXX not found.");
00800	              pspec:-pspec.next;
00810	            END;
00820	        END;
00830	        c__level:-environment;
00840	      END class__exit;
00850	.s
00860	    PROCEDURE normal__declaration(idno);
00870	      INTEGER idno;
00880	      c__level.head.declarations:-
00890	        NEW zqu(idno,FALSE,FALSE,FALSE,
00900	        c__level.head.declarations);
00910	.s
00920	    PROCEDURE hidden__protected__specification
00930	      (idno,no,hid,prot);
00940	      INTEGER idno;
00950	      BOOLEAN no,hid,prot;
00960	      BEGIN
00970	        IF hid THEN
00980	          (c__level.head QUA zhb).hspec:-
00990	            NEW zqu(idno,no,TRUE,FALSE,
01000	            (c__level.head QUA zhb).hspec);
01010	        IF prot THEN c__level.pspec:-NEW zqu
01020	          (idno,no,FALSE,TRUE,c__level.pspec);
01030	      END hidden__protected__specification;
01040	.s
01050	  END pass 1 ;
01060	.s
01070	.s
01080	.s
01090	.s
01100	.s
01110	  BEGIN COMMENT  pass 2;
01120	.s
01130	    CLASS level(pzhe);
01140	      REF(zhe) pzhe;
01150	      BEGIN
01160	        REF(level) environment;
01170	        REF(display__stack) sobj;
01180	        environment:-c__level;
01190	      END level;
01200	.s
01210	    REF(level) c__level;
01220	.s
01230	    CLASS display__stack(idno,pzqu);
01240	      COMMENT  Here all redeclarations are saved;
01250	      INTEGER idno;
01260	      REF(zqu) pzqu;
01270	      BEGIN
01280	        REF(display__stack) prev;
01290	        prev:-c__level.sobj;
01300	      END display__stack;
01310	.s
01320	    REF(zqu) ARRAY display__array[1:3072];
01330	      COMMENT  Contains declared items;
01340	.s
01350	    PROCEDURE hide(pzhb);
01360	      REF(zhb) pzhb;
01370	      INSPECT pzhb DO BEGIN
01380	        REF(zqu) phid,pzqu;
01390	        hide(prefix);
01400	        unprotect(THIS zhb);
01410	        IF hspec=/=NONE THEN BEGIN
01420	          WHILE pzhb=/=NONE DO BEGIN
01430	            pzqu:-pzhb.declarations;
01440	            WHILE pzqu=/=NONE DO BEGIN
01450	              IF NOT pzqu.invisible THEN BEGIN
01460	                BOOLEAN found;
01470	                phid:-hspec;
01480	                WHILE phid=/=NONE AND NOT found DO
01490	                  IF pzqu.idno=phid.idno
01500	                  THEN found:=TRUE
01510	                  ELSE phid:-phid.next;
01520	                IF hspec.no THEN BEGIN
01530	                  IF NOT found THEN BEGIN
01540	                    IF pzqu.match THEN
01550	                      pzqu.match:=FALSE
01560	                    ELSE BEGIN
01570	                      IF pzqu.prot THEN
01580	                        pzqu.invisible:=TRUE;
01590	                      IF NOT pzqu.virtual__match THEN BEGIN
01600	                        INTEGER idno;
01610	                        REF(zhb) rzh;
01620	                        REF(zqu) rzq;
01630	                        idno:=pzqu.idno;
01640	                        rzh:-pzhb.prefix;
01650	                        WHILE rzh=/=NONE DO BEGIN
01660	                          rzq:-rzh.declarations;
01670	                          WHILE rzq=/=NONE DO BEGIN
01680	                            IF idno=rzq.idno AND NOT
01690	                              rzq.invisible
01700	                            THEN rzq.match:=TRUE;
01710	                            rzq:-rzq.next;
01720	                          END;
01730	                          rzh:-rzh.prefix;
01740	                        END;
01750	                      END;
01760	                    END;
01770	                  END;
01780	                END ELSE
01790	                  IF found AND NOT phid.match THEN BEGIN
01800	                    IF pzqu.prot THEN
01810	                      pzqu.invisible:=TRUE;
01820	                    IF NOT pzqu.virtual__match THEN
01830	                      phid.match:=TRUE;
01840	                  END;
01850	              END;
01860	              pzqu:-pzqu.next;
01870	            END;
01880	            pzhb:-pzhb.prefix;
01890	          END;
01900	          phid:-hspec;
01910	          WHILE phid=/=NONE DO BEGIN
01920	            phid.match:=FALSE;
01930	            phid:-phid.next;
01940	          END;
01950	        END;
01960	      END hide;
01970	.s
01980	    PROCEDURE check__hidden(pzhb);
01990	      REF(zhb) pzhb;
02000	      INSPECT pzhb DO
02010	        IF hspec=/=NONE THEN BEGIN
02020	          REF(zqu) pzqu,phid;
02030	          WHILE pzhb=/=NONE DO BEGIN
02040	            pzqu:-pzhb.declarations;
02050	            WHILE pzqu=/=NONE DO BEGIN
02060	              IF NOT pzqu.invisible THEN BEGIN
02070	                BOOLEAN found;
02080	                phid:-hspec;
02090	                WHILE  phid=/=NONE AND NOT found DO
02100	                  IF phid.idno=pzqu.idno
02110	                  THEN found:=TRUE
02120	                  ELSE phid:-phid.next;
02130	                IF found AND NOT phid.match THEN BEGIN
02140	                  phid.match:=TRUE;
02150	                  IF NOT(pzqu.prot OR phid.no) THEN
02160	                    error("Attribute HIDDEN"
02170	                    " but not PROTECTED");
02180	                END;
02190	              END;
02200	              pzqu:-pzqu.next;
02210	            END;
02220	            pzhb:-pzhb.prefix;
02230	          END;
02240	          phid:-hspec;
02250	          WHILE phid=/=NONE DO BEGIN
02260	            IF NOT phid.match THEN
02270	              error("No attribute XXXX visible");
02280	            phid.match:=FALSE;
02290	            phid:-phid.next;
02300	          END;
02310	        END hidden check;
02320	.s
02330	    PROCEDURE unprotect(pzhb);
02340	      REF(zhb) pzhb;
02350	      BEGIN
02360	        REF(zqu) pzqu;
02370	        pzqu:-pzhb.declarations;
02380	        WHILE pzqu=/=NONE DO BEGIN
02390	          pzqu.invisible:=false;
02400	          pzqu:-pzqu.next
02410	        END
02420	      END unprotect;
02430	.s
02440	    PROCEDURE display(pzhe);
02450	      REF(zhe) pzhe;
02460	      INSPECT pzhe DO BEGIN
02470	        REF(zqu) pzqu;
02480	        INSPECT THIS zhe WHEN zhb DO display(prefix);
02490	        pzqu:-declarations;
02500	        WHILE pzqu=/=NONE DO BEGIN
02510	          IF NOT pzqu.invisible THEN BEGIN
02520	            c__level.sobj:-NEW display__stack
02530	              (pzqu.idno,display__array[pzqu.idno]);
02540	            display__array[pzqu.idno]:-pzqu;
02550	          END;
02560	          pzqu:-pzqu.next;
02570	        END;
02580	      END display;
02590	.s
02600	    PROCEDURE undisplay;
02610	      WHILE c__level.sobj=/=NONE DO BEGIN
02620	        display__array[c__level.sobj.idno]:-
02630	          c__level.sobj.pzqu;
02640	        c__level.sobj:-c__level.sobj.prev;
02650	      END undisplay;
02660	.s
02670	    PROCEDURE protect(pzhb);
02680	      REF(zhb) pzhb;
02690	      INSPECT pzhb DO BEGIN
02700	        REF(zqu) pzqu;
02710	        pzqu:-declarations;
02720	        WHILE pzqu=/=NONE DO BEGIN
02730	          IF pzqu.prot THEN pzqu.invisible:=TRUE;
02740	          pzqu:-pzqu.next;
02750	        END;
02760	        protect(prefix);
02770	      END protect;
02780	.s
02790	    PROCEDURE class__declaration(pzhb);
02800	      COMMENT Called for all new classes when a declaration
02810	      segment has been read;
02820	      REF(zhb) pzhb;
02830	      BEGIN
02840	        hide(pzhb.prefix);
02850	        unprotect(pzhb);
02860	        check__hidden(pzhb);
02870	        protect(pzhb);
02880	      END class__declaration;
02890	.s
02900	    REF(zqu) PROCEDURE normal__access(idno);
02910	      INTEGER idno;
02920	      IF display__array[idno]==NONE
02930	      THEN error("Identifier not declared")
02940	      ELSE normal__access:-display__array[idno];
02950	.s
02960	    REF(zqu) PROCEDURE remote__access(idno,pzhb);
02970	      INTEGER idno;
02980	      REF(zhb) pzhb; COMMENT Qualifying class;
02990	      BEGIN
03000	        REF(zqu) pzqu;
03010	        BOOLEAN found;
03020	        WHILE pzhb=/=NONE AND NOT found DO BEGIN
03030	          pzqu:-pzhb.declarations;
03040	          WHILE pzqu=/=NONE AND NOT found DO
03050	            IF pzqu.idno=idno AND NOT pzqu.invisible
03060	            THEN found:=TRUE
03070	            ELSE pzqu:-pzqu.next;
03080	          pzhb:-pzhb.prefix;
03090	        END;
03100	        remote__access:-pzqu;
03110	      END remote__access;
03120	.s
03130	    PROCEDURE class__entry(pzhb);
03140	      REF(zhb) pzhb;
03150	      BEGIN
03160	        c__level:-NEW level(pzhb);
03170	        hide(pzhb.prefix);
03180	        unprotect(pzhb);
03190	        display(pzhb);
03200	      END class__entry;
03210	.s
03220	    PROCEDURE class__exit;
03230	      BEGIN
03240	        undisplay;
03250	        protect(c__level.pzhe QUA zhb);
03260	        c__level:-c__level.environment;
03270	      END class__exit;
03280	.s
03290	    PROCEDURE entry__prefix__block(pzhb);
03300	      REF(zhb) pzhb;
03310	      BEGIN
03320	        c__level:-NEW level(pzhb);
03330	        hide(pzhb.prefix);
03340	        display(pzhb);
03350	      END entry__prefix__block;
03360	.s
03370	    PROCEDURE exit__prefix__block;
03380	      BEGIN
03390	        undisplay;
03400	        protect((c__level.pzhe QUA zhb).prefix);
03410	        c__level:-c__level.environment;
03420	      END exit__prefix__block;
03430	.s
03440	    PROCEDURE entry__connection(pzhb);
03450	      REF(zhb) pzhb;
03460	      BEGIN
03470	        c__level:-NEW level(pzhb);
03480	        display(pzhb.prefix);
03490	      END entry__connection__block;
03500	.s
03510	    PROCEDURE exit__connection;
03520	      BEGIN
03530	        undisplay;
03540	        c__level:-c__level.environment;
03550	      END exit__connection__block;
03560	.s
03570	  END pass 2;
03580	.s
03590	END Declaration handling: DECsystem-10;
     
00010	.f;.s
00020	COMMENT 
00030	The algorithms above show only the logic of the implementation. In reality
00040	they are more complicated due to some lists being merged together and some
00050	pointers being substituted with the relation
00060	"placed in the immediately following
00070	memory location". As these details only would clutter up the description they
00080	are not given here. For the same reason, a lot of details which are irrelevant
00090	here are missing.
00100	;