about summary refs log tree commit diff stats
path: root/arc/mu.arc.t.html
blob: dd64147234bc17c1d22801695febd83c119201c8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>mu.arc.t</title>
<meta name="Generator" content="Vim/7.4">
<meta name="plugin-version" content="vim7.4_v1">
<meta name="syntax" content="scheme">
<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy=">
<meta name="colorscheme" content="minimal">
<style type="text/css">
<!--
pre { white-space: pre-wrap; font-family: monospace; color: #aaaaaa; background-color: #000000; }
body { font-family: monospace; color: #aaaaaa; background-color: #000000; }
a { color:#4444ff; }
* { font-size: 1em; }
.Global { color: #00af87; }
.SalientComment { color: #00ffff; }
.CommentedCode { color: #666666; }
.Mu, .Mu .Normal, .Mu .Constant { color: #eeeeee; }
.Op { color: #ff8888; }
.Delimiter { color: #600060; }
.Normal { color: #aaaaaa; }
.Comment { color: #8080ff; }
.Constant, .MuConstant { color: #008080; }
.Identifier { color: #008080; }
-->
</style>

<script type='text/javascript'>
<!--

-->
</script>
</head>
<body>
<pre id='vimCodeElement'>
<span class="Comment">; Mu: An exploration on making the global structure of programs more accessible.</span>
<span class="Comment">;</span>
<span class="Comment">;   &quot;Is it a language, or an operating system, or a virtual machine? Mu.&quot;</span>
<span class="Comment">;   (with apologies to Robert Pirsig: <a href="http://en.wikipedia.org/wiki/Mu_%28negative%29#In_popular_culture">http://en.wikipedia.org/wiki/Mu_%28negative%29#In_popular_culture</a>)</span>
<span class="Comment">;</span>
<span class="SalientComment">;; Motivation</span>
<span class="Comment">;</span>
<span class="Comment">; I want to live in a world where I can have an itch to tweak a program, clone</span>
<span class="Comment">; its open-source repository, orient myself on how it's organized, and make</span>
<span class="Comment">; the simple change I envisioned, all in an afternoon. This codebase tries to</span>
<span class="Comment">; make this possible for its readers. (More details: <a href="http://akkartik.name/about">http://akkartik.name/about</a>)</span>
<span class="Comment">;</span>
<span class="Comment">; What helps comprehend the global structure of programs? For starters, let's</span>
<span class="Comment">; enumerate what doesn't: idiomatic code, adherence to a style guide or naming</span>
<span class="Comment">; convention, consistent indentation, API documentation for each class, etc.</span>
<span class="Comment">; These conventional considerations improve matters in the small, but don't</span>
<span class="Comment">; help understand global organization. They help existing programmers manage</span>
<span class="Comment">; day-to-day operations, but they can't turn outsider programmers into</span>
<span class="Comment">; insiders. (Elaboration: <a href="http://akkartik.name/post/readable-bad">http://akkartik.name/post/readable-bad</a>)</span>
<span class="Comment">;</span>
<span class="Comment">; In my experience, two things have improved matters so far: version control</span>
<span class="Comment">; and automated tests. Version control lets me rewind back to earlier, simpler</span>
<span class="Comment">; times when the codebase was simpler, when its core skeleton was easier to</span>
<span class="Comment">; ascertain. Indeed, arguably what came first is by definition the skeleton of</span>
<span class="Comment">; a program, modulo major rewrites. Once you understand the skeleton, it</span>
<span class="Comment">; becomes tractable to 'play back' later major features one by one. (Previous</span>
<span class="Comment">; project that fleshed out this idea: <a href="http://akkartik.name/post/wart-layers">http://akkartik.name/post/wart-layers</a>)</span>
<span class="Comment">;</span>
<span class="Comment">; The second and biggest boost to comprehension comes from tests. Tests are</span>
<span class="Comment">; good for writers for well-understood reasons: they avoid regressions, and</span>
<span class="Comment">; they can influence code to be more decoupled and easier to change. In</span>
<span class="Comment">; addition, tests are also good for the outsider reader because they permit</span>
<span class="Comment">; active reading. If you can't build a program and run its tests it can't help</span>
<span class="Comment">; you understand it. It hangs limp at best, and might even be actively</span>
<span class="Comment">; misleading. If you can run its tests, however, it comes alive. You can step</span>
<span class="Comment">; through scenarios in a debugger. You can add logging and scan logs to make</span>
<span class="Comment">; sense of them. You can run what-if scenarios: &quot;why is this line not written</span>
<span class="Comment">; like this?&quot; Make a change, rerun tests: &quot;Oh, that's why.&quot; (Elaboration:</span>
<span class="Comment">; <a href="http://akkartik.name/post/literate-programming">http://akkartik.name/post/literate-programming</a>)</span>
<span class="Comment">;</span>
<span class="Comment">; However, tests are only useful to the extent that they exist. Think back to</span>
<span class="Comment">; your most recent codebase. Do you feel comfortable releasing a new version</span>
<span class="Comment">; just because the tests pass? I'm not aware of any such project. There's just</span>
<span class="Comment">; too many situations envisaged by the authors that were never encoded in a</span>
<span class="Comment">; test. Even disciplined authors can't test for performance or race conditions</span>
<span class="Comment">; or fault tolerance. If a line is phrased just so because of some subtle</span>
<span class="Comment">; performance consideration, it's hard to communicate to newcomers.</span>
<span class="Comment">;</span>
<span class="Comment">; This isn't an arcane problem, and it isn't just a matter of altruism. As</span>
<span class="Comment">; more and more such implicit considerations proliferate, and as the original</span>
<span class="Comment">; authors are replaced by latecomers for day-to-day operations, knowledge is</span>
<span class="Comment">; actively forgotten and lost. The once-pristine codebase turns into legacy</span>
<span class="Comment">; code that is hard to modify without expensive and stress-inducing</span>
<span class="Comment">; regressions.</span>
<span class="Comment">;</span>
<span class="Comment">; How to write tests for performance, fault tolerance, race conditions, etc.?</span>
<span class="Comment">; How can we state and verify that a codepath doesn't ever perform memory</span>
<span class="Comment">; allocation, or write to disk? It requires better, more observable primitives</span>
<span class="Comment">; than we currently have. Modern operating systems have their roots in the</span>
<span class="Comment">; 70s. Their interfaces were not designed to be testable. They provide no way</span>
<span class="Comment">; to simulate a full disk, or a specific sequence of writes from different</span>
<span class="Comment">; threads. We need something better.</span>
<span class="Comment">;</span>
<span class="Comment">; This project tries to move, groping, towards that 'something better', a</span>
<span class="Comment">; platform that is both thoroughly tested and allows programs written for it</span>
<span class="Comment">; to be thoroughly tested. It tries to answer the question:</span>
<span class="Comment">;</span>
<span class="Comment">;   If Denis Ritchie and Ken Thompson were to set out today to co-design unix</span>
<span class="Comment">;   and C, knowing what we know about automated tests, what would they do</span>
<span class="Comment">;   differently?</span>
<span class="Comment">;</span>
<span class="Comment">; To try to impose *some* constraints on this gigantic yak-shave, we'll try to</span>
<span class="Comment">; keep both language and OS as simple as possible, focused entirely on</span>
<span class="Comment">; permitting more kinds of tests, on first *collecting* all the information</span>
<span class="Comment">; about implicit considerations in some form so that readers and tools can</span>
<span class="Comment">; have at least some hope of making sense of it.</span>
<span class="Comment">;</span>
<span class="Comment">; The initial language will be just assembly. We'll try to make it convenient</span>
<span class="Comment">; to program in with some simple localized rewrite rules inspired by lisp</span>
<span class="Comment">; macros and literate programming. Programmers will have to do their own</span>
<span class="Comment">; memory management and register allocation, but we'll provide libraries to</span>
<span class="Comment">; help with them.</span>
<span class="Comment">;</span>
<span class="Comment">; The initial OS will provide just memory management and concurrency</span>
<span class="Comment">; primitives. No users or permissions (we don't live on mainframes anymore),</span>
<span class="Comment">; no kernel- vs user-mode, no virtual memory or process abstraction, all</span>
<span class="Comment">; threads sharing a single address space (use VMs for security and</span>
<span class="Comment">; sandboxing). The only use case we care about is getting a test harness to</span>
<span class="Comment">; run some code, feed it data through blocking channels, stop it and observe</span>
<span class="Comment">; its internals. The code under test is expected to cooperate in such testing,</span>
<span class="Comment">; by logging important events for the test harness to observe. (More info:</span>
<span class="Comment">; <a href="http://akkartik.name/post/tracing-tests">http://akkartik.name/post/tracing-tests</a>)</span>
<span class="Comment">;</span>
<span class="Comment">; The common thread here is elimination of abstractions, and it's not an</span>
<span class="Comment">; accident. Abstractions help insiders manage the evolution of a codebase, but</span>
<span class="Comment">; they actively hinder outsiders in understanding it from scratch. This</span>
<span class="Comment">; matters, because the funnel to turn outsiders into insiders is critical to</span>
<span class="Comment">; the long-term life of a codebase. Perhaps authors should raise their</span>
<span class="Comment">; estimation of the costs of abstraction, and go against their instincts for</span>
<span class="Comment">; introducing it. That's what I'll be trying to do: question every abstraction</span>
<span class="Comment">; before I introduce it. We'll see how it goes.</span>

<span class="Comment">; ---</span>

<span class="SalientComment">;; Getting started</span>
<span class="Comment">;</span>
<span class="Comment">; Mu is currently built atop Racket and Arc, but this is temporary and</span>
<span class="Comment">; contingent. We want to keep our options open, whether to port to a different</span>
<span class="Comment">; host language, and easy to rewrite to native code for any platform. So we'll</span>
<span class="Comment">; try to avoid 'cheating': relying on the host platform for advanced</span>
<span class="Comment">; functionality.</span>
<span class="Comment">;</span>
<span class="Comment">; Other than that, we'll say no more about the code, and focus in the rest of</span>
<span class="Comment">; this file on the scenarios the code cares about.</span>

<span class="Delimiter">(</span>selective-load <span class="Constant">&quot;mu.arc&quot;</span> section-level<span class="Delimiter">)</span>
<span class="CommentedCode">;? (quit)</span>

<span class="Delimiter">(</span>section <span class="Constant">20</span>

<span class="Comment">; Our language is assembly-like in that functions consist of series of</span>
<span class="Comment">; statements, and statements consist of an operation and its arguments (input</span>
<span class="Comment">; and output).</span>
<span class="Comment">;</span>
<span class="Comment">;   oarg1, oarg2, ... <span class="Op">&lt;-</span> op arg1, arg2, ...</span>
<span class="Comment">;</span>
<span class="Comment">; Args must be atomic, like an integer or a memory address, they can't be</span>
<span class="Comment">; expressions doing arithmetic or function calls. But we can have any number</span>
<span class="Comment">; of them.</span>
<span class="Comment">;</span>
<span class="Comment">; Since we're building on lisp, our code samples won't look quite like the</span>
<span class="Comment">; idealized syntax above. For now they will look like this:</span>
<span class="Comment">;</span>
<span class="Comment">;   (function f [</span>
<span class="Comment">;     (oarg1 oarg2 ... <span class="Op">&lt;-</span> op arg1 arg2 ...)</span>
<span class="Comment">;     ...</span>
<span class="Comment">;     ...</span>
<span class="Comment">;    ])</span>
<span class="Comment">;</span>
<span class="Comment">; Each arg/oarg can contain metadata separated by slashes and colons. In this</span>
<span class="Comment">; first example below, the only metadata is types: 'integer' for a memory</span>
<span class="Comment">; location containing an integer, and 'literal' for a value included directly</span>
<span class="Comment">; in code. (Assembly languages traditionally call them 'immediate' operands.)</span>
<span class="Comment">; In the future a simple tool will check that the types line up as expected in</span>
<span class="Comment">; each op. A different tool might add types where they aren't provided.</span>
<span class="Comment">; Instead of a monolithic compiler I want to build simple, lightweight tools</span>
<span class="Comment">; that can be combined in various ways, say for using different typecheckers</span>
<span class="Comment">; in different subsystems.</span>
<span class="Comment">;</span>
<span class="Comment">; In our tests we'll define such mu functions using a call to 'add-code', so</span>
<span class="Comment">; look for it when reading the code examples. Everything outside 'add-code' is</span>
<span class="Comment">; just test-harness details that can be skipped at first.</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="CommentedCode">;? (set dump-trace*)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;literal&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">23</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="CommentedCode">;? (set dump-trace*)</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Global">memory*</span><span class="Constant">.1</span> <span class="Constant">23</span><span class="Delimiter">)</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'copy' writes its lone 'arg' after the instruction name to its lone 'oarg' or output arg before the arrow. After this test, the value 23 is stored in memory address 1.&quot;</span><span class="Delimiter">))</span>
<span class="CommentedCode">;? (quit)</span>

<span class="Comment">; Our basic arithmetic ops can operate on memory locations or literals.</span>
<span class="Comment">; (Ignore hardware details like registers for now.)</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;add&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">1</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">3</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:integer <span class="Op">&lt;-</span> add <span class="Constant">1</span>:integer <span class="Constant">2</span>:integer<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Global">memory*</span> <span class="Delimiter">(</span>obj <span class="Constant">1</span> <span class="Constant">1</span>  <span class="Constant">2</span> <span class="Constant">3</span>  <span class="Constant">3</span> <span class="Constant">4</span><span class="Delimiter">))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'add' operates on two addresses&quot;</span><span class="Delimiter">))</span>
<span class="CommentedCode">;? (quit)</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;add-literal&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> add <span class="MuConstant">2</span>:literal <span class="MuConstant">3</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Global">memory*</span><span class="Constant">.1</span> <span class="Constant">5</span><span class="Delimiter">)</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - ops can take 'literal' operands (but not return them)&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;sub-literal&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> subtract <span class="MuConstant">1</span>:literal <span class="MuConstant">3</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Global">memory*</span><span class="Constant">.1</span> <span class="Constant">-2</span><span class="Delimiter">)</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'subtract'&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;mul-literal&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> multiply <span class="MuConstant">2</span>:literal <span class="MuConstant">3</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Global">memory*</span><span class="Constant">.1</span> <span class="Constant">6</span><span class="Delimiter">)</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'multiply'&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;div-literal&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> divide <span class="MuConstant">8</span>:literal <span class="MuConstant">3</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Global">memory*</span><span class="Constant">.1</span> <span class="Delimiter">(</span>/ real.8 <span class="Constant">3</span><span class="Delimiter">))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'divide'&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;idiv-literal&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Constant">2</span>:integer <span class="Op">&lt;-</span> divide-with-remainder <span class="MuConstant">23</span>:literal <span class="MuConstant">6</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Global">memory*</span> <span class="Delimiter">(</span>obj <span class="Constant">1</span> <span class="Constant">3</span>  <span class="Constant">2</span> <span class="Constant">5</span><span class="Delimiter">))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'divide-with-remainder' performs integer division&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;dummy-oarg&quot;</span><span class="Delimiter">)</span>
<span class="CommentedCode">;? (set dump-trace*)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span>_ <span class="Constant">2</span>:integer <span class="Op">&lt;-</span> divide-with-remainder <span class="MuConstant">23</span>:literal <span class="MuConstant">6</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Global">memory*</span> <span class="Delimiter">(</span>obj <span class="Constant">2</span> <span class="Constant">5</span><span class="Delimiter">))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - '_' oarg can ignore some results&quot;</span><span class="Delimiter">))</span>
<span class="CommentedCode">;? (quit)</span>

<span class="Comment">; Basic boolean operations: and, or, not</span>
<span class="Comment">; There are easy ways to encode booleans in binary, but we'll skip past those</span>
<span class="Comment">; details for now.</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;and-literal&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:boolean <span class="Op">&lt;-</span> and <span class="MuConstant">t</span>:literal <span class="MuConstant">nil</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="CommentedCode">;? (set dump-trace*)</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Global">memory*</span><span class="Constant">.1</span> nil<span class="Delimiter">)</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - logical 'and' for booleans&quot;</span><span class="Delimiter">))</span>

<span class="Comment">; Basic comparison operations</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;lt-literal&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:boolean <span class="Op">&lt;-</span> less-than <span class="MuConstant">4</span>:literal <span class="MuConstant">3</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Global">memory*</span><span class="Constant">.1</span> nil<span class="Delimiter">)</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'less-than' inequality operator&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;le-literal-false&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:boolean <span class="Op">&lt;-</span> lesser-or-equal <span class="MuConstant">4</span>:literal <span class="MuConstant">3</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Global">memory*</span><span class="Constant">.1</span> nil<span class="Delimiter">)</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'lesser-or-equal'&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;le-literal-true&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:boolean <span class="Op">&lt;-</span> lesser-or-equal <span class="MuConstant">4</span>:literal <span class="MuConstant">4</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Global">memory*</span><span class="Constant">.1</span> t<span class="Delimiter">)</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'lesser-or-equal' returns true for equal operands&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;le-literal-true-2&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:boolean <span class="Op">&lt;-</span> lesser-or-equal <span class="MuConstant">4</span>:literal <span class="MuConstant">5</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Global">memory*</span><span class="Constant">.1</span> t<span class="Delimiter">)</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'lesser-or-equal' - 2&quot;</span><span class="Delimiter">))</span>

<span class="Comment">; Control flow operations: jump, jump-if, jump-unless</span>
<span class="Comment">; These introduce a new type -- 'offset' -- for literals that refer to memory</span>
<span class="Comment">; locations relative to the current location.</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;jump-skip&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">8</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Identifier">jump</span> <span class="MuConstant">1</span>:offset<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">3</span>:literal<span class="Delimiter">)</span>  <span class="Comment">; should be skipped</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Identifier">reply</span><span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="CommentedCode">;? (set dump-trace*)</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Global">memory*</span> <span class="Delimiter">(</span>obj <span class="Constant">1</span> <span class="Constant">8</span><span class="Delimiter">))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'jump' skips some instructions&quot;</span><span class="Delimiter">))</span>
<span class="CommentedCode">;? (quit)</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;jump-target&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">8</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Identifier">jump</span> <span class="MuConstant">1</span>:offset<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">3</span>:literal<span class="Delimiter">)</span>  <span class="Comment">; should be skipped</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Identifier">reply</span><span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">34</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>  <span class="Comment">; never reached</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Global">memory*</span> <span class="Delimiter">(</span>obj <span class="Constant">1</span> <span class="Constant">8</span><span class="Delimiter">))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'jump' doesn't skip too many instructions&quot;</span><span class="Delimiter">))</span>
<span class="CommentedCode">;? (quit)</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;jump-if-skip&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">1</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:boolean <span class="Op">&lt;-</span> equal <span class="MuConstant">1</span>:literal <span class="Constant">2</span>:integer<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Identifier">jump-if</span> <span class="Constant">1</span>:boolean <span class="MuConstant">1</span>:offset<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">3</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Identifier">reply</span><span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">34</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Global">memory*</span> <span class="Delimiter">(</span>obj <span class="Constant">1</span> t  <span class="Constant">2</span> <span class="Constant">1</span><span class="Delimiter">))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'jump-if' is a conditional 'jump'&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;jump-if-fallthrough&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:boolean <span class="Op">&lt;-</span> equal <span class="MuConstant">1</span>:literal <span class="MuConstant">2</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Identifier">jump-if</span> <span class="Constant">3</span>:boolean <span class="MuConstant">1</span>:offset<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">3</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Identifier">reply</span><span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">34</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Global">memory*</span> <span class="Delimiter">(</span>obj <span class="Constant">1</span> nil  <span class="Constant">2</span> <span class="Constant">3</span><span class="Delimiter">))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - if 'jump-if's first arg is false, it doesn't skip any instructions&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;jump-if-backward&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">2</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">1</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Comment">; loop</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> add <span class="Constant">2</span>:integer <span class="Constant">2</span>:integer<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:boolean <span class="Op">&lt;-</span> equal <span class="Constant">1</span>:integer <span class="Constant">2</span>:integer<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Identifier">jump-if</span> <span class="Constant">3</span>:boolean <span class="MuConstant">-3</span>:offset<span class="Delimiter">)</span>  <span class="Comment">; to loop</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">4</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">3</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Identifier">reply</span><span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">34</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Global">memory*</span> <span class="Delimiter">(</span>obj <span class="Constant">1</span> <span class="Constant">2</span>  <span class="Constant">2</span> <span class="Constant">4</span>  <span class="Constant">3</span> nil  <span class="Constant">4</span> <span class="Constant">3</span><span class="Delimiter">))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'jump-if' can take a negative offset to make backward jumps&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;jump-label&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">2</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">1</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Identifier">loop</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> add <span class="Constant">2</span>:integer <span class="Constant">2</span>:integer<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:boolean <span class="Op">&lt;-</span> equal <span class="Constant">1</span>:integer <span class="Constant">2</span>:integer<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Identifier">jump-if</span> <span class="Constant">3</span>:boolean <span class="Identifier">loop</span>:offset<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">4</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">3</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Identifier">reply</span><span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">34</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="CommentedCode">;? (set dump-trace*)</span>
<span class="CommentedCode">;? (= dump-trace* (obj whitelist '(&quot;-&quot;)))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Global">memory*</span> <span class="Delimiter">(</span>obj <span class="Constant">1</span> <span class="Constant">2</span>  <span class="Constant">2</span> <span class="Constant">4</span>  <span class="Constant">3</span> nil  <span class="Constant">4</span> <span class="Constant">3</span><span class="Delimiter">))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'jump-if' can take a negative offset to make backward jumps&quot;</span><span class="Delimiter">))</span>
<span class="CommentedCode">;? (quit)</span>

<span class="Comment">; Data movement relies on addressing modes:</span>
<span class="Comment">;   'direct' - refers to a memory location; default for most types.</span>
<span class="Comment">;   'literal' - directly encoded in the code; implicit for some types like 'offset'.</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;direct-addressing&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">34</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="Constant">1</span>:integer<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Global">memory*</span> <span class="Delimiter">(</span>obj <span class="Constant">1</span> <span class="Constant">34</span>  <span class="Constant">2</span> <span class="Constant">34</span><span class="Delimiter">))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'copy' performs direct addressing&quot;</span><span class="Delimiter">))</span>

<span class="Comment">; 'Indirect' addressing refers to an address stored in a memory location.</span>
<span class="Comment">; Indicated by the metadata 'deref'. Usually requires an address type.</span>
<span class="Comment">; In the test below, the memory location 1 contains '2', so an indirect read</span>
<span class="Comment">; of location 1 returns the value of location 2.</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;indirect-addressing&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer-address <span class="Op">&lt;-</span> copy <span class="MuConstant">2</span>:literal<span class="Delimiter">)</span>  <span class="Comment">; unsafe; can't do this in general</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">34</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:integer <span class="Op">&lt;-</span> copy <span class="Constant">1</span>:integer-address/deref<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Global">memory*</span> <span class="Delimiter">(</span>obj <span class="Constant">1</span> <span class="Constant">2</span>  <span class="Constant">2</span> <span class="Constant">34</span>  <span class="Constant">3</span> <span class="Constant">34</span><span class="Delimiter">))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'copy' performs indirect addressing&quot;</span><span class="Delimiter">))</span>

<span class="Comment">; Output args can use indirect addressing. In the test below the value is</span>
<span class="Comment">; stored at the location stored in location 1 (i.e. location 2).</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;indirect-addressing-oarg&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer-address <span class="Op">&lt;-</span> copy <span class="MuConstant">2</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">34</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer-address/deref <span class="Op">&lt;-</span> add <span class="Constant">2</span>:integer <span class="MuConstant">2</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Global">memory*</span> <span class="Delimiter">(</span>obj <span class="Constant">1</span> <span class="Constant">2</span>  <span class="Constant">2</span> <span class="Constant">36</span><span class="Delimiter">))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - instructions can perform indirect addressing on output arg&quot;</span><span class="Delimiter">))</span>

<span class="SalientComment">;; Compound data types</span>
<span class="Comment">;</span>
<span class="Comment">; Until now we've dealt with scalar types like integers and booleans and</span>
<span class="Comment">; addresses, where mu looks like other assembly languages. In addition, mu</span>
<span class="Comment">; provides first-class support for compound types: arrays and and-records.</span>
<span class="Comment">;</span>
<span class="Comment">; 'get' accesses fields in and-records</span>
<span class="Comment">; 'index' accesses indices in arrays</span>
<span class="Comment">;</span>
<span class="Comment">; Both operations require knowledge about the types being worked on, so all</span>
<span class="Comment">; types used in mu programs are defined in a single global system-wide table</span>
<span class="Comment">; (see type* in mu.arc for the complete list of types; we'll add to it over</span>
<span class="Comment">; time).</span>

<span class="Comment">; first a sanity check that the table of types is consistent</span>
<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>each <span class="Delimiter">(</span>typ typeinfo<span class="Delimiter">)</span> <span class="Global">type*</span>
  <span class="Delimiter">(</span>when typeinfo!and-record
    <span class="Delimiter">(</span>assert <span class="Delimiter">(</span>is typeinfo!size <span class="Delimiter">(</span>len typeinfo!elems<span class="Delimiter">)))</span>
    <span class="Delimiter">(</span>when typeinfo!fields
      <span class="Delimiter">(</span>assert <span class="Delimiter">(</span>is typeinfo!size <span class="Delimiter">(</span>len typeinfo!fields<span class="Delimiter">))))))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;get-record&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">34</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:boolean <span class="Op">&lt;-</span> copy <span class="MuConstant">nil</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:boolean <span class="Op">&lt;-</span> get <span class="Constant">1</span>:integer-boolean-pair <span class="MuConstant">1</span>:offset<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">4</span>:integer <span class="Op">&lt;-</span> get <span class="Constant">1</span>:integer-boolean-pair <span class="MuConstant">0</span>:offset<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="CommentedCode">;? (set dump-trace*)</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Global">memory*</span> <span class="Delimiter">(</span>obj <span class="Constant">1</span> <span class="Constant">34</span>  <span class="Constant">2</span> nil  <span class="Constant">3</span> nil  <span class="Constant">4</span> <span class="Constant">34</span><span class="Delimiter">))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'get' accesses fields of and-records&quot;</span><span class="Delimiter">))</span>
<span class="CommentedCode">;? (quit)</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;get-indirect&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">34</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:boolean <span class="Op">&lt;-</span> copy <span class="MuConstant">nil</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:integer-boolean-pair-address <span class="Op">&lt;-</span> copy <span class="MuConstant">1</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">4</span>:boolean <span class="Op">&lt;-</span> get <span class="Constant">3</span>:integer-boolean-pair-address/deref <span class="MuConstant">1</span>:offset<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">5</span>:integer <span class="Op">&lt;-</span> get <span class="Constant">3</span>:integer-boolean-pair-address/deref <span class="MuConstant">0</span>:offset<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="CommentedCode">;? (set dump-trace*)</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Global">memory*</span> <span class="Delimiter">(</span>obj <span class="Constant">1</span> <span class="Constant">34</span>  <span class="Constant">2</span> nil  <span class="Constant">3</span> <span class="Constant">1</span>  <span class="Constant">4</span> nil  <span class="Constant">5</span> <span class="Constant">34</span><span class="Delimiter">))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'get' accesses fields of and-record address&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;get-indirect-repeated&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">34</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">35</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">36</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">4</span>:integer-point-pair-address <span class="Op">&lt;-</span> copy <span class="MuConstant">1</span>:literal<span class="Delimiter">)</span>  <span class="Comment">; unsafe</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">5</span>:integer-point-pair-address-address <span class="Op">&lt;-</span> copy <span class="MuConstant">4</span>:literal<span class="Delimiter">)</span>  <span class="Comment">; unsafe</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">6</span>:integer-integer-pair <span class="Op">&lt;-</span> get <span class="Constant">5</span>:integer-point-pair-address-address/deref/deref <span class="MuConstant">1</span>:offset<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">8</span>:integer <span class="Op">&lt;-</span> get <span class="Constant">5</span>:integer-point-pair-address-address/deref/deref <span class="MuConstant">0</span>:offset<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~memory-contains <span class="Constant">6</span> <span class="Delimiter">'(</span><span class="Constant">35</span> <span class="Constant">36</span> <span class="Constant">34</span><span class="Delimiter">))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'get' can deref multiple times&quot;</span><span class="Delimiter">))</span>
<span class="CommentedCode">;? (quit)</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;get-compound-field&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">34</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">35</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">36</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">4</span>:integer-integer-pair <span class="Op">&lt;-</span> get <span class="Constant">1</span>:integer-point-pair <span class="MuConstant">1</span>:offset<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Global">memory*</span> <span class="Delimiter">(</span>obj <span class="Constant">1</span> <span class="Constant">34</span>  <span class="Constant">2</span> <span class="Constant">35</span>  <span class="Constant">3</span> <span class="Constant">36</span>  <span class="Constant">4</span> <span class="Constant">35</span>  <span class="Constant">5</span> <span class="Constant">36</span><span class="Delimiter">))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'get' accesses fields spanning multiple locations&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;get-address&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">34</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:boolean <span class="Op">&lt;-</span> copy <span class="MuConstant">t</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:boolean-address <span class="Op">&lt;-</span> get-address <span class="Constant">1</span>:integer-boolean-pair <span class="MuConstant">1</span>:offset<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Global">memory*</span> <span class="Delimiter">(</span>obj <span class="Constant">1</span> <span class="Constant">34</span>  <span class="Constant">2</span> t  <span class="Constant">3</span> <span class="Constant">2</span><span class="Delimiter">))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'get-address' returns address of fields of and-records&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;get-address-indirect&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">34</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:boolean <span class="Op">&lt;-</span> copy <span class="MuConstant">t</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:integer-boolean-pair-address <span class="Op">&lt;-</span> copy <span class="MuConstant">1</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">4</span>:boolean-address <span class="Op">&lt;-</span> get-address <span class="Constant">3</span>:integer-boolean-pair-address/deref <span class="MuConstant">1</span>:offset<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Global">memory*</span> <span class="Delimiter">(</span>obj <span class="Constant">1</span> <span class="Constant">34</span>  <span class="Constant">2</span> t  <span class="Constant">3</span> <span class="Constant">1</span>  <span class="Constant">4</span> <span class="Constant">2</span><span class="Delimiter">))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'get-address' accesses fields of and-record address&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;index-literal&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">2</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">23</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:boolean <span class="Op">&lt;-</span> copy <span class="MuConstant">nil</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">4</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">24</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">5</span>:boolean <span class="Op">&lt;-</span> copy <span class="MuConstant">t</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">6</span>:integer-boolean-pair <span class="Op">&lt;-</span> index <span class="Constant">1</span>:integer-boolean-pair-array <span class="MuConstant">1</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Global">memory*</span> <span class="Delimiter">(</span>obj <span class="Constant">1</span> <span class="Constant">2</span>  <span class="Constant">2</span> <span class="Constant">23</span> <span class="Constant">3</span> nil  <span class="Constant">4</span> <span class="Constant">24</span> <span class="Constant">5</span> t  <span class="Constant">6</span> <span class="Constant">24</span> <span class="Constant">7</span> t<span class="Delimiter">))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'index' accesses indices of arrays&quot;</span><span class="Delimiter">))</span>
<span class="CommentedCode">;? (quit)</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;index-direct&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">2</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">23</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:boolean <span class="Op">&lt;-</span> copy <span class="MuConstant">nil</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">4</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">24</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">5</span>:boolean <span class="Op">&lt;-</span> copy <span class="MuConstant">t</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">6</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">1</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">7</span>:integer-boolean-pair <span class="Op">&lt;-</span> index <span class="Constant">1</span>:integer-boolean-pair-array <span class="Constant">6</span>:integer<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Global">memory*</span> <span class="Delimiter">(</span>obj <span class="Constant">1</span> <span class="Constant">2</span>  <span class="Constant">2</span> <span class="Constant">23</span> <span class="Constant">3</span> nil  <span class="Constant">4</span> <span class="Constant">24</span> <span class="Constant">5</span> t  <span class="Constant">6</span> <span class="Constant">1</span>  <span class="Constant">7</span> <span class="Constant">24</span> <span class="Constant">8</span> t<span class="Delimiter">))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'index' accesses indices of arrays&quot;</span><span class="Delimiter">))</span>
<span class="CommentedCode">;? (quit)</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;index-indirect&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">2</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">23</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:boolean <span class="Op">&lt;-</span> copy <span class="MuConstant">nil</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">4</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">24</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">5</span>:boolean <span class="Op">&lt;-</span> copy <span class="MuConstant">t</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">6</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">1</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">7</span>:integer-boolean-pair-array-address <span class="Op">&lt;-</span> copy <span class="MuConstant">1</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">8</span>:integer-boolean-pair <span class="Op">&lt;-</span> index <span class="Constant">7</span>:integer-boolean-pair-array-address/deref <span class="Constant">6</span>:integer<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="CommentedCode">;? (= dump-trace* (obj blacklist '(&quot;sz&quot; &quot;m&quot; &quot;setm&quot; &quot;addr&quot; &quot;cvt0&quot; &quot;cvt1&quot;)))</span>
<span class="CommentedCode">;? (set dump-trace*)</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Global">memory*</span> <span class="Delimiter">(</span>obj <span class="Constant">1</span> <span class="Constant">2</span>  <span class="Constant">2</span> <span class="Constant">23</span> <span class="Constant">3</span> nil  <span class="Constant">4</span> <span class="Constant">24</span> <span class="Constant">5</span> t  <span class="Constant">6</span> <span class="Constant">1</span>  <span class="Constant">7</span> <span class="Constant">1</span>  <span class="Constant">8</span> <span class="Constant">24</span> <span class="Constant">9</span> t<span class="Delimiter">))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'index' accesses indices of array address&quot;</span><span class="Delimiter">))</span>
<span class="CommentedCode">;? (quit)</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;index-indirect-multiple&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">4</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">23</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">24</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">4</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">25</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">5</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">26</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">6</span>:integer-array-address <span class="Op">&lt;-</span> copy <span class="MuConstant">1</span>:literal<span class="Delimiter">)</span>  <span class="Comment">; unsafe</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">7</span>:integer-array-address-address <span class="Op">&lt;-</span> copy <span class="MuConstant">6</span>:literal<span class="Delimiter">)</span>  <span class="Comment">; unsafe</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">8</span>:integer <span class="Op">&lt;-</span> index <span class="Constant">7</span>:integer-array-address-address/deref/deref <span class="MuConstant">1</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Global">memory*</span><span class="Constant">.8</span> <span class="Constant">24</span><span class="Delimiter">)</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'index' can deref multiple times&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;index-address&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">2</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">23</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:boolean <span class="Op">&lt;-</span> copy <span class="MuConstant">nil</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">4</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">24</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">5</span>:boolean <span class="Op">&lt;-</span> copy <span class="MuConstant">t</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">6</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">1</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">7</span>:integer-boolean-pair-address <span class="Op">&lt;-</span> index-address <span class="Constant">1</span>:integer-boolean-pair-array <span class="Constant">6</span>:integer<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Global">memory*</span> <span class="Delimiter">(</span>obj <span class="Constant">1</span> <span class="Constant">2</span>  <span class="Constant">2</span> <span class="Constant">23</span> <span class="Constant">3</span> nil  <span class="Constant">4</span> <span class="Constant">24</span> <span class="Constant">5</span> t  <span class="Constant">6</span> <span class="Constant">1</span>  <span class="Constant">7</span> <span class="Constant">4</span><span class="Delimiter">))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'index-address' returns addresses of indices of arrays&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;index-address-indirect&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">2</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">23</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:boolean <span class="Op">&lt;-</span> copy <span class="MuConstant">nil</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">4</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">24</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">5</span>:boolean <span class="Op">&lt;-</span> copy <span class="MuConstant">t</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">6</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">1</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">7</span>:integer-boolean-pair-array-address <span class="Op">&lt;-</span> copy <span class="MuConstant">1</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">8</span>:integer-boolean-pair-address <span class="Op">&lt;-</span> index-address <span class="Constant">7</span>:integer-boolean-pair-array-address/deref <span class="Constant">6</span>:integer<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Global">memory*</span> <span class="Delimiter">(</span>obj <span class="Constant">1</span> <span class="Constant">2</span>  <span class="Constant">2</span> <span class="Constant">23</span> <span class="Constant">3</span> nil  <span class="Constant">4</span> <span class="Constant">24</span> <span class="Constant">5</span> t  <span class="Constant">6</span> <span class="Constant">1</span>  <span class="Constant">7</span> <span class="Constant">1</span>  <span class="Constant">8</span> <span class="Constant">4</span><span class="Delimiter">))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'index-address' returns addresses of indices of array addresses&quot;</span><span class="Delimiter">))</span>

<span class="Comment">; Array values know their length. Record lengths are saved in the types table.</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;len-array&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">2</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">23</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:boolean <span class="Op">&lt;-</span> copy <span class="MuConstant">nil</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">4</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">24</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">5</span>:boolean <span class="Op">&lt;-</span> copy <span class="MuConstant">t</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">6</span>:integer <span class="Op">&lt;-</span> length <span class="Constant">1</span>:integer-boolean-pair-array<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Global">memory*</span><span class="Constant">.6</span> <span class="Constant">2</span><span class="Delimiter">)</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'length' of array&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;len-array-indirect&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">2</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">23</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:boolean <span class="Op">&lt;-</span> copy <span class="MuConstant">nil</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">4</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">24</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">5</span>:boolean <span class="Op">&lt;-</span> copy <span class="MuConstant">t</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">6</span>:integer-address <span class="Op">&lt;-</span> copy <span class="MuConstant">1</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">7</span>:integer <span class="Op">&lt;-</span> length <span class="Constant">6</span>:integer-boolean-pair-array-address/deref<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="CommentedCode">;? (set dump-trace*)</span>
<span class="CommentedCode">;? (= dump-trace* (obj blacklist '(&quot;sz&quot; &quot;m&quot; &quot;setm&quot; &quot;addr&quot; &quot;cvt0&quot; &quot;cvt1&quot;)))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Global">memory*</span><span class="Constant">.7</span> <span class="Constant">2</span><span class="Delimiter">)</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'length' of array address&quot;</span><span class="Delimiter">))</span>

<span class="Comment">; 'sizeof' is a helper to determine the amount of memory required by a type.</span>
<span class="Comment">; Only for non-arrays.</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;sizeof-record&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> sizeof integer-boolean-pair:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Global">memory*</span><span class="Constant">.1</span> <span class="Constant">2</span><span class="Delimiter">)</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'sizeof' returns space required by arg&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;sizeof-record-not-len&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> sizeof integer-point-pair:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>is <span class="Global">memory*</span><span class="Constant">.1</span> <span class="Constant">2</span><span class="Delimiter">)</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'sizeof' is different from number of elems&quot;</span><span class="Delimiter">))</span>

<span class="Comment">; Regardless of a type's length, you can move it around just like a primitive.</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;copy-record&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">34</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:boolean <span class="Op">&lt;-</span> copy <span class="MuConstant">nil</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">4</span>:boolean <span class="Op">&lt;-</span> copy <span class="MuConstant">t</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:integer-boolean-pair <span class="Op">&lt;-</span> copy <span class="Constant">1</span>:integer-boolean-pair<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Global">memory*</span> <span class="Delimiter">(</span>obj <span class="Constant">1</span> <span class="Constant">34</span>  <span class="Constant">2</span> nil  <span class="Constant">3</span> <span class="Constant">34</span>  <span class="Constant">4</span> nil<span class="Delimiter">))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - ops can operate on records spanning multiple locations&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;copy-record2&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">34</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">35</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">36</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">4</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">5</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">6</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">4</span>:integer-point-pair <span class="Op">&lt;-</span> copy <span class="Constant">1</span>:integer-point-pair<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="CommentedCode">;? (= dump-trace* (obj whitelist '(&quot;run&quot; &quot;sizeof&quot;)))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Global">memory*</span> <span class="Delimiter">(</span>obj <span class="Constant">1</span> <span class="Constant">34</span>  <span class="Constant">2</span> <span class="Constant">35</span>  <span class="Constant">3</span> <span class="Constant">36</span>
                       <span class="Comment">; result</span>
                       <span class="Constant">4</span> <span class="Constant">34</span>  <span class="Constant">5</span> <span class="Constant">35</span>  <span class="Constant">6</span> <span class="Constant">36</span><span class="Delimiter">))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - ops can operate on records with fields spanning multiple locations&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">)</span>  <span class="Comment">; section 20</span>

<span class="Delimiter">(</span>section <span class="Constant">100</span>

<span class="Comment">; A special kind of record is the 'tagged type'. It lets us represent</span>
<span class="Comment">; dynamically typed values, which save type information in memory rather than</span>
<span class="Comment">; in the code to use them. This will let us do things like create heterogenous</span>
<span class="Comment">; lists containing both integers and strings. Tagged values admit two</span>
<span class="Comment">; operations:</span>
<span class="Comment">;</span>
<span class="Comment">;   'save-type' - turns a regular value into a tagged-value of the appropriate type</span>
<span class="Comment">;   'maybe-coerce' - turns a tagged value into a regular value if the type matches</span>
<span class="Comment">;</span>
<span class="Comment">; The payload of a tagged value must occupy just one location. Save pointers</span>
<span class="Comment">; to records.</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;tagged-value&quot;</span><span class="Delimiter">)</span>
<span class="CommentedCode">;? (= dump-trace* (obj blacklist '(&quot;sz&quot; &quot;m&quot; &quot;setm&quot; &quot;addr&quot; &quot;cvt0&quot; &quot;cvt1&quot;)))</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:type <span class="Op">&lt;-</span> copy integer:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">34</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:integer <span class="Constant">4</span>:boolean <span class="Op">&lt;-</span> maybe-coerce <span class="Constant">1</span>:tagged-value integer:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="CommentedCode">;? (set dump-trace*)</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn completed-routines*)</span>
<span class="Delimiter">(</span>each routine <span class="Global">completed-routines*</span>
  <span class="Delimiter">(</span>aif rep.routine!error <span class="Delimiter">(</span>prn <span class="Constant">&quot;error - &quot;</span> it<span class="Delimiter">)))</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span><span class="Normal">or</span> <span class="Delimiter">(</span>~is <span class="Global">memory*</span><span class="Constant">.3</span> <span class="Constant">34</span><span class="Delimiter">)</span>
        <span class="Delimiter">(</span>~is <span class="Global">memory*</span><span class="Constant">.4</span> t<span class="Delimiter">))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'maybe-coerce' copies value only if type tag matches&quot;</span><span class="Delimiter">))</span>
<span class="CommentedCode">;? (quit)</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;tagged-value-2&quot;</span><span class="Delimiter">)</span>
<span class="CommentedCode">;? (set dump-trace*)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:type <span class="Op">&lt;-</span> copy integer-address:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">34</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:boolean <span class="Constant">4</span>:boolean <span class="Op">&lt;-</span> maybe-coerce <span class="Constant">1</span>:tagged-value boolean:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span><span class="Normal">or</span> <span class="Delimiter">(</span>~is <span class="Global">memory*</span><span class="Constant">.3</span> <span class="Constant">0</span><span class="Delimiter">)</span>
        <span class="Delimiter">(</span>~is <span class="Global">memory*</span><span class="Constant">.4</span> nil<span class="Delimiter">))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'maybe-coerce' doesn't copy value when type tag doesn't match&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;save-type&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">34</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:tagged-value <span class="Op">&lt;-</span> save-type <span class="Constant">1</span>:integer<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Global">memory*</span> <span class="Delimiter">(</span>obj  <span class="Constant">1</span> <span class="Constant">34</span>  <span class="Constant">2</span> <span class="Delimiter">'</span>integer  <span class="Constant">3</span> <span class="Constant">34</span><span class="Delimiter">))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'save-type' saves the type of a value at runtime, turning it into a tagged-value&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;init-tagged-value&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">34</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:tagged-value-address <span class="Op">&lt;-</span> init-tagged-value integer:literal <span class="Constant">1</span>:integer<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:integer <span class="Constant">4</span>:boolean <span class="Op">&lt;-</span> maybe-coerce <span class="Constant">2</span>:tagged-value-address/deref integer:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="CommentedCode">;? (= dump-trace* (obj blacklist '(&quot;sz&quot; &quot;m&quot; &quot;setm&quot; &quot;addr&quot; &quot;cvt0&quot; &quot;cvt1&quot; &quot;sizeof&quot;)))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span><span class="Normal">or</span> <span class="Delimiter">(</span>~is <span class="Global">memory*</span><span class="Constant">.3</span> <span class="Constant">34</span><span class="Delimiter">)</span>
        <span class="Delimiter">(</span>~is <span class="Global">memory*</span><span class="Constant">.4</span> t<span class="Delimiter">))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'init-tagged-value' is the converse of 'maybe-coerce'&quot;</span><span class="Delimiter">))</span>
<span class="CommentedCode">;? (quit)</span>

<span class="Comment">; Now that we can package values together with their types, we can construct a</span>
<span class="Comment">; dynamically typed list.</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;list&quot;</span><span class="Delimiter">)</span>
<span class="CommentedCode">;? (set dump-trace*)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Comment">; 1 points at first node: tagged-value (int 34)</span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:list-address <span class="Op">&lt;-</span> new list:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:tagged-value-address <span class="Op">&lt;-</span> list-value-address <span class="Constant">1</span>:list-address<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:type-address <span class="Op">&lt;-</span> get-address <span class="Constant">2</span>:tagged-value-address/deref type:offset<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:type-address/deref <span class="Op">&lt;-</span> copy integer:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">4</span>:location <span class="Op">&lt;-</span> get-address <span class="Constant">2</span>:tagged-value-address/deref payload:offset<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">4</span>:location/deref <span class="Op">&lt;-</span> copy <span class="MuConstant">34</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">5</span>:list-address-address <span class="Op">&lt;-</span> get-address <span class="Constant">1</span>:list-address/deref cdr:offset<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">5</span>:list-address-address/deref <span class="Op">&lt;-</span> new list:literal<span class="Delimiter">)</span></span>
      <span class="Comment">; 6 points at second node: tagged-value (boolean t)</span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">6</span>:list-address <span class="Op">&lt;-</span> copy <span class="Constant">5</span>:list-address-address/deref<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">7</span>:tagged-value-address <span class="Op">&lt;-</span> list-value-address <span class="Constant">6</span>:list-address<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">8</span>:type-address <span class="Op">&lt;-</span> get-address <span class="Constant">7</span>:tagged-value-address/deref type:offset<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">8</span>:type-address/deref <span class="Op">&lt;-</span> copy boolean:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">9</span>:location <span class="Op">&lt;-</span> get-address <span class="Constant">7</span>:tagged-value-address/deref payload:offset<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">9</span>:location/deref <span class="Op">&lt;-</span> copy <span class="MuConstant">t</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">10</span>:list-address <span class="Op">&lt;-</span> get <span class="Constant">6</span>:list-address/deref <span class="MuConstant">1</span>:offset<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span><span class="Normal">let</span> routine make-routine!main
  <span class="Delimiter">(</span>enq routine <span class="Global">running-routines*</span><span class="Delimiter">)</span>
  <span class="Delimiter">(</span><span class="Normal">let</span> first rep.routine!alloc
<span class="CommentedCode">;?     (= dump-trace* (obj whitelist '(&quot;run&quot;)))</span>
<span class="CommentedCode">;?     (set dump-trace*)</span>
    <span class="Delimiter">(</span>run<span class="Delimiter">)</span>
<span class="CommentedCode">;?     (prn memory*)</span>
    <span class="Delimiter">(</span>each routine <span class="Global">completed-routines*</span>
      <span class="Delimiter">(</span>aif rep.routine!error <span class="Delimiter">(</span>prn <span class="Constant">&quot;error - &quot;</span> it<span class="Delimiter">)))</span>
    <span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span><span class="Normal">or</span> <span class="Delimiter">(</span>~all first <span class="Delimiter">(</span>map <span class="Global">memory*</span> <span class="Delimiter">'(</span><span class="Constant">1</span> <span class="Constant">2</span> <span class="Constant">3</span><span class="Delimiter">)))</span>
            <span class="Delimiter">(</span>~is <span class="Global">memory*</span>.first  <span class="Delimiter">'</span>integer<span class="Delimiter">)</span>
            <span class="Delimiter">(</span>~is <span class="Global">memory*</span><span class="Constant">.4</span> <span class="Delimiter">(</span>+ first <span class="Constant">1</span><span class="Delimiter">))</span>
            <span class="Delimiter">(</span>~is <span class="Delimiter">(</span><span class="Global">memory*</span> <span class="Delimiter">(</span>+ first <span class="Constant">1</span><span class="Delimiter">))</span>  <span class="Constant">34</span><span class="Delimiter">)</span>
            <span class="Delimiter">(</span>~is <span class="Global">memory*</span><span class="Constant">.5</span> <span class="Delimiter">(</span>+ first <span class="Constant">2</span><span class="Delimiter">))</span>
            <span class="Delimiter">(</span><span class="Normal">let</span> second <span class="Global">memory*</span><span class="Constant">.6</span>
              <span class="Delimiter">(</span><span class="Normal">or</span>
                <span class="Delimiter">(</span>~is <span class="Delimiter">(</span><span class="Global">memory*</span> <span class="Delimiter">(</span>+ first <span class="Constant">2</span><span class="Delimiter">))</span> second<span class="Delimiter">)</span>
                <span class="Delimiter">(</span>~all second <span class="Delimiter">(</span>map <span class="Global">memory*</span> <span class="Delimiter">'(</span><span class="Constant">6</span> <span class="Constant">7</span> <span class="Constant">8</span><span class="Delimiter">)))</span>
                <span class="Delimiter">(</span>~is <span class="Global">memory*</span>.second <span class="Delimiter">'</span>boolean<span class="Delimiter">)</span>
                <span class="Delimiter">(</span>~is <span class="Global">memory*</span><span class="Constant">.9</span> <span class="Delimiter">(</span>+ second <span class="Constant">1</span><span class="Delimiter">))</span>
                <span class="Delimiter">(</span>~is <span class="Delimiter">(</span><span class="Global">memory*</span> <span class="Delimiter">(</span>+ second <span class="Constant">1</span><span class="Delimiter">))</span> t<span class="Delimiter">)</span>
                <span class="Delimiter">(</span>~is <span class="Global">memory*</span><span class="Constant">.10</span> nil<span class="Delimiter">))))</span>
      <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - lists can contain elements of different types&quot;</span><span class="Delimiter">))))</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function test2 <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">10</span>:list-address <span class="Op">&lt;-</span> list-next <span class="Constant">1</span>:list-address<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="CommentedCode">;? (set dump-trace*)</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>test2<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span>each routine <span class="Global">completed-routines*</span>
  <span class="Delimiter">(</span>aif rep.routine!error <span class="Delimiter">(</span>prn <span class="Constant">&quot;error - &quot;</span> it<span class="Delimiter">)))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Global">memory*</span><span class="Constant">.10</span> <span class="Global">memory*</span><span class="Constant">.6</span><span class="Delimiter">)</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'list-next can move a list pointer to the next node&quot;</span><span class="Delimiter">))</span>
<span class="CommentedCode">;? (quit)</span>

<span class="Comment">; 'init-list' takes a variable number of args and constructs a list containing</span>
<span class="Comment">; them. Just integers for now.</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;init-list&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> init-list <span class="MuConstant">3</span>:literal <span class="MuConstant">4</span>:literal <span class="MuConstant">5</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="CommentedCode">;? (= dump-trace* (obj blacklist '(&quot;sz&quot; &quot;m&quot; &quot;setm&quot; &quot;addr&quot; &quot;cvt0&quot; &quot;cvt1&quot; &quot;sizeof&quot;)))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">let</span> first <span class="Global">memory*</span><span class="Constant">.1</span>
<span class="CommentedCode">;?   (prn first)</span>
  <span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span><span class="Normal">or</span> <span class="Delimiter">(</span>~is <span class="Global">memory*</span>.first  <span class="Delimiter">'</span>integer<span class="Delimiter">)</span>
          <span class="Delimiter">(</span>~is <span class="Delimiter">(</span><span class="Global">memory*</span> <span class="Delimiter">(</span>+ first <span class="Constant">1</span><span class="Delimiter">))</span>  <span class="Constant">3</span><span class="Delimiter">)</span>
          <span class="Delimiter">(</span><span class="Normal">let</span> second <span class="Delimiter">(</span><span class="Global">memory*</span> <span class="Delimiter">(</span>+ first <span class="Constant">2</span><span class="Delimiter">))</span>
<span class="CommentedCode">;?             (prn second)</span>
            <span class="Delimiter">(</span><span class="Normal">or</span> <span class="Delimiter">(</span>~is <span class="Global">memory*</span>.second <span class="Delimiter">'</span>integer<span class="Delimiter">)</span>
                <span class="Delimiter">(</span>~is <span class="Delimiter">(</span><span class="Global">memory*</span> <span class="Delimiter">(</span>+ second <span class="Constant">1</span><span class="Delimiter">))</span> <span class="Constant">4</span><span class="Delimiter">)</span>
                <span class="Delimiter">(</span><span class="Normal">let</span> third <span class="Delimiter">(</span><span class="Global">memory*</span> <span class="Delimiter">(</span>+ second <span class="Constant">2</span><span class="Delimiter">))</span>
<span class="CommentedCode">;?                   (prn third)</span>
                  <span class="Delimiter">(</span><span class="Normal">or</span> <span class="Delimiter">(</span>~is <span class="Global">memory*</span>.third <span class="Delimiter">'</span>integer<span class="Delimiter">)</span>
                      <span class="Delimiter">(</span>~is <span class="Delimiter">(</span><span class="Global">memory*</span> <span class="Delimiter">(</span>+ third <span class="Constant">1</span><span class="Delimiter">))</span> <span class="Constant">5</span><span class="Delimiter">)</span>
                      <span class="Delimiter">(</span>~is <span class="Delimiter">(</span><span class="Global">memory*</span> <span class="Delimiter">(</span>+ third <span class="Constant">2</span><span class="Delimiter">)</span> nil<span class="Delimiter">)))))))</span>
    <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'init-list' can construct a list of integers&quot;</span><span class="Delimiter">)))</span>

<span class="Delimiter">)</span>  <span class="Comment">; section 100</span>

<span class="Delimiter">(</span>section <span class="Constant">20</span>

<span class="SalientComment">;; Functions</span>
<span class="Comment">;</span>
<span class="Comment">; Just like the table of types is centralized, functions are conceptualized as</span>
<span class="Comment">; a centralized table of operations just like the &quot;primitives&quot; we've seen so</span>
<span class="Comment">; far. If you create a function you can call it like any other op.</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;new-fn&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function test1 <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:integer <span class="Op">&lt;-</span> add <span class="Constant">1</span>:integer <span class="Constant">2</span>:integer<span class="Delimiter">)</span></span>
     <span class="Delimiter">])</span>
    <span class="Mu"><span class="Delimiter">(</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">1</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">3</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span>test1<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Global">memory*</span> <span class="Delimiter">(</span>obj <span class="Constant">1</span> <span class="Constant">1</span>  <span class="Constant">2</span> <span class="Constant">3</span>  <span class="Constant">3</span> <span class="Constant">4</span><span class="Delimiter">))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - calling a user-defined function runs its instructions&quot;</span><span class="Delimiter">))</span>
<span class="CommentedCode">;? (quit)</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;new-fn-once&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function test1 <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">1</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])</span>
    <span class="Mu"><span class="Delimiter">(</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span>test1<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="CommentedCode">;? (= dump-trace* (obj whitelist '(&quot;run&quot;)))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Constant">2</span> <span class="Global">curr-cycle*</span><span class="Delimiter">)</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - calling a user-defined function runs its instructions exactly once &quot;</span> <span class="Global">curr-cycle*</span><span class="Delimiter">))</span>
<span class="CommentedCode">;? (quit)</span>

<span class="Comment">; User-defined functions communicate with their callers through two</span>
<span class="Comment">; primitives:</span>
<span class="Comment">;</span>
<span class="Comment">;   'arg' - to access inputs</span>
<span class="Comment">;   'reply' - to return outputs</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;new-fn-reply&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function test1 <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:integer <span class="Op">&lt;-</span> add <span class="Constant">1</span>:integer <span class="Constant">2</span>:integer<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Identifier">reply</span><span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">4</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">34</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])</span>
    <span class="Mu"><span class="Delimiter">(</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">1</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">3</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span>test1<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Global">memory*</span> <span class="Delimiter">(</span>obj <span class="Constant">1</span> <span class="Constant">1</span>  <span class="Constant">2</span> <span class="Constant">3</span>  <span class="Constant">3</span> <span class="Constant">4</span><span class="Delimiter">))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'reply' stops executing the current function&quot;</span><span class="Delimiter">))</span>
<span class="CommentedCode">;? (quit)</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;new-fn-reply-nested&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function test1 <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:integer <span class="Op">&lt;-</span> test2<span class="Delimiter">)</span></span>
     <span class="Delimiter">])</span>
    <span class="Mu"><span class="Delimiter">(</span>function test2 <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Identifier">reply</span> <span class="Constant">2</span>:integer<span class="Delimiter">)</span></span>
     <span class="Delimiter">])</span>
    <span class="Mu"><span class="Delimiter">(</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">34</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span>test1<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Global">memory*</span> <span class="Delimiter">(</span>obj <span class="Constant">2</span> <span class="Constant">34</span>  <span class="Constant">3</span> <span class="Constant">34</span><span class="Delimiter">))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'reply' stops executing any callers as necessary&quot;</span><span class="Delimiter">))</span>
<span class="CommentedCode">;? (quit)</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;new-fn-reply-once&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function test1 <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:integer <span class="Op">&lt;-</span> add <span class="Constant">1</span>:integer <span class="Constant">2</span>:integer<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Identifier">reply</span><span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">4</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">34</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])</span>
    <span class="Mu"><span class="Delimiter">(</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">1</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">3</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span>test1<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="CommentedCode">;? (= dump-trace* (obj whitelist '(&quot;run&quot;)))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Constant">5</span> <span class="Global">curr-cycle*</span><span class="Delimiter">)</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'reply' executes instructions exactly once &quot;</span> <span class="Global">curr-cycle*</span><span class="Delimiter">))</span>
<span class="CommentedCode">;? (quit)</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;reply-increments-caller-pc&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function callee <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Identifier">reply</span><span class="Delimiter">)</span></span>
     <span class="Delimiter">])</span>
    <span class="Mu"><span class="Delimiter">(</span>function caller <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>freeze <span class="Global">function*</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>= <span class="Global">routine*</span> <span class="Delimiter">(</span>make-routine <span class="Delimiter">'</span>caller<span class="Delimiter">))</span>
<span class="Delimiter">(</span>assert <span class="Delimiter">(</span>is <span class="Constant">0</span> pc.routine*<span class="Delimiter">))</span>
<span class="Delimiter">(</span>push-stack <span class="Global">routine*</span> <span class="Delimiter">'</span>callee<span class="Delimiter">)</span>  <span class="Comment">; pretend call was at first instruction of caller</span>
<span class="Delimiter">(</span>run-for-time-slice <span class="Constant">1</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Constant">1</span> pc.routine*<span class="Delimiter">)</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'reply' should increment pc in caller (to move past calling instruction)&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;new-fn-arg-sequential&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function test1 <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">4</span>:integer <span class="Op">&lt;-</span> <span class="Identifier">next-input</span><span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">5</span>:integer <span class="Op">&lt;-</span> <span class="Identifier">next-input</span><span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:integer <span class="Op">&lt;-</span> add <span class="Constant">4</span>:integer <span class="Constant">5</span>:integer<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Identifier">reply</span><span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">4</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">34</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])</span>
    <span class="Mu"><span class="Delimiter">(</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">1</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">3</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span>test1 <span class="Constant">1</span>:integer <span class="Constant">2</span>:integer<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Global">memory*</span> <span class="Delimiter">(</span>obj <span class="Constant">1</span> <span class="Constant">1</span>  <span class="Constant">2</span> <span class="Constant">3</span>  <span class="Constant">3</span> <span class="Constant">4</span>
                       <span class="Comment">; test1's temporaries</span>
                       <span class="Constant">4</span> <span class="Constant">1</span>  <span class="Constant">5</span> <span class="Constant">3</span><span class="Delimiter">))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'arg' accesses in order the operands of the most recent function call (the caller)&quot;</span><span class="Delimiter">))</span>
<span class="CommentedCode">;? (quit)</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;new-fn-arg-random-access&quot;</span><span class="Delimiter">)</span>
<span class="CommentedCode">;? (set dump-trace*)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function test1 <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">5</span>:integer <span class="Op">&lt;-</span> <span class="Identifier">input</span> <span class="MuConstant">1</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">4</span>:integer <span class="Op">&lt;-</span> <span class="Identifier">input</span> <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:integer <span class="Op">&lt;-</span> add <span class="Constant">4</span>:integer <span class="Constant">5</span>:integer<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Identifier">reply</span><span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">4</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">34</span>:literal<span class="Delimiter">)</span>  <span class="Comment">; should never run</span></span>
     <span class="Delimiter">])</span>
    <span class="Mu"><span class="Delimiter">(</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">1</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">3</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span>test1 <span class="Constant">1</span>:integer <span class="Constant">2</span>:integer<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Global">memory*</span> <span class="Delimiter">(</span>obj <span class="Constant">1</span> <span class="Constant">1</span>  <span class="Constant">2</span> <span class="Constant">3</span>  <span class="Constant">3</span> <span class="Constant">4</span>
                       <span class="Comment">; test's temporaries</span>
                       <span class="Constant">4</span> <span class="Constant">1</span>  <span class="Constant">5</span> <span class="Constant">3</span><span class="Delimiter">))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'arg' with index can access function call arguments out of order&quot;</span><span class="Delimiter">))</span>
<span class="CommentedCode">;? (quit)</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;new-fn-arg-random-then-sequential&quot;</span><span class="Delimiter">)</span>
<span class="CommentedCode">;? (set dump-trace*)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function test1 <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span>_ <span class="Op">&lt;-</span> <span class="Identifier">input</span> <span class="MuConstant">1</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> <span class="Identifier">next-input</span><span class="Delimiter">)</span>  <span class="Comment">; takes next arg after index 1</span></span>
     <span class="Delimiter">])</span>  <span class="Comment">; should never run</span>
    <span class="Mu"><span class="Delimiter">(</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span>test1 <span class="MuConstant">1</span>:literal <span class="MuConstant">2</span>:literal <span class="MuConstant">3</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Global">memory*</span> <span class="Delimiter">(</span>obj <span class="Constant">1</span> <span class="Constant">3</span><span class="Delimiter">))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'arg' with index resets index for later calls&quot;</span><span class="Delimiter">))</span>
<span class="CommentedCode">;? (quit)</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;new-fn-arg-status&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function test1 <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">4</span>:integer <span class="Constant">5</span>:boolean <span class="Op">&lt;-</span> <span class="Identifier">next-input</span><span class="Delimiter">)</span></span>
     <span class="Delimiter">])</span>
    <span class="Mu"><span class="Delimiter">(</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span>test1 <span class="MuConstant">1</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Global">memory*</span> <span class="Delimiter">(</span>obj <span class="Constant">4</span> <span class="Constant">1</span>  <span class="Constant">5</span> t<span class="Delimiter">))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'arg' sets a second oarg when arg exists&quot;</span><span class="Delimiter">))</span>
<span class="CommentedCode">;? (quit)</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;new-fn-arg-missing&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function test1 <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">4</span>:integer <span class="Op">&lt;-</span> <span class="Identifier">next-input</span><span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">5</span>:integer <span class="Op">&lt;-</span> <span class="Identifier">next-input</span><span class="Delimiter">)</span></span>
     <span class="Delimiter">])</span>
    <span class="Mu"><span class="Delimiter">(</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span>test1 <span class="MuConstant">1</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Global">memory*</span> <span class="Delimiter">(</span>obj <span class="Constant">4</span> <span class="Constant">1</span><span class="Delimiter">))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - missing 'arg' doesn't cause error&quot;</span><span class="Delimiter">))</span>
<span class="CommentedCode">;? (quit)</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;new-fn-arg-missing-2&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function test1 <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">4</span>:integer <span class="Op">&lt;-</span> <span class="Identifier">next-input</span><span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">5</span>:integer <span class="Constant">6</span>:boolean <span class="Op">&lt;-</span> <span class="Identifier">next-input</span><span class="Delimiter">)</span></span>
     <span class="Delimiter">])</span>
    <span class="Mu"><span class="Delimiter">(</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span>test1 <span class="MuConstant">1</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Global">memory*</span> <span class="Delimiter">(</span>obj <span class="Constant">4</span> <span class="Constant">1</span>  <span class="Constant">6</span> nil<span class="Delimiter">))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - missing 'arg' wipes second oarg when provided&quot;</span><span class="Delimiter">))</span>
<span class="CommentedCode">;? (quit)</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;new-fn-arg-missing-3&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function test1 <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">4</span>:integer <span class="Op">&lt;-</span> <span class="Identifier">next-input</span><span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">5</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">34</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">5</span>:integer <span class="Constant">6</span>:boolean <span class="Op">&lt;-</span> <span class="Identifier">next-input</span><span class="Delimiter">)</span></span>
    <span class="Delimiter">])</span>
    <span class="Mu"><span class="Delimiter">(</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span>test1 <span class="MuConstant">1</span>:literal<span class="Delimiter">)</span></span>
    <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Global">memory*</span> <span class="Delimiter">(</span>obj <span class="Constant">4</span> <span class="Constant">1</span>  <span class="Constant">6</span> nil<span class="Delimiter">))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - missing 'arg' consistently wipes its oarg&quot;</span><span class="Delimiter">))</span>
<span class="CommentedCode">;? (quit)</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;new-fn-arg-missing-4&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function test1 <span class="Delimiter">[</span></span>
      <span class="Comment">; if given two args, adds them; if given one arg, increments</span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">4</span>:integer <span class="Op">&lt;-</span> <span class="Identifier">next-input</span><span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">5</span>:integer <span class="Constant">6</span>:boolean <span class="Op">&lt;-</span> <span class="Identifier">next-input</span><span class="Delimiter">)</span></span>
      { <span class="CommentedCode">begin</span>
        <span class="Mu"><span class="Delimiter">(</span><span class="Identifier">break-if</span> <span class="Constant">6</span>:boolean<span class="Delimiter">)</span></span>
        <span class="Mu"><span class="Delimiter">(</span><span class="Constant">5</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">1</span>:literal<span class="Delimiter">)</span></span>
      }
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">7</span>:integer <span class="Op">&lt;-</span> add <span class="Constant">4</span>:integer <span class="Constant">5</span>:integer<span class="Delimiter">)</span></span>
     <span class="Delimiter">])</span>
    <span class="Mu"><span class="Delimiter">(</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span>test1 <span class="MuConstant">34</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="CommentedCode">;? (set dump-trace*)</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Global">memory*</span> <span class="Delimiter">(</span>obj <span class="Constant">4</span> <span class="Constant">34</span>  <span class="Constant">5</span> <span class="Constant">1</span>  <span class="Constant">6</span> nil  <span class="Constant">7</span> <span class="Constant">35</span><span class="Delimiter">))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - function with optional second arg&quot;</span><span class="Delimiter">))</span>
<span class="CommentedCode">;? (quit)</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;new-fn-arg-by-value&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function test1 <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span>  <span class="Comment">; overwrite caller memory</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> <span class="Identifier">next-input</span><span class="Delimiter">)</span></span>
     <span class="Delimiter">])</span>  <span class="Comment">; arg not clobbered</span>
    <span class="Mu"><span class="Delimiter">(</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">34</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span>test1 <span class="Constant">1</span>:integer<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Global">memory*</span> <span class="Delimiter">(</span>obj <span class="Constant">1</span> <span class="Constant">0</span>  <span class="Constant">2</span> <span class="Constant">34</span><span class="Delimiter">))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'arg' passes by value&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;arg-record&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function test1 <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">4</span>:integer-boolean-pair <span class="Op">&lt;-</span> <span class="Identifier">next-input</span><span class="Delimiter">)</span></span>
     <span class="Delimiter">])</span>
    <span class="Mu"><span class="Delimiter">(</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">34</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:boolean <span class="Op">&lt;-</span> copy <span class="MuConstant">nil</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span>test1 <span class="Constant">1</span>:integer-boolean-pair<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Global">memory*</span> <span class="Delimiter">(</span>obj <span class="Constant">1</span> <span class="Constant">34</span>  <span class="Constant">2</span> nil  <span class="Constant">4</span> <span class="Constant">34</span>  <span class="Constant">5</span> nil<span class="Delimiter">))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'arg' can copy records spanning multiple locations&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;arg-record-indirect&quot;</span><span class="Delimiter">)</span>
<span class="CommentedCode">;? (set dump-trace*)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function test1 <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">4</span>:integer-boolean-pair <span class="Op">&lt;-</span> <span class="Identifier">next-input</span><span class="Delimiter">)</span></span>
     <span class="Delimiter">])</span>
    <span class="Mu"><span class="Delimiter">(</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">34</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:boolean <span class="Op">&lt;-</span> copy <span class="MuConstant">nil</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:integer-boolean-pair-address <span class="Op">&lt;-</span> copy <span class="MuConstant">1</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span>test1 <span class="Constant">3</span>:integer-boolean-pair-address/deref<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Global">memory*</span> <span class="Delimiter">(</span>obj <span class="Constant">1</span> <span class="Constant">34</span>  <span class="Constant">2</span> nil  <span class="Constant">3</span> <span class="Constant">1</span>  <span class="Constant">4</span> <span class="Constant">34</span>  <span class="Constant">5</span> nil<span class="Delimiter">))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'arg' can copy records spanning multiple locations in indirect mode&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;new-fn-reply-oarg&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function test1 <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">4</span>:integer <span class="Op">&lt;-</span> <span class="Identifier">next-input</span><span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">5</span>:integer <span class="Op">&lt;-</span> <span class="Identifier">next-input</span><span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">6</span>:integer <span class="Op">&lt;-</span> add <span class="Constant">4</span>:integer <span class="Constant">5</span>:integer<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Identifier">reply</span> <span class="Constant">6</span>:integer<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">4</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">34</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])</span>
    <span class="Mu"><span class="Delimiter">(</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">1</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">3</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:integer <span class="Op">&lt;-</span> test1 <span class="Constant">1</span>:integer <span class="Constant">2</span>:integer<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Global">memory*</span> <span class="Delimiter">(</span>obj <span class="Constant">1</span> <span class="Constant">1</span>  <span class="Constant">2</span> <span class="Constant">3</span>  <span class="Constant">3</span> <span class="Constant">4</span>
                       <span class="Comment">; test1's temporaries</span>
                       <span class="Constant">4</span> <span class="Constant">1</span>  <span class="Constant">5</span> <span class="Constant">3</span>  <span class="Constant">6</span> <span class="Constant">4</span><span class="Delimiter">))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'reply' can take aguments that are returned, or written back into output args of caller&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;new-fn-reply-oarg-multiple&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function test1 <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">4</span>:integer <span class="Op">&lt;-</span> <span class="Identifier">next-input</span><span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">5</span>:integer <span class="Op">&lt;-</span> <span class="Identifier">next-input</span><span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">6</span>:integer <span class="Op">&lt;-</span> add <span class="Constant">4</span>:integer <span class="Constant">5</span>:integer<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Identifier">reply</span> <span class="Constant">6</span>:integer <span class="Constant">5</span>:integer<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">4</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">34</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])</span>
    <span class="Mu"><span class="Delimiter">(</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">1</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">3</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:integer <span class="Constant">7</span>:integer <span class="Op">&lt;-</span> test1 <span class="Constant">1</span>:integer <span class="Constant">2</span>:integer<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Global">memory*</span> <span class="Delimiter">(</span>obj <span class="Constant">1</span> <span class="Constant">1</span>  <span class="Constant">2</span> <span class="Constant">3</span>  <span class="Constant">3</span> <span class="Constant">4</span>    <span class="Constant">7</span> <span class="Constant">3</span>
                         <span class="Comment">; test1's temporaries</span>
                         <span class="Constant">4</span> <span class="Constant">1</span>  <span class="Constant">5</span> <span class="Constant">3</span>  <span class="Constant">6</span> <span class="Constant">4</span><span class="Delimiter">))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'reply' permits a function to return multiple values at once&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;new-fn-prepare-reply&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function test1 <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">4</span>:integer <span class="Op">&lt;-</span> <span class="Identifier">next-input</span><span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">5</span>:integer <span class="Op">&lt;-</span> <span class="Identifier">next-input</span><span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">6</span>:integer <span class="Op">&lt;-</span> add <span class="Constant">4</span>:integer <span class="Constant">5</span>:integer<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span>prepare-reply <span class="Constant">6</span>:integer <span class="Constant">5</span>:integer<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Identifier">reply</span><span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">4</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">34</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])</span>
    <span class="Mu"><span class="Delimiter">(</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">1</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">3</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:integer <span class="Constant">7</span>:integer <span class="Op">&lt;-</span> test1 <span class="Constant">1</span>:integer <span class="Constant">2</span>:integer<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Global">memory*</span> <span class="Delimiter">(</span>obj <span class="Constant">1</span> <span class="Constant">1</span>  <span class="Constant">2</span> <span class="Constant">3</span>  <span class="Constant">3</span> <span class="Constant">4</span>    <span class="Constant">7</span> <span class="Constant">3</span>
                         <span class="Comment">; test1's temporaries</span>
                         <span class="Constant">4</span> <span class="Constant">1</span>  <span class="Constant">5</span> <span class="Constant">3</span>  <span class="Constant">6</span> <span class="Constant">4</span><span class="Delimiter">))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - without args, 'reply' returns values from previous 'prepare-reply'.&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">)</span>  <span class="Comment">; section 20</span>

<span class="Delimiter">(</span>section <span class="Constant">11</span>

<span class="SalientComment">;; Structured programming</span>
<span class="Comment">;</span>
<span class="Comment">; Our jump operators are quite inconvenient to use, so mu provides a</span>
<span class="Comment">; lightweight tool called 'convert-braces' to work in a slightly more</span>
<span class="Comment">; convenient format with nested braces:</span>
<span class="Comment">;</span>
<span class="Comment">;   {</span>
<span class="Comment">;     some instructions</span>
<span class="Comment">;     {</span>
<span class="Comment">;       more instructions</span>
<span class="Comment">;     }</span>
<span class="Comment">;   }</span>
<span class="Comment">;</span>
<span class="Comment">; Braces are like labels in assembly language, they require no special</span>
<span class="Comment">; parsing. The operations 'loop' and 'break' jump to just after the enclosing</span>
<span class="Comment">; '{' and '}' respectively.</span>
<span class="Comment">;</span>
<span class="Comment">; Conditional and unconditional 'loop' and 'break' should give us 80% of the</span>
<span class="Comment">; benefits of the control-flow primitives we're used to in other languages,</span>
<span class="Comment">; like 'if', 'while', 'for', etc.</span>
<span class="Comment">;</span>
<span class="Comment">; Compare 'unquoted blocks' using {} with 'quoted blocks' using [] that we've</span>
<span class="Comment">; gotten used to seeing. Quoted blocks are used by top-level instructions to</span>
<span class="Comment">; provide code without running it.</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;convert-braces&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>= <span class="Global">traces*</span> <span class="Delimiter">(</span>queue<span class="Delimiter">))</span>
<span class="CommentedCode">;? (= dump-trace* (obj whitelist '(&quot;c{0&quot; &quot;c{1&quot;)))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Delimiter">(</span>convert-braces
            <span class="Mu"><span class="Delimiter">'((((</span><span class="Constant">1</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
              <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">2</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
              <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">3</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
              { <span class="CommentedCode">begin</span>  <span class="Comment">; 'begin' is just a hack because racket turns braces into parens</span>
                <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">4</span> boolean<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>not-equal<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="Constant">1</span> integer<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="Constant">3</span> integer<span class="Delimiter">)))</span></span>
                <span class="Mu"><span class="Delimiter">(((</span><span class="Identifier">break-if</span><span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="Constant">4</span> boolean<span class="Delimiter">)))</span></span>
                <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">5</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
              }
              <span class="Mu"><span class="Delimiter">(((</span><span class="Identifier">reply</span><span class="Delimiter">)))))</span></span>
          <span class="Mu"><span class="Delimiter">'((((</span><span class="Constant">1</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
            <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">2</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
            <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">3</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
            <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">4</span> boolean<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>not-equal<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="Constant">1</span> integer<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="Constant">3</span> integer<span class="Delimiter">)))</span></span>
            <span class="Mu"><span class="Delimiter">(((</span><span class="Identifier">jump-if</span><span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="Constant">4</span> boolean<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">1</span> offset<span class="Delimiter">)))</span></span>
            <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">5</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
            <span class="Mu"><span class="Delimiter">(((</span><span class="Identifier">reply</span><span class="Delimiter">)))))</span></span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - convert-braces replaces break-if with a jump-if to after the next close-brace&quot;</span><span class="Delimiter">))</span>
<span class="CommentedCode">;? (quit)</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;convert-braces-empty-block&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>= <span class="Global">traces*</span> <span class="Delimiter">(</span>queue<span class="Delimiter">))</span>
<span class="CommentedCode">;? (= dump-trace* (obj whitelist '(&quot;c{0&quot; &quot;c{1&quot;)))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Delimiter">(</span>convert-braces
            <span class="Mu"><span class="Delimiter">'((((</span><span class="Constant">1</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
              <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">2</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
              <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">3</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
              { <span class="CommentedCode">begin</span>
                <span class="Mu"><span class="Delimiter">(((</span><span class="Identifier">break</span><span class="Delimiter">)))</span></span>
              }
              <span class="Mu"><span class="Delimiter">(((</span><span class="Identifier">reply</span><span class="Delimiter">)))))</span></span>
          <span class="Mu"><span class="Delimiter">'((((</span><span class="Constant">1</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
            <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">2</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
            <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">3</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
            <span class="Mu"><span class="Delimiter">(((</span><span class="Identifier">jump</span><span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> offset<span class="Delimiter">)))</span></span>
            <span class="Mu"><span class="Delimiter">(((</span><span class="Identifier">reply</span><span class="Delimiter">)))))</span></span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - convert-braces works for degenerate blocks&quot;</span><span class="Delimiter">))</span>
<span class="CommentedCode">;? (quit)</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;convert-braces-nested-break&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>= <span class="Global">traces*</span> <span class="Delimiter">(</span>queue<span class="Delimiter">))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Delimiter">(</span>convert-braces
            <span class="Mu"><span class="Delimiter">'((((</span><span class="Constant">1</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
              <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">2</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
              <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">3</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
              { <span class="CommentedCode">begin</span>
                <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">4</span> boolean<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>not-equal<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="Constant">1</span> integer<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="Constant">3</span> integer<span class="Delimiter">)))</span></span>
                <span class="Mu"><span class="Delimiter">(((</span><span class="Identifier">break-if</span><span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="Constant">4</span> boolean<span class="Delimiter">)))</span></span>
                { <span class="CommentedCode">begin</span>
                  <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">5</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
                }
              }
              <span class="Mu"><span class="Delimiter">(((</span><span class="Identifier">reply</span><span class="Delimiter">)))))</span></span>
          <span class="Mu"><span class="Delimiter">'((((</span><span class="Constant">1</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
            <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">2</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
            <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">3</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
            <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">4</span> boolean<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>not-equal<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="Constant">1</span> integer<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="Constant">3</span> integer<span class="Delimiter">)))</span></span>
            <span class="Mu"><span class="Delimiter">(((</span><span class="Identifier">jump-if</span><span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="Constant">4</span> boolean<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">1</span> offset<span class="Delimiter">)))</span></span>
            <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">5</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
            <span class="Mu"><span class="Delimiter">(((</span><span class="Identifier">reply</span><span class="Delimiter">)))))</span></span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - convert-braces balances braces when converting break&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;convert-braces-repeated-jump&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>= <span class="Global">traces*</span> <span class="Delimiter">(</span>queue<span class="Delimiter">))</span>
<span class="CommentedCode">;? (= dump-trace* (obj whitelist '(&quot;c{0&quot; &quot;c{1&quot;)))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Delimiter">(</span>convert-braces
            <span class="Mu"><span class="Delimiter">'((((</span><span class="Constant">1</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
              { <span class="CommentedCode">begin</span>
                <span class="Mu"><span class="Delimiter">(((</span><span class="Identifier">break</span><span class="Delimiter">)))</span></span>
                <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">2</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
              }
              { <span class="CommentedCode">begin</span>
                <span class="Mu"><span class="Delimiter">(((</span><span class="Identifier">break</span><span class="Delimiter">)))</span></span>
                <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">3</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
              }
              <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">4</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))))</span></span>
          <span class="Mu"><span class="Delimiter">'((((</span><span class="Constant">1</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
            <span class="Mu"><span class="Delimiter">(((</span><span class="Identifier">jump</span><span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">1</span> offset<span class="Delimiter">)))</span></span>
            <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">2</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
            <span class="Mu"><span class="Delimiter">(((</span><span class="Identifier">jump</span><span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">1</span> offset<span class="Delimiter">)))</span></span>
            <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">3</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
            <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">4</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))))</span></span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - convert-braces handles jumps on jumps&quot;</span><span class="Delimiter">))</span>
<span class="CommentedCode">;? (quit)</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;convert-braces-nested-loop&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>= <span class="Global">traces*</span> <span class="Delimiter">(</span>queue<span class="Delimiter">))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Delimiter">(</span>convert-braces
            <span class="Mu"><span class="Delimiter">'((((</span><span class="Constant">1</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
              <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">2</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
              { <span class="CommentedCode">begin</span>
                <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">3</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
                { <span class="CommentedCode">begin</span>
                  <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">4</span> boolean<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>not-equal<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="Constant">1</span> integer<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="Constant">3</span> integer<span class="Delimiter">)))</span></span>
                }
                <span class="Mu"><span class="Delimiter">(((</span><span class="Identifier">loop-if</span><span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="Constant">4</span> boolean<span class="Delimiter">)))</span></span>
                <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">5</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
              }
              <span class="Mu"><span class="Delimiter">(((</span><span class="Identifier">reply</span><span class="Delimiter">)))))</span></span>
          <span class="Mu"><span class="Delimiter">'((((</span><span class="Constant">1</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
            <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">2</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
            <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">3</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
            <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">4</span> boolean<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>not-equal<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="Constant">1</span> integer<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="Constant">3</span> integer<span class="Delimiter">)))</span></span>
            <span class="Mu"><span class="Delimiter">(((</span><span class="Identifier">jump-if</span><span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="Constant">4</span> boolean<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">-3</span> offset<span class="Delimiter">)))</span></span>
            <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">5</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
            <span class="Mu"><span class="Delimiter">(((</span><span class="Identifier">reply</span><span class="Delimiter">)))))</span></span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - convert-braces balances braces when converting 'loop'&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;convert-braces-label&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>= <span class="Global">traces*</span> <span class="Delimiter">(</span>queue<span class="Delimiter">))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Delimiter">(</span>convert-braces
            <span class="Mu"><span class="Delimiter">'((((</span><span class="Constant">1</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
              foo
              <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">2</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))))</span></span>
          <span class="Mu"><span class="Delimiter">'((((</span><span class="Constant">1</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
            foo
            <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">2</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))))</span></span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - convert-braces skips past labels&quot;</span><span class="Delimiter">))</span>
<span class="CommentedCode">;? (quit)</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;convert-braces-label-increments-offset&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>= <span class="Global">traces*</span> <span class="Delimiter">(</span>queue<span class="Delimiter">))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Delimiter">(</span>convert-braces
            <span class="Mu"><span class="Delimiter">'((((</span><span class="Constant">1</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
              { <span class="CommentedCode">begin</span>
                <span class="Mu"><span class="Delimiter">(((</span><span class="Identifier">break</span><span class="Delimiter">)))</span></span>
                foo
              }
              <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">2</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))))</span></span>
          <span class="Mu"><span class="Delimiter">'((((</span><span class="Constant">1</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
            <span class="Delimiter">(((</span><span class="Identifier">jump</span><span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">1</span> offset<span class="Delimiter">)))</span>
            foo
            <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">2</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))))</span></span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - convert-braces treats labels as instructions&quot;</span><span class="Delimiter">))</span>
<span class="CommentedCode">;? (quit)</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;convert-braces-label-increments-offset2&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>= <span class="Global">traces*</span> <span class="Delimiter">(</span>queue<span class="Delimiter">))</span>
<span class="CommentedCode">;? (= dump-trace* (obj whitelist '(&quot;c{0&quot; &quot;c{1&quot;)))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Delimiter">(</span>convert-braces
            <span class="Mu"><span class="Delimiter">'((((</span><span class="Constant">1</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
              { <span class="CommentedCode">begin</span>
                <span class="Mu"><span class="Delimiter">(((</span><span class="Identifier">break</span><span class="Delimiter">)))</span></span>
                foo
              }
              <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">2</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
              { <span class="CommentedCode">begin</span>
                <span class="Mu"><span class="Delimiter">(((</span><span class="Identifier">break</span><span class="Delimiter">)))</span></span>
                <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">3</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
              }
              <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">4</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))))</span></span>
          <span class="Mu"><span class="Delimiter">'((((</span><span class="Constant">1</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
            <span class="Mu"><span class="Delimiter">(((</span><span class="Identifier">jump</span><span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">1</span> offset<span class="Delimiter">)))</span></span>
            foo
            <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">2</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
            <span class="Mu"><span class="Delimiter">(((</span><span class="Identifier">jump</span><span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">1</span> offset<span class="Delimiter">)))</span></span>
            <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">3</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
            <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">4</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))))</span></span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - convert-braces treats labels as instructions - 2&quot;</span><span class="Delimiter">))</span>
<span class="CommentedCode">;? (quit)</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;break-multiple&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>= <span class="Global">traces*</span> <span class="Delimiter">(</span>queue<span class="Delimiter">))</span>
<span class="CommentedCode">;? (= dump-trace* (obj whitelist '(&quot;-&quot;)))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Delimiter">(</span>convert-braces
            <span class="Mu"><span class="Delimiter">'((((</span><span class="Constant">1</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
              { <span class="CommentedCode">begin</span>
                { <span class="CommentedCode">begin</span>
                  <span class="Mu"><span class="Delimiter">(((</span><span class="Identifier">break</span><span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="Constant">2</span> blocks<span class="Delimiter">)))</span></span>
                }
                <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">2</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
                <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">3</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
                <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">4</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
                <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">5</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
              }<span class="Delimiter">))</span>
          <span class="Mu"><span class="Delimiter">'((((</span><span class="Constant">1</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
            <span class="Mu"><span class="Delimiter">(((</span><span class="Identifier">jump</span><span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">4</span> offset<span class="Delimiter">)))</span></span>
            <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">2</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
            <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">3</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
            <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">4</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
            <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">5</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))))</span></span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'break' can take an extra arg with number of nested blocks to exit&quot;</span><span class="Delimiter">))</span>
<span class="CommentedCode">;? (quit)</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;loop&quot;</span><span class="Delimiter">)</span>
<span class="CommentedCode">;? (set dump-trace*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Delimiter">(</span>convert-braces
            <span class="Mu"><span class="Delimiter">'((((</span><span class="Constant">1</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
              <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">2</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
              { <span class="CommentedCode">begin</span>
                <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">3</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
                <span class="Mu"><span class="Delimiter">(((</span><span class="Identifier">loop</span><span class="Delimiter">)))</span></span>
              }<span class="Delimiter">))</span>
          <span class="Mu"><span class="Delimiter">'((((</span><span class="Constant">1</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
            <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">2</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
            <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">3</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
            <span class="Mu"><span class="Delimiter">(((</span><span class="Identifier">jump</span><span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">-2</span> offset<span class="Delimiter">)))))</span></span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'loop' jumps to start of containing block&quot;</span><span class="Delimiter">))</span>
<span class="CommentedCode">;? (quit)</span>

<span class="Comment">; todo: fuzz-test invariant: convert-braces offsets should be robust to any</span>
<span class="Comment">; number of inner blocks inside but not around the loop block.</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;loop-nested&quot;</span><span class="Delimiter">)</span>
<span class="CommentedCode">;? (set dump-trace*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Delimiter">(</span>convert-braces
            <span class="Mu"><span class="Delimiter">'((((</span><span class="Constant">1</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
              <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">2</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
              { <span class="CommentedCode">begin</span>
                <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">3</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
                { <span class="CommentedCode">begin</span>
                  <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">4</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
                }
                <span class="Mu"><span class="Delimiter">(((</span><span class="Identifier">loop</span><span class="Delimiter">)))</span></span>
              }<span class="Delimiter">))</span>
          <span class="Mu"><span class="Delimiter">'((((</span><span class="Constant">1</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
            <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">2</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
            <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">3</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
            <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">4</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
            <span class="Mu"><span class="Delimiter">(((</span><span class="Identifier">jump</span><span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">-3</span> offset<span class="Delimiter">)))))</span></span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'loop' correctly jumps back past nested braces&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;loop-multiple&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>= <span class="Global">traces*</span> <span class="Delimiter">(</span>queue<span class="Delimiter">))</span>
<span class="CommentedCode">;? (= dump-trace* (obj whitelist '(&quot;-&quot;)))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Delimiter">(</span>convert-braces
            <span class="Mu"><span class="Delimiter">'((((</span><span class="Constant">1</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
              { <span class="CommentedCode">begin</span>
                <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">2</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
                <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">3</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
                { <span class="CommentedCode">begin</span>
                  <span class="Mu"><span class="Delimiter">(((</span><span class="Identifier">loop</span><span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="Constant">2</span> blocks<span class="Delimiter">)))</span></span>
                }
              }<span class="Delimiter">))</span>
          <span class="Mu"><span class="Delimiter">'((((</span><span class="Constant">1</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
            <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">2</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
            <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">3</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
            <span class="Mu"><span class="Delimiter">(((</span><span class="Identifier">jump</span><span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">-3</span> offset<span class="Delimiter">)))))</span></span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'loop' can take an extra arg with number of nested blocks to exit&quot;</span><span class="Delimiter">))</span>
<span class="CommentedCode">;? (quit)</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;convert-labels&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>= <span class="Global">traces*</span> <span class="Delimiter">(</span>queue<span class="Delimiter">))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Delimiter">(</span>convert-labels
            <span class="Mu"><span class="Delimiter">'(</span><span class="Identifier">loop</span></span>
              <span class="Mu"><span class="Delimiter">(((</span><span class="Identifier">jump</span><span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="Identifier">loop</span> offset<span class="Delimiter">)))))</span></span>
          <span class="Mu"><span class="Delimiter">'(</span><span class="Identifier">loop</span></span>
            <span class="Mu"><span class="Delimiter">(((</span><span class="Identifier">jump</span><span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">-2</span> offset<span class="Delimiter">)))))</span></span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'convert-labels' rewrites jumps to labels&quot;</span><span class="Delimiter">))</span>

<span class="SalientComment">;; Variables</span>
<span class="Comment">;</span>
<span class="Comment">; A big convenience high-level languages provide is the ability to name memory</span>
<span class="Comment">; locations. In mu, a lightweight tool called 'convert-names' provides this</span>
<span class="Comment">; convenience.</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;convert-names&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>= <span class="Global">traces*</span> <span class="Delimiter">(</span>queue<span class="Delimiter">))</span>
<span class="CommentedCode">;? (set dump-trace*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Delimiter">(</span>convert-names
            <span class="Mu"><span class="Delimiter">'((((</span>x integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
              <span class="Mu"><span class="Delimiter">(((</span>y integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
              <span class="Mu"><span class="Delimiter">(((</span>z integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))))</span></span>
          <span class="Mu"><span class="Delimiter">'((((</span><span class="Constant">1</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
            <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">2</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
            <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">3</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))))</span></span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - convert-names renames symbolic names to integer locations&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;convert-names-compound&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>= <span class="Global">traces*</span> <span class="Delimiter">(</span>queue<span class="Delimiter">))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Delimiter">(</span>convert-names
            <span class="Comment">; copying 0 into pair is meaningless; just for testing</span>
            <span class="Mu"><span class="Delimiter">'((((</span>x integer-boolean-pair<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
              <span class="Mu"><span class="Delimiter">(((</span>y integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))))</span></span>
          <span class="Mu"><span class="Delimiter">'((((</span><span class="Constant">1</span> integer-boolean-pair<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
            <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">3</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))))</span></span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - convert-names increments integer locations by the size of the type of the previous var&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;convert-names-nil&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>= <span class="Global">traces*</span> <span class="Delimiter">(</span>queue<span class="Delimiter">))</span>
<span class="CommentedCode">;? (set dump-trace*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Delimiter">(</span>convert-names
            <span class="Mu"><span class="Delimiter">'((((</span>x integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
              <span class="Mu"><span class="Delimiter">(((</span>y integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
              <span class="Comment">; nil location is meaningless; just for testing</span>
              <span class="Mu"><span class="Delimiter">(((</span>nil integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))))</span></span>
          <span class="Mu"><span class="Delimiter">'((((</span><span class="Constant">1</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
            <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">2</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
            <span class="Mu"><span class="Delimiter">(((</span>nil integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))))</span></span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - convert-names never renames nil&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;convert-names-string&quot;</span><span class="Delimiter">)</span>
<span class="CommentedCode">;? (set dump-trace*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Delimiter">(</span>convert-names
            <span class="Mu"><span class="Delimiter">'((((</span><span class="Constant">1</span> integer-address<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>new<span class="Delimiter">))</span> <span class="Constant">&quot;foo&quot;</span><span class="Delimiter">)))</span></span>
          <span class="Mu"><span class="Delimiter">'((((</span><span class="Constant">1</span> integer-address<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>new<span class="Delimiter">))</span> <span class="Constant">&quot;foo&quot;</span><span class="Delimiter">)))</span></span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;convert-names passes through raw strings (just a convenience arg for 'new')&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;convert-names-raw&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>= <span class="Global">traces*</span> <span class="Delimiter">(</span>queue<span class="Delimiter">))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Delimiter">(</span>convert-names
            <span class="Mu"><span class="Delimiter">'((((</span>x integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
              <span class="Mu"><span class="Delimiter">(((</span>y integer<span class="Delimiter">)</span> <span class="Delimiter">(</span>raw<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))))</span></span>
          <span class="Mu"><span class="Delimiter">'((((</span><span class="Constant">1</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
            <span class="Mu"><span class="Delimiter">(((</span>y integer<span class="Delimiter">)</span> <span class="Delimiter">(</span>raw<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))))</span></span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - convert-names never renames raw operands&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;convert-names-literal&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>= <span class="Global">traces*</span> <span class="Delimiter">(</span>queue<span class="Delimiter">))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Delimiter">(</span>convert-names
            <span class="Comment">; meaningless; just for testing</span>
            <span class="Mu"><span class="Delimiter">'((((</span>x literal<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))))</span></span>
          <span class="Mu"><span class="Delimiter">'((((</span>x literal<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))))</span></span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - convert-names never renames literals&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;convert-names-literal-2&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>= <span class="Global">traces*</span> <span class="Delimiter">(</span>queue<span class="Delimiter">))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Delimiter">(</span>convert-names
            <span class="Mu"><span class="Delimiter">'((((</span>x boolean<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span>x literal<span class="Delimiter">)))))</span></span>
          <span class="Mu"><span class="Delimiter">'((((</span><span class="Constant">1</span> boolean<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span>x literal<span class="Delimiter">)))))</span></span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - convert-names never renames literals, even when the name matches a variable&quot;</span><span class="Delimiter">))</span>

<span class="Comment">; kludgy support for 'fork' below</span>
<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;convert-names-functions&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>= <span class="Global">traces*</span> <span class="Delimiter">(</span>queue<span class="Delimiter">))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Delimiter">(</span>convert-names
            <span class="Mu"><span class="Delimiter">'((((</span>x integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
              <span class="Mu"><span class="Delimiter">(((</span>y integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
              <span class="Comment">; meaningless; just for testing</span>
              <span class="Mu"><span class="Delimiter">(((</span>z fn<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))))</span></span>
          <span class="Mu"><span class="Delimiter">'((((</span><span class="Constant">1</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
            <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">2</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
            <span class="Mu"><span class="Delimiter">(((</span>z fn<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))))</span></span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - convert-names never renames fns&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;convert-names-record-fields&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>= <span class="Global">traces*</span> <span class="Delimiter">(</span>queue<span class="Delimiter">))</span>
<span class="CommentedCode">;? (= dump-trace* (obj whitelist '(&quot;cn0&quot;)))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Delimiter">(</span>convert-names
            <span class="Mu"><span class="Delimiter">'((((</span>x integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>get<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="Constant">34</span> integer-boolean-pair<span class="Delimiter">))</span> <span class="Delimiter">((</span>bool offset<span class="Delimiter">)))))</span></span>
          <span class="Mu"><span class="Delimiter">'((((</span><span class="Constant">1</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>get<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="Constant">34</span> integer-boolean-pair<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">1</span> offset<span class="Delimiter">)))))</span></span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - convert-names replaces record field offsets&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;convert-names-record-fields-ambiguous&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>= <span class="Global">traces*</span> <span class="Delimiter">(</span>queue<span class="Delimiter">))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>errsafe <span class="Delimiter">(</span>convert-names
               <span class="Mu"><span class="Delimiter">'((((</span>bool boolean<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">t</span> literal<span class="Delimiter">)))</span></span>
                 <span class="Mu"><span class="Delimiter">(((</span>x integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>get<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="Constant">34</span> integer-boolean-pair<span class="Delimiter">))</span> <span class="Delimiter">((</span>bool offset<span class="Delimiter">))))))</span></span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - convert-names doesn't allow offsets and variables with the same name in a function&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;convert-names-record-fields-ambiguous-2&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>= <span class="Global">traces*</span> <span class="Delimiter">(</span>queue<span class="Delimiter">))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>errsafe <span class="Delimiter">(</span>convert-names
               <span class="Mu"><span class="Delimiter">'((((</span>x integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>get<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="Constant">34</span> integer-boolean-pair<span class="Delimiter">))</span> <span class="Delimiter">((</span>bool offset<span class="Delimiter">)))</span></span>
                 <span class="Mu"><span class="Delimiter">(((</span>bool boolean<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">t</span> literal<span class="Delimiter">))))))</span></span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - convert-names doesn't allow offsets and variables with the same name in a function - 2&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;convert-names-record-fields-indirect&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>= <span class="Global">traces*</span> <span class="Delimiter">(</span>queue<span class="Delimiter">))</span>
<span class="CommentedCode">;? (= dump-trace* (obj whitelist '(&quot;cn0&quot;)))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Delimiter">(</span>convert-names
            <span class="Mu"><span class="Delimiter">'((((</span>x integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>get<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="Constant">34</span> integer-boolean-pair-address<span class="Delimiter">)</span> <span class="Delimiter">(</span>deref<span class="Delimiter">))</span> <span class="Delimiter">((</span>bool offset<span class="Delimiter">)))))</span></span>
          <span class="Mu"><span class="Delimiter">'((((</span><span class="Constant">1</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>get<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="Constant">34</span> integer-boolean-pair-address<span class="Delimiter">)</span> <span class="Delimiter">(</span>deref<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">1</span> offset<span class="Delimiter">)))))</span></span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - convert-names replaces field offsets for record addresses&quot;</span><span class="Delimiter">))</span>
<span class="CommentedCode">;? (quit)</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;convert-names-record-fields-multiple&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>= <span class="Global">traces*</span> <span class="Delimiter">(</span>queue<span class="Delimiter">))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Delimiter">(</span>convert-names
            <span class="Mu"><span class="Delimiter">'((((</span><span class="Constant">2</span> boolean<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>get<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="Constant">1</span> integer-boolean-pair<span class="Delimiter">))</span> <span class="Delimiter">((</span>bool offset<span class="Delimiter">)))</span></span>
              <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">3</span> boolean<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>get<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="Constant">1</span> integer-boolean-pair<span class="Delimiter">))</span> <span class="Delimiter">((</span>bool offset<span class="Delimiter">)))))</span></span>
          <span class="Mu"><span class="Delimiter">'((((</span><span class="Constant">2</span> boolean<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>get<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="Constant">1</span> integer-boolean-pair<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">1</span> offset<span class="Delimiter">)))</span></span>
            <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">3</span> boolean<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>get<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="Constant">1</span> integer-boolean-pair<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">1</span> offset<span class="Delimiter">)))))</span></span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - convert-names replaces field offsets with multiple mentions&quot;</span><span class="Delimiter">))</span>
<span class="CommentedCode">;? (quit)</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;convert-names-label&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>= <span class="Global">traces*</span> <span class="Delimiter">(</span>queue<span class="Delimiter">))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Delimiter">(</span>convert-names
            <span class="Mu"><span class="Delimiter">'((((</span><span class="Constant">1</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
              foo<span class="Delimiter">))</span>
          <span class="Mu"><span class="Delimiter">'((((</span><span class="Constant">1</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
            foo<span class="Delimiter">))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - convert-names skips past labels&quot;</span><span class="Delimiter">))</span>
<span class="CommentedCode">;? (quit)</span>

<span class="Delimiter">)</span>  <span class="Comment">; section 11</span>

<span class="Delimiter">(</span>section <span class="Constant">20</span>

<span class="Comment">; A rudimentary memory allocator. Eventually we want to write this in mu.</span>
<span class="Comment">;</span>
<span class="Comment">; No deallocation yet; let's see how much code we can build in mu before we</span>
<span class="Comment">; feel the need for it.</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;new-primitive&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer-address <span class="Op">&lt;-</span> new integer:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span><span class="Normal">let</span> routine make-routine!main
  <span class="Delimiter">(</span>enq routine <span class="Global">running-routines*</span><span class="Delimiter">)</span>
  <span class="Delimiter">(</span><span class="Normal">let</span> before rep.routine!alloc
<span class="CommentedCode">;?     (set dump-trace*)</span>
    <span class="Delimiter">(</span>run<span class="Delimiter">)</span>
<span class="CommentedCode">;?     (prn memory*)</span>
    <span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Global">memory*</span><span class="Constant">.1</span> before<span class="Delimiter">)</span>
      <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'new' returns current high-water mark&quot;</span><span class="Delimiter">))</span>
    <span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso rep.routine!alloc <span class="Delimiter">(</span>+ before <span class="Constant">1</span><span class="Delimiter">))</span>
      <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'new' on primitive types increments high-water mark by their size&quot;</span><span class="Delimiter">))))</span>
<span class="CommentedCode">;? (quit)</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;new-array-literal&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:type-array-address <span class="Op">&lt;-</span> new type-array:literal <span class="MuConstant">5</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span><span class="Normal">let</span> routine make-routine!main
  <span class="Delimiter">(</span>enq routine <span class="Global">running-routines*</span><span class="Delimiter">)</span>
  <span class="Delimiter">(</span><span class="Normal">let</span> before rep.routine!alloc
    <span class="Delimiter">(</span>run<span class="Delimiter">)</span>
<span class="CommentedCode">;?     (prn memory*)</span>
    <span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Global">memory*</span><span class="Constant">.1</span> before<span class="Delimiter">)</span>
      <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'new' on array with literal size returns current high-water mark&quot;</span><span class="Delimiter">))</span>
    <span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso rep.routine!alloc <span class="Delimiter">(</span>+ before <span class="Constant">6</span><span class="Delimiter">))</span>
      <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'new' on primitive arrays increments high-water mark by their size&quot;</span><span class="Delimiter">))))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;new-array-direct&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">5</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:type-array-address <span class="Op">&lt;-</span> new type-array:literal <span class="Constant">1</span>:integer<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span><span class="Normal">let</span> routine make-routine!main
  <span class="Delimiter">(</span>enq routine <span class="Global">running-routines*</span><span class="Delimiter">)</span>
  <span class="Delimiter">(</span><span class="Normal">let</span> before rep.routine!alloc
    <span class="Delimiter">(</span>run<span class="Delimiter">)</span>
<span class="CommentedCode">;?     (prn memory*)</span>
    <span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Global">memory*</span><span class="Constant">.2</span> before<span class="Delimiter">)</span>
      <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'new' on array with variable size returns current high-water mark&quot;</span><span class="Delimiter">))</span>
    <span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso rep.routine!alloc <span class="Delimiter">(</span>+ before <span class="Constant">6</span><span class="Delimiter">))</span>
      <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'new' on primitive arrays increments high-water mark by their (variable) size&quot;</span><span class="Delimiter">))))</span>

<span class="Comment">; Even though our memory locations can now have names, the names are all</span>
<span class="Comment">; globals, accessible from any function. To isolate functions from their</span>
<span class="Comment">; callers we need local variables, and mu provides them using a special</span>
<span class="Comment">; variable called default-space. When you initialize such a variable (likely</span>
<span class="Comment">; with a call to our just-defined memory allocator) mu interprets memory</span>
<span class="Comment">; locations as offsets from its value. If default-space is set to 1000, for</span>
<span class="Comment">; example, reads and writes to memory location 1 will really go to 1001.</span>
<span class="Comment">;</span>
<span class="Comment">; 'default-space' is itself hard-coded to be function-local; it's nil in a new</span>
<span class="Comment">; function, and it's restored when functions return to their callers. But the</span>
<span class="Comment">; actual space allocation is independent. So you can define closures, or do</span>
<span class="Comment">; even more funky things like share locals between two coroutines.</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;set-default-space&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span>default-space:space-address <span class="Op">&lt;-</span> new space:literal <span class="MuConstant">2</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">23</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span><span class="Normal">let</span> routine make-routine!main
  <span class="Delimiter">(</span>enq routine <span class="Global">running-routines*</span><span class="Delimiter">)</span>
  <span class="Delimiter">(</span><span class="Normal">let</span> before rep.routine!alloc
<span class="CommentedCode">;?     (set dump-trace*)</span>
    <span class="Delimiter">(</span>run<span class="Delimiter">)</span>
<span class="CommentedCode">;?     (prn memory*)</span>
    <span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~and <span class="Delimiter">(</span>~is <span class="Constant">23</span> <span class="Global">memory*</span><span class="Constant">.1</span><span class="Delimiter">)</span>
              <span class="Delimiter">(</span>is <span class="Constant">23</span> <span class="Delimiter">(</span><span class="Global">memory*</span> <span class="Delimiter">(</span>+ before <span class="Constant">2</span><span class="Delimiter">))))</span>
      <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - default-space implicitly modifies variable locations&quot;</span><span class="Delimiter">))))</span>
<span class="CommentedCode">;? (quit)</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;set-default-space-skips-offset&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span>default-space:space-address <span class="Op">&lt;-</span> new space:literal <span class="MuConstant">2</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">23</span>:offset<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span><span class="Normal">let</span> routine make-routine!main
  <span class="Delimiter">(</span>enq routine <span class="Global">running-routines*</span><span class="Delimiter">)</span>
  <span class="Delimiter">(</span><span class="Normal">let</span> before rep.routine!alloc
<span class="CommentedCode">;?     (set dump-trace*)</span>
    <span class="Delimiter">(</span>run<span class="Delimiter">)</span>
<span class="CommentedCode">;?     (prn memory*)</span>
    <span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~and <span class="Delimiter">(</span>~is <span class="Constant">23</span> <span class="Global">memory*</span><span class="Constant">.1</span><span class="Delimiter">)</span>
              <span class="Delimiter">(</span>is <span class="Constant">23</span> <span class="Delimiter">(</span><span class="Global">memory*</span> <span class="Delimiter">(</span>+ before <span class="Constant">2</span><span class="Delimiter">))))</span>
      <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - default-space skips 'offset' types just like literals&quot;</span><span class="Delimiter">))))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;default-space-bounds-check&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span>default-space:space-address <span class="Op">&lt;-</span> new space:literal <span class="MuConstant">2</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">23</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="CommentedCode">;? (set dump-trace*)</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">let</span> routine <span class="Delimiter">(</span>car <span class="Global">completed-routines*</span><span class="Delimiter">)</span>
  <span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>no rep.routine!error<span class="Delimiter">)</span>
    <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - default-space checks bounds&quot;</span><span class="Delimiter">)))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;default-space-and-get-indirect&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span>default-space:space-address <span class="Op">&lt;-</span> new space:literal <span class="MuConstant">5</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer-boolean-pair-address <span class="Op">&lt;-</span> new integer-boolean-pair:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer-address <span class="Op">&lt;-</span> get-address <span class="Constant">1</span>:integer-boolean-pair-address/deref <span class="MuConstant">0</span>:offset<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer-address/deref <span class="Op">&lt;-</span> copy <span class="MuConstant">34</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:integer/raw <span class="Op">&lt;-</span> get <span class="Constant">1</span>:integer-boolean-pair-address/deref <span class="MuConstant">0</span>:offset<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="CommentedCode">;? (= dump-trace* (obj blacklist '(&quot;sz&quot; &quot;m&quot; &quot;setm&quot; &quot;addr&quot; &quot;cvt0&quot; &quot;cvt1&quot;)))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="CommentedCode">;? (prn completed-routines*)</span>
<span class="Delimiter">(</span>each routine <span class="Global">completed-routines*</span>
  <span class="Delimiter">(</span>aif rep.routine!error <span class="Delimiter">(</span>prn <span class="Constant">&quot;error - &quot;</span> it<span class="Delimiter">)))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Constant">34</span> <span class="Global">memory*</span><span class="Constant">.3</span><span class="Delimiter">)</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - indirect 'get' works in the presence of default-space&quot;</span><span class="Delimiter">))</span>
<span class="CommentedCode">;? (quit)</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;default-space-and-index-indirect&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span>default-space:space-address <span class="Op">&lt;-</span> new space:literal <span class="MuConstant">5</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer-array-address <span class="Op">&lt;-</span> new integer-array:literal <span class="MuConstant">4</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer-address <span class="Op">&lt;-</span> index-address <span class="Constant">1</span>:integer-array-address/deref <span class="MuConstant">2</span>:offset<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer-address/deref <span class="Op">&lt;-</span> copy <span class="MuConstant">34</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:integer/raw <span class="Op">&lt;-</span> index <span class="Constant">1</span>:integer-array-address/deref <span class="MuConstant">2</span>:offset<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="CommentedCode">;? (= dump-trace* (obj whitelist '(&quot;run&quot; &quot;array-info&quot;)))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="CommentedCode">;? (prn completed-routines*)</span>
<span class="Delimiter">(</span>each routine <span class="Global">completed-routines*</span>
  <span class="Delimiter">(</span>aif rep.routine!error <span class="Delimiter">(</span>prn <span class="Constant">&quot;error - &quot;</span> it<span class="Delimiter">)))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Constant">34</span> <span class="Global">memory*</span><span class="Constant">.3</span><span class="Delimiter">)</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - indirect 'index' works in the presence of default-space&quot;</span><span class="Delimiter">))</span>
<span class="CommentedCode">;? (quit)</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;convert-names-default-space&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>= <span class="Global">traces*</span> <span class="Delimiter">(</span>queue<span class="Delimiter">))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Delimiter">(</span>convert-names
            <span class="Mu"><span class="Delimiter">'((((</span>x integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">4</span> literal<span class="Delimiter">)))</span></span>
              <span class="Mu"><span class="Delimiter">(((</span>y integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">2</span> literal<span class="Delimiter">)))</span></span>
              <span class="Comment">; unsafe in general; don't write random values to 'default-space'</span>
              <span class="Mu"><span class="Delimiter">(((</span>default-space integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>add<span class="Delimiter">))</span> <span class="Delimiter">((</span>x integer<span class="Delimiter">))</span> <span class="Delimiter">((</span>y integer<span class="Delimiter">)))))</span></span>
          <span class="Mu"><span class="Delimiter">'((((</span><span class="Constant">1</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">4</span> literal<span class="Delimiter">)))</span></span>
            <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">2</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">2</span> literal<span class="Delimiter">)))</span></span>
            <span class="Mu"><span class="Delimiter">(((</span>default-space integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>add<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="Constant">1</span> integer<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="Constant">2</span> integer<span class="Delimiter">)))))</span></span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - convert-names never renames default-space&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;suppress-default-space&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span>default-space:space-address <span class="Op">&lt;-</span> new space:literal <span class="MuConstant">2</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer/raw <span class="Op">&lt;-</span> copy <span class="MuConstant">23</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span><span class="Normal">let</span> routine make-routine!main
  <span class="Delimiter">(</span>enq routine <span class="Global">running-routines*</span><span class="Delimiter">)</span>
  <span class="Delimiter">(</span><span class="Normal">let</span> before rep.routine!alloc
<span class="CommentedCode">;?     (set dump-trace*)</span>
    <span class="Delimiter">(</span>run<span class="Delimiter">)</span>
<span class="CommentedCode">;?     (prn memory*)</span>
    <span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~and <span class="Delimiter">(</span>is <span class="Constant">23</span> <span class="Global">memory*</span><span class="Constant">.1</span><span class="Delimiter">)</span>
              <span class="Delimiter">(</span>~is <span class="Constant">23</span> <span class="Delimiter">(</span><span class="Global">memory*</span> <span class="Delimiter">(</span>+ before <span class="Constant">1</span><span class="Delimiter">))))</span>
      <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - default-space skipped for locations with metadata 'raw'&quot;</span><span class="Delimiter">))))</span>
<span class="CommentedCode">;? (quit)</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;array-copy-indirect-scoped&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">10</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">30</span>:literal<span class="Delimiter">)</span>  <span class="Comment">; pretend allocation</span></span>
      <span class="Mu"><span class="Delimiter">(</span>default-space:space-address <span class="Op">&lt;-</span> copy <span class="MuConstant">10</span>:literal<span class="Delimiter">)</span>  <span class="Comment">; unsafe</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">2</span>:literal<span class="Delimiter">)</span>  <span class="Comment">; raw location 12</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">23</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:boolean <span class="Op">&lt;-</span> copy <span class="MuConstant">nil</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">4</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">24</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">5</span>:boolean <span class="Op">&lt;-</span> copy <span class="MuConstant">t</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">6</span>:integer-boolean-pair-array-address <span class="Op">&lt;-</span> copy <span class="MuConstant">12</span>:literal<span class="Delimiter">)</span>  <span class="Comment">; unsafe</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">7</span>:integer-boolean-pair-array <span class="Op">&lt;-</span> copy <span class="Constant">6</span>:integer-boolean-pair-array-address/deref<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="CommentedCode">;? (set dump-trace*)</span>
<span class="CommentedCode">;? (= dump-trace* (obj whitelist '(&quot;run&quot; &quot;m&quot; &quot;sizeof&quot;)))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span>each routine <span class="Global">completed-routines*</span>
  <span class="Delimiter">(</span>aif rep.routine!error <span class="Delimiter">(</span>prn <span class="Constant">&quot;error - &quot;</span> it<span class="Delimiter">)))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Global">memory*</span><span class="Constant">.18</span> <span class="Constant">2</span><span class="Delimiter">)</span>  <span class="Comment">; variable 7</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - indirect array copy in the presence of 'default-space'&quot;</span><span class="Delimiter">))</span>
<span class="CommentedCode">;? (quit)</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;len-array-indirect-scoped&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">10</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">30</span>:literal<span class="Delimiter">)</span>  <span class="Comment">; pretend allocation</span></span>
      <span class="Mu"><span class="Delimiter">(</span>default-space:space-address <span class="Op">&lt;-</span> copy <span class="MuConstant">10</span>:literal<span class="Delimiter">)</span>  <span class="Comment">; unsafe</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">2</span>:literal<span class="Delimiter">)</span>  <span class="Comment">; raw location 12</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">23</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:boolean <span class="Op">&lt;-</span> copy <span class="MuConstant">nil</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">4</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">24</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">5</span>:boolean <span class="Op">&lt;-</span> copy <span class="MuConstant">t</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">6</span>:integer-address <span class="Op">&lt;-</span> copy <span class="MuConstant">12</span>:literal<span class="Delimiter">)</span>  <span class="Comment">; unsafe</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">7</span>:integer <span class="Op">&lt;-</span> length <span class="Constant">6</span>:integer-boolean-pair-array-address/deref<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="CommentedCode">;? (= dump-trace* (obj whitelist '(&quot;run&quot; &quot;addr&quot; &quot;sz&quot; &quot;array-len&quot;)))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Global">memory*</span><span class="Constant">.18</span> <span class="Constant">2</span><span class="Delimiter">)</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'len' accesses length of array address&quot;</span><span class="Delimiter">))</span>
<span class="CommentedCode">;? (quit)</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;default-space-shared&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function init-counter <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span>default-space:space-address <span class="Op">&lt;-</span> new space:literal <span class="MuConstant">30</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">3</span>:literal<span class="Delimiter">)</span>  <span class="Comment">; initialize to 3</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Identifier">reply</span> default-space:space-address<span class="Delimiter">)</span></span>
     <span class="Delimiter">])</span>
    <span class="Mu"><span class="Delimiter">(</span>function increment-counter <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span>default-space:space-address <span class="Op">&lt;-</span> <span class="Identifier">next-input</span><span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> add <span class="Constant">1</span>:integer <span class="MuConstant">1</span>:literal<span class="Delimiter">)</span>  <span class="Comment">; increment</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Identifier">reply</span> <span class="Constant">1</span>:integer<span class="Delimiter">)</span></span>
     <span class="Delimiter">])</span>
    <span class="Mu"><span class="Delimiter">(</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:space-address <span class="Op">&lt;-</span> init-counter<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> increment-counter <span class="Constant">1</span>:space-address<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:integer <span class="Op">&lt;-</span> increment-counter <span class="Constant">1</span>:space-address<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="Delimiter">(</span>each routine <span class="Global">completed-routines*</span>
  <span class="Delimiter">(</span>aif rep.routine!error <span class="Delimiter">(</span>prn <span class="Constant">&quot;error - &quot;</span> it<span class="Delimiter">)))</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span><span class="Normal">or</span> <span class="Delimiter">(</span>~is <span class="Global">memory*</span><span class="Constant">.2</span> <span class="Constant">4</span><span class="Delimiter">)</span>
        <span class="Delimiter">(</span>~is <span class="Global">memory*</span><span class="Constant">.3</span> <span class="Constant">5</span><span class="Delimiter">))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - multiple calls to a function can share locals&quot;</span><span class="Delimiter">))</span>
<span class="CommentedCode">;? (quit)</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;default-space-closure&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function init-counter <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span>default-space:space-address <span class="Op">&lt;-</span> new space:literal <span class="MuConstant">30</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">3</span>:literal<span class="Delimiter">)</span>  <span class="Comment">; initialize to 3</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Identifier">reply</span> default-space:space-address<span class="Delimiter">)</span></span>
     <span class="Delimiter">])</span>
    <span class="Mu"><span class="Delimiter">(</span>function increment-counter <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span>default-space:space-address <span class="Op">&lt;-</span> new space:literal <span class="MuConstant">30</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">0</span>:space-address <span class="Op">&lt;-</span> <span class="Identifier">next-input</span><span class="Delimiter">)</span>  <span class="Comment">; share outer space</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer/space:1 <span class="Op">&lt;-</span> add <span class="Constant">1</span>:integer/space:1 <span class="MuConstant">1</span>:literal<span class="Delimiter">)</span>  <span class="Comment">; increment</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">34</span>:literal<span class="Delimiter">)</span>  <span class="Comment">; dummy</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Identifier">reply</span> <span class="Constant">1</span>:integer/space:1<span class="Delimiter">)</span></span>
     <span class="Delimiter">])</span>
    <span class="Mu"><span class="Delimiter">(</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:space-address <span class="Op">&lt;-</span> init-counter<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> increment-counter <span class="Constant">1</span>:space-address<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:integer <span class="Op">&lt;-</span> increment-counter <span class="Constant">1</span>:space-address<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="CommentedCode">;? (set dump-trace*)</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="Delimiter">(</span>each routine <span class="Global">completed-routines*</span>
  <span class="Delimiter">(</span>aif rep.routine!error <span class="Delimiter">(</span>prn <span class="Constant">&quot;error - &quot;</span> it<span class="Delimiter">)))</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span><span class="Normal">or</span> <span class="Delimiter">(</span>~is <span class="Global">memory*</span><span class="Constant">.2</span> <span class="Constant">4</span><span class="Delimiter">)</span>
        <span class="Delimiter">(</span>~is <span class="Global">memory*</span><span class="Constant">.3</span> <span class="Constant">5</span><span class="Delimiter">))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - multiple calls to a function can share locals&quot;</span><span class="Delimiter">))</span>
<span class="CommentedCode">;? (quit)</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;default-space-closure-with-names&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function init-counter <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span>default-space:space-address <span class="Op">&lt;-</span> new space:literal <span class="MuConstant">30</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span>x:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">23</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span>y:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">3</span>:literal<span class="Delimiter">)</span>  <span class="Comment">; correct copy of y</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Identifier">reply</span> default-space:space-address<span class="Delimiter">)</span></span>
     <span class="Delimiter">])</span>
    <span class="Mu"><span class="Delimiter">(</span>function increment-counter <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span>default-space:space-address <span class="Op">&lt;-</span> new space:literal <span class="MuConstant">30</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">0</span>:space-address/names:init-counter <span class="Op">&lt;-</span> <span class="Identifier">next-input</span><span class="Delimiter">)</span>  <span class="Comment">; outer space must be created by 'init-counter' above</span></span>
      <span class="Mu"><span class="Delimiter">(</span>y:integer/space:1 <span class="Op">&lt;-</span> add y:integer/space:1 <span class="MuConstant">1</span>:literal<span class="Delimiter">)</span>  <span class="Comment">; increment</span></span>
      <span class="Mu"><span class="Delimiter">(</span>y:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">34</span>:literal<span class="Delimiter">)</span>  <span class="Comment">; dummy</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Identifier">reply</span> y:integer/space:1<span class="Delimiter">)</span></span>
     <span class="Delimiter">])</span>
    <span class="Mu"><span class="Delimiter">(</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:space-address/names:init-counter <span class="Op">&lt;-</span> init-counter<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> increment-counter <span class="Constant">1</span>:space-address/names:init-counter<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:integer <span class="Op">&lt;-</span> increment-counter <span class="Constant">1</span>:space-address/names:init-counter<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="CommentedCode">;? (set dump-trace*)</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="Delimiter">(</span>each routine <span class="Global">completed-routines*</span>
  <span class="Delimiter">(</span>aif rep.routine!error <span class="Delimiter">(</span>prn <span class="Constant">&quot;error - &quot;</span> it<span class="Delimiter">)))</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span><span class="Normal">or</span> <span class="Delimiter">(</span>~is <span class="Global">memory*</span><span class="Constant">.2</span> <span class="Constant">4</span><span class="Delimiter">)</span>
        <span class="Delimiter">(</span>~is <span class="Global">memory*</span><span class="Constant">.3</span> <span class="Constant">5</span><span class="Delimiter">))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - multiple calls to a function can share locals&quot;</span><span class="Delimiter">))</span>
<span class="CommentedCode">;? (quit)</span>

<span class="Delimiter">)</span>  <span class="Comment">; section 20</span>

<span class="Delimiter">(</span>section <span class="Constant">100</span>

<span class="SalientComment">;; Dynamic dispatch</span>
<span class="Comment">;</span>
<span class="Comment">; Putting it all together, here's how you define generic functions that run</span>
<span class="Comment">; different code based on the types of their args.</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;dispatch-clause&quot;</span><span class="Delimiter">)</span>
<span class="CommentedCode">;? (set dump-trace*)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function test1 <span class="Delimiter">[</span></span>
      <span class="Comment">; doesn't matter too much how many locals you allocate space for (here 20)</span>
      <span class="Comment">; if it's slightly too many -- memory is plentiful</span>
      <span class="Comment">; if it's too few -- mu will raise an error</span>
      <span class="Mu"><span class="Delimiter">(</span>default-space:space-address <span class="Op">&lt;-</span> new space:literal <span class="MuConstant">20</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span>first-arg-box:tagged-value-address <span class="Op">&lt;-</span> <span class="Identifier">next-input</span><span class="Delimiter">)</span></span>
      <span class="Comment">; if given integers, add them</span>
      { <span class="CommentedCode">begin</span>
        <span class="Mu"><span class="Delimiter">(</span>first-arg:integer match?:boolean <span class="Op">&lt;-</span> maybe-coerce first-arg-box:tagged-value-address/deref integer:literal<span class="Delimiter">)</span></span>
        <span class="Mu"><span class="Delimiter">(</span><span class="Identifier">break-unless</span> match?:boolean<span class="Delimiter">)</span></span>
        <span class="Mu"><span class="Delimiter">(</span>second-arg-box:tagged-value-address <span class="Op">&lt;-</span> <span class="Identifier">next-input</span><span class="Delimiter">)</span></span>
        <span class="Mu"><span class="Delimiter">(</span>second-arg:integer <span class="Op">&lt;-</span> maybe-coerce second-arg-box:tagged-value-address/deref integer:literal<span class="Delimiter">)</span></span>
        <span class="Mu"><span class="Delimiter">(</span>result:integer <span class="Op">&lt;-</span> add first-arg:integer second-arg:integer<span class="Delimiter">)</span></span>
        <span class="Mu"><span class="Delimiter">(</span><span class="Identifier">reply</span> result:integer<span class="Delimiter">)</span></span>
      }
      <span class="Mu"><span class="Delimiter">(</span><span class="Identifier">reply</span> <span class="MuConstant">nil</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])</span>
    <span class="Mu"><span class="Delimiter">(</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:tagged-value-address <span class="Op">&lt;-</span> init-tagged-value integer:literal <span class="MuConstant">34</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:tagged-value-address <span class="Op">&lt;-</span> init-tagged-value integer:literal <span class="MuConstant">3</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:integer <span class="Op">&lt;-</span> test1 <span class="Constant">1</span>:tagged-value-address <span class="Constant">2</span>:tagged-value-address<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Global">memory*</span><span class="Constant">.3</span> <span class="Constant">37</span><span class="Delimiter">)</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - an example function that checks that its oarg is an integer&quot;</span><span class="Delimiter">))</span>
<span class="CommentedCode">;? (quit)</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;dispatch-multiple-clauses&quot;</span><span class="Delimiter">)</span>
<span class="CommentedCode">;? (set dump-trace*)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function test1 <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span>default-space:space-address <span class="Op">&lt;-</span> new space:literal <span class="MuConstant">20</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span>first-arg-box:tagged-value-address <span class="Op">&lt;-</span> <span class="Identifier">next-input</span><span class="Delimiter">)</span></span>
      <span class="Comment">; if given integers, add them</span>
      { <span class="CommentedCode">begin</span>
        <span class="Mu"><span class="Delimiter">(</span>first-arg:integer match?:boolean <span class="Op">&lt;-</span> maybe-coerce first-arg-box:tagged-value-address/deref integer:literal<span class="Delimiter">)</span></span>
        <span class="Mu"><span class="Delimiter">(</span><span class="Identifier">break-unless</span> match?:boolean<span class="Delimiter">)</span></span>
        <span class="Mu"><span class="Delimiter">(</span>second-arg-box:tagged-value-address <span class="Op">&lt;-</span> <span class="Identifier">next-input</span><span class="Delimiter">)</span></span>
        <span class="Mu"><span class="Delimiter">(</span>second-arg:integer <span class="Op">&lt;-</span> maybe-coerce second-arg-box:tagged-value-address/deref integer:literal<span class="Delimiter">)</span></span>
        <span class="Mu"><span class="Delimiter">(</span>result:integer <span class="Op">&lt;-</span> add first-arg:integer second-arg:integer<span class="Delimiter">)</span></span>
        <span class="Mu"><span class="Delimiter">(</span><span class="Identifier">reply</span> result:integer<span class="Delimiter">)</span></span>
      }
      <span class="Comment">; if given booleans, or them (it's a silly kind of generic function)</span>
      { <span class="CommentedCode">begin</span>
        <span class="Mu"><span class="Delimiter">(</span>first-arg:boolean match?:boolean <span class="Op">&lt;-</span> maybe-coerce first-arg-box:tagged-value-address/deref boolean:literal<span class="Delimiter">)</span></span>
        <span class="Mu"><span class="Delimiter">(</span><span class="Identifier">break-unless</span> match?:boolean<span class="Delimiter">)</span></span>
        <span class="Mu"><span class="Delimiter">(</span>second-arg-box:tagged-value-address <span class="Op">&lt;-</span> <span class="Identifier">next-input</span><span class="Delimiter">)</span></span>
        <span class="Mu"><span class="Delimiter">(</span>second-arg:boolean <span class="Op">&lt;-</span> maybe-coerce second-arg-box:tagged-value-address/deref boolean:literal<span class="Delimiter">)</span></span>
        <span class="Mu"><span class="Delimiter">(</span>result:boolean <span class="Op">&lt;-</span> or first-arg:boolean second-arg:boolean<span class="Delimiter">)</span></span>
        <span class="Mu"><span class="Delimiter">(</span><span class="Identifier">reply</span> result:integer<span class="Delimiter">)</span></span>
      }
      <span class="Mu"><span class="Delimiter">(</span><span class="Identifier">reply</span> <span class="MuConstant">nil</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])</span>
    <span class="Mu"><span class="Delimiter">(</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:tagged-value-address <span class="Op">&lt;-</span> init-tagged-value boolean:literal <span class="MuConstant">t</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:tagged-value-address <span class="Op">&lt;-</span> init-tagged-value boolean:literal <span class="MuConstant">nil</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:boolean <span class="Op">&lt;-</span> test1 <span class="Constant">1</span>:tagged-value-address <span class="Constant">2</span>:tagged-value-address<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="CommentedCode">;? (each stmt function*!test-fn</span>
<span class="CommentedCode">;?   (prn &quot;  &quot; stmt))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (wipe dump-trace*)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Global">memory*</span><span class="Constant">.3</span> t<span class="Delimiter">)</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - an example function that can do different things (dispatch) based on the type of its args or oargs&quot;</span><span class="Delimiter">))</span>
<span class="CommentedCode">;? (quit)</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;dispatch-multiple-calls&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function test1 <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span>default-space:space-address <span class="Op">&lt;-</span> new space:literal <span class="MuConstant">20</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span>first-arg-box:tagged-value-address <span class="Op">&lt;-</span> <span class="Identifier">next-input</span><span class="Delimiter">)</span></span>
      <span class="Comment">; if given integers, add them</span>
      { <span class="CommentedCode">begin</span>
        <span class="Mu"><span class="Delimiter">(</span>first-arg:integer match?:boolean <span class="Op">&lt;-</span> maybe-coerce first-arg-box:tagged-value-address/deref integer:literal<span class="Delimiter">)</span></span>
        <span class="Mu"><span class="Delimiter">(</span><span class="Identifier">break-unless</span> match?:boolean<span class="Delimiter">)</span></span>
        <span class="Mu"><span class="Delimiter">(</span>second-arg-box:tagged-value-address <span class="Op">&lt;-</span> <span class="Identifier">next-input</span><span class="Delimiter">)</span></span>
        <span class="Mu"><span class="Delimiter">(</span>second-arg:integer <span class="Op">&lt;-</span> maybe-coerce second-arg-box:tagged-value-address/deref integer:literal<span class="Delimiter">)</span></span>
        <span class="Mu"><span class="Delimiter">(</span>result:integer <span class="Op">&lt;-</span> add first-arg:integer second-arg:integer<span class="Delimiter">)</span></span>
        <span class="Mu"><span class="Delimiter">(</span><span class="Identifier">reply</span> result:integer<span class="Delimiter">)</span></span>
      }
      <span class="Comment">; if given booleans, or them (it's a silly kind of generic function)</span>
      { <span class="CommentedCode">begin</span>
        <span class="Mu"><span class="Delimiter">(</span>first-arg:boolean match?:boolean <span class="Op">&lt;-</span> maybe-coerce first-arg-box:tagged-value-address/deref boolean:literal<span class="Delimiter">)</span></span>
        <span class="Mu"><span class="Delimiter">(</span><span class="Identifier">break-unless</span> match?:boolean<span class="Delimiter">)</span></span>
        <span class="Mu"><span class="Delimiter">(</span>second-arg-box:tagged-value-address <span class="Op">&lt;-</span> <span class="Identifier">next-input</span><span class="Delimiter">)</span></span>
        <span class="Mu"><span class="Delimiter">(</span>second-arg:boolean <span class="Op">&lt;-</span> maybe-coerce second-arg-box:tagged-value-address/deref boolean:literal<span class="Delimiter">)</span></span>
        <span class="Mu"><span class="Delimiter">(</span>result:boolean <span class="Op">&lt;-</span> or first-arg:boolean second-arg:boolean<span class="Delimiter">)</span></span>
        <span class="Mu"><span class="Delimiter">(</span><span class="Identifier">reply</span> result:integer<span class="Delimiter">)</span></span>
      }
      <span class="Mu"><span class="Delimiter">(</span><span class="Identifier">reply</span> <span class="MuConstant">nil</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])</span>
    <span class="Mu"><span class="Delimiter">(</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:tagged-value-address <span class="Op">&lt;-</span> init-tagged-value boolean:literal <span class="MuConstant">t</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:tagged-value-address <span class="Op">&lt;-</span> init-tagged-value boolean:literal <span class="MuConstant">nil</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:boolean <span class="Op">&lt;-</span> test1 <span class="Constant">1</span>:tagged-value-address <span class="Constant">2</span>:tagged-value-address<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">10</span>:tagged-value-address <span class="Op">&lt;-</span> init-tagged-value integer:literal <span class="MuConstant">34</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">11</span>:tagged-value-address <span class="Op">&lt;-</span> init-tagged-value integer:literal <span class="MuConstant">3</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">12</span>:integer <span class="Op">&lt;-</span> test1 <span class="Constant">10</span>:tagged-value-address <span class="Constant">11</span>:tagged-value-address<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~and <span class="Delimiter">(</span>is <span class="Global">memory*</span><span class="Constant">.3</span> t<span class="Delimiter">)</span> <span class="Delimiter">(</span>is <span class="Global">memory*</span><span class="Constant">.12</span> <span class="Constant">37</span><span class="Delimiter">))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - different calls can exercise different clauses of the same function&quot;</span><span class="Delimiter">))</span>

<span class="Comment">; We can also dispatch based on the type of the operands or results at the</span>
<span class="Comment">; caller.</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;dispatch-otype&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function test1 <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">4</span>:type <span class="Op">&lt;-</span> otype <span class="MuConstant">0</span>:offset<span class="Delimiter">)</span></span>
      { <span class="CommentedCode">begin</span>
        <span class="Mu"><span class="Delimiter">(</span><span class="Constant">5</span>:boolean <span class="Op">&lt;-</span> equal <span class="Constant">4</span>:type integer:literal<span class="Delimiter">)</span></span>
        <span class="Mu"><span class="Delimiter">(</span><span class="Identifier">break-unless</span> <span class="Constant">5</span>:boolean<span class="Delimiter">)</span></span>
        <span class="Mu"><span class="Delimiter">(</span><span class="Constant">6</span>:integer <span class="Op">&lt;-</span> <span class="Identifier">next-input</span><span class="Delimiter">)</span></span>
        <span class="Mu"><span class="Delimiter">(</span><span class="Constant">7</span>:integer <span class="Op">&lt;-</span> <span class="Identifier">next-input</span><span class="Delimiter">)</span></span>
        <span class="Mu"><span class="Delimiter">(</span><span class="Constant">8</span>:integer <span class="Op">&lt;-</span> add <span class="Constant">6</span>:integer <span class="Constant">7</span>:integer<span class="Delimiter">)</span></span>
      }
      <span class="Mu"><span class="Delimiter">(</span><span class="Identifier">reply</span> <span class="Constant">8</span>:integer<span class="Delimiter">)</span></span>
     <span class="Delimiter">])</span>
    <span class="Mu"><span class="Delimiter">(</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> test1 <span class="MuConstant">1</span>:literal <span class="MuConstant">3</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Global">memory*</span><span class="Constant">.1</span> <span class="Constant">4</span><span class="Delimiter">)</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - an example function that checks that its oarg is an integer&quot;</span><span class="Delimiter">))</span>
<span class="CommentedCode">;? (quit)</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;dispatch-otype-multiple-clauses&quot;</span><span class="Delimiter">)</span>
<span class="CommentedCode">;? (set dump-trace*)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function test1 <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">4</span>:type <span class="Op">&lt;-</span> otype <span class="MuConstant">0</span>:offset<span class="Delimiter">)</span></span>
      { <span class="CommentedCode">begin</span>
        <span class="Comment">; integer needed? add args</span>
        <span class="Mu"><span class="Delimiter">(</span><span class="Constant">5</span>:boolean <span class="Op">&lt;-</span> equal <span class="Constant">4</span>:type integer:literal<span class="Delimiter">)</span></span>
        <span class="Mu"><span class="Delimiter">(</span><span class="Identifier">break-unless</span> <span class="Constant">5</span>:boolean<span class="Delimiter">)</span></span>
        <span class="Mu"><span class="Delimiter">(</span><span class="Constant">6</span>:integer <span class="Op">&lt;-</span> <span class="Identifier">next-input</span><span class="Delimiter">)</span></span>
        <span class="Mu"><span class="Delimiter">(</span><span class="Constant">7</span>:integer <span class="Op">&lt;-</span> <span class="Identifier">next-input</span><span class="Delimiter">)</span></span>
        <span class="Mu"><span class="Delimiter">(</span><span class="Constant">8</span>:integer <span class="Op">&lt;-</span> add <span class="Constant">6</span>:integer <span class="Constant">7</span>:integer<span class="Delimiter">)</span></span>
        <span class="Mu"><span class="Delimiter">(</span><span class="Identifier">reply</span> <span class="Constant">8</span>:integer<span class="Delimiter">)</span></span>
      }
      { <span class="CommentedCode">begin</span>
        <span class="Comment">; boolean needed? 'or' args</span>
        <span class="Mu"><span class="Delimiter">(</span><span class="Constant">5</span>:boolean <span class="Op">&lt;-</span> equal <span class="Constant">4</span>:type boolean:literal<span class="Delimiter">)</span></span>
        <span class="Mu"><span class="Delimiter">(</span><span class="Identifier">break-unless</span> <span class="Constant">5</span>:boolean <span class="MuConstant">4</span>:offset<span class="Delimiter">)</span></span>
        <span class="Mu"><span class="Delimiter">(</span><span class="Constant">6</span>:boolean <span class="Op">&lt;-</span> <span class="Identifier">next-input</span><span class="Delimiter">)</span></span>
        <span class="Mu"><span class="Delimiter">(</span><span class="Constant">7</span>:boolean <span class="Op">&lt;-</span> <span class="Identifier">next-input</span><span class="Delimiter">)</span></span>
        <span class="Mu"><span class="Delimiter">(</span><span class="Constant">8</span>:boolean <span class="Op">&lt;-</span> or <span class="Constant">6</span>:boolean <span class="Constant">7</span>:boolean<span class="Delimiter">)</span></span>
        <span class="Mu"><span class="Delimiter">(</span><span class="Identifier">reply</span> <span class="Constant">8</span>:boolean<span class="Delimiter">)</span></span>
      }<span class="Delimiter">])</span>
    <span class="Mu"><span class="Delimiter">(</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:boolean <span class="Op">&lt;-</span> test1 <span class="MuConstant">t</span>:literal <span class="MuConstant">t</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="CommentedCode">;? (each stmt function*!test1</span>
<span class="CommentedCode">;?   (prn &quot;  &quot; stmt))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (wipe dump-trace*)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Global">memory*</span><span class="Constant">.1</span> t<span class="Delimiter">)</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - an example function that can do different things (dispatch) based on the type of its args or oargs&quot;</span><span class="Delimiter">))</span>
<span class="CommentedCode">;? (quit)</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;dispatch-otype-multiple-calls&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function test1 <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">4</span>:type <span class="Op">&lt;-</span> otype <span class="MuConstant">0</span>:offset<span class="Delimiter">)</span></span>
      { <span class="CommentedCode">begin</span>
        <span class="Mu"><span class="Delimiter">(</span><span class="Constant">5</span>:boolean <span class="Op">&lt;-</span> equal <span class="Constant">4</span>:type integer:literal<span class="Delimiter">)</span></span>
        <span class="Mu"><span class="Delimiter">(</span><span class="Identifier">break-unless</span> <span class="Constant">5</span>:boolean<span class="Delimiter">)</span></span>
        <span class="Mu"><span class="Delimiter">(</span><span class="Constant">6</span>:integer <span class="Op">&lt;-</span> <span class="Identifier">next-input</span><span class="Delimiter">)</span></span>
        <span class="Mu"><span class="Delimiter">(</span><span class="Constant">7</span>:integer <span class="Op">&lt;-</span> <span class="Identifier">next-input</span><span class="Delimiter">)</span></span>
        <span class="Mu"><span class="Delimiter">(</span><span class="Constant">8</span>:integer <span class="Op">&lt;-</span> add <span class="Constant">6</span>:integer <span class="Constant">7</span>:integer<span class="Delimiter">)</span></span>
        <span class="Mu"><span class="Delimiter">(</span><span class="Identifier">reply</span> <span class="Constant">8</span>:integer<span class="Delimiter">)</span></span>
      }
      { <span class="CommentedCode">begin</span>
        <span class="Mu"><span class="Delimiter">(</span><span class="Constant">5</span>:boolean <span class="Op">&lt;-</span> equal <span class="Constant">4</span>:type boolean:literal<span class="Delimiter">)</span></span>
        <span class="Mu"><span class="Delimiter">(</span><span class="Identifier">break-unless</span> <span class="Constant">5</span>:boolean<span class="Delimiter">)</span></span>
        <span class="Mu"><span class="Delimiter">(</span><span class="Constant">6</span>:boolean <span class="Op">&lt;-</span> <span class="Identifier">next-input</span><span class="Delimiter">)</span></span>
        <span class="Mu"><span class="Delimiter">(</span><span class="Constant">7</span>:boolean <span class="Op">&lt;-</span> <span class="Identifier">next-input</span><span class="Delimiter">)</span></span>
        <span class="Mu"><span class="Delimiter">(</span><span class="Constant">8</span>:boolean <span class="Op">&lt;-</span> or <span class="Constant">6</span>:boolean <span class="Constant">7</span>:boolean<span class="Delimiter">)</span></span>
        <span class="Mu"><span class="Delimiter">(</span><span class="Identifier">reply</span> <span class="Constant">8</span>:boolean<span class="Delimiter">)</span></span>
      }<span class="Delimiter">])</span>
    <span class="Mu"><span class="Delimiter">(</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:boolean <span class="Op">&lt;-</span> test1 <span class="MuConstant">t</span>:literal <span class="MuConstant">t</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> test1 <span class="MuConstant">3</span>:literal <span class="MuConstant">4</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~and <span class="Delimiter">(</span>is <span class="Global">memory*</span><span class="Constant">.1</span> t<span class="Delimiter">)</span> <span class="Delimiter">(</span>is <span class="Global">memory*</span><span class="Constant">.2</span> <span class="Constant">7</span><span class="Delimiter">))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - different calls can exercise different clauses of the same function&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">)</span>  <span class="Comment">; section 100</span>

<span class="Delimiter">(</span>section <span class="Constant">20</span>

<span class="SalientComment">;; Concurrency</span>
<span class="Comment">;</span>
<span class="Comment">; A rudimentary process scheduler. You can 'run' multiple functions at once,</span>
<span class="Comment">; and they share the virtual processor.</span>
<span class="Comment">;</span>
<span class="Comment">; There's also a 'fork' primitive to let functions create new threads of</span>
<span class="Comment">; execution (we call them routines).</span>
<span class="Comment">;</span>
<span class="Comment">; Eventually we want to allow callers to influence how much of their CPU they</span>
<span class="Comment">; give to their 'children', or to rescind a child's running privileges.</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;scheduler&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>= <span class="Global">traces*</span> <span class="Delimiter">(</span>queue<span class="Delimiter">))</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function f1 <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">3</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])</span>
    <span class="Mu"><span class="Delimiter">(</span>function f2 <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">4</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>f1 <span class="Delimiter">'</span>f2<span class="Delimiter">)</span>
<span class="Delimiter">(</span>when <span class="Delimiter">(</span>~iso <span class="Constant">2</span> <span class="Global">curr-cycle*</span><span class="Delimiter">)</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - scheduler didn't run the right number of instructions: &quot;</span> <span class="Global">curr-cycle*</span><span class="Delimiter">))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Global">memory*</span> <span class="Delimiter">(</span>obj <span class="Constant">1</span> <span class="Constant">3</span>  <span class="Constant">2</span> <span class="Constant">4</span><span class="Delimiter">))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - scheduler runs multiple functions: &quot;</span> <span class="Global">memory*</span><span class="Delimiter">))</span>
<span class="Delimiter">(</span>check-trace-contents <span class="Constant">&quot;scheduler orders functions correctly&quot;</span>
  <span class="Delimiter">'((</span><span class="Constant">&quot;schedule&quot;</span> <span class="Constant">&quot;f1&quot;</span><span class="Delimiter">)</span>
    <span class="Delimiter">(</span><span class="Constant">&quot;schedule&quot;</span> <span class="Constant">&quot;f2&quot;</span><span class="Delimiter">)</span>
  <span class="Delimiter">))</span>
<span class="Delimiter">(</span>check-trace-contents <span class="Constant">&quot;scheduler orders schedule and run events correctly&quot;</span>
  <span class="Delimiter">'((</span><span class="Constant">&quot;schedule&quot;</span> <span class="Constant">&quot;f1&quot;</span><span class="Delimiter">)</span>
    <span class="Delimiter">(</span><span class="Constant">&quot;run&quot;</span> <span class="Constant">&quot;f1 0&quot;</span><span class="Delimiter">)</span>
    <span class="Delimiter">(</span><span class="Constant">&quot;schedule&quot;</span> <span class="Constant">&quot;f2&quot;</span><span class="Delimiter">)</span>
    <span class="Delimiter">(</span><span class="Constant">&quot;run&quot;</span> <span class="Constant">&quot;f2 0&quot;</span><span class="Delimiter">)</span>
  <span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;scheduler-alternate&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>= <span class="Global">traces*</span> <span class="Delimiter">(</span>queue<span class="Delimiter">))</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function f1 <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])</span>
    <span class="Mu"><span class="Delimiter">(</span>function f2 <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>= <span class="Global">scheduling-interval*</span> <span class="Constant">1</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>f1 <span class="Delimiter">'</span>f2<span class="Delimiter">)</span>
<span class="Delimiter">(</span>check-trace-contents <span class="Constant">&quot;scheduler alternates between routines&quot;</span>
  <span class="Delimiter">'((</span><span class="Constant">&quot;run&quot;</span> <span class="Constant">&quot;f1 0&quot;</span><span class="Delimiter">)</span>
    <span class="Delimiter">(</span><span class="Constant">&quot;run&quot;</span> <span class="Constant">&quot;f2 0&quot;</span><span class="Delimiter">)</span>
    <span class="Delimiter">(</span><span class="Constant">&quot;run&quot;</span> <span class="Constant">&quot;f1 1&quot;</span><span class="Delimiter">)</span>
    <span class="Delimiter">(</span><span class="Constant">&quot;run&quot;</span> <span class="Constant">&quot;f2 1&quot;</span><span class="Delimiter">)</span>
  <span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;scheduler-sleep&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>= <span class="Global">traces*</span> <span class="Delimiter">(</span>queue<span class="Delimiter">))</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function f1 <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])</span>
    <span class="Mu"><span class="Delimiter">(</span>function f2 <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Comment">; add one baseline routine to run (empty running-routines* handled below)</span>
<span class="Delimiter">(</span>enq make-routine!f1 <span class="Global">running-routines*</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>assert <span class="Delimiter">(</span>is <span class="Constant">1</span> len.running-routines*<span class="Delimiter">))</span>
<span class="Comment">; sleeping routine</span>
<span class="Delimiter">(</span><span class="Normal">let</span> routine make-routine!f2
  <span class="Mu"><span class="Delimiter">(</span>= rep.routine!sleep <span class="Delimiter">'(</span>for-some-cycles <span class="Constant">23</span><span class="Delimiter">))</span></span>
  <span class="Delimiter">(</span>set <span class="Global">sleeping-routines*</span>.routine<span class="Delimiter">))</span>
<span class="Comment">; not yet time for it to wake up</span>
<span class="Delimiter">(</span>= <span class="Global">curr-cycle*</span> <span class="Constant">23</span><span class="Delimiter">)</span>
<span class="CommentedCode">;? (set dump-trace*)</span>
<span class="CommentedCode">;? (= dump-trace* (obj whitelist '(&quot;run&quot; &quot;schedule&quot;)))</span>
<span class="Delimiter">(</span>update-scheduler-state<span class="Delimiter">)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Constant">1</span> len.running-routines*<span class="Delimiter">)</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - scheduler lets routines sleep&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;scheduler-wakeup&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>= <span class="Global">traces*</span> <span class="Delimiter">(</span>queue<span class="Delimiter">))</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function f1 <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])</span>
    <span class="Mu"><span class="Delimiter">(</span>function f2 <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Comment">; add one baseline routine to run (empty running-routines* handled below)</span>
<span class="Delimiter">(</span>enq make-routine!f1 <span class="Global">running-routines*</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>assert <span class="Delimiter">(</span>is <span class="Constant">1</span> len.running-routines*<span class="Delimiter">))</span>
<span class="Comment">; sleeping routine</span>
<span class="Delimiter">(</span><span class="Normal">let</span> routine make-routine!f2
  <span class="Delimiter">(</span>= rep.routine!sleep <span class="Delimiter">'(</span>for-some-cycles <span class="Constant">23</span><span class="Delimiter">))</span>
  <span class="Delimiter">(</span>set <span class="Global">sleeping-routines*</span>.routine<span class="Delimiter">))</span>
<span class="Comment">; time for it to wake up</span>
<span class="Delimiter">(</span>= <span class="Global">curr-cycle*</span> <span class="Constant">24</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>update-scheduler-state<span class="Delimiter">)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Constant">2</span> len.running-routines*<span class="Delimiter">)</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - scheduler wakes up sleeping routines at the right time&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;scheduler-sleep-location&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>= <span class="Global">traces*</span> <span class="Delimiter">(</span>queue<span class="Delimiter">))</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function f1 <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])</span>
    <span class="Mu"><span class="Delimiter">(</span>function f2 <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Comment">; add one baseline routine to run (empty running-routines* handled below)</span>
<span class="Delimiter">(</span>enq make-routine!f1 <span class="Global">running-routines*</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>assert <span class="Delimiter">(</span>is <span class="Constant">1</span> len.running-routines*<span class="Delimiter">))</span>
<span class="Comment">; blocked routine waiting for location 23 to change</span>
<span class="Delimiter">(</span><span class="Normal">let</span> routine make-routine!f2
  <span class="Delimiter">(</span>= rep.routine!sleep <span class="Delimiter">'(</span>until-location-changes <span class="Constant">23</span> <span class="Constant">0</span><span class="Delimiter">))</span>
  <span class="Delimiter">(</span>set <span class="Global">sleeping-routines*</span>.routine<span class="Delimiter">))</span>
<span class="Comment">; leave memory location 23 unchanged</span>
<span class="Delimiter">(</span>= <span class="Global">memory*</span><span class="Constant">.23</span> <span class="Constant">0</span><span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="CommentedCode">;? (prn running-routines*)</span>
<span class="CommentedCode">;? (prn sleeping-routines*)</span>
<span class="CommentedCode">;? (set dump-trace*)</span>
<span class="CommentedCode">;? (= dump-trace* (obj whitelist '(&quot;run&quot; &quot;schedule&quot;)))</span>
<span class="Delimiter">(</span>update-scheduler-state<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn running-routines*)</span>
<span class="CommentedCode">;? (prn sleeping-routines*)</span>
<span class="Comment">; routine remains blocked</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Constant">1</span> len.running-routines*<span class="Delimiter">)</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - scheduler lets routines block on locations&quot;</span><span class="Delimiter">))</span>
<span class="CommentedCode">;? (quit)</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;scheduler-wakeup-location&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>= <span class="Global">traces*</span> <span class="Delimiter">(</span>queue<span class="Delimiter">))</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function f1 <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])</span>
    <span class="Mu"><span class="Delimiter">(</span>function f2 <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Comment">; add one baseline routine to run (empty running-routines* handled below)</span>
<span class="Delimiter">(</span>enq make-routine!f1 <span class="Global">running-routines*</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>assert <span class="Delimiter">(</span>is <span class="Constant">1</span> len.running-routines*<span class="Delimiter">))</span>
<span class="Comment">; blocked routine waiting for location 23 to change</span>
<span class="Delimiter">(</span><span class="Normal">let</span> routine make-routine!f2
  <span class="Delimiter">(</span>= rep.routine!sleep <span class="Delimiter">'(</span>until-location-changes <span class="Constant">23</span> <span class="Constant">0</span><span class="Delimiter">))</span>
  <span class="Delimiter">(</span>set <span class="Global">sleeping-routines*</span>.routine<span class="Delimiter">))</span>
<span class="Comment">; change memory location 23</span>
<span class="Delimiter">(</span>= <span class="Global">memory*</span><span class="Constant">.23</span> <span class="Constant">1</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>update-scheduler-state<span class="Delimiter">)</span>
<span class="Comment">; routine unblocked</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Constant">2</span> len.running-routines*<span class="Delimiter">)</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - scheduler unblocks routines blocked on locations&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;scheduler-skip&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>= <span class="Global">traces*</span> <span class="Delimiter">(</span>queue<span class="Delimiter">))</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function f1 <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Comment">; running-routines* is empty</span>
<span class="Delimiter">(</span>assert <span class="Delimiter">(</span>empty <span class="Global">running-routines*</span><span class="Delimiter">))</span>
<span class="Comment">; sleeping routine</span>
<span class="Delimiter">(</span><span class="Normal">let</span> routine make-routine!f1
  <span class="Delimiter">(</span>= rep.routine!sleep <span class="Delimiter">'(</span>for-some-cycles <span class="Constant">34</span><span class="Delimiter">))</span>
  <span class="Delimiter">(</span>set <span class="Global">sleeping-routines*</span>.routine<span class="Delimiter">))</span>
<span class="Comment">; long time left for it to wake up</span>
<span class="Delimiter">(</span>= <span class="Global">curr-cycle*</span> <span class="Constant">0</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>update-scheduler-state<span class="Delimiter">)</span>
<span class="Delimiter">(</span>assert <span class="Delimiter">(</span>is <span class="Global">curr-cycle*</span> <span class="Constant">35</span><span class="Delimiter">))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Constant">1</span> len.running-routines*<span class="Delimiter">)</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - scheduler skips ahead to earliest sleeping routines when nothing to run&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;scheduler-deadlock&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>= <span class="Global">traces*</span> <span class="Delimiter">(</span>queue<span class="Delimiter">))</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function f1 <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>assert <span class="Delimiter">(</span>empty <span class="Global">running-routines*</span><span class="Delimiter">))</span>
<span class="Delimiter">(</span>assert <span class="Delimiter">(</span>empty <span class="Global">completed-routines*</span><span class="Delimiter">))</span>
<span class="Comment">; blocked routine</span>
<span class="Delimiter">(</span><span class="Normal">let</span> routine make-routine!f1
  <span class="Delimiter">(</span>= rep.routine!sleep <span class="Delimiter">'(</span>until-location-changes <span class="Constant">23</span> <span class="Constant">0</span><span class="Delimiter">))</span>
  <span class="Delimiter">(</span>set <span class="Global">sleeping-routines*</span>.routine<span class="Delimiter">))</span>
<span class="Comment">; location it's waiting on is 'unchanged'</span>
<span class="Delimiter">(</span>= <span class="Global">memory*</span><span class="Constant">.23</span> <span class="Constant">0</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>update-scheduler-state<span class="Delimiter">)</span>
<span class="Delimiter">(</span>assert <span class="Delimiter">(</span>~empty <span class="Global">completed-routines*</span><span class="Delimiter">))</span>
<span class="CommentedCode">;? (prn completed-routines*)</span>
<span class="Delimiter">(</span><span class="Normal">let</span> routine <span class="Global">completed-routines*</span><span class="Constant">.0</span>
  <span class="Delimiter">(</span>when <span class="Delimiter">(</span>~posmatch <span class="Constant">&quot;deadlock&quot;</span> rep.routine!error<span class="Delimiter">)</span>
    <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - scheduler detects deadlock&quot;</span><span class="Delimiter">)))</span>
<span class="CommentedCode">;? (quit)</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;scheduler-deadlock2&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>= <span class="Global">traces*</span> <span class="Delimiter">(</span>queue<span class="Delimiter">))</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function f1 <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Comment">; running-routines* is empty</span>
<span class="Delimiter">(</span>assert <span class="Delimiter">(</span>empty <span class="Global">running-routines*</span><span class="Delimiter">))</span>
<span class="Comment">; blocked routine</span>
<span class="Delimiter">(</span><span class="Normal">let</span> routine make-routine!f1
  <span class="Delimiter">(</span>= rep.routine!sleep <span class="Delimiter">'(</span>until-location-changes <span class="Constant">23</span> <span class="Constant">0</span><span class="Delimiter">))</span>
  <span class="Delimiter">(</span>set <span class="Global">sleeping-routines*</span>.routine<span class="Delimiter">))</span>
<span class="Comment">; but is about to become ready</span>
<span class="Delimiter">(</span>= <span class="Global">memory*</span><span class="Constant">.23</span> <span class="Constant">1</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>update-scheduler-state<span class="Delimiter">)</span>
<span class="Delimiter">(</span>when <span class="Delimiter">(</span>~empty <span class="Global">completed-routines*</span><span class="Delimiter">)</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - scheduler ignores sleeping but ready threads when detecting deadlock&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;sleep&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function f1 <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span>sleep for-some-cycles:literal <span class="MuConstant">1</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])</span>
    <span class="Mu"><span class="Delimiter">(</span>function f2 <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="CommentedCode">;? (= dump-trace* (obj whitelist '(&quot;run&quot; &quot;schedule&quot;)))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>f1 <span class="Delimiter">'</span>f2<span class="Delimiter">)</span>
<span class="Delimiter">(</span>check-trace-contents <span class="Constant">&quot;scheduler handles sleeping routines&quot;</span>
  <span class="Delimiter">'((</span><span class="Constant">&quot;run&quot;</span> <span class="Constant">&quot;f1 0&quot;</span><span class="Delimiter">)</span>
    <span class="Delimiter">(</span><span class="Constant">&quot;run&quot;</span> <span class="Constant">&quot;sleeping until 2&quot;</span><span class="Delimiter">)</span>
    <span class="Delimiter">(</span><span class="Constant">&quot;schedule&quot;</span> <span class="Constant">&quot;pushing f1 to sleep queue&quot;</span><span class="Delimiter">)</span>
    <span class="Delimiter">(</span><span class="Constant">&quot;run&quot;</span> <span class="Constant">&quot;f2 0&quot;</span><span class="Delimiter">)</span>
    <span class="Delimiter">(</span><span class="Constant">&quot;run&quot;</span> <span class="Constant">&quot;f2 1&quot;</span><span class="Delimiter">)</span>
    <span class="Delimiter">(</span><span class="Constant">&quot;schedule&quot;</span> <span class="Constant">&quot;waking up f1&quot;</span><span class="Delimiter">)</span>
    <span class="Delimiter">(</span><span class="Constant">&quot;run&quot;</span> <span class="Constant">&quot;f1 1&quot;</span><span class="Delimiter">)</span>
    <span class="Delimiter">(</span><span class="Constant">&quot;run&quot;</span> <span class="Constant">&quot;f1 2&quot;</span><span class="Delimiter">)</span>
  <span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;sleep-long&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function f1 <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span>sleep for-some-cycles:literal <span class="MuConstant">20</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])</span>
    <span class="Mu"><span class="Delimiter">(</span>function f2 <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="CommentedCode">;? (= dump-trace* (obj whitelist '(&quot;run&quot; &quot;schedule&quot;)))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>f1 <span class="Delimiter">'</span>f2<span class="Delimiter">)</span>
<span class="Delimiter">(</span>check-trace-contents <span class="Constant">&quot;scheduler progresses sleeping routines when there are no routines left to run&quot;</span>
  <span class="Delimiter">'((</span><span class="Constant">&quot;run&quot;</span> <span class="Constant">&quot;f1 0&quot;</span><span class="Delimiter">)</span>
    <span class="Delimiter">(</span><span class="Constant">&quot;run&quot;</span> <span class="Constant">&quot;sleeping until 21&quot;</span><span class="Delimiter">)</span>
    <span class="Delimiter">(</span><span class="Constant">&quot;schedule&quot;</span> <span class="Constant">&quot;pushing f1 to sleep queue&quot;</span><span class="Delimiter">)</span>
    <span class="Delimiter">(</span><span class="Constant">&quot;run&quot;</span> <span class="Constant">&quot;f2 0&quot;</span><span class="Delimiter">)</span>
    <span class="Delimiter">(</span><span class="Constant">&quot;run&quot;</span> <span class="Constant">&quot;f2 1&quot;</span><span class="Delimiter">)</span>
    <span class="Delimiter">(</span><span class="Constant">&quot;schedule&quot;</span> <span class="Constant">&quot;waking up f1&quot;</span><span class="Delimiter">)</span>
    <span class="Delimiter">(</span><span class="Constant">&quot;run&quot;</span> <span class="Constant">&quot;f1 1&quot;</span><span class="Delimiter">)</span>
    <span class="Delimiter">(</span><span class="Constant">&quot;run&quot;</span> <span class="Constant">&quot;f1 2&quot;</span><span class="Delimiter">)</span>
  <span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;sleep-location&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function f1 <span class="Delimiter">[</span></span>
      <span class="Comment">; waits for memory location 1 to be set, before computing its successor</span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span>sleep until-location-changes:literal <span class="Constant">1</span>:integer<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> add <span class="Constant">1</span>:integer <span class="MuConstant">1</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])</span>
    <span class="Mu"><span class="Delimiter">(</span>function f2 <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span>sleep for-some-cycles:literal <span class="MuConstant">30</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">3</span>:literal<span class="Delimiter">)</span>  <span class="Comment">; set to value</span></span>
     <span class="Delimiter">])))</span>
<span class="CommentedCode">;? (= dump-trace* (obj whitelist '(&quot;run&quot; &quot;schedule&quot;)))</span>
<span class="CommentedCode">;? (set dump-trace*)</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>f1 <span class="Delimiter">'</span>f2<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn int-canon.memory*)</span>
<span class="Delimiter">(</span>each routine <span class="Global">completed-routines*</span>
  <span class="Delimiter">(</span>aif rep.routine!error <span class="Delimiter">(</span>prn <span class="Constant">&quot;error - &quot;</span> it<span class="Delimiter">)))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Global">memory*</span><span class="Constant">.2</span> <span class="Constant">4</span><span class="Delimiter">)</span>  <span class="Comment">; successor of value</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - sleep can block on a memory location&quot;</span><span class="Delimiter">))</span>
<span class="CommentedCode">;? (quit)</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;sleep-scoped-location&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function f1 <span class="Delimiter">[</span></span>
      <span class="Comment">; waits for memory location 1 to be changed, before computing its successor</span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">10</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">5</span>:literal<span class="Delimiter">)</span>  <span class="Comment">; array of locals</span></span>
      <span class="Mu"><span class="Delimiter">(</span>default-space:space-address <span class="Op">&lt;-</span> copy <span class="MuConstant">10</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">23</span>:literal<span class="Delimiter">)</span>  <span class="Comment">; really location 12</span></span>
      <span class="Mu"><span class="Delimiter">(</span>sleep until-location-changes:literal <span class="Constant">1</span>:integer<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> add <span class="Constant">1</span>:integer <span class="MuConstant">1</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])</span>
    <span class="Mu"><span class="Delimiter">(</span>function f2 <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span>sleep for-some-cycles:literal <span class="MuConstant">30</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">12</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">3</span>:literal<span class="Delimiter">)</span>  <span class="Comment">; set to value</span></span>
     <span class="Delimiter">])))</span>
<span class="CommentedCode">;? (= dump-trace* (obj whitelist '(&quot;run&quot; &quot;schedule&quot;)))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>f1 <span class="Delimiter">'</span>f2<span class="Delimiter">)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Global">memory*</span><span class="Constant">.13</span> <span class="Constant">4</span><span class="Delimiter">)</span>  <span class="Comment">; successor of value</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - sleep can block on a scoped memory location&quot;</span><span class="Delimiter">))</span>
<span class="CommentedCode">;? (quit)</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;fork&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function f1 <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span>fork f2:fn<span class="Delimiter">)</span></span>
     <span class="Delimiter">])</span>
    <span class="Mu"><span class="Delimiter">(</span>function f2 <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">4</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>f1<span class="Delimiter">)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Global">memory*</span><span class="Constant">.2</span> <span class="Constant">4</span><span class="Delimiter">)</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - fork works&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;fork-with-args&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function f1 <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span>fork f2:fn <span class="MuConstant">nil</span>:literal <span class="MuConstant">4</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])</span>
    <span class="Mu"><span class="Delimiter">(</span>function f2 <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> <span class="Identifier">next-input</span><span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>f1<span class="Delimiter">)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Global">memory*</span><span class="Constant">.2</span> <span class="Constant">4</span><span class="Delimiter">)</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - fork can pass args&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;fork-copies-args&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function f1 <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span>default-space:space-address <span class="Op">&lt;-</span> new space:literal <span class="MuConstant">5</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span>x:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">4</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span>fork f2:fn <span class="MuConstant">nil</span>:literal x:integer<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span>x:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span>  <span class="Comment">; should be ignored</span></span>
     <span class="Delimiter">])</span>
    <span class="Mu"><span class="Delimiter">(</span>function f2 <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> <span class="Identifier">next-input</span><span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>f1<span class="Delimiter">)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Global">memory*</span><span class="Constant">.2</span> <span class="Constant">4</span><span class="Delimiter">)</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - fork passes args by value&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;fork-global&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function f1 <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer/raw <span class="Op">&lt;-</span> copy <span class="Constant">2</span>:integer/space:global<span class="Delimiter">)</span></span>
     <span class="Delimiter">])</span>
    <span class="Mu"><span class="Delimiter">(</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span>default-space:space-address <span class="Op">&lt;-</span> new space:literal <span class="MuConstant">5</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">4</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span>fork f1:fn default-space:space-address<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="Delimiter">(</span>each routine <span class="Global">completed-routines*</span>
  <span class="Delimiter">(</span>awhen rep.routine!error <span class="Delimiter">(</span>prn <span class="Constant">&quot;error - &quot;</span> it<span class="Delimiter">)))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Global">memory*</span><span class="Constant">.1</span> <span class="Constant">4</span><span class="Delimiter">)</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - fork can take a space of global variables to access&quot;</span><span class="Delimiter">))</span>

<span class="Comment">; The scheduler needs to keep track of the call stack for each routine.</span>
<span class="Comment">; Eventually we'll want to save this information in mu's address space itself,</span>
<span class="Comment">; along with the types array, the magic buffers for args and oargs, and so on.</span>
<span class="Comment">;</span>
<span class="Comment">; Eventually we want the right stack-management primitives to build delimited</span>
<span class="Comment">; continuations in mu.</span>

<span class="Comment">; Routines can throw errors.</span>
<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;array-bounds-check&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">2</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">23</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">24</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">4</span>:integer <span class="Op">&lt;-</span> index <span class="Constant">1</span>:integer-array <span class="MuConstant">2</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="CommentedCode">;? (set dump-trace*)</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">let</span> routine <span class="Delimiter">(</span>car <span class="Global">completed-routines*</span><span class="Delimiter">)</span>
  <span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>no rep.routine!error<span class="Delimiter">)</span>
    <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'index' throws an error if out of bounds&quot;</span><span class="Delimiter">)))</span>

<span class="Delimiter">)</span>  <span class="Comment">; section 20</span>

<span class="Delimiter">(</span>section <span class="Constant">100</span>

<span class="SalientComment">;; Synchronization</span>
<span class="Comment">;</span>
<span class="Comment">; Mu synchronizes using channels rather than locks, like Erlang and Go.</span>
<span class="Comment">;</span>
<span class="Comment">; The two ends of a channel will usually belong to different routines, but</span>
<span class="Comment">; each end should only be used by a single one. Don't try to read from or</span>
<span class="Comment">; write to it from multiple routines at once.</span>
<span class="Comment">;</span>
<span class="Comment">; To avoid locking, writer and reader will never write to the same location.</span>
<span class="Comment">; So channels will include fields in pairs, one for the writer and one for the</span>
<span class="Comment">; reader.</span>

<span class="Comment">; The core circular buffer contains values at index 'first-full' up to (but</span>
<span class="Comment">; not including) index 'first-empty'. The reader always modifies it at</span>
<span class="Comment">; first-full, while the writer always modifies it at first-empty.</span>
<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;channel-new&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:channel-address <span class="Op">&lt;-</span> init-channel <span class="MuConstant">3</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> get <span class="Constant">1</span>:channel-address/deref first-full:offset<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:integer <span class="Op">&lt;-</span> get <span class="Constant">1</span>:channel-address/deref first-free:offset<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="CommentedCode">;? (set dump-trace*)</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span><span class="Normal">or</span> <span class="Delimiter">(</span>~is <span class="Constant">0</span> <span class="Global">memory*</span><span class="Constant">.2</span><span class="Delimiter">)</span>
        <span class="Delimiter">(</span>~is <span class="Constant">0</span> <span class="Global">memory*</span><span class="Constant">.3</span><span class="Delimiter">))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'init-channel' initializes 'first-full and 'first-free to 0&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;channel-write&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:channel-address <span class="Op">&lt;-</span> init-channel <span class="MuConstant">3</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">34</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:tagged-value <span class="Op">&lt;-</span> save-type <span class="Constant">2</span>:integer<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:channel-address/deref <span class="Op">&lt;-</span> write <span class="Constant">1</span>:channel-address <span class="Constant">3</span>:tagged-value<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">5</span>:integer <span class="Op">&lt;-</span> get <span class="Constant">1</span>:channel-address/deref first-full:offset<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">6</span>:integer <span class="Op">&lt;-</span> get <span class="Constant">1</span>:channel-address/deref first-free:offset<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="CommentedCode">;? (prn function*!write)</span>
<span class="CommentedCode">;? (set dump-trace*)</span>
<span class="CommentedCode">;? (= dump-trace* (obj blacklist '(&quot;sz&quot; &quot;m&quot; &quot;setm&quot; &quot;addr&quot; &quot;array-len&quot; &quot;cvt0&quot; &quot;cvt1&quot;)))</span>
<span class="CommentedCode">;? (= dump-trace* (obj whitelist '(&quot;jump&quot;)))</span>
<span class="CommentedCode">;? (= dump-trace* (obj whitelist '(&quot;run&quot; &quot;reply&quot;)))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="Delimiter">(</span>each routine <span class="Global">completed-routines*</span>
  <span class="Delimiter">(</span>aif rep.routine!error <span class="Delimiter">(</span>prn <span class="Constant">&quot;error - &quot;</span> it<span class="Delimiter">)))</span>
<span class="CommentedCode">;? (prn canon.memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span><span class="Normal">or</span> <span class="Delimiter">(</span>~is <span class="Constant">0</span> <span class="Global">memory*</span><span class="Constant">.5</span><span class="Delimiter">)</span>
        <span class="Delimiter">(</span>~is <span class="Constant">1</span> <span class="Global">memory*</span><span class="Constant">.6</span><span class="Delimiter">))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'write' enqueues item to channel&quot;</span><span class="Delimiter">))</span>
<span class="CommentedCode">;? (quit)</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;channel-read&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:channel-address <span class="Op">&lt;-</span> init-channel <span class="MuConstant">3</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">34</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:tagged-value <span class="Op">&lt;-</span> save-type <span class="Constant">2</span>:integer<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:channel-address/deref <span class="Op">&lt;-</span> write <span class="Constant">1</span>:channel-address <span class="Constant">3</span>:tagged-value<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">5</span>:tagged-value <span class="Constant">1</span>:channel-address/deref <span class="Op">&lt;-</span> read <span class="Constant">1</span>:channel-address<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">7</span>:integer <span class="Op">&lt;-</span> maybe-coerce <span class="Constant">5</span>:tagged-value integer:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">8</span>:integer <span class="Op">&lt;-</span> get <span class="Constant">1</span>:channel-address/deref first-full:offset<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">9</span>:integer <span class="Op">&lt;-</span> get <span class="Constant">1</span>:channel-address/deref first-free:offset<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="CommentedCode">;? (set dump-trace*)</span>
<span class="CommentedCode">;? (= dump-trace* (obj blacklist '(&quot;sz&quot; &quot;m&quot; &quot;setm&quot; &quot;addr&quot; &quot;array-len&quot; &quot;cvt0&quot; &quot;cvt1&quot;)))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn int-canon.memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Global">memory*</span><span class="Constant">.7</span> <span class="Constant">34</span><span class="Delimiter">)</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'read' returns written value&quot;</span><span class="Delimiter">))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span><span class="Normal">or</span> <span class="Delimiter">(</span>~is <span class="Constant">1</span> <span class="Global">memory*</span><span class="Constant">.8</span><span class="Delimiter">)</span>
        <span class="Delimiter">(</span>~is <span class="Constant">1</span> <span class="Global">memory*</span><span class="Constant">.9</span><span class="Delimiter">))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'read' dequeues item from channel&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;channel-write-wrap&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Comment">; channel with 1 slot</span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:channel-address <span class="Op">&lt;-</span> init-channel <span class="MuConstant">1</span>:literal<span class="Delimiter">)</span></span>
      <span class="Comment">; write a value</span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">34</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:tagged-value <span class="Op">&lt;-</span> save-type <span class="Constant">2</span>:integer<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:channel-address/deref <span class="Op">&lt;-</span> write <span class="Constant">1</span>:channel-address <span class="Constant">3</span>:tagged-value<span class="Delimiter">)</span></span>
      <span class="Comment">; first-free will now be 1</span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">5</span>:integer <span class="Op">&lt;-</span> get <span class="Constant">1</span>:channel-address/deref first-free:offset<span class="Delimiter">)</span></span>
      <span class="Comment">; read one value</span>
      <span class="Mu"><span class="Delimiter">(</span>_ <span class="Constant">1</span>:channel-address/deref <span class="Op">&lt;-</span> read <span class="Constant">1</span>:channel-address<span class="Delimiter">)</span></span>
      <span class="Comment">; write a second value; verify that first-free wraps around to 0.</span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:channel-address/deref <span class="Op">&lt;-</span> write <span class="Constant">1</span>:channel-address <span class="Constant">3</span>:tagged-value<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">6</span>:integer <span class="Op">&lt;-</span> get <span class="Constant">1</span>:channel-address/deref first-free:offset<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="CommentedCode">;? (set dump-trace*)</span>
<span class="CommentedCode">;? (= dump-trace* (obj blacklist '(&quot;sz&quot; &quot;m&quot; &quot;setm&quot; &quot;addr&quot; &quot;array-len&quot; &quot;cvt0&quot; &quot;cvt1&quot;)))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn canon.memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span><span class="Normal">or</span> <span class="Delimiter">(</span>~is <span class="Constant">1</span> <span class="Global">memory*</span><span class="Constant">.5</span><span class="Delimiter">)</span>
        <span class="Delimiter">(</span>~is <span class="Constant">0</span> <span class="Global">memory*</span><span class="Constant">.6</span><span class="Delimiter">))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'write' can wrap pointer back to start&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;channel-read-wrap&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Comment">; channel with 1 slot</span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:channel-address <span class="Op">&lt;-</span> init-channel <span class="MuConstant">1</span>:literal<span class="Delimiter">)</span></span>
      <span class="Comment">; write a value</span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">34</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:tagged-value <span class="Op">&lt;-</span> save-type <span class="Constant">2</span>:integer<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:channel-address/deref <span class="Op">&lt;-</span> write <span class="Constant">1</span>:channel-address <span class="Constant">3</span>:tagged-value<span class="Delimiter">)</span></span>
      <span class="Comment">; read one value</span>
      <span class="Mu"><span class="Delimiter">(</span>_ <span class="Constant">1</span>:channel-address/deref <span class="Op">&lt;-</span> read <span class="Constant">1</span>:channel-address<span class="Delimiter">)</span></span>
      <span class="Comment">; first-full will now be 1</span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">5</span>:integer <span class="Op">&lt;-</span> get <span class="Constant">1</span>:channel-address/deref first-full:offset<span class="Delimiter">)</span></span>
      <span class="Comment">; write a second value</span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:channel-address/deref <span class="Op">&lt;-</span> write <span class="Constant">1</span>:channel-address <span class="Constant">3</span>:tagged-value<span class="Delimiter">)</span></span>
      <span class="Comment">; read second value; verify that first-full wraps around to 0.</span>
      <span class="Mu"><span class="Delimiter">(</span>_ <span class="Constant">1</span>:channel-address/deref <span class="Op">&lt;-</span> read <span class="Constant">1</span>:channel-address<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">6</span>:integer <span class="Op">&lt;-</span> get <span class="Constant">1</span>:channel-address/deref first-full:offset<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="CommentedCode">;? (set dump-trace*)</span>
<span class="CommentedCode">;? (= dump-trace* (obj blacklist '(&quot;sz&quot; &quot;m&quot; &quot;setm&quot; &quot;addr&quot; &quot;array-len&quot; &quot;cvt0&quot; &quot;cvt1&quot;)))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn canon.memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span><span class="Normal">or</span> <span class="Delimiter">(</span>~is <span class="Constant">1</span> <span class="Global">memory*</span><span class="Constant">.5</span><span class="Delimiter">)</span>
        <span class="Delimiter">(</span>~is <span class="Constant">0</span> <span class="Global">memory*</span><span class="Constant">.6</span><span class="Delimiter">))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'read' can wrap pointer back to start&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;channel-new-empty-not-full&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:channel-address <span class="Op">&lt;-</span> init-channel <span class="MuConstant">3</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:boolean <span class="Op">&lt;-</span> empty? <span class="Constant">1</span>:channel-address/deref<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:boolean <span class="Op">&lt;-</span> full? <span class="Constant">1</span>:channel-address/deref<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="CommentedCode">;? (set dump-trace*)</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span><span class="Normal">or</span> <span class="Delimiter">(</span>~is t <span class="Global">memory*</span><span class="Constant">.2</span><span class="Delimiter">)</span>
        <span class="Delimiter">(</span>~is nil <span class="Global">memory*</span><span class="Constant">.3</span><span class="Delimiter">))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - a new channel is always empty, never full&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;channel-write-not-empty&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:channel-address <span class="Op">&lt;-</span> init-channel <span class="MuConstant">3</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">34</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:tagged-value <span class="Op">&lt;-</span> save-type <span class="Constant">2</span>:integer<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:channel-address/deref <span class="Op">&lt;-</span> write <span class="Constant">1</span>:channel-address <span class="Constant">3</span>:tagged-value<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">5</span>:boolean <span class="Op">&lt;-</span> empty? <span class="Constant">1</span>:channel-address/deref<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">6</span>:boolean <span class="Op">&lt;-</span> full? <span class="Constant">1</span>:channel-address/deref<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="CommentedCode">;? (set dump-trace*)</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span><span class="Normal">or</span> <span class="Delimiter">(</span>~is nil <span class="Global">memory*</span><span class="Constant">.5</span><span class="Delimiter">)</span>
        <span class="Delimiter">(</span>~is nil <span class="Global">memory*</span><span class="Constant">.6</span><span class="Delimiter">))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - a channel after writing is never empty&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;channel-write-full&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:channel-address <span class="Op">&lt;-</span> init-channel <span class="MuConstant">1</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">34</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:tagged-value <span class="Op">&lt;-</span> save-type <span class="Constant">2</span>:integer<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:channel-address/deref <span class="Op">&lt;-</span> write <span class="Constant">1</span>:channel-address <span class="Constant">3</span>:tagged-value<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">5</span>:boolean <span class="Op">&lt;-</span> empty? <span class="Constant">1</span>:channel-address/deref<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">6</span>:boolean <span class="Op">&lt;-</span> full? <span class="Constant">1</span>:channel-address/deref<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="CommentedCode">;? (set dump-trace*)</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span><span class="Normal">or</span> <span class="Delimiter">(</span>~is nil <span class="Global">memory*</span><span class="Constant">.5</span><span class="Delimiter">)</span>
        <span class="Delimiter">(</span>~is t <span class="Global">memory*</span><span class="Constant">.6</span><span class="Delimiter">))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - a channel after writing may be full&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;channel-read-not-full&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:channel-address <span class="Op">&lt;-</span> init-channel <span class="MuConstant">3</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">34</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:tagged-value <span class="Op">&lt;-</span> save-type <span class="Constant">2</span>:integer<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:channel-address/deref <span class="Op">&lt;-</span> write <span class="Constant">1</span>:channel-address <span class="Constant">3</span>:tagged-value<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:channel-address/deref <span class="Op">&lt;-</span> write <span class="Constant">1</span>:channel-address <span class="Constant">3</span>:tagged-value<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span>_ <span class="Constant">1</span>:channel-address/deref <span class="Op">&lt;-</span> read <span class="Constant">1</span>:channel-address<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">5</span>:boolean <span class="Op">&lt;-</span> empty? <span class="Constant">1</span>:channel-address/deref<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">6</span>:boolean <span class="Op">&lt;-</span> full? <span class="Constant">1</span>:channel-address/deref<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="CommentedCode">;? (set dump-trace*)</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span><span class="Normal">or</span> <span class="Delimiter">(</span>~is nil <span class="Global">memory*</span><span class="Constant">.5</span><span class="Delimiter">)</span>
        <span class="Delimiter">(</span>~is nil <span class="Global">memory*</span><span class="Constant">.6</span><span class="Delimiter">))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - a channel after reading is never full&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;channel-read-empty&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:channel-address <span class="Op">&lt;-</span> init-channel <span class="MuConstant">3</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">34</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:tagged-value <span class="Op">&lt;-</span> save-type <span class="Constant">2</span>:integer<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:channel-address/deref <span class="Op">&lt;-</span> write <span class="Constant">1</span>:channel-address <span class="Constant">3</span>:tagged-value<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span>_ <span class="Constant">1</span>:channel-address/deref <span class="Op">&lt;-</span> read <span class="Constant">1</span>:channel-address<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">5</span>:boolean <span class="Op">&lt;-</span> empty? <span class="Constant">1</span>:channel-address/deref<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">6</span>:boolean <span class="Op">&lt;-</span> full? <span class="Constant">1</span>:channel-address/deref<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="CommentedCode">;? (set dump-trace*)</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span><span class="Normal">or</span> <span class="Delimiter">(</span>~is t <span class="Global">memory*</span><span class="Constant">.5</span><span class="Delimiter">)</span>
        <span class="Delimiter">(</span>~is nil <span class="Global">memory*</span><span class="Constant">.6</span><span class="Delimiter">))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - a channel after reading may be empty&quot;</span><span class="Delimiter">))</span>

<span class="Comment">; The key property of channels; writing to a full channel blocks the current</span>
<span class="Comment">; routine until it creates space. Ditto reading from an empty channel.</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;channel-read-block&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:channel-address <span class="Op">&lt;-</span> init-channel <span class="MuConstant">3</span>:literal<span class="Delimiter">)</span></span>
      <span class="Comment">; channel is empty, but receives a read</span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:tagged-value <span class="Constant">1</span>:channel-address/deref <span class="Op">&lt;-</span> read <span class="Constant">1</span>:channel-address<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="CommentedCode">;? (set dump-trace*)</span>
<span class="CommentedCode">;? (= dump-trace* (obj whitelist '(&quot;run&quot; &quot;schedule&quot;)))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn int-canon.memory*)</span>
<span class="CommentedCode">;? (prn sleeping-routines*)</span>
<span class="CommentedCode">;? (prn completed-routines*)</span>
<span class="Comment">; read should cause the routine to sleep, and</span>
<span class="Comment">; the sole sleeping routine should trigger the deadlock detector</span>
<span class="Delimiter">(</span><span class="Normal">let</span> routine <span class="Delimiter">(</span>car <span class="Global">completed-routines*</span><span class="Delimiter">)</span>
  <span class="Delimiter">(</span>when <span class="Delimiter">(</span><span class="Normal">or</span> <span class="Delimiter">(</span>no routine<span class="Delimiter">)</span>
            <span class="Delimiter">(</span>no rep.routine!error<span class="Delimiter">)</span>
            <span class="Delimiter">(</span>~posmatch <span class="Constant">&quot;deadlock&quot;</span> rep.routine!error<span class="Delimiter">))</span>
    <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'read' on empty channel blocks (puts the routine to sleep until the channel gets data)&quot;</span><span class="Delimiter">)))</span>
<span class="CommentedCode">;? (quit)</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;channel-write-block&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:channel-address <span class="Op">&lt;-</span> init-channel <span class="MuConstant">1</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">34</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:tagged-value <span class="Op">&lt;-</span> save-type <span class="Constant">2</span>:integer<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:channel-address/deref <span class="Op">&lt;-</span> write <span class="Constant">1</span>:channel-address <span class="Constant">3</span>:tagged-value<span class="Delimiter">)</span></span>
      <span class="Comment">; channel has capacity 1, but receives a second write</span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:channel-address/deref <span class="Op">&lt;-</span> write <span class="Constant">1</span>:channel-address <span class="Constant">3</span>:tagged-value<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="CommentedCode">;? (set dump-trace*)</span>
<span class="CommentedCode">;? (= dump-trace* (obj whitelist '(&quot;run&quot; &quot;schedule&quot; &quot;addr&quot;)))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn int-canon.memory*)</span>
<span class="CommentedCode">;? (prn running-routines*)</span>
<span class="CommentedCode">;? (prn sleeping-routines*)</span>
<span class="CommentedCode">;? (prn completed-routines*)</span>
<span class="Comment">; second write should cause the routine to sleep, and</span>
<span class="Comment">; the sole sleeping routine should trigger the deadlock detector</span>
<span class="Delimiter">(</span><span class="Normal">let</span> routine <span class="Delimiter">(</span>car <span class="Global">completed-routines*</span><span class="Delimiter">)</span>
  <span class="Delimiter">(</span>when <span class="Delimiter">(</span><span class="Normal">or</span> <span class="Delimiter">(</span>no routine<span class="Delimiter">)</span>
            <span class="Delimiter">(</span>no rep.routine!error<span class="Delimiter">)</span>
            <span class="Delimiter">(</span>~posmatch <span class="Constant">&quot;deadlock&quot;</span> rep.routine!error<span class="Delimiter">))</span>
    <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'write' on full channel blocks (puts the routine to sleep until the channel gets data)&quot;</span><span class="Delimiter">)))</span>
<span class="CommentedCode">;? (quit)</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;channel-handoff&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function consumer <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span>default-space:space-address <span class="Op">&lt;-</span> new space:literal <span class="MuConstant">30</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span>chan:channel-address <span class="Op">&lt;-</span> init-channel <span class="MuConstant">3</span>:literal<span class="Delimiter">)</span>  <span class="Comment">; create a channel</span></span>
      <span class="Mu"><span class="Delimiter">(</span>fork producer:fn <span class="MuConstant">nil</span>:literal chan:channel-address<span class="Delimiter">)</span>  <span class="Comment">; fork a routine to produce a value in it</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:tagged-value/raw <span class="Op">&lt;-</span> read chan:channel-address<span class="Delimiter">)</span>  <span class="Comment">; wait for input on channel</span></span>
     <span class="Delimiter">])</span>
    <span class="Mu"><span class="Delimiter">(</span>function producer <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span>default-space:space-address <span class="Op">&lt;-</span> new space:literal <span class="MuConstant">30</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span>n:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">24</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span>ochan:channel-address <span class="Op">&lt;-</span> <span class="Identifier">next-input</span><span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span>x:tagged-value <span class="Op">&lt;-</span> save-type n:integer<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span>ochan:channel-address/deref <span class="Op">&lt;-</span> write ochan:channel-address x:tagged-value<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="CommentedCode">;? (set dump-trace*)</span>
<span class="CommentedCode">;? (= dump-trace* (obj whitelist '(&quot;schedule&quot; &quot;run&quot; &quot;addr&quot;)))</span>
<span class="CommentedCode">;? (= dump-trace* (obj whitelist '(&quot;-&quot;)))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>consumer<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*)</span>
<span class="Delimiter">(</span>each routine <span class="Global">completed-routines*</span>
  <span class="Delimiter">(</span>aif rep.routine!error <span class="Delimiter">(</span>prn <span class="Constant">&quot;error - &quot;</span> it<span class="Delimiter">)))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Constant">24</span> <span class="Global">memory*</span><span class="Constant">.2</span><span class="Delimiter">)</span>  <span class="Comment">; location 1 contains tagged-value x above</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - channels are meant to be shared between routines&quot;</span><span class="Delimiter">))</span>
<span class="CommentedCode">;? (quit)</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;channel-handoff-routine&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function consumer <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span>default-space:space-address <span class="Op">&lt;-</span> new space:literal <span class="MuConstant">30</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:channel-address <span class="Op">&lt;-</span> init-channel <span class="MuConstant">3</span>:literal<span class="Delimiter">)</span>  <span class="Comment">; create a channel</span></span>
      <span class="Mu"><span class="Delimiter">(</span>fork producer:fn default-space:space-address<span class="Delimiter">)</span>  <span class="Comment">; pass it as a global to another routine</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:tagged-value/raw <span class="Op">&lt;-</span> read <span class="Constant">1</span>:channel-address<span class="Delimiter">)</span>  <span class="Comment">; wait for input on channel</span></span>
     <span class="Delimiter">])</span>
    <span class="Mu"><span class="Delimiter">(</span>function producer <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span>default-space:space-address <span class="Op">&lt;-</span> new space:literal <span class="MuConstant">30</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span>n:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">24</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span>x:tagged-value <span class="Op">&lt;-</span> save-type n:integer<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:channel-address/space:global/deref <span class="Op">&lt;-</span> write <span class="Constant">1</span>:channel-address/space:global x:tagged-value<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>consumer<span class="Delimiter">)</span>
<span class="Delimiter">(</span>each routine <span class="Global">completed-routines*</span>
  <span class="Delimiter">(</span>aif rep.routine!error <span class="Delimiter">(</span>prn <span class="Constant">&quot;error - &quot;</span> it<span class="Delimiter">)))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Constant">24</span> <span class="Global">memory*</span><span class="Constant">.2</span><span class="Delimiter">)</span>  <span class="Comment">; location 1 contains tagged-value x above</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - channels are meant to be shared between routines&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">)</span>  <span class="Comment">; section 100</span>

<span class="Delimiter">(</span>section <span class="Constant">10</span>

<span class="SalientComment">;; Separating concerns</span>
<span class="Comment">;</span>
<span class="Comment">; Lightweight tools can also operate on quoted lists of statements surrounded</span>
<span class="Comment">; by square brackets. In the example below, we mimic Go's 'defer' keyword</span>
<span class="Comment">; using 'convert-quotes'. It lets us write code anywhere in a function, but</span>
<span class="Comment">; have it run just before the function exits. Great for keeping code to</span>
<span class="Comment">; reclaim memory or other resources close to the code to allocate it. (C++</span>
<span class="Comment">; programmers know this as RAII.) We'll use 'defer' when we build a memory</span>
<span class="Comment">; deallocation routine like C's 'free'.</span>
<span class="Comment">;</span>
<span class="Comment">; More powerful reorderings are also possible like in Literate Programming or</span>
<span class="Comment">; Aspect-Oriented Programming; one advantage of prohibiting arbitrarily nested</span>
<span class="Comment">; code is that we can naturally name 'join points' wherever we want.</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;convert-quotes-defer&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>= <span class="Global">traces*</span> <span class="Delimiter">(</span>queue<span class="Delimiter">))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Delimiter">(</span>convert-quotes
            <span class="Mu"><span class="Delimiter">'((</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">4</span>:literal<span class="Delimiter">)</span></span>
              <span class="Mu"><span class="Delimiter">(</span>defer <span class="Delimiter">[</span></span>
                       <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">6</span>:literal<span class="Delimiter">)</span></span>
                     <span class="Delimiter">])</span>
              <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">5</span>:literal<span class="Delimiter">)))</span></span>
          <span class="Mu"><span class="Delimiter">'((</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">4</span>:literal<span class="Delimiter">)</span></span>
            <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">5</span>:literal<span class="Delimiter">)</span></span>
            <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">6</span>:literal<span class="Delimiter">)))</span></span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - convert-quotes can handle 'defer'&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;convert-quotes-defer-reply&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>= <span class="Global">traces*</span> <span class="Delimiter">(</span>queue<span class="Delimiter">))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Delimiter">(</span>convert-quotes
            <span class="Mu"><span class="Delimiter">'((</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
              <span class="Mu"><span class="Delimiter">(</span>defer <span class="Delimiter">[</span></span>
                       <span class="Mu"><span class="Delimiter">(</span><span class="Constant">5</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
                     <span class="Delimiter">])</span>
              <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
              <span class="Mu"><span class="Delimiter">(</span><span class="Identifier">reply</span><span class="Delimiter">)</span></span>
              <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
              <span class="Mu"><span class="Delimiter">(</span><span class="Constant">4</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)))</span></span>
          <span class="Mu"><span class="Delimiter">'((</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
            <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
            <span class="Mu"><span class="Delimiter">(</span><span class="Constant">5</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
            <span class="Mu"><span class="Delimiter">(</span><span class="Identifier">reply</span><span class="Delimiter">)</span></span>
            <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
            <span class="Mu"><span class="Delimiter">(</span><span class="Constant">4</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
            <span class="Mu"><span class="Delimiter">(</span><span class="Constant">5</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)))</span></span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - convert-quotes inserts code at early exits&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;convert-quotes-defer-reply-arg&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>= <span class="Global">traces*</span> <span class="Delimiter">(</span>queue<span class="Delimiter">))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Delimiter">(</span>convert-quotes
            <span class="Mu"><span class="Delimiter">'((</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
              <span class="Mu"><span class="Delimiter">(</span>defer <span class="Delimiter">[</span></span>
                       <span class="Mu"><span class="Delimiter">(</span><span class="Constant">5</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
                     <span class="Delimiter">])</span>
              <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
              <span class="Mu"><span class="Delimiter">(</span><span class="Identifier">reply</span> <span class="MuConstant">2</span>:literal<span class="Delimiter">)</span></span>
              <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
              <span class="Mu"><span class="Delimiter">(</span><span class="Constant">4</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)))</span></span>
          <span class="Mu"><span class="Delimiter">'((</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
            <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
            <span class="Mu"><span class="Delimiter">(</span>prepare-reply <span class="MuConstant">2</span>:literal<span class="Delimiter">)</span></span>
            <span class="Mu"><span class="Delimiter">(</span><span class="Constant">5</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
            <span class="Mu"><span class="Delimiter">(</span><span class="Identifier">reply</span><span class="Delimiter">)</span></span>
            <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
            <span class="Mu"><span class="Delimiter">(</span><span class="Constant">4</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
            <span class="Mu"><span class="Delimiter">(</span><span class="Constant">5</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)))</span></span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - convert-quotes inserts code at early exits&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;convert-quotes-label&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>= <span class="Global">traces*</span> <span class="Delimiter">(</span>queue<span class="Delimiter">))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Delimiter">(</span>convert-quotes
            <span class="Mu"><span class="Delimiter">'((</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">4</span>:literal<span class="Delimiter">)</span></span>
              foo
              <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">5</span>:literal<span class="Delimiter">)))</span></span>
          <span class="Mu"><span class="Delimiter">'((</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">4</span>:literal<span class="Delimiter">)</span></span>
            foo
            <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">5</span>:literal<span class="Delimiter">)))</span></span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - convert-quotes can handle labels&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;before&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>= <span class="Global">traces*</span> <span class="Delimiter">(</span>queue<span class="Delimiter">))</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>before label1 <span class="Delimiter">[</span></span>
     <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
    <span class="Delimiter">])))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Delimiter">(</span>as cons <span class="Global">before*</span>!label1<span class="Delimiter">)</span>
          <span class="Delimiter">'(</span><span class="Comment">; fragment</span>
            <span class="Delimiter">(</span>
              <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">))))</span></span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'before' records fragments of code to insert before labels&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Delimiter">(</span>insert-code
            <span class="Mu"><span class="Delimiter">'((</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
              <span class="Mu">label1</span>
              <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)))</span></span>
          <span class="Mu"><span class="Delimiter">'((</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
            <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
            <span class="Mu">label1</span>
            <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)))</span></span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'insert-code' can insert fragments before labels&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;before-multiple&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>= <span class="Global">traces*</span> <span class="Delimiter">(</span>queue<span class="Delimiter">))</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>before label1 <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])</span>
    <span class="Mu"><span class="Delimiter">(</span>before label1 <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Delimiter">(</span>as cons <span class="Global">before*</span>!label1<span class="Delimiter">)</span>
          <span class="Delimiter">'(</span><span class="Comment">; fragment</span>
            <span class="Delimiter">(</span>
              <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">))</span></span>
            <span class="Delimiter">(</span>
              <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">))))</span></span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'before' records fragments in order&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Delimiter">(</span>insert-code
            <span class="Mu"><span class="Delimiter">'((</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
              <span class="Mu">label1</span>
              <span class="Mu"><span class="Delimiter">(</span><span class="Constant">4</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)))</span></span>
          <span class="Mu"><span class="Delimiter">'((</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
            <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
            <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
            <span class="Mu">label1</span>
            <span class="Mu"><span class="Delimiter">(</span><span class="Constant">4</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)))</span></span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'insert-code' can insert multiple fragments in order before label&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;before-scoped&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>= <span class="Global">traces*</span> <span class="Delimiter">(</span>queue<span class="Delimiter">))</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>before f/label1 <span class="Delimiter">[</span>  <span class="Comment">; label1 only inside function f</span></span>
     <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
    <span class="Delimiter">])))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Delimiter">(</span>insert-code
            <span class="Mu"><span class="Delimiter">'((</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
              <span class="Mu">label1</span>
              <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">))</span></span>
            <span class="Delimiter">'</span>f<span class="Delimiter">)</span>
          <span class="Mu"><span class="Delimiter">'((</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
            <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
            <span class="Mu">label1</span>
            <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)))</span></span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'insert-code' can insert fragments before labels just in specified functions&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;before-scoped2&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>= <span class="Global">traces*</span> <span class="Delimiter">(</span>queue<span class="Delimiter">))</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>before f/label1 <span class="Delimiter">[</span>  <span class="Comment">; label1 only inside function f</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Delimiter">(</span>insert-code
            <span class="Mu"><span class="Delimiter">'((</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
              <span class="Mu">label1</span>
              <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)))</span></span>
          <span class="Mu"><span class="Delimiter">'((</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
            <span class="Mu">label1</span>
            <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)))</span></span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'insert-code' ignores labels not in specified functions&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;after&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>= <span class="Global">traces*</span> <span class="Delimiter">(</span>queue<span class="Delimiter">))</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>after label1 <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Delimiter">(</span>as cons <span class="Global">after*</span>!label1<span class="Delimiter">)</span>
          <span class="Delimiter">'(</span><span class="Comment">; fragment</span>
            <span class="Delimiter">(</span>
              <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">))))</span></span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'after' records fragments of code to insert after labels&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Delimiter">(</span>insert-code
            <span class="Mu"><span class="Delimiter">'((</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
              <span class="Mu">label1</span>
              <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)))</span></span>
          <span class="Mu"><span class="Delimiter">'((</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
            <span class="Mu">label1</span>
            <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
            <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)))</span></span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'insert-code' can insert fragments after labels&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;after-multiple&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>= <span class="Global">traces*</span> <span class="Delimiter">(</span>queue<span class="Delimiter">))</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>after label1 <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])</span>
    <span class="Mu"><span class="Delimiter">(</span>after label1 <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Delimiter">(</span>as cons <span class="Global">after*</span>!label1<span class="Delimiter">)</span>
          <span class="Delimiter">'(</span><span class="Comment">; fragment</span>
            <span class="Delimiter">(</span>
              <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">))</span></span>
            <span class="Delimiter">(</span>
              <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">))))</span></span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'after' records fragments in *reverse* order&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Delimiter">(</span>insert-code
            <span class="Mu"><span class="Delimiter">'((</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
              <span class="Mu">label1</span>
              <span class="Mu"><span class="Delimiter">(</span><span class="Constant">4</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)))</span></span>
          <span class="Mu"><span class="Delimiter">'((</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
            <span class="Mu">label1</span>
            <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
            <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
            <span class="Mu"><span class="Delimiter">(</span><span class="Constant">4</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)))</span></span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'insert-code' can insert multiple fragments in order after label&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;before-after&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>= <span class="Global">traces*</span> <span class="Delimiter">(</span>queue<span class="Delimiter">))</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>before label1 <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])</span>
    <span class="Mu"><span class="Delimiter">(</span>after label1 <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span><span class="Normal">and</span> <span class="Delimiter">(</span>~iso <span class="Delimiter">(</span>as cons <span class="Global">before*</span>!label1<span class="Delimiter">)</span>
               <span class="Delimiter">'(</span><span class="Comment">; fragment</span>
                 <span class="Delimiter">(</span>
                   <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">))))</span></span>
         <span class="Delimiter">(</span>~iso <span class="Delimiter">(</span>as cons <span class="Global">after*</span>!label1<span class="Delimiter">)</span>
               <span class="Delimiter">'(</span><span class="Comment">; fragment</span>
                 <span class="Delimiter">(</span>
                   <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)))))</span></span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'before' and 'after' fragments work together&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Delimiter">(</span>insert-code
            <span class="Mu"><span class="Delimiter">'((</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
              <span class="Mu">label1</span>
              <span class="Mu"><span class="Delimiter">(</span><span class="Constant">4</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)))</span></span>
          <span class="Mu"><span class="Delimiter">'((</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
            <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
            <span class="Mu">label1</span>
            <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
            <span class="Mu"><span class="Delimiter">(</span><span class="Constant">4</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)))</span></span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'insert-code' can insert multiple fragments around label&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;before-after-multiple&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>= <span class="Global">traces*</span> <span class="Delimiter">(</span>queue<span class="Delimiter">))</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>before label1 <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])</span>
    <span class="Mu"><span class="Delimiter">(</span>after label1 <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">4</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])</span>
    <span class="Mu"><span class="Delimiter">(</span>before label1 <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">5</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])</span>
    <span class="Mu"><span class="Delimiter">(</span>after label1 <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">6</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">7</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span><span class="Normal">or</span> <span class="Delimiter">(</span>~iso <span class="Delimiter">(</span>as cons <span class="Global">before*</span>!label1<span class="Delimiter">)</span>
              <span class="Delimiter">'(</span><span class="Comment">; fragment</span>
                <span class="Delimiter">(</span>
                  <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
                  <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">))</span></span>
                <span class="Delimiter">(</span>
                  <span class="Mu"><span class="Delimiter">(</span><span class="Constant">5</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">))))</span></span>
        <span class="Delimiter">(</span>~iso <span class="Delimiter">(</span>as cons <span class="Global">after*</span>!label1<span class="Delimiter">)</span>
              <span class="Delimiter">'(</span><span class="Comment">; fragment</span>
                <span class="Delimiter">(</span>
                  <span class="Mu"><span class="Delimiter">(</span><span class="Constant">6</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
                  <span class="Mu"><span class="Delimiter">(</span><span class="Constant">7</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">))</span></span>
                <span class="Delimiter">(</span>
                  <span class="Mu"><span class="Delimiter">(</span><span class="Constant">4</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)))))</span></span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - multiple 'before' and 'after' fragments at once&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Delimiter">(</span>insert-code
            <span class="Mu"><span class="Delimiter">'((</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
              <span class="Mu">label1</span>
              <span class="Mu"><span class="Delimiter">(</span><span class="Constant">8</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)))</span></span>
          <span class="Mu"><span class="Delimiter">'((</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
            <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
            <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
            <span class="Mu"><span class="Delimiter">(</span><span class="Constant">5</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
            <span class="Mu">label1</span>
            <span class="Mu"><span class="Delimiter">(</span><span class="Constant">6</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
            <span class="Mu"><span class="Delimiter">(</span><span class="Constant">7</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
            <span class="Mu"><span class="Delimiter">(</span><span class="Constant">4</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
            <span class="Mu"><span class="Delimiter">(</span><span class="Constant">8</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)))</span></span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'insert-code' can insert multiple fragments around label - 2&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;before-after-independent&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>= <span class="Global">traces*</span> <span class="Delimiter">(</span>queue<span class="Delimiter">))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Delimiter">(</span><span class="Normal">do</span>
            <span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
            <span class="Delimiter">(</span>add-code
              <span class="Mu"><span class="Delimiter">'((</span>before label1 <span class="Delimiter">[</span></span>
                  <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
                 <span class="Delimiter">])</span>
                <span class="Mu"><span class="Delimiter">(</span>after label1 <span class="Delimiter">[</span></span>
                  <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
                 <span class="Delimiter">])</span>
                <span class="Mu"><span class="Delimiter">(</span>before label1 <span class="Delimiter">[</span></span>
                  <span class="Mu"><span class="Delimiter">(</span><span class="Constant">4</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
                 <span class="Delimiter">])</span>
                <span class="Mu"><span class="Delimiter">(</span>after label1 <span class="Delimiter">[</span></span>
                  <span class="Mu"><span class="Delimiter">(</span><span class="Constant">5</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
                 <span class="Delimiter">])))</span>
            <span class="Delimiter">(</span>list <span class="Global">before*</span>!label1 <span class="Global">after*</span>!label1<span class="Delimiter">))</span>
          <span class="Delimiter">(</span><span class="Normal">do</span>
            <span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
            <span class="Delimiter">(</span>add-code
              <span class="Mu"><span class="Delimiter">'((</span>before label1 <span class="Delimiter">[</span></span>
                  <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
                 <span class="Delimiter">])</span>
                <span class="Mu"><span class="Delimiter">(</span>before label1 <span class="Delimiter">[</span></span>
                  <span class="Mu"><span class="Delimiter">(</span><span class="Constant">4</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
                 <span class="Delimiter">])</span>
                <span class="Mu"><span class="Delimiter">(</span>after label1 <span class="Delimiter">[</span></span>
                  <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
                 <span class="Delimiter">])</span>
                <span class="Mu"><span class="Delimiter">(</span>after label1 <span class="Delimiter">[</span></span>
                  <span class="Mu"><span class="Delimiter">(</span><span class="Constant">5</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
                 <span class="Delimiter">])))</span>
            <span class="Delimiter">(</span>list <span class="Global">before*</span>!label1 <span class="Global">after*</span>!label1<span class="Delimiter">)))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - order matters between 'before' and between 'after' fragments, but not *across* 'before' and 'after' fragments&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;before-after-braces&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>= <span class="Global">traces*</span> <span class="Delimiter">(</span>queue<span class="Delimiter">))</span>
<span class="Delimiter">(</span>= <span class="Global">function*</span> <span class="Delimiter">(</span>table<span class="Delimiter">))</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>after label1 <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])</span>
    <span class="Mu"><span class="Delimiter">(</span>function f1 <span class="Delimiter">[</span></span>
      { <span class="CommentedCode">begin</span>
        <span class="Mu">label1</span>
      }
     <span class="Delimiter">])))</span>
<span class="CommentedCode">;? (= dump-trace* (obj whitelist '(&quot;cn0&quot;)))</span>
<span class="Delimiter">(</span>freeze <span class="Global">function*</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Global">function*</span>!f1
          <span class="Mu"><span class="Delimiter">'(</span>label1</span>
            <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">1</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))))</span></span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - before/after works inside blocks&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;before-after-any-order&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>= <span class="Global">traces*</span> <span class="Delimiter">(</span>queue<span class="Delimiter">))</span>
<span class="Delimiter">(</span>= <span class="Global">function*</span> <span class="Delimiter">(</span>table<span class="Delimiter">))</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function f1 <span class="Delimiter">[</span></span>
      { <span class="CommentedCode">begin</span>
        <span class="Mu">label1</span>
      }
     <span class="Delimiter">])</span>
    <span class="Mu"><span class="Delimiter">(</span>after label1 <span class="Delimiter">[</span></span>
       <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>freeze <span class="Global">function*</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Global">function*</span>!f1
          <span class="Mu"><span class="Delimiter">'(</span>label1</span>
            <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">1</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))))</span></span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - before/after can come after the function they need to modify&quot;</span><span class="Delimiter">))</span>
<span class="CommentedCode">;? (quit)</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;multiple-defs&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>= <span class="Global">traces*</span> <span class="Delimiter">(</span>queue<span class="Delimiter">))</span>
<span class="Delimiter">(</span>= <span class="Global">function*</span> <span class="Delimiter">(</span>table<span class="Delimiter">))</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function f1 <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])</span>
    <span class="Mu"><span class="Delimiter">(</span>function f1 <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>freeze <span class="Global">function*</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Global">function*</span>!f1
          <span class="Mu"><span class="Delimiter">'((((</span><span class="Constant">2</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))</span></span>
            <span class="Mu"><span class="Delimiter">(((</span><span class="Constant">1</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))))</span></span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - multiple 'def' of the same function add clauses&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;def!&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>= <span class="Global">traces*</span> <span class="Delimiter">(</span>queue<span class="Delimiter">))</span>
<span class="Delimiter">(</span>= <span class="Global">function*</span> <span class="Delimiter">(</span>table<span class="Delimiter">))</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function f1 <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])</span>
    <span class="Mu"><span class="Delimiter">(</span>function! f1 <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> copy <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>freeze <span class="Global">function*</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Global">function*</span>!f1
          <span class="Mu"><span class="Delimiter">'((((</span><span class="Constant">2</span> integer<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>copy<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">0</span> literal<span class="Delimiter">)))))</span></span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'def!' clears all previous clauses&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">)</span>  <span class="Comment">; section 10</span>

<span class="SalientComment">;; ---</span>

<span class="Delimiter">(</span>section <span class="Constant">100</span>  <span class="Comment">; string utilities</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;string-new&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:string-address <span class="Op">&lt;-</span> new string:literal <span class="MuConstant">5</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span><span class="Normal">let</span> routine make-routine!main
  <span class="Delimiter">(</span>enq routine <span class="Global">running-routines*</span><span class="Delimiter">)</span>
  <span class="Delimiter">(</span><span class="Normal">let</span> before rep.routine!alloc
    <span class="Delimiter">(</span>run<span class="Delimiter">)</span>
    <span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso rep.routine!alloc <span class="Delimiter">(</span>+ before <span class="Constant">5</span> <span class="Constant">1</span><span class="Delimiter">))</span>
      <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'new' allocates arrays of bytes for strings&quot;</span><span class="Delimiter">))))</span>

<span class="Comment">; Convenience: initialize strings using string literals</span>
<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;string-literal&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:string-address <span class="Op">&lt;-</span> new <span class="Constant">&quot;hello&quot;</span><span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span><span class="Normal">let</span> routine make-routine!main
  <span class="Delimiter">(</span>enq routine <span class="Global">running-routines*</span><span class="Delimiter">)</span>
  <span class="Delimiter">(</span><span class="Normal">let</span> before rep.routine!alloc
<span class="CommentedCode">;?     (set dump-trace*)</span>
<span class="CommentedCode">;?     (= dump-trace* (obj whitelist '(&quot;schedule&quot; &quot;run&quot; &quot;addr&quot;)))</span>
    <span class="Delimiter">(</span>run<span class="Delimiter">)</span>
    <span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso rep.routine!alloc <span class="Delimiter">(</span>+ before <span class="Constant">5</span> <span class="Constant">1</span><span class="Delimiter">))</span>
      <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'new' allocates arrays of bytes for string literals&quot;</span><span class="Delimiter">))</span>
    <span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~memory-contains-array before <span class="Constant">&quot;hello&quot;</span><span class="Delimiter">)</span>
      <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'new' initializes allocated memory to string literal&quot;</span><span class="Delimiter">))))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;strcat&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:string-address <span class="Op">&lt;-</span> new <span class="Constant">&quot;hello,&quot;</span><span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:string-address <span class="Op">&lt;-</span> new <span class="Constant">&quot; world!&quot;</span><span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:string-address <span class="Op">&lt;-</span> strcat <span class="Constant">1</span>:string-address <span class="Constant">2</span>:string-address<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~memory-contains-array <span class="Global">memory*</span><span class="Constant">.3</span> <span class="Constant">&quot;hello, world!&quot;</span><span class="Delimiter">)</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'strcat' concatenates strings&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;interpolate&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:string-address <span class="Op">&lt;-</span> new <span class="Constant">&quot;hello, _!&quot;</span><span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:string-address <span class="Op">&lt;-</span> new <span class="Constant">&quot;abc&quot;</span><span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:string-address <span class="Op">&lt;-</span> interpolate <span class="Constant">1</span>:string-address <span class="Constant">2</span>:string-address<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="CommentedCode">;? (= dump-trace* (obj whitelist '(&quot;run&quot;)))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~memory-contains-array <span class="Global">memory*</span><span class="Constant">.3</span> <span class="Constant">&quot;hello, abc!&quot;</span><span class="Delimiter">)</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'interpolate' splices strings&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;interpolate-empty&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:string-address <span class="Op">&lt;-</span> new <span class="Constant">&quot;hello!&quot;</span><span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:string-address <span class="Op">&lt;-</span> new <span class="Constant">&quot;abc&quot;</span><span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:string-address <span class="Op">&lt;-</span> interpolate <span class="Constant">1</span>:string-address <span class="Constant">2</span>:string-address<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="CommentedCode">;? (= dump-trace* (obj whitelist '(&quot;run&quot;)))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~memory-contains-array <span class="Global">memory*</span><span class="Constant">.3</span> <span class="Constant">&quot;hello!&quot;</span><span class="Delimiter">)</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'interpolate' without underscore returns template&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;interpolate-at-start&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:string-address <span class="Op">&lt;-</span> new <span class="Constant">&quot;_, hello!&quot;</span><span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:string-address <span class="Op">&lt;-</span> new <span class="Constant">&quot;abc&quot;</span><span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:string-address <span class="Op">&lt;-</span> interpolate <span class="Constant">1</span>:string-address <span class="Constant">2</span>:string-address<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="CommentedCode">;? (= dump-trace* (obj whitelist '(&quot;run&quot;)))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~memory-contains-array <span class="Global">memory*</span><span class="Constant">.3</span> <span class="Constant">&quot;abc, hello&quot;</span><span class="Delimiter">)</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'interpolate' splices strings at start&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;interpolate-at-end&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:string-address <span class="Op">&lt;-</span> new <span class="Constant">&quot;hello, _&quot;</span><span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:string-address <span class="Op">&lt;-</span> new <span class="Constant">&quot;abc&quot;</span><span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:string-address <span class="Op">&lt;-</span> interpolate <span class="Constant">1</span>:string-address <span class="Constant">2</span>:string-address<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="CommentedCode">;? (= dump-trace* (obj whitelist '(&quot;run&quot;)))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~memory-contains-array <span class="Global">memory*</span><span class="Constant">.3</span> <span class="Constant">&quot;hello, abc&quot;</span><span class="Delimiter">)</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'interpolate' splices strings at start&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;interpolate-varargs&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:string-address <span class="Op">&lt;-</span> new <span class="Constant">&quot;hello, _, _, and _!&quot;</span><span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:string-address <span class="Op">&lt;-</span> new <span class="Constant">&quot;abc&quot;</span><span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">3</span>:string-address <span class="Op">&lt;-</span> new <span class="Constant">&quot;def&quot;</span><span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">4</span>:string-address <span class="Op">&lt;-</span> new <span class="Constant">&quot;ghi&quot;</span><span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">5</span>:string-address <span class="Op">&lt;-</span> interpolate <span class="Constant">1</span>:string-address <span class="Constant">2</span>:string-address <span class="Constant">3</span>:string-address <span class="Constant">4</span>:string-address<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="CommentedCode">;? (= dump-trace* (obj whitelist '(&quot;run&quot;)))</span>
<span class="CommentedCode">;? (= dump-trace* (obj whitelist '(&quot;run&quot; &quot;array-info&quot;)))</span>
<span class="CommentedCode">;? (set dump-trace*)</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (quit)</span>
<span class="CommentedCode">;? (up i 1 (+ 1 (memory* memory*.5))</span>
<span class="CommentedCode">;?   (prn (memory* (+ memory*.5 i))))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~memory-contains-array <span class="Global">memory*</span><span class="Constant">.5</span> <span class="Constant">&quot;hello, abc, def, and ghi!&quot;</span><span class="Delimiter">)</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'interpolate' splices in any number of strings&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;string-find-next&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:string-address <span class="Op">&lt;-</span> new <span class="Constant">&quot;a/b&quot;</span><span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> find-next <span class="Constant">1</span>:string-address <span class="Delimiter">((</span><span class="MuConstant">#\/</span> literal<span class="Delimiter">))</span> <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Global">memory*</span><span class="Constant">.2</span> <span class="Constant">1</span><span class="Delimiter">)</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'find-next' finds first location of a character&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;string-find-next-empty&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:string-address <span class="Op">&lt;-</span> new <span class="Constant">&quot;&quot;</span><span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> find-next <span class="Constant">1</span>:string-address <span class="Delimiter">((</span><span class="MuConstant">#\/</span> literal<span class="Delimiter">))</span> <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="Delimiter">(</span>each routine <span class="Global">completed-routines*</span>
  <span class="Delimiter">(</span>aif rep.routine!error <span class="Delimiter">(</span>prn <span class="Constant">&quot;error - &quot;</span> it<span class="Delimiter">)))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Global">memory*</span><span class="Constant">.2</span> <span class="Constant">0</span><span class="Delimiter">)</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'find-next' finds first location of a character&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;string-find-next-initial&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:string-address <span class="Op">&lt;-</span> new <span class="Constant">&quot;/abc&quot;</span><span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> find-next <span class="Constant">1</span>:string-address <span class="Delimiter">((</span><span class="MuConstant">#\/</span> literal<span class="Delimiter">))</span> <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Global">memory*</span><span class="Constant">.2</span> <span class="Constant">0</span><span class="Delimiter">)</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'find-next' handles prefix match&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;string-find-next-final&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:string-address <span class="Op">&lt;-</span> new <span class="Constant">&quot;abc/&quot;</span><span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> find-next <span class="Constant">1</span>:string-address <span class="Delimiter">((</span><span class="MuConstant">#\/</span> literal<span class="Delimiter">))</span> <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*.2)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Global">memory*</span><span class="Constant">.2</span> <span class="Constant">3</span><span class="Delimiter">)</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'find-next' handles suffix match&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;string-find-next-missing&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:string-address <span class="Op">&lt;-</span> new <span class="Constant">&quot;abc&quot;</span><span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> find-next <span class="Constant">1</span>:string-address <span class="Delimiter">((</span><span class="MuConstant">#\/</span> literal<span class="Delimiter">))</span> <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn memory*.2)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Global">memory*</span><span class="Constant">.2</span> <span class="Constant">3</span><span class="Delimiter">)</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'find-next' handles no match&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;string-find-next-invalid-index&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:string-address <span class="Op">&lt;-</span> new <span class="Constant">&quot;abc&quot;</span><span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> find-next <span class="Constant">1</span>:string-address <span class="Delimiter">((</span><span class="MuConstant">#\/</span> literal<span class="Delimiter">))</span> <span class="MuConstant">4</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="CommentedCode">;? (= dump-trace* (obj whitelist '(&quot;run&quot;)))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="Delimiter">(</span>each routine <span class="Global">completed-routines*</span>
  <span class="Delimiter">(</span>aif rep.routine!error <span class="Delimiter">(</span>prn <span class="Constant">&quot;error - &quot;</span> it<span class="Delimiter">)))</span>
<span class="CommentedCode">;? (prn memory*.2)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Global">memory*</span><span class="Constant">.2</span> <span class="Constant">4</span><span class="Delimiter">)</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'find-next' skips invalid index (past end of string)&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;string-find-next-first&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:string-address <span class="Op">&lt;-</span> new <span class="Constant">&quot;ab/c/&quot;</span><span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> find-next <span class="Constant">1</span>:string-address <span class="Delimiter">((</span><span class="MuConstant">#\/</span> literal<span class="Delimiter">))</span> <span class="MuConstant">0</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Global">memory*</span><span class="Constant">.2</span> <span class="Constant">2</span><span class="Delimiter">)</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'find-next' finds first of multiple options&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;string-find-next-second&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:string-address <span class="Op">&lt;-</span> new <span class="Constant">&quot;ab/c/&quot;</span><span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:integer <span class="Op">&lt;-</span> find-next <span class="Constant">1</span>:string-address <span class="Delimiter">((</span><span class="MuConstant">#\/</span> literal<span class="Delimiter">))</span> <span class="MuConstant">3</span>:literal<span class="Delimiter">)</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Global">memory*</span><span class="Constant">.2</span> <span class="Constant">4</span><span class="Delimiter">)</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'find-next' finds second of multiple options&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;string-split&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:string-address <span class="Op">&lt;-</span> new <span class="Constant">&quot;a/b&quot;</span><span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:string-address-array-address <span class="Op">&lt;-</span> split <span class="Constant">1</span>:string-address <span class="Delimiter">((</span><span class="MuConstant">#\/</span> literal<span class="Delimiter">)))</span></span>
     <span class="Delimiter">])))</span>
<span class="CommentedCode">;? (set dump-trace*)</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="Delimiter">(</span>each routine <span class="Global">completed-routines*</span>
  <span class="Delimiter">(</span>aif rep.routine!error <span class="Delimiter">(</span>prn <span class="Constant">&quot;error - &quot;</span> it<span class="Delimiter">)))</span>
<span class="Delimiter">(</span><span class="Normal">let</span> base <span class="Global">memory*</span><span class="Constant">.2</span>
<span class="CommentedCode">;?   (prn base &quot; &quot; memory*.base)</span>
  <span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span><span class="Normal">or</span> <span class="Delimiter">(</span>~is <span class="Global">memory*</span>.base <span class="Constant">2</span><span class="Delimiter">)</span>
<span class="CommentedCode">;?           (do1 nil prn.111)</span>
          <span class="Delimiter">(</span>~memory-contains-array <span class="Delimiter">(</span><span class="Global">memory*</span> <span class="Delimiter">(</span>+ base <span class="Constant">1</span><span class="Delimiter">))</span> <span class="Constant">&quot;a&quot;</span><span class="Delimiter">)</span>
<span class="CommentedCode">;?           (do1 nil prn.111)</span>
          <span class="Delimiter">(</span>~memory-contains-array <span class="Delimiter">(</span><span class="Global">memory*</span> <span class="Delimiter">(</span>+ base <span class="Constant">2</span><span class="Delimiter">))</span> <span class="Constant">&quot;b&quot;</span><span class="Delimiter">))</span>
    <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'split' cuts string at delimiter&quot;</span><span class="Delimiter">)))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;string-split2&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:string-address <span class="Op">&lt;-</span> new <span class="Constant">&quot;a/b/c&quot;</span><span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:string-address-array-address <span class="Op">&lt;-</span> split <span class="Constant">1</span>:string-address <span class="Delimiter">((</span><span class="MuConstant">#\/</span> literal<span class="Delimiter">)))</span></span>
     <span class="Delimiter">])))</span>
<span class="CommentedCode">;? (set dump-trace*)</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="Delimiter">(</span>each routine <span class="Global">completed-routines*</span>
  <span class="Delimiter">(</span>aif rep.routine!error <span class="Delimiter">(</span>prn <span class="Constant">&quot;error - &quot;</span> it<span class="Delimiter">)))</span>
<span class="Delimiter">(</span><span class="Normal">let</span> base <span class="Global">memory*</span><span class="Constant">.2</span>
<span class="CommentedCode">;?   (prn base &quot; &quot; memory*.base)</span>
  <span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span><span class="Normal">or</span> <span class="Delimiter">(</span>~is <span class="Global">memory*</span>.base <span class="Constant">3</span><span class="Delimiter">)</span>
<span class="CommentedCode">;?           (do1 nil prn.111)</span>
          <span class="Delimiter">(</span>~memory-contains-array <span class="Delimiter">(</span><span class="Global">memory*</span> <span class="Delimiter">(</span>+ base <span class="Constant">1</span><span class="Delimiter">))</span> <span class="Constant">&quot;a&quot;</span><span class="Delimiter">)</span>
<span class="CommentedCode">;?           (do1 nil prn.111)</span>
          <span class="Delimiter">(</span>~memory-contains-array <span class="Delimiter">(</span><span class="Global">memory*</span> <span class="Delimiter">(</span>+ base <span class="Constant">2</span><span class="Delimiter">))</span> <span class="Constant">&quot;b&quot;</span><span class="Delimiter">)</span>
<span class="CommentedCode">;?           (do1 nil prn.111)</span>
          <span class="Delimiter">(</span>~memory-contains-array <span class="Delimiter">(</span><span class="Global">memory*</span> <span class="Delimiter">(</span>+ base <span class="Constant">3</span><span class="Delimiter">))</span> <span class="Constant">&quot;c&quot;</span><span class="Delimiter">))</span>
    <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'split' cuts string at two delimiters&quot;</span><span class="Delimiter">)))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;string-split-missing&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:string-address <span class="Op">&lt;-</span> new <span class="Constant">&quot;abc&quot;</span><span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:string-address-array-address <span class="Op">&lt;-</span> split <span class="Constant">1</span>:string-address <span class="Delimiter">((</span><span class="MuConstant">#\/</span> literal<span class="Delimiter">)))</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="Delimiter">(</span>each routine <span class="Global">completed-routines*</span>
  <span class="Delimiter">(</span>aif rep.routine!error <span class="Delimiter">(</span>prn <span class="Constant">&quot;error - &quot;</span> it<span class="Delimiter">)))</span>
<span class="Delimiter">(</span><span class="Normal">let</span> base <span class="Global">memory*</span><span class="Constant">.2</span>
  <span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span><span class="Normal">or</span> <span class="Delimiter">(</span>~is <span class="Global">memory*</span>.base <span class="Constant">1</span><span class="Delimiter">)</span>
          <span class="Delimiter">(</span>~memory-contains-array <span class="Delimiter">(</span><span class="Global">memory*</span> <span class="Delimiter">(</span>+ base <span class="Constant">1</span><span class="Delimiter">))</span> <span class="Constant">&quot;abc&quot;</span><span class="Delimiter">))</span>
    <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'split' handles missing delimiter&quot;</span><span class="Delimiter">)))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;string-split-empty&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:string-address <span class="Op">&lt;-</span> new <span class="Constant">&quot;&quot;</span><span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:string-address-array-address <span class="Op">&lt;-</span> split <span class="Constant">1</span>:string-address <span class="Delimiter">((</span><span class="MuConstant">#\/</span> literal<span class="Delimiter">)))</span></span>
     <span class="Delimiter">])))</span>
<span class="CommentedCode">;? (= dump-trace* (obj whitelist '(&quot;run&quot;)))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="Delimiter">(</span>each routine <span class="Global">completed-routines*</span>
  <span class="Delimiter">(</span>aif rep.routine!error <span class="Delimiter">(</span>prn <span class="Constant">&quot;error - &quot;</span> it<span class="Delimiter">)))</span>
<span class="Delimiter">(</span><span class="Normal">let</span> base <span class="Global">memory*</span><span class="Constant">.2</span>
<span class="CommentedCode">;?   (prn base &quot; &quot; memory*.base)</span>
  <span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Global">memory*</span>.base <span class="Constant">0</span><span class="Delimiter">)</span>
    <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'split' handles empty string&quot;</span><span class="Delimiter">)))</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;string-split-empty-piece&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Mu"><span class="Delimiter">'((</span>function main <span class="Delimiter">[</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">1</span>:string-address <span class="Op">&lt;-</span> new <span class="Constant">&quot;a/b//c&quot;</span><span class="Delimiter">)</span></span>
      <span class="Mu"><span class="Delimiter">(</span><span class="Constant">2</span>:string-address-array-address <span class="Op">&lt;-</span> split <span class="Constant">1</span>:string-address <span class="Delimiter">((</span><span class="MuConstant">#\/</span> literal<span class="Delimiter">)))</span></span>
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span>run <span class="Delimiter">'</span>main<span class="Delimiter">)</span>
<span class="Delimiter">(</span>each routine <span class="Global">completed-routines*</span>
  <span class="Delimiter">(</span>aif rep.routine!error <span class="Delimiter">(</span>prn <span class="Constant">&quot;error - &quot;</span> it<span class="Delimiter">)))</span>
<span class="Delimiter">(</span><span class="Normal">let</span> base <span class="Global">memory*</span><span class="Constant">.2</span>
  <span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span><span class="Normal">or</span> <span class="Delimiter">(</span>~is <span class="Global">memory*</span>.base <span class="Constant">4</span><span class="Delimiter">)</span>
          <span class="Delimiter">(</span>~memory-contains-array <span class="Delimiter">(</span><span class="Global">memory*</span> <span class="Delimiter">(</span>+ base <span class="Constant">1</span><span class="Delimiter">))</span> <span class="Constant">&quot;a&quot;</span><span class="Delimiter">)</span>
          <span class="Delimiter">(</span>~memory-contains-array <span class="Delimiter">(</span><span class="Global">memory*</span> <span class="Delimiter">(</span>+ base <span class="Constant">2</span><span class="Delimiter">))</span> <span class="Constant">&quot;b&quot;</span><span class="Delimiter">)</span>
          <span class="Delimiter">(</span>~memory-contains-array <span class="Delimiter">(</span><span class="Global">memory*</span> <span class="Delimiter">(</span>+ base <span class="Constant">3</span><span class="Delimiter">))</span> <span class="Constant">&quot;&quot;</span><span class="Delimiter">)</span>
          <span class="Delimiter">(</span>~memory-contains-array <span class="Delimiter">(</span><span class="Global">memory*</span> <span class="Delimiter">(</span>+ base <span class="Constant">4</span><span class="Delimiter">))</span> <span class="Constant">&quot;c&quot;</span><span class="Delimiter">))</span>
    <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'split' cuts string at two delimiters&quot;</span><span class="Delimiter">)))</span>

<span class="Delimiter">)</span>  <span class="Comment">; section 100 for string utilities</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>new-trace <span class="Constant">&quot;parse-and-record&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>add-code
  <span class="Delimiter">'((</span>and-record foo <span class="Delimiter">[</span>
      x:string
      y:integer
      z:boolean
     <span class="Delimiter">])))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Global">type*</span>!foo <span class="Delimiter">(</span>obj size <span class="Constant">3</span>  and-record t  elems <span class="Delimiter">'((</span>string<span class="Delimiter">)</span> <span class="Delimiter">(</span>integer<span class="Delimiter">)</span> <span class="Delimiter">(</span>boolean<span class="Delimiter">))</span>  <span class="Normal">fields</span> <span class="Delimiter">'(</span>x y z<span class="Delimiter">)))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'add-code' can add new and-records&quot;</span><span class="Delimiter">))</span>

<span class="SalientComment">;; unit tests for various helpers</span>

<span class="Comment">; tokenize-args</span>
<span class="Delimiter">(</span>prn <span class="Constant">&quot;== tokenize-args&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>assert:iso <span class="Delimiter">'((</span>a b<span class="Delimiter">)</span> <span class="Delimiter">(</span>c d<span class="Delimiter">))</span>
            <span class="Delimiter">(</span>tokenize-arg <span class="Delimiter">'</span>a:b/c:d<span class="Delimiter">))</span>
<span class="Comment">; numbers are not symbols</span>
<span class="Delimiter">(</span>assert:iso <span class="Delimiter">'((</span>a b<span class="Delimiter">)</span> <span class="Delimiter">(</span><span class="Constant">1</span> d<span class="Delimiter">))</span>
            <span class="Delimiter">(</span>tokenize-arg <span class="Delimiter">'</span>a:b/1:d<span class="Delimiter">))</span>
<span class="Comment">; special symbols are skipped</span>
<span class="Mu"><span class="Delimiter">(</span>assert:iso <span class="Delimiter">'</span><span class="Op">&lt;-</span></span>
            <span class="Mu"><span class="Delimiter">(</span>tokenize-arg <span class="Delimiter">'</span><span class="Op">&lt;-</span><span class="Delimiter">))</span></span>
<span class="Delimiter">(</span>assert:iso <span class="Delimiter">'</span>_
            <span class="Delimiter">(</span>tokenize-arg <span class="Delimiter">'</span>_<span class="Delimiter">))</span>

<span class="Comment">; idempotent</span>
<span class="Delimiter">(</span>assert:iso <span class="Delimiter">(</span>tokenize-arg:tokenize-arg <span class="Delimiter">'</span>a:b/c:d<span class="Delimiter">)</span>
            <span class="Delimiter">(</span>tokenize-arg              <span class="Delimiter">'</span>a:b/c:d<span class="Delimiter">))</span>

<span class="Comment">; support labels</span>
<span class="Mu"><span class="Delimiter">(</span>assert:iso <span class="Delimiter">'((((</span>default-space space-address<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>new<span class="Delimiter">))</span> <span class="Delimiter">((</span>space literal<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">30</span> literal<span class="Delimiter">)))</span></span>
              foo<span class="Delimiter">)</span>
            <span class="Delimiter">(</span>tokenize-args
              <span class="Mu"><span class="Delimiter">'((</span>default-space:space-address <span class="Op">&lt;-</span> new space:literal <span class="MuConstant">30</span>:literal<span class="Delimiter">)</span></span>
                foo<span class="Delimiter">)))</span>

<span class="Comment">; support braces</span>
<span class="Mu"><span class="Delimiter">(</span>assert:iso <span class="Delimiter">'((((</span>default-space space-address<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>new<span class="Delimiter">))</span> <span class="Delimiter">((</span>space literal<span class="Delimiter">))</span> <span class="Delimiter">((</span><span class="MuConstant">30</span> literal<span class="Delimiter">)))</span></span>
              foo
              { <span class="CommentedCode">begin</span>
                bar
                <span class="Mu"><span class="Delimiter">(((</span>a b<span class="Delimiter">))</span> <span class="Op">&lt;-</span> <span class="Delimiter">((</span>op<span class="Delimiter">))</span> <span class="Delimiter">((</span>c d<span class="Delimiter">))</span> <span class="Delimiter">((</span>e f<span class="Delimiter">)))</span></span>
              }<span class="Delimiter">)</span>
            <span class="Delimiter">(</span>tokenize-args
              <span class="Mu"><span class="Delimiter">'((</span>default-space:space-address <span class="Op">&lt;-</span> new space:literal <span class="MuConstant">30</span>:literal<span class="Delimiter">)</span></span>
                foo
                { <span class="CommentedCode">begin</span>
                  bar
                  <span class="Mu"><span class="Delimiter">(</span>a:b <span class="Op">&lt;-</span> op c:d e:f<span class="Delimiter">)</span></span>
                }<span class="Delimiter">)))</span>

<span class="Comment">; space</span>
<span class="Delimiter">(</span>prn <span class="Constant">&quot;== space&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Constant">0</span> <span class="Delimiter">(</span>space <span class="Delimiter">'((</span><span class="Constant">4</span> integer<span class="Delimiter">))))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'space' is 0 by default&quot;</span><span class="Delimiter">))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Constant">1</span> <span class="Delimiter">(</span>space <span class="Delimiter">'((</span><span class="Constant">4</span> integer<span class="Delimiter">)</span> <span class="Delimiter">(</span>space <span class="Constant">1</span><span class="Delimiter">))))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'space' picks up space when available&quot;</span><span class="Delimiter">))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Delimiter">'</span>global <span class="Delimiter">(</span>space <span class="Delimiter">'((</span><span class="Constant">4</span> integer<span class="Delimiter">)</span> <span class="Delimiter">(</span>space global<span class="Delimiter">))))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'space' understands routine-global space&quot;</span><span class="Delimiter">))</span>

<span class="Comment">; absolutize</span>
<span class="Delimiter">(</span>prn <span class="Constant">&quot;== absolutize&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Delimiter">'((</span><span class="Constant">4</span> integer<span class="Delimiter">))</span> <span class="Delimiter">(</span>absolutize <span class="Delimiter">'((</span><span class="Constant">4</span> integer<span class="Delimiter">))))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'absolutize' works without routine&quot;</span><span class="Delimiter">))</span>
<span class="Delimiter">(</span>= <span class="Global">routine*</span> make-routine!foo<span class="Delimiter">)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Delimiter">'((</span><span class="Constant">4</span> integer<span class="Delimiter">))</span> <span class="Delimiter">(</span>absolutize <span class="Delimiter">'((</span><span class="Constant">4</span> integer<span class="Delimiter">))))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'absolutize' works without default-space&quot;</span><span class="Delimiter">))</span>
<span class="Delimiter">(</span>= rep.routine*!call-stack.0!default-space <span class="Constant">10</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>= <span class="Global">memory*</span><span class="Constant">.10</span> <span class="Constant">5</span><span class="Delimiter">)</span>  <span class="Comment">; bounds check for default-space</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Delimiter">'((</span><span class="Constant">15</span> integer<span class="Delimiter">)</span> <span class="Delimiter">(</span>raw<span class="Delimiter">))</span>
          <span class="Delimiter">(</span>absolutize <span class="Delimiter">'((</span><span class="Constant">4</span> integer<span class="Delimiter">))))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'absolutize' works with default-space&quot;</span><span class="Delimiter">))</span>
<span class="Delimiter">(</span>absolutize <span class="Delimiter">'((</span><span class="Constant">5</span> integer<span class="Delimiter">)))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~posmatch <span class="Constant">&quot;no room&quot;</span> rep.routine*!error<span class="Delimiter">)</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'absolutize' checks against default-space bounds&quot;</span><span class="Delimiter">))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Delimiter">'((</span>_ integer<span class="Delimiter">))</span> <span class="Delimiter">(</span>absolutize <span class="Delimiter">'((</span>_ integer<span class="Delimiter">))))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'absolutize' passes dummy args right through&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>= <span class="Global">memory*</span><span class="Constant">.20</span> <span class="Constant">5</span><span class="Delimiter">)</span>  <span class="Comment">; pretend array</span>
<span class="Delimiter">(</span>= rep.routine*!globals <span class="Constant">20</span><span class="Delimiter">)</span>  <span class="Comment">; provide it to routine global</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Delimiter">'((</span><span class="Constant">22</span> integer<span class="Delimiter">)</span> <span class="Delimiter">(</span>raw<span class="Delimiter">))</span>
          <span class="Delimiter">(</span>absolutize <span class="Delimiter">'((</span><span class="Constant">1</span> integer<span class="Delimiter">)</span> <span class="Delimiter">(</span>space global<span class="Delimiter">))))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'absolutize' handles variables in the global space&quot;</span><span class="Delimiter">))</span>

<span class="Comment">; deref</span>
<span class="Delimiter">(</span>prn <span class="Constant">&quot;== deref&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>= <span class="Global">memory*</span><span class="Constant">.3</span> <span class="Constant">4</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Delimiter">'((</span><span class="Constant">4</span> integer<span class="Delimiter">))</span>
          <span class="Delimiter">(</span>deref <span class="Delimiter">'((</span><span class="Constant">3</span> integer-address<span class="Delimiter">)</span>
                   <span class="Delimiter">(</span>deref<span class="Delimiter">))))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'deref' handles simple addresses&quot;</span><span class="Delimiter">))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Delimiter">'((</span><span class="Constant">4</span> integer<span class="Delimiter">)</span> <span class="Delimiter">(</span>deref<span class="Delimiter">))</span>
          <span class="Delimiter">(</span>deref <span class="Delimiter">'((</span><span class="Constant">3</span> integer-address<span class="Delimiter">)</span>
                   <span class="Delimiter">(</span>deref<span class="Delimiter">)</span>
                   <span class="Delimiter">(</span>deref<span class="Delimiter">))))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'deref' deletes just one deref&quot;</span><span class="Delimiter">))</span>
<span class="Delimiter">(</span>= <span class="Global">memory*</span><span class="Constant">.4</span> <span class="Constant">5</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Delimiter">'((</span><span class="Constant">5</span> integer<span class="Delimiter">))</span>
          <span class="Delimiter">(</span>deref:deref <span class="Delimiter">'((</span><span class="Constant">3</span> integer-address-address<span class="Delimiter">)</span>
                         <span class="Delimiter">(</span>deref<span class="Delimiter">)</span>
                         <span class="Delimiter">(</span>deref<span class="Delimiter">))))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'deref' can be chained&quot;</span><span class="Delimiter">))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Delimiter">'((</span><span class="Constant">5</span> integer<span class="Delimiter">)</span> <span class="Delimiter">(</span>foo<span class="Delimiter">))</span>
          <span class="Delimiter">(</span>deref:deref <span class="Delimiter">'((</span><span class="Constant">3</span> integer-address-address<span class="Delimiter">)</span>
                         <span class="Delimiter">(</span>deref<span class="Delimiter">)</span>
                         <span class="Delimiter">(</span>foo<span class="Delimiter">)</span>
                         <span class="Delimiter">(</span>deref<span class="Delimiter">))))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'deref' skips junk&quot;</span><span class="Delimiter">))</span>

<span class="Comment">; addr</span>
<span class="Delimiter">(</span>prn <span class="Constant">&quot;== addr&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>= <span class="Global">routine*</span> nil<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn 111)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Constant">4</span> <span class="Delimiter">(</span>addr <span class="Delimiter">'((</span><span class="Constant">4</span> integer<span class="Delimiter">))))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - directly addressed operands are their own address&quot;</span><span class="Delimiter">))</span>
<span class="CommentedCode">;? (quit)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Constant">4</span> <span class="Delimiter">(</span>addr <span class="Delimiter">'((</span><span class="Constant">4</span> integer-address<span class="Delimiter">))))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - directly addressed operands are their own address - 2&quot;</span><span class="Delimiter">))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Constant">4</span> <span class="Delimiter">(</span>addr <span class="Delimiter">'((</span><span class="MuConstant">4</span> literal<span class="Delimiter">))))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'addr' doesn't understand literals&quot;</span><span class="Delimiter">))</span>
<span class="CommentedCode">;? (prn 201)</span>
<span class="Delimiter">(</span>= <span class="Global">memory*</span><span class="Constant">.4</span> <span class="Constant">23</span><span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn 202)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Constant">23</span> <span class="Delimiter">(</span>addr <span class="Delimiter">'((</span><span class="Constant">4</span> integer-address<span class="Delimiter">)</span> <span class="Delimiter">(</span>deref<span class="Delimiter">))))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'addr' works with indirectly-addressed 'deref'&quot;</span><span class="Delimiter">))</span>
<span class="CommentedCode">;? (quit)</span>
<span class="Delimiter">(</span>= <span class="Global">memory*</span><span class="Constant">.3</span> <span class="Constant">4</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Constant">23</span> <span class="Delimiter">(</span>addr <span class="Delimiter">'((</span><span class="Constant">3</span> integer-address-address<span class="Delimiter">)</span> <span class="Delimiter">(</span>deref<span class="Delimiter">)</span> <span class="Delimiter">(</span>deref<span class="Delimiter">))))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'addr' works with multiple 'deref'&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>= <span class="Global">routine*</span> make-routine!foo<span class="Delimiter">)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Constant">4</span> <span class="Delimiter">(</span>addr <span class="Delimiter">'((</span><span class="Constant">4</span> integer<span class="Delimiter">))))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - directly addressed operands are their own address inside routines&quot;</span><span class="Delimiter">))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Constant">4</span> <span class="Delimiter">(</span>addr <span class="Delimiter">'((</span><span class="Constant">4</span> integer-address<span class="Delimiter">))))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - directly addressed operands are their own address inside routines - 2&quot;</span><span class="Delimiter">))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Constant">4</span> <span class="Delimiter">(</span>addr <span class="Delimiter">'((</span><span class="MuConstant">4</span> literal<span class="Delimiter">))))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'addr' doesn't understand literals inside routines&quot;</span><span class="Delimiter">))</span>
<span class="Delimiter">(</span>= <span class="Global">memory*</span><span class="Constant">.4</span> <span class="Constant">23</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Constant">23</span> <span class="Delimiter">(</span>addr <span class="Delimiter">'((</span><span class="Constant">4</span> integer-address<span class="Delimiter">)</span> <span class="Delimiter">(</span>deref<span class="Delimiter">))))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'addr' works with indirectly-addressed 'deref' inside routines&quot;</span><span class="Delimiter">))</span>

<span class="CommentedCode">;? (prn 301)</span>
<span class="Delimiter">(</span>= rep.routine*!call-stack.0!default-space <span class="Constant">10</span><span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn 302)</span>
<span class="Delimiter">(</span>= <span class="Global">memory*</span><span class="Constant">.10</span> <span class="Constant">5</span><span class="Delimiter">)</span>  <span class="Comment">; bounds check for default-space</span>
<span class="CommentedCode">;? (prn 303)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Constant">15</span> <span class="Delimiter">(</span>addr <span class="Delimiter">'((</span><span class="Constant">4</span> integer<span class="Delimiter">))))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - directly addressed operands in routines add default-space&quot;</span><span class="Delimiter">))</span>
<span class="CommentedCode">;? (quit)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Constant">15</span> <span class="Delimiter">(</span>addr <span class="Delimiter">'((</span><span class="Constant">4</span> integer-address<span class="Delimiter">))))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - directly addressed operands in routines add default-space - 2&quot;</span><span class="Delimiter">))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Constant">15</span> <span class="Delimiter">(</span>addr <span class="Delimiter">'((</span><span class="MuConstant">4</span> literal<span class="Delimiter">))))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'addr' doesn't understand literals&quot;</span><span class="Delimiter">))</span>
<span class="Delimiter">(</span>= <span class="Global">memory*</span><span class="Constant">.15</span> <span class="Constant">23</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Constant">23</span> <span class="Delimiter">(</span>addr <span class="Delimiter">'((</span><span class="Constant">4</span> integer-address<span class="Delimiter">)</span> <span class="Delimiter">(</span>deref<span class="Delimiter">))))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'addr' adds default-space before 'deref', not after&quot;</span><span class="Delimiter">))</span>
<span class="CommentedCode">;? (quit)</span>

<span class="Comment">; array-len</span>
<span class="Delimiter">(</span>prn <span class="Constant">&quot;== array-len&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>= <span class="Global">memory*</span><span class="Constant">.35</span> <span class="Constant">4</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Constant">4</span> <span class="Delimiter">(</span>array-len <span class="Delimiter">'((</span><span class="Constant">35</span> integer-boolean-pair-array<span class="Delimiter">))))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'array-len'&quot;</span><span class="Delimiter">))</span>
<span class="Delimiter">(</span>= <span class="Global">memory*</span><span class="Constant">.34</span> <span class="Constant">35</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Constant">4</span> <span class="Delimiter">(</span>array-len <span class="Delimiter">'((</span><span class="Constant">34</span> integer-boolean-pair-array-address<span class="Delimiter">)</span> <span class="Delimiter">(</span>deref<span class="Delimiter">))))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'array-len'&quot;</span><span class="Delimiter">))</span>
<span class="CommentedCode">;? (quit)</span>

<span class="Comment">; sizeof</span>
<span class="Delimiter">(</span>prn <span class="Constant">&quot;== sizeof&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="CommentedCode">;? (set dump-trace*)</span>
<span class="CommentedCode">;? (prn 401)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Constant">1</span> <span class="Delimiter">(</span>sizeof <span class="Delimiter">'((</span>_ integer<span class="Delimiter">))))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'sizeof' works on primitives&quot;</span><span class="Delimiter">))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Constant">1</span> <span class="Delimiter">(</span>sizeof <span class="Delimiter">'((</span>_ integer-address<span class="Delimiter">))))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'sizeof' works on addresses&quot;</span><span class="Delimiter">))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Constant">2</span> <span class="Delimiter">(</span>sizeof <span class="Delimiter">'((</span>_ integer-boolean-pair<span class="Delimiter">))))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'sizeof' works on and-records&quot;</span><span class="Delimiter">))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Constant">3</span> <span class="Delimiter">(</span>sizeof <span class="Delimiter">'((</span>_ integer-point-pair<span class="Delimiter">))))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'sizeof' works on and-records with and-record fields&quot;</span><span class="Delimiter">))</span>

<span class="CommentedCode">;? (prn 410)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Constant">1</span> <span class="Delimiter">(</span>sizeof <span class="Delimiter">'((</span><span class="Constant">34</span> integer<span class="Delimiter">))))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'sizeof' works on primitive operands&quot;</span><span class="Delimiter">))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Constant">1</span> <span class="Delimiter">(</span>sizeof <span class="Delimiter">'((</span><span class="Constant">34</span> integer-address<span class="Delimiter">))))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'sizeof' works on address operands&quot;</span><span class="Delimiter">))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Constant">2</span> <span class="Delimiter">(</span>sizeof <span class="Delimiter">'((</span><span class="Constant">34</span> integer-boolean-pair<span class="Delimiter">))))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'sizeof' works on and-record operands&quot;</span><span class="Delimiter">))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Constant">3</span> <span class="Delimiter">(</span>sizeof <span class="Delimiter">'((</span><span class="Constant">34</span> integer-point-pair<span class="Delimiter">))))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'sizeof' works on and-record operands with and-record fields&quot;</span><span class="Delimiter">))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Constant">2</span> <span class="Delimiter">(</span>sizeof <span class="Delimiter">'((</span><span class="Constant">34</span> integer-boolean-pair-address<span class="Delimiter">)</span> <span class="Delimiter">(</span>deref<span class="Delimiter">))))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'sizeof' works on pointers to and-records&quot;</span><span class="Delimiter">))</span>
<span class="Delimiter">(</span>= <span class="Global">memory*</span><span class="Constant">.35</span> <span class="Constant">4</span><span class="Delimiter">)</span>  <span class="Comment">; size of array</span>
<span class="Delimiter">(</span>= <span class="Global">memory*</span><span class="Constant">.34</span> <span class="Constant">35</span><span class="Delimiter">)</span>
<span class="CommentedCode">;? (= dump-trace* (obj whitelist '(&quot;sizeof&quot; &quot;array-len&quot;)))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Constant">9</span> <span class="Delimiter">(</span>sizeof <span class="Delimiter">'((</span><span class="Constant">34</span> integer-boolean-pair-array-address<span class="Delimiter">)</span> <span class="Delimiter">(</span>deref<span class="Delimiter">))))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'sizeof' works on pointers to arrays&quot;</span><span class="Delimiter">))</span>
<span class="CommentedCode">;? (quit)</span>

<span class="CommentedCode">;? (prn 420)</span>
<span class="Delimiter">(</span>= <span class="Global">memory*</span><span class="Constant">.4</span> <span class="Constant">23</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Constant">24</span> <span class="Delimiter">(</span>sizeof <span class="Delimiter">'((</span><span class="Constant">4</span> integer-array<span class="Delimiter">))))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'sizeof' reads array lengths from memory&quot;</span><span class="Delimiter">))</span>
<span class="Delimiter">(</span>= <span class="Global">memory*</span><span class="Constant">.3</span> <span class="Constant">4</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Constant">24</span> <span class="Delimiter">(</span>sizeof <span class="Delimiter">'((</span><span class="Constant">3</span> integer-array-address<span class="Delimiter">)</span> <span class="Delimiter">(</span>deref<span class="Delimiter">))))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'sizeof' handles pointers to arrays&quot;</span><span class="Delimiter">))</span>
<span class="Delimiter">(</span>= <span class="Global">memory*</span><span class="Constant">.15</span> <span class="Constant">34</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>= <span class="Global">routine*</span> make-routine!foo<span class="Delimiter">)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Constant">24</span> <span class="Delimiter">(</span>sizeof <span class="Delimiter">'((</span><span class="Constant">4</span> integer-array<span class="Delimiter">))))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'sizeof' reads array lengths from memory inside routines&quot;</span><span class="Delimiter">))</span>
<span class="Delimiter">(</span>= rep.routine*!call-stack.0!default-space <span class="Constant">10</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>= <span class="Global">memory*</span><span class="Constant">.10</span> <span class="Constant">5</span><span class="Delimiter">)</span>  <span class="Comment">; bounds check for default-space</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Constant">35</span> <span class="Delimiter">(</span>sizeof <span class="Delimiter">'((</span><span class="Constant">4</span> integer-array<span class="Delimiter">))))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'sizeof' reads array lengths from memory using default-space&quot;</span><span class="Delimiter">))</span>
<span class="Delimiter">(</span>= <span class="Global">memory*</span><span class="Constant">.35</span> <span class="Constant">4</span><span class="Delimiter">)</span>  <span class="Comment">; size of array</span>
<span class="Delimiter">(</span>= <span class="Global">memory*</span><span class="Constant">.15</span> <span class="Constant">35</span><span class="Delimiter">)</span>
<span class="CommentedCode">;? (= dump-trace* (obj whitelist '(&quot;sizeof&quot;)))</span>
<span class="Delimiter">(</span>aif rep.routine*!error <span class="Delimiter">(</span>prn <span class="Constant">&quot;error - &quot;</span> it<span class="Delimiter">))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Constant">9</span> <span class="Delimiter">(</span>sizeof <span class="Delimiter">'((</span><span class="Constant">4</span> integer-boolean-pair-array-address<span class="Delimiter">)</span> <span class="Delimiter">(</span>deref<span class="Delimiter">))))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'sizeof' works on pointers to arrays using default-space&quot;</span><span class="Delimiter">))</span>
<span class="CommentedCode">;? (quit)</span>

<span class="Comment">; m</span>
<span class="Delimiter">(</span>prn <span class="Constant">&quot;== m&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Constant">4</span> <span class="Delimiter">(</span>m <span class="Delimiter">'((</span><span class="MuConstant">4</span> literal<span class="Delimiter">))))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'm' avoids reading memory for literals&quot;</span><span class="Delimiter">))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Constant">4</span> <span class="Delimiter">(</span>m <span class="Delimiter">'((</span><span class="MuConstant">4</span> offset<span class="Delimiter">))))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'm' avoids reading memory for offsets&quot;</span><span class="Delimiter">))</span>
<span class="Delimiter">(</span>= <span class="Global">memory*</span><span class="Constant">.4</span> <span class="Constant">34</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Constant">34</span> <span class="Delimiter">(</span>m <span class="Delimiter">'((</span><span class="Constant">4</span> integer<span class="Delimiter">))))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'm' reads memory for simple types&quot;</span><span class="Delimiter">))</span>
<span class="Delimiter">(</span>= <span class="Global">memory*</span><span class="Constant">.3</span> <span class="Constant">4</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Constant">34</span> <span class="Delimiter">(</span>m <span class="Delimiter">'((</span><span class="Constant">3</span> integer-address<span class="Delimiter">)</span> <span class="Delimiter">(</span>deref<span class="Delimiter">))))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'm' redirects addresses&quot;</span><span class="Delimiter">))</span>
<span class="Delimiter">(</span>= <span class="Global">memory*</span><span class="Constant">.2</span> <span class="Constant">3</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Constant">34</span> <span class="Delimiter">(</span>m <span class="Delimiter">'((</span><span class="Constant">2</span> integer-address-address<span class="Delimiter">)</span> <span class="Delimiter">(</span>deref<span class="Delimiter">)</span> <span class="Delimiter">(</span>deref<span class="Delimiter">))))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'm' multiply redirects addresses&quot;</span><span class="Delimiter">))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Delimiter">(</span>annotate <span class="Delimiter">'</span>record <span class="Delimiter">'(</span><span class="Constant">34</span> nil<span class="Delimiter">))</span> <span class="Delimiter">(</span>m <span class="Delimiter">'((</span><span class="Constant">4</span> integer-boolean-pair<span class="Delimiter">))))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'm' supports compound records&quot;</span><span class="Delimiter">))</span>
<span class="Delimiter">(</span>= <span class="Global">memory*</span><span class="Constant">.5</span> <span class="Constant">35</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>= <span class="Global">memory*</span><span class="Constant">.6</span> <span class="Constant">36</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Delimiter">(</span>annotate <span class="Delimiter">'</span>record <span class="Delimiter">'(</span><span class="Constant">34</span> <span class="Constant">35</span> <span class="Constant">36</span><span class="Delimiter">))</span> <span class="Delimiter">(</span>m <span class="Delimiter">'((</span><span class="Constant">4</span> integer-point-pair<span class="Delimiter">))))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'm' supports records with compound fields&quot;</span><span class="Delimiter">))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Delimiter">(</span>annotate <span class="Delimiter">'</span>record <span class="Delimiter">'(</span><span class="Constant">34</span> <span class="Constant">35</span> <span class="Constant">36</span><span class="Delimiter">))</span> <span class="Delimiter">(</span>m <span class="Delimiter">'((</span><span class="Constant">3</span> integer-point-pair-address<span class="Delimiter">)</span> <span class="Delimiter">(</span>deref<span class="Delimiter">))))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'm' supports indirect access to records&quot;</span><span class="Delimiter">))</span>
<span class="Delimiter">(</span>= <span class="Global">memory*</span><span class="Constant">.4</span> <span class="Constant">2</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Delimiter">(</span>annotate <span class="Delimiter">'</span>record <span class="Delimiter">'(</span><span class="Constant">2</span> <span class="Constant">35</span> <span class="Constant">36</span><span class="Delimiter">))</span> <span class="Delimiter">(</span>m <span class="Delimiter">'((</span><span class="Constant">4</span> integer-array<span class="Delimiter">))))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'm' supports access to arrays&quot;</span><span class="Delimiter">))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Delimiter">(</span>annotate <span class="Delimiter">'</span>record <span class="Delimiter">'(</span><span class="Constant">2</span> <span class="Constant">35</span> <span class="Constant">36</span><span class="Delimiter">))</span> <span class="Delimiter">(</span>m <span class="Delimiter">'((</span><span class="Constant">3</span> integer-array-address<span class="Delimiter">)</span> <span class="Delimiter">(</span>deref<span class="Delimiter">))))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'm' supports indirect access to arrays&quot;</span><span class="Delimiter">))</span>

<span class="Delimiter">(</span>= <span class="Global">routine*</span> make-routine!foo<span class="Delimiter">)</span>
<span class="Delimiter">(</span>= <span class="Global">memory*</span><span class="Constant">.10</span> <span class="Constant">5</span><span class="Delimiter">)</span>  <span class="Comment">; fake array</span>
<span class="Delimiter">(</span>= <span class="Global">memory*</span><span class="Constant">.12</span> <span class="Constant">34</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>= rep.routine*!globals <span class="Constant">10</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~iso <span class="Constant">34</span> <span class="Delimiter">(</span>m <span class="Delimiter">'((</span><span class="Constant">1</span> integer<span class="Delimiter">)</span> <span class="Delimiter">(</span>space global<span class="Delimiter">))))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'm' supports access to per-routine globals&quot;</span><span class="Delimiter">))</span>

<span class="Comment">; setm</span>
<span class="Delimiter">(</span>prn <span class="Constant">&quot;== setm&quot;</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>
<span class="Delimiter">(</span>setm <span class="Delimiter">'((</span><span class="Constant">4</span> integer<span class="Delimiter">))</span> <span class="Constant">34</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Constant">34</span> <span class="Global">memory*</span><span class="Constant">.4</span><span class="Delimiter">)</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'setm' writes primitives to memory&quot;</span><span class="Delimiter">))</span>
<span class="Delimiter">(</span>setm <span class="Delimiter">'((</span><span class="Constant">3</span> integer-address<span class="Delimiter">))</span> <span class="Constant">4</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Constant">4</span> <span class="Global">memory*</span><span class="Constant">.3</span><span class="Delimiter">)</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'setm' writes addresses to memory&quot;</span><span class="Delimiter">))</span>
<span class="Delimiter">(</span>setm <span class="Delimiter">'((</span><span class="Constant">3</span> integer-address<span class="Delimiter">)</span> <span class="Delimiter">(</span>deref<span class="Delimiter">))</span> <span class="Constant">35</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Constant">35</span> <span class="Global">memory*</span><span class="Constant">.4</span><span class="Delimiter">)</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'setm' redirects writes&quot;</span><span class="Delimiter">))</span>
<span class="Delimiter">(</span>= <span class="Global">memory*</span><span class="Constant">.2</span> <span class="Constant">3</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>setm <span class="Delimiter">'((</span><span class="Constant">2</span> integer-address-address<span class="Delimiter">)</span> <span class="Delimiter">(</span>deref<span class="Delimiter">)</span> <span class="Delimiter">(</span>deref<span class="Delimiter">))</span> <span class="Constant">36</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~is <span class="Constant">36</span> <span class="Global">memory*</span><span class="Constant">.4</span><span class="Delimiter">)</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'setm' multiply redirects writes&quot;</span><span class="Delimiter">))</span>
<span class="CommentedCode">;? (prn 505)</span>
<span class="Delimiter">(</span>setm <span class="Delimiter">'((</span><span class="Constant">4</span> integer-integer-pair<span class="Delimiter">))</span> <span class="Delimiter">(</span>annotate <span class="Delimiter">'</span>record <span class="Delimiter">'(</span><span class="Constant">23</span> <span class="Constant">24</span><span class="Delimiter">)))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~memory-contains <span class="Constant">4</span> <span class="Delimiter">'(</span><span class="Constant">23</span> <span class="Constant">24</span><span class="Delimiter">))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'setm' writes compound records&quot;</span><span class="Delimiter">))</span>
<span class="Delimiter">(</span>assert <span class="Delimiter">(</span>is <span class="Global">memory*</span><span class="Constant">.7</span> nil<span class="Delimiter">))</span>
<span class="CommentedCode">;? (prn 506)</span>
<span class="Delimiter">(</span>setm <span class="Delimiter">'((</span><span class="Constant">7</span> integer-point-pair<span class="Delimiter">))</span> <span class="Delimiter">(</span>annotate <span class="Delimiter">'</span>record <span class="Delimiter">'(</span><span class="Constant">23</span> <span class="Constant">24</span> <span class="Constant">25</span><span class="Delimiter">)))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~memory-contains <span class="Constant">7</span> <span class="Delimiter">'(</span><span class="Constant">23</span> <span class="Constant">24</span> <span class="Constant">25</span><span class="Delimiter">))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'setm' writes records with compound fields&quot;</span><span class="Delimiter">))</span>
<span class="Delimiter">(</span>= <span class="Global">routine*</span> make-routine!foo<span class="Delimiter">)</span>
<span class="Delimiter">(</span>setm <span class="Delimiter">'((</span><span class="Constant">4</span> integer-point-pair<span class="Delimiter">))</span> <span class="Delimiter">(</span>annotate <span class="Delimiter">'</span>record <span class="Delimiter">'(</span><span class="Constant">33</span> <span class="Constant">34</span><span class="Delimiter">)))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~posmatch <span class="Constant">&quot;incorrect size&quot;</span> rep.routine*!error<span class="Delimiter">)</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'setm' checks size of target&quot;</span><span class="Delimiter">))</span>
<span class="Delimiter">(</span>wipe <span class="Global">routine*</span><span class="Delimiter">)</span>
<span class="Delimiter">(</span>setm <span class="Delimiter">'((</span><span class="Constant">3</span> integer-point-pair-address<span class="Delimiter">)</span> <span class="Delimiter">(</span>deref<span class="Delimiter">))</span> <span class="Delimiter">(</span>annotate <span class="Delimiter">'</span>record <span class="Delimiter">'(</span><span class="Constant">43</span> <span class="Constant">44</span> <span class="Constant">45</span><span class="Delimiter">)))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~memory-contains <span class="Constant">4</span> <span class="Delimiter">'(</span><span class="Constant">43</span> <span class="Constant">44</span> <span class="Constant">45</span><span class="Delimiter">))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'setm' supports indirect writes to records&quot;</span><span class="Delimiter">))</span>
<span class="Delimiter">(</span>setm <span class="Delimiter">'((</span><span class="Constant">2</span> integer-point-pair-address-address<span class="Delimiter">)</span> <span class="Delimiter">(</span>deref<span class="Delimiter">)</span> <span class="Delimiter">(</span>deref<span class="Delimiter">))</span> <span class="Delimiter">(</span>annotate <span class="Delimiter">'</span>record <span class="Delimiter">'(</span><span class="Constant">53</span> <span class="Constant">54</span> <span class="Constant">55</span><span class="Delimiter">)))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~memory-contains <span class="Constant">4</span> <span class="Delimiter">'(</span><span class="Constant">53</span> <span class="Constant">54</span> <span class="Constant">55</span><span class="Delimiter">))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'setm' supports multiply indirect writes to records&quot;</span><span class="Delimiter">))</span>
<span class="Delimiter">(</span>setm <span class="Delimiter">'((</span><span class="Constant">4</span> integer-array<span class="Delimiter">))</span> <span class="Delimiter">(</span>annotate <span class="Delimiter">'</span>record <span class="Delimiter">'(</span><span class="Constant">2</span> <span class="Constant">31</span> <span class="Constant">32</span><span class="Delimiter">)))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~memory-contains <span class="Constant">4</span> <span class="Delimiter">'(</span><span class="Constant">2</span> <span class="Constant">31</span> <span class="Constant">32</span><span class="Delimiter">))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'setm' writes arrays&quot;</span><span class="Delimiter">))</span>
<span class="Delimiter">(</span>setm <span class="Delimiter">'((</span><span class="Constant">3</span> integer-array-address<span class="Delimiter">)</span> <span class="Delimiter">(</span>deref<span class="Delimiter">))</span> <span class="Delimiter">(</span>annotate <span class="Delimiter">'</span>record <span class="Delimiter">'(</span><span class="Constant">2</span> <span class="Constant">41</span> <span class="Constant">42</span><span class="Delimiter">)))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~memory-contains <span class="Constant">4</span> <span class="Delimiter">'(</span><span class="Constant">2</span> <span class="Constant">41</span> <span class="Constant">42</span><span class="Delimiter">))</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'setm' supports indirect writes to arrays&quot;</span><span class="Delimiter">))</span>
<span class="Delimiter">(</span>= <span class="Global">routine*</span> make-routine!foo<span class="Delimiter">)</span>
<span class="Delimiter">(</span>setm <span class="Delimiter">'((</span><span class="Constant">4</span> integer-array<span class="Delimiter">))</span> <span class="Delimiter">(</span>annotate <span class="Delimiter">'</span>record <span class="Delimiter">'(</span><span class="Constant">2</span> <span class="Constant">31</span> <span class="Constant">32</span> <span class="Constant">33</span><span class="Delimiter">)))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~posmatch <span class="Constant">&quot;invalid array&quot;</span> rep.routine*!error<span class="Delimiter">)</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'setm' checks that array written is well-formed&quot;</span><span class="Delimiter">))</span>
<span class="Delimiter">(</span>= <span class="Global">routine*</span> make-routine!foo<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn 111)</span>
<span class="CommentedCode">;? (= dump-trace* (obj whitelist '(&quot;sizeof&quot; &quot;setm&quot;)))</span>
<span class="Delimiter">(</span>setm <span class="Delimiter">'((</span><span class="Constant">4</span> integer-boolean-pair-array<span class="Delimiter">))</span> <span class="Delimiter">(</span>annotate <span class="Delimiter">'</span>record <span class="Delimiter">'(</span><span class="Constant">2</span> <span class="Constant">31</span> nil <span class="Constant">32</span> nil <span class="Constant">33</span><span class="Delimiter">)))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>~posmatch <span class="Constant">&quot;invalid array&quot;</span> rep.routine*!error<span class="Delimiter">)</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'setm' checks that array of records is well-formed&quot;</span><span class="Delimiter">))</span>
<span class="Delimiter">(</span>= <span class="Global">routine*</span> make-routine!foo<span class="Delimiter">)</span>
<span class="CommentedCode">;? (prn 222)</span>
<span class="Delimiter">(</span>setm <span class="Delimiter">'((</span><span class="Constant">4</span> integer-boolean-pair-array<span class="Delimiter">))</span> <span class="Delimiter">(</span>annotate <span class="Delimiter">'</span>record <span class="Delimiter">'(</span><span class="Constant">2</span> <span class="Constant">31</span> nil <span class="Constant">32</span> nil<span class="Delimiter">)))</span>
<span class="Delimiter">(</span><span class="Normal">if</span> <span class="Delimiter">(</span>posmatch <span class="Constant">&quot;invalid array&quot;</span> rep.routine*!error<span class="Delimiter">)</span>
  <span class="Delimiter">(</span>prn <span class="Constant">&quot;F - 'setm' checks that array of records is well-formed - 2&quot;</span><span class="Delimiter">))</span>
<span class="Delimiter">(</span>wipe <span class="Global">routine*</span><span class="Delimiter">)</span>

<span class="Delimiter">(</span>reset<span class="Delimiter">)</span>  <span class="Comment">; end file with this to persist the trace for the final test</span>
</pre>
</body>
</html>
<!-- vim: set foldmethod=manual : -->