ack/lang/a68s/test/test.8

238 lines
7 KiB
Groff
Raw Normal View History

1988-10-05 13:29:42 +00:00
00050 .PR POINT .PR
00100 .BEGIN
00110 .PRIO .CHECK = 1;
00120 .OP .CHECK = (.INT C, I).VOID:
00130 PRINT((C=I ! (WHOLE(I,0), NEWLINE) ! ("ERROR ", WHOLE(I,0), " SHOULD BE ", WHOLE(C,0), NEWLINE)));
00140 .OP .CHECK = ([] .INT C, A).VOID:
00150 PRINT((.LOC .BOOL FAIL := .FALSE;
00160 .FOR I .FROM .LWB A .TO .UPB A .DO FAIL := FAIL .OR A[I]/=C[I] .OD;
00170 FAIL ! ("ERROR", A, " SHOULD BE", C, NEWLINE) ! ( A, NEWLINE)));
00180 .MODE .R = .STRUCT(.INT O, P, Q);
00190 .MODE .S = .STRUCT(.INT I, J, K, .R R, .REF .INT RI1, RI2);
00200 .MODE .MA = [1:3].INT, .MB = [1:1].R, .MC = [1:2].REF .INT, .MD = [1:3,1:1].S;
00210 .LOC .INT I;
00220 .LOC .REF .INT II := I;
00230 .LOC .R R1;
00240 .LOC .REF .R RR := R1;
00250 .LOC.S S1, S2, S3;
00260 .LOC .MA M1, M2, M3, .LOC .MB MB1, MB2, .LOC .MC MC1, .LOC .MD MD1, MD2;
00270 .REF .R PR = R.OF S1, QR = R.OF S2;
00280 .REF .R PM = MB1[1], QM = MB2[1];
00290 .REF .REF .INT RRI = RI1 .OF S1;
00300 .REF .REF .INT MMI = MC1[1];
00310 .REF.INT RI = I.OF S1;
00320 .REF .INT MI = M1[1];
00330 #NASSTS(REFN)#
00340 I.OF S1 := 1; J.OF S1 := 2; K.OF S1 := 3;
00350 M1[1] := 1; M1[2] := 2; M1[3] := 3;
00360 #NASSTS(REFSE)#
00370 P .OF PR := 4;
00380 4 .CHECK P .OF R .OF S1;
00390 #NASSTS(REFSL1)#
00400 P .OF PM := 4;
00410 4 .CHECK P .OF MB1[1];
00420 #NASSTP#
00430 R.OF S2 := PR;
00440 4 .CHECK P.OF R.OF S2;
00450 MB2[1] := PM;
00460 4 .CHECK P .OF MB2[1];
00470 #TASSTS(REFSE)#
00480 RI := 1;
00490 1 .CHECK I.OF S1;
00500 #TASSTS(REFSL1)#
00510 MI := 1;
00520 1 .CHECK M1[1];
00530 #TASSTS(CREF)#
00540 .REF .INT (II) := 2;
00550 2 .CHECK I;
00560 #TASSTP(REFN), DREFN(REFN)#
00570 S3 := S2 := S1;
00580 3 .CHECK K.OF S3;
00590 #TASSTM(REFR), DREFN(REFR)#
00600 M3 := M2 := M1;
00610 [].INT(1,2,3) .CHECK M3;
00620 #REFSLN:=REFSLN#
00630 M1[1:2] := M1[2:3];
00640 [].INT(2,3,3) .CHECK M1;
00650 [] .INT MM1 = M1[@2];
00660 #REFR:=REFSLN#
00670 M2 := MM1[@1];
00680 M1[3] := 4; #FORCES COPY OF MM1#
00690 [].INT(2,3,3) .CHECK M2;
00700 #REFSLN:=REFR#
00710 M3[@2] := MM1;
00720 [].INT(2,3,3) .CHECK M3;
00730 #TASSTP(REFSE)#
00740 Q.OF R.OF S2 := 2;
00750 PR := QR;
00760 2 .CHECK Q.OF R.OF S1;
00770 #TASSTP(REFSL1)#
00780 MB2 := R .OF S2; #ROWNM#
00790 PM := QM;
00800 2 .CHECK Q .OF MB1[1];
00810 #NASSNS(REFN)#
00820 I.OF S1 := J.OF S2;
00830 2 .CHECK RI;
00840 #NASSNS(REFR)#
00850 M1[1] := M2[3];
00860 3 .CHECK MI;
00870 #NASSNS(REFSLN)#
00880 M1[2:3][1] := M1[3];
00890 [].INT(3,4,4) .CHECK M1;
00900 #NASSNP#
00910 Q.OF R.OF S2 := 1;
00920 R.OF S1 := R.OF S2;
00930 1 .CHECK Q.OF R.OF S1;
00940 Q .OF MB2[1] := 1;
00950 MB1[1] := MB2[1];
00960 1 .CHECK Q .OF MB1[1];
00970 #TASSNS#
00980 RI := K.OF S3;
00990 3 .CHECK RI;
01000 MI := M3[3];
01010 3 .CHECK MI;
01020 #TASSNP(REFN)#
01030 R1 := R.OF S1;
01040 4 .CHECK P.OF R1;
01050 R1 := MB1[1];
01060 4 .CHECK P .OF R1;
01070 #TASSNP(REFSE)#
01080 O.OF R.OF S3 := 3;
01090 PR := R .OF S3;
01100 3 .CHECK O.OF PR;
01110 #TASSNP(REFSL1)#
01120 O .OF MB2[1] := 3;
01130 PM := MB2[1];
01140 3 .CHECK O .OF PM;
01150 #TASSNP(CREF)#
01160 .REF .R (RR) := R .OF S3;
01170 3 .CHECK O .OF R1;
01180 .REF .R (RR) := MB2[1];
01190 3 .CHECK O .OF R1;
01200 #NASSTPT#
01210 RI2.OF S1 := RI;
01220 3 .CHECK RI2.OF S1;
01230 MC1[2] := MI;
01240 3 .CHECK MC1[2];
01250 #TASSTPT(REFSE)#
01260 RRI := RI;
01270 3 .CHECK RRI;
01280 MMI := MI;
01290 3 .CHECK MMI;
01300 #NASSNRF#
01310 RI2.OF S1 := J.OF S1;
01320 2 .CHECK RI2.OF S1;
01330 MC1[2] := M1[2];
01340 4 .CHECK MC1[2];
01350 #TASSNRF#
01360 RRI := O .OF PM;
01370 3 .CHECK RRI;
01380 MMI := M2[@2][2];
01390 2 .CHECK MMI;
01400 #2#
01410 #STRUCTURE-DISPLAYS#
01420 S1 := (1 #COLLTS# , 2, .SKIP, (3,4,5), RI #COLLTPT# , .NIL);
01430 1 .CHECK I .OF S1; 4 .CHECK P .OF R .OF S1; 1 .CHECK RI1 .OF S1;
01440 S2 := (J .OF S1 #COLLNS#, 3, .SKIP, R .OF S1 #COLLNP#, .SKIP, .SKIP);
01450 2 .CHECK I .OF S2; 3 .CHECK J .OF S2; 4 .CHECK P .OF R .OF S2;
01460 S2 := (J .OF S1 #COLLNS# , 3, .SKIP, R .OF S1 #COLLNP# , J .OF S1 #COLLNRF# , RI1 .OF S1);
01470 2 .CHECK I .OF S2; 3 .CHECK J .OF S2; 4 .CHECK P .OF R .OF S2; 2 .CHECK RI1 .OF S2; 1 .CHECK RI2 .OF S2;
01480 S3 := (1, 2, 3, R1 #COLLTP# , .NIL, .NIL);
01490 4 .CHECK P .OF R .OF S3;
01500 #ROWNM#
01510 MD1[1, ] := S1; MD1[2, ] := S2; MD1[3, ] := S3;
01520 [].INT(1,2,1) .CHECK I .OF MD1[ ,1];
01530 #INCR- AND DECRSLICE#
01540 MD1[2, ] := MD1[1, ];
01550 MD2 := MD1;
01560 1 .CHECK RI1 .OF MD2[2,1];
01570 #ROWM#
01580 .LOC [1:1,1:3] .S MD3;
01590 MD3 := MD2[ ,1];
01600 [].INT(1,1,1) .CHECK I .OF MD3[1, ];
01610 #LOC GENERATOR#
01620 II := .LOC .INT := 5;
01630 5 .CHECK II;
01640 .VOID:
01650 .BEGIN
01660 .MODE .CHAIN = .STRUCT(.INT VAL, .REF .CHAIN NEXT);
01670 .LOC .REF .CHAIN START := .LOC .CHAIN;
01680 .REF .CHAIN (START) :=
01690 (1, .LOC .CHAIN := (2, .LOC .CHAIN := (3, START)));
01700 .MODE .REFCHAIN = .REF .STRUCT(.INT VAL, .REF .STRUCT(.INT VAL, .REFCHAIN NEXT) NEXT);
01710 .LOC .REFCHAIN P := START;
01720 .FOR I .WHILE I .CHECK VAL .OF P; P := NEXT .OF P; .REF .CHAIN (P) .ISNT START .DO .SKIP .OD;
01730 START := P := .NIL
01740 #THE .CHAIN LOOP IS NOW ISOLATED, AND THE GARBAGE COLLECTOR SHOULD
01750 LOSE IT UPON EXIT FROM THIS ROUTINE#
01760 .END;
01770 .PROC T=.VOID:
01780 (.LOC.INT A:=0
01790 ;.PROC PC=(.PROC.VOID P).VOID:P
01800 ;.PROC P1=.VOID:
01810 (.PROC P2=.VOID:
01820 (A:=99)
01830 ;PC(P2)
01840 )
01850 ;PC(P1)
01860 ;99.CHECK A
01870 )
01880 ;T
01890 ; .LOC .INT III, J := 0
01900 ; [] .INT A0 = (9,9,9,9)
01910 ; .LOC [0:3] .INT A := A0[@0]
01920 ; START:
01930 III := 0
01940 ; J +:= 1
01950 ; .GOTO LOOP
01960 ; III := 1
01970 ; LOOP:
01980 A[III] := III
01990 ; .IF (III+:=1)=3
02000 .THEN .LOC .INT Y
02010 ; .GO .TO END
02020 .FI
02030 ; .GOTO LOOP
02040 ; END:
02050 [] .INT(0,1,2,9)[@0] .CHECK A
02060 ; A := A0[@0]
02070 ; .IF J<=1
02080 .THEN .GOTO START
02090 .FI
02100 ; 2 .CHECK J
02110 ; .PR NOWARN .PR
02120 ( .PROC P = (.STRING S1, .INT I1, .STRING S2, S3).INT: .SKIP
02130 ; 13 .CHECK 4+4+(1+1+.INT(.LOC .INT Y; (.FALSE ! .SKIP !
02140 1+1+2*2*(.LOC .INT X; .TRUE ! 1+1+2*2*3^2^P(""+"", 2, ""+"", .GOTO L))
02150 ))
02160 ; L: 5
02170 )
02180 ; .FOR I .TO 2 .DO
02190 50.CHECK .ROUND(100*.CASE I.IN SIN,COS.ESAC(PI*I/6))
02200 .OD
02210 .PR WARN .PR
02220 ; .PROC R = (.PROC .VOID Q, .INT LEVEL, .STRING ST).STRING:
02230 """"+ST+
02240 ( .STRING TS = ST+"."
02250 ; ( .PROC S = .VOID:
02260 ( .INT L = LEVEL
02270 ; L=5
02280 ! PRINT((R(.VOID:
02290 ( .LOC .STRING T; T +:= .STRING(.GOTO M))
02300 , LEVEL+1
02310 , TS
02320 ), NEWLINE))
02330 !: LEVEL=10 ! Q
02340 ! PRINT((R(Q, LEVEL+1, TS), NEWLINE))
02350 )
02360 ; S
02370 ; ";"
02380 )
02390 .EXIT
02400 M: "!"
02410 )
02420 ; PRINT((R(.SKIP, 0, ""), NEWLINE))
02430 ; .GOTO STOP
02440 )
02450 .END