summaryrefslogtreecommitdiff
path: root/gcc/melt/warmelt-base.melt
blob: 112810ea271152cd47c36733c740b3e032e06a63 (plain)
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
;; -*- Lisp -*-
;; file warmelt-base.melt
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(comment "***
    Copyright 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
    Contributed by Basile Starynkevitch <basile@starynkevitch.net>
               and Pierre Vittet  <piervit@pvittet.com>

    This file is part of GCC.

    GCC is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 3, or (at your option)
    any later version.

    GCC is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with GCC; see the file COPYING3.  If not see
    <http://www.gnu.org/licenses/>.
***")

;; the copyright notice above apply both to warmelt-base.melt and 
;; to the generated file  warmelt-base*.c

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;    This file is part of a bootstrapping compiler for the MELT lisp
;;    dialect, compiler which should be able to compile itself (into
;;    generated C file[s])
;;    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;; primitive to ignore a value
(defprimitive ignore (v) :void
  :doc #{Ignore the value passed as argument. Useful to avoid translation warnings, or to force the type of a conditional. See $CTYPE_VOID.}#
  #{/*ignore*/(void)($v)}#)  


;; primitive to return a void
(defprimitive void () :void 
  :doc #{Return a void value. See $IGNORE and $CTYPE_VOID.}#
#{/*void*/0}#)

;; negation of is_object
(defprimitive is_not_object (obj) :long
  :doc #{Test if $OBJ is not an object. Negation of $IS_OBJECT.}#
  #{(melt_magic_discr((melt_ptr_t)($obj)) != MELTOBMAG_OBJECT)}#)


;; primitive to safely return a global predef by its index
(defprimitive get_globpredef (:long ix) :value
  :doc #{Safely gives the predefined of index $IX or null.}#
  #{/*get_globpredef*/ ((melt_ptr_t) melt_globpredef($ix))}#)

;; primitive to get the hashcode of an object (or 0)
(defprimitive obj_hash (v) :long
  :doc #{Safely gives the hashcode of object $V or else 0.}#
  #{(melt_obj_hash((melt_ptr_t)($v)))}#)

;; primitive to clone a value with another discriminant.
(defprimitive clone_with_discriminant (val discr) :value
  :doc #{Clone value $VAL with new discriminant $DISCR. Gives the
  original $VAL when cloning is not possible. For objects, make a new
  one copying the common fields. See the $VALDESC_CLONECHUNK field in
  $CLASS_VALUE_DESCRIPTOR. The primitive's code is generated.}#
  #{ meltgc_clone_with_discriminant((melt_ptr_t)($VAL), (melt_ptr_t)($DISCR)) }#)

;; primitive to get the length of an object (or 0)
(defprimitive obj_len (v) :long
  :doc #{Safely gives the length of object $V or else 0.}#
  #{(melt_obj_len((melt_ptr_t)($v)))}#)


;; primitive to get the number of an object (or 0)
(defprimitive obj_num (v) :long
  :doc #{Safely gives the number of object $V or else 0.}#
  #{(melt_obj_num((melt_ptr_t)($v)))}#)

;; primitive to compute a nonzero hash
(defprimitive nonzero_hash () :long
  :doc #{Gives a pseudo-random non-zero number suitable as an hash code.}# 
  "(melt_nonzerohash())")


;; primitives to force garbage collection
(defprimitive minor_garbcoll (:long siz) :void 
  :doc #{Force a minor MELT garbage collection. The $SIZ is the amount
  of memory to reserve.}#
  #{melt_garbcoll(($siz), MELT_MINOR_OR_FULL)}#)

(defprimitive full_garbcoll (:long siz) :void
  :doc #{Force a full MELT garbage collection. The $SIZ is the amount
  of memory to reserve.}#
  #{melt_garbcoll(($siz), MELT_NEED_FULL)}#)


;; check explicitly the call stack  
(defprimitive checkcallstack_msg (:cstring msg) :void
  :doc #{Low level costly primitive to check the entire call stack to
help hunt memory or GC bugs. Displays the given $MSG if the check went
wrong. Use it when desperate.}#
  #{melt_check_call_frames(MELT_ANYWHERE, $msg);}#)

;; internal primitive useful to increment the debug counter, used to
;; expand (DEBUG ...) macro
(defprimitive melt_increment_dbgcounter () :void
  #{/*melt_increment_dbgcounter*/ 
#if MELT_HAVE_DEBUG
melt_dbgcounter++;
#endif
}#)

;; for breakpoint
(defprimitive cbreak_msg (:cstring msg) :void
  :doc #{Low level primitive for GDB breakpoints. Use it temporarily,
given a string $MSG, with gdb when desperate.}#
  #{melt_cbreak($msg)}#)


(defprimitive c_time () :long
  :doc #{Get the current time(2) since Unix epoch in seconds.}#
  #{((long)time((time_t*)0))}#)

(defprimitive c_clock () :long
  :doc #{Get the current cpu clock(3) in microseconds.}#
  #{((long)clock())}#)

;; compare of longs [some primitives remain in warmelt-first.melt
;; because they are needed there]

(defprimitive <=i (:long a b) :long :doc #{Integer test that $A less or equal to $B.}#
  #{(($a) <= ($b))}#)

(defprimitive ==i (:long a b) :long  :doc #{Integer test that $A is equal to $B.}#
  #{(($a) == ($b))}#)


(defprimitive !=i (:long a b) :long  :doc #{Integer test that $A is unequal to $B.}#
  #{(($a) != ($b))}#)

;;; maximal & minimal of two longs
(defprimitive maxi (:long a b) :long 
  :doc #{$MAXI gives the maximum of two integers $A and $B}# 
#{MAX(($a),($b))}#)

(defprimitive mini (:long a b) :long 
  :doc #{$MINI gives the maximum of two integers $A and $B}# 
#{MIN(($a),($b))}#)


;;; long integer arithmetics; some primitives stay in warmelt-first.melt
(defprimitive -i (:long a b) :long  :doc #{Integer binary substraction of $a and $b.}#
  #{(($a) - ($b))}#)

(defprimitive *i (:long a b) :long  :doc #{Integer binary product of $a and $b.}#
  #{(($a) * ($b))}#)
(defprimitive andi (:long a b) :long   :doc #{Integer binary bitwise and of $a and $b.}#
  #{(($a) & ($b))}#)
(defprimitive ori (:long a b) :long  :doc #{Integer binary bitwise or of $a and $b.}#
  #{(($a) | ($b))}#)
(defprimitive xori (:long a b) :long :doc #{Integer binary bitwise exclusive-or of $a and $b.}#  
  #{(($a) ^ ($b))}#)

(defprimitive negi (:long i) :long  :doc #{Integer unary negation of $i.}#
  #{(-($i))}#)
(defprimitive noti (:long i) :long :doc #{Integer unary bitwise complement of $i.}# 
  #{(~($i))}#)


;;; functions for boxed arithmetic are costly, but you might find them useful.
(defun +iv (a b) 
  :doc #{Boxed integer addition of two boxed integers. 
  It is slow, since it is boxing.}#
  (if (is_integerbox a)
      (if (is_integerbox b)
	  (make_integerbox discr_constant_integer 
			   (+i (get_int a) (get_int b))))))

(defun -iv (a b) 
  :doc #{Boxed integer substraction of two boxed integers. 
  It is slow, since it is boxing.}#
  (if (is_integerbox a)
      (if (is_integerbox b)
	  (make_integerbox discr_constant_integer 
			   (-i (get_int a) (get_int b))))))


(defun *iv (a b) 
  :doc #{Boxed integer multiplication of two boxed integers. 
  It is slow, since it is boxing.}#
  (if (is_integerbox a)
      (if (is_integerbox b)
	  (make_integerbox discr_constant_integer 
			   (*i (get_int a) (get_int b))))))

(defun /iv (a b) 
  :doc #{Boxed integer division of two boxed integers. 
  It is slow, since it is boxing. Return null when undefined.}#
  (if (is_integerbox a)
      (if (is_integerbox b)
	  (if (get_int b)
	      (make_integerbox discr_constant_integer 
			       (/i (get_int a) (get_int b)))))))


(defun %iv (a b) 
  :doc #{Boxed integer remainder of two boxed integers. 
  It is slow, since it is boxing. Return null when undefined.}#
  (if (is_integerbox a)
      (if (is_integerbox b)
	  (let ( (:long ib (get_int b)) )
	    (if ib
		(make_integerbox discr_constant_integer 
				 (%i (get_int a) ib)))))))


(defprimitive +ivi (a :long lb) :value
  :doc #{Add boxed integer $A to constant raw long $LB. Return null if $A is not a boxed integer.}#
  #{/*+ivi*/ ((melt_magic_discr((melt_ptr_t) $A)==MELTOBMAG_INT)?
	 (meltgc_new_int
	   ((meltobject_ptr_t) MELT_PREDEF (DISCR_CONSTANT_INTEGER),
            (melt_unsafe_boxed_int_value((melt_ptr_t) $A) + ($LB))))
         :(melt_ptr_t)NULL)}#)



(defprimitive -ivi (a :long lb) :value
  :doc #{substract from boxed integer $A the constant raw long $LB. Return null if $A is not a boxed integer.}#
  #{/* -ivi*/ ((melt_magic_discr($A)==MELTOBMAG_INT)?
	 (meltgc_new_int
	   ((meltobject_ptr_t) MELT_PREDEF (DISCR_CONSTANT_INTEGER),
            (melt_unsafe_boxed_int_value($A) - ($LB))))
         :(melt_ptr_t)NULL)}#)


(defprimitive *ivi (a :long lb) :value
  :doc #{multiply boxed integer $A by constant raw long $LB. Return null if $A is not a boxed integer.}#
  #{/* *ivi*/ ((melt_magic_discr($A)==MELTOBMAG_INT)?
	 (meltgc_new_int
	   ((meltobject_ptr_t) MELT_PREDEF (DISCR_CONSTANT_INTEGER),
            (melt_unsafe_boxed_int_value($A) * ($LB))))
         :(melt_ptr_t)NULL)}#)


(defprimitive /ivi (a :long lb) :value
  :doc #{divide boxed integer $A by constant raw long $LB. Return null if $A is not a boxed integer or $LB is zero.}#
  #{/* /ivi*/ ((melt_magic_discr($A)==MELTOBMAG_INT && ($LB != 0L))?
	 (meltgc_new_int
	   ((meltobject_ptr_t) MELT_PREDEF (DISCR_CONSTANT_INTEGER),
            (melt_unsafe_boxed_int_value($A) / ($LB))))
         :(melt_ptr_t)NULL)}#)


(defprimitive %ivi (a :long lb) :value
  :doc #{modulus boxed integer $A by constant raw long $LB. Return null if $A is not a boxed integer or $LB is zero.}#
  #{/* %ivi*/ ((melt_magic_discr($A)==MELTOBMAG_INT && ($LB != 0L))?
	 (meltgc_new_int
	   ((meltobject_ptr_t) MELT_PREDEF (DISCR_CONSTANT_INTEGER),
            (melt_unsafe_boxed_int_value($A) % ($LB))))
         :(melt_ptr_t)NULL)}#)


(defprimitive <iv (a b) :long
  :doc #{Boxed integer compare of $A and $B for less than. 
Return 0 for non-boxed integer values.}#
  #{/* <iv */ ((melt_magic_discr((melt_ptr_t)($A)) == MELTOBMAG_INT)
           && (melt_magic_discr((melt_ptr_t)($B)) == MELTOBMAG_INT)
	   && (melt_unsafe_boxed_int_value($A)
               < (melt_unsafe_boxed_int_value($B))))}#)

(defprimitive <=iv (a b) :long
  :doc #{Boxed integer compare of $A and $B for less or equal. 
Return 0 for non-boxed integer values.}#
  #{/* <=iv */ ((melt_magic_discr((melt_ptr_t)($A)) == MELTOBMAG_INT)
           && (melt_magic_discr((melt_ptr_t)($B)) == MELTOBMAG_INT)
	   && (melt_unsafe_boxed_int_value($A)
               <= (melt_unsafe_boxed_int_value($B))))}#)

(defprimitive =iv (a b) :long
  :doc #{Boxed integer compare of $A and $B for numeric equality. 
Return 0 for non-boxed integer values.}#
  #{/* =iv */ ((melt_magic_discr((melt_ptr_t)($A)) == MELTOBMAG_INT)
           && (melt_magic_discr((melt_ptr_t)($B)) == MELTOBMAG_INT)
	   && (melt_unsafe_boxed_int_value($A)
               == (melt_unsafe_boxed_int_value($B))))}#)

(defprimitive !=iv (a b) :long
  :doc #{Boxed integer compare of $A and $B for numeric inequality. 
Return 0 for non-boxed integer values.}#
  #{/* !=iv */ ((melt_magic_discr((melt_ptr_t)($A)) == MELTOBMAG_INT)
           && (melt_magic_discr((melt_ptr_t)($B)) == MELTOBMAG_INT)
	   && (melt_unsafe_boxed_int_value($A)
               != (melt_unsafe_boxed_int_value($B))))}#)

(defprimitive >iv (a b) :long
  :doc #{Boxed integer compare of $A and $B for greater than. 
Return 0 for non-boxed integer values.}#
  #{/* >iv */ ((melt_magic_discr((melt_ptr_t)($A)) == MELTOBMAG_INT)
           && (melt_magic_discr((melt_ptr_t)($B)) == MELTOBMAG_INT)
	   && (melt_unsafe_boxed_int_value($A)
               > (melt_unsafe_boxed_int_value($B))))}#)

(defprimitive >=iv (a b) :long
  :doc #{Boxed integer compare of $A and $B for greater or equal. 
Return 0 for non-boxed integer values.}#
  #{/* >=iv */ ((melt_magic_discr((melt_ptr_t)($A)) == MELTOBMAG_INT)
           && (melt_magic_discr((melt_ptr_t)($B)) == MELTOBMAG_INT)
	   && (melt_unsafe_boxed_int_value($A)
               >= (melt_unsafe_boxed_int_value($B))))}#)

(defprimitive <ivi (a :long lb) :long
  :doc #{Compare boxed integer $A with constant raw long $LB for less than. Return 0 if $A is not a boxed integer.}#
  #{/* <ivi*/ ((melt_magic_discr($A)==MELTOBMAG_INT) && (melt_unsafe_boxed_int_value($A) < ($LB)))}#)

(defprimitive <=ivi (a :long lb) :long
  :doc #{Compare boxed integer $A with constant raw long $LB for less or equal. Return 0 if $A is not a boxed integer.}#
  #{/* <=ivi*/ ((melt_magic_discr($A)==MELTOBMAG_INT) && (melt_unsafe_boxed_int_value($A) <= ($LB)))}#)

(defprimitive >ivi (a :long lb) :long
  :doc #{Compare boxed integer $A with constant raw long $LB for greater than. Return 0 if $A is not a boxed integer.}#
  #{/* >ivi*/ ((melt_magic_discr($A)==MELTOBMAG_INT) && (melt_unsafe_boxed_int_value($A) > ($LB)))}#)

(defprimitive >=ivi (a :long lb) :long
  :doc #{Compare boxed integer $A with constant raw long $LB for greater or equal. Return 0 if $A is not a boxed integer.}#
  #{/* >=ivi*/ ((melt_magic_discr($A)==MELTOBMAG_INT) && (melt_unsafe_boxed_int_value($A) >= ($LB)))}#)

(defprimitive =ivi (a :long lb) :long
  :doc #{Compare boxed integer $A with constant raw long $LB for numeric equality. Return 0 if $A is not a boxed integer.}#
  #{/* >=ivi*/ ((melt_magic_discr($A)==MELTOBMAG_INT) && (melt_unsafe_boxed_int_value($A) == ($LB)))}#)

(defprimitive !=ivi (a :long lb) :long
  :doc #{Compare boxed integer $A with constant raw long $LB for numeric inequality. Return 0 if $A is not a boxed integer.}#
  #{/* >=ivi*/ ((melt_magic_discr($A)==MELTOBMAG_INT) && (melt_unsafe_boxed_int_value($A) != ($LB)))}#)

;;; various tests

(defprimitive notnull (v) :long :doc #{Test that $V is not the null value.}#
  #{(($v) != NULL)}#)

;;; zero test (for numbers)
(defprimitive zerop (:long i)  :long :doc #{Test that $I is zero.}# 
  #{/*zerop:*/ (($I) == 0L)}#)

;;; debug on dumpfile
(defprimitive outcstring_dbg (:cstring s) :void :doc #{output a debug string $S.}#
  #{melt_puts(dump_file,($s))}#)
(defprimitive outnum_dbg (:cstring pref :long l :cstring suf) :void
  :doc #{debug output an integer $L with prefix $PREF and suffix $SUF.}#
  #{melt_putnum(dump_file,($pref), ($l), ($suf))}#)
(defprimitive outstr_dbg (str) :void :doc #{output a debug string value $STR.}#
  #{melt_putstr(dump_file,(melt_ptr_t)($str))}#)

(defprimitive outstrbuf_dbg (sbuf) :void :doc #{output a debug stringbuffer value $SBUF.}#
  #{melt_putstrbuf(dump_file,(melt_ptr_t)($sbuf))}#)
(defprimitive outnewline_dbg () :void :doc #{output a debug newline.}#
  #{melt_newlineflush(dump_file)}#)
;;; output on stderr
(defprimitive outnum_err (:cstring pref :long l :cstring suf) :void
  :doc #{output on stderr the number $L with prefix $PREF and suffix $SUF.}#
  #{melt_putnum(stderr,($pref), ($l), ($suf))}#)
(defprimitive outcstring_err (:cstring s) :void
  :doc #{Output on stderr the string $s.}#
  #{melt_puts(stderr,($s))}#)
(defprimitive outstrbuf_err (sbuf) :void
  :doc #{Output on stderr the stringbuffer value $sbuf.}#
  #{melt_putstrbuf(stderr,(melt_ptr_t)($sbuf))}#)


;; various primitives

;; change the head of a pair
(defprimitive pair_set_head (pa hd) :void
  :doc #{Safely set in pair $PA its head to $HD. 
Please avoid using that to introduce circularities in lists.}#
 #{meltgc_pair_set_head((melt_ptr_t)($pa), ($hd))}#)
;; length of a pair list
(defprimitive pair_listlength (pa) :long
  :doc #{Compute the linked length of given pair value $PA or else 0.}#
  #{(melt_pair_listlength((melt_ptr_t)($pa)))}#)

;; make a pair
(defprimitive make_pair (discr hd tl) :value
  :doc #{Create a new pair of given discrimiant $DISCR head $HD and
tail $TL or else null.}#
  #{(meltgc_new_pair((meltobject_ptr_t)($discr), (melt_ptr_t)($hd), (melt_ptr_t)($tl)))}#)

;;;;;; MIXINT primitives (use get_int to get the integer)
(defprimitive is_mixint (mi) :long
  :doc #{Test if value $MI is a mixedint value.}#
  #{(melt_magic_discr((melt_ptr_t)($mi)) == MELTOBMAG_MIXINT)}#)
;; get the value
(defprimitive mixint_val (mi) :value
  :doc #{Get the value inside a mixedint value $MI. The integer can be retrieved using $GET_INT.}#
  #{(melt_val_mixint((melt_ptr_t)($mi)))}#)
;; make a mixint
(defprimitive make_mixint (dis val :long num) :value
  :doc #{Make a mixint value of given discriminant $DIS value $VAL and number $NUM or else null.}#
  #{(meltgc_new_mixint((meltobject_ptr_t)($dis), (melt_ptr_t)($val), ($num)))}#)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;; MIXLOC primitives (use get_int to get the integer)
;; test
(defprimitive is_mixloc (mi) :long
  :doc #{Test if value $MI is a mixed location value.}#
  #{(melt_magic_discr((melt_ptr_t)($mi)) == MELTOBMAG_MIXLOC)}#)
;; get the value
(defprimitive mixloc_val (mi) :value
  :doc #{Safely retrieve the value inside a mixed location value $MI.}#
  #{(melt_val_mixloc((melt_ptr_t)($mi)))}#)
(defprimitive mixloc_location (mi) :long
  :doc #{Safely retrieve as an opaque long the location of a mixed location value $MI.}#
  #{((long) melt_location_mixloc((melt_ptr_t)($mi)))}#)
(defprimitive mixloc_locline (mi) :long
  :doc #{Retrieve the line of the location of a mixed location value $MI.}#
  #{(LOCATION_LINE(melt_location_mixloc((melt_ptr_t)$mi)))}#)
(defprimitive mixloc_locfile (mi) :cstring
  :doc #{Retrieve the filename as a raw cstring of a mixed location value $MI.}#
  #{(LOCATION_FILE(melt_location_mixloc((melt_ptr_t)$mi)))}#)
(defprimitive mixloc_locbasefile (mi) :cstring
  :doc #{Retrieve the base filename as a raw cstring of a mixed location value $MI.}#
  #{(lbasename(LOCATION_FILE(melt_location_mixloc((melt_ptr_t)$mi))))}#)

(defprimitive make_string_mixloc_file (mi dis) :value
  :doc #{Retrieve the filename as a boxed string of a mixed location value $MI.}#
  #{(meltgc_new_stringdup((meltobject_ptr_t)($DIS), 
			  (LOCATION_FILE(melt_location_mixloc((melt_ptr_t)$MI)))))}#)

;; make a mixloc
(defprimitive make_mixloc (dis val :long num loc) :value
  :doc #{Make a mixed location value of given discriminant $DIS value $VAL
number $NUM opaque location number $LOC.}#
  #{(meltgc_new_mixloc((meltobject_ptr_t)($dis), (melt_ptr_t)($val), 
		       ($num), (location_t)($loc)))}#)



;; test for mixbigint
(defprimitive is_mixbigint (mb) :long
  :doc #{Test if value $MB is a mixed bigint.}#
  #{(melt_magic_discr((melt_ptr_t)($MB)) == MELTOBMAG_MIXBIGINT)}#)
(defprimitive mixbigint_val (mb) :value
  :doc #{Retrieve the value inside a mixed bigint $MB.}#
  #{melt_val_mixbigint((melt_ptr_t) $MB)}#)

(defprimitive ppstrbuf_mixbigint (:value sbuf :long indent :value mb) :void
 :doc #{Pretty prints into string buffer $SBUF at indentation $INDENT the mixed bigint $MB.}#
 #{meltgc_ppstrbuf_mixbigint((melt_ptr_t) $SBUF,$INDENT,(melt_ptr_t) $MB);}#
)


;;; READ FILE primitive
(defprimitive read_file (filnam) :value
  :doc #{Read from file named by the $FILNAM string balue a list of MELT s-expressions.}#
  #{(meltgc_read_file (melt_string_str((melt_ptr_t)($FILNAM)), (char*)0))}#)

(defprimitive read_strv (strv) :value
  :doc #{Return the list of s-exprs contained in in parsed string
  $STRV. $STRV can be a boxed string or a strbuf value.}#
  #{(meltgc_read_from_val ((melt_ptr_t) ($STRV), NULL))}# )

;; to signal an error in a  source with some additional string value
(defprimitive error_strv (loc :cstring cmsg :value strv) :void
  :doc #{Show an error at boxed location $LOC with raw message string $CMSG and string value $STRV.}#
  #{melt_error_str((melt_ptr_t)($loc), ($cmsg), (melt_ptr_t)($strv))}#)


;; signal a plain error in a  source
(defprimitive error_plain (loc :cstring cmsg) :void
  :doc #{Show a plain error at boxed location $LOC with raw message string $CMSG.}#
  #{/* error_plain */ melt_error_str((melt_ptr_t)($loc), ($cmsg), (melt_ptr_t)0)}#)


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; to signal an warning in a  source with some additional string value
(defprimitive warning_strv (loc :cstring cmsg :value strv) :void
  :doc #{Show a warning at boxed location $LOC with raw message string $CMSG and string value $STRV.}#
  #{melt_warning_str(0, (melt_ptr_t)($loc), ($cmsg), (melt_ptr_t)($strv))}#)

;; signal a plain warning in a  source
(defprimitive warning_plain (loc :cstring cmsg) :void
  :doc #{Show a plain warning at boxed location $LOC with raw message string $CMSG.}#
  #{melt_warning_str(0, (melt_ptr_t)($loc), ($cmsg), (melt_ptr_t)0)}#)

;; signal a plain warning 
(defprimitive warningmsg_plain (:cstring cmsg) :void
  :doc #{Show a plain warning with raw message string $CMSG.}#
  #{warning(0, "MELT WARNING MSG [#%ld]::: %s", melt_dbgcounter, ($cmsg))}#  )

;; signal a plain error 
(defprimitive errormsg_plain (:cstring cmsg) :void
  :doc #{Show a plain error with raw message string $CMSG.}#
  #{error ("MELT ERROR MSG [#%ld]::: %s", melt_dbgcounter, ($cmsg))}#
  )




;; signal a plain warning with string
(defprimitive warningmsg_strv (:cstring cmsg :value strv) :void
  :doc #{Show a plain warning with raw message string $CMSG and string value $STRV.}#
  #{warning (0, "MELT WARNING MSG [#%ld]::: %s - %s", melt_dbgcounter, ($cmsg),
	  melt_string_str((melt_ptr_t)($STRV)))}#
  )

;; signal a plain error with string
(defprimitive errormsg_strv (:cstring cmsg :value strv) :void
  :doc #{Show a plain error with raw message string $CMSG and string value $STRV.}#
  #{error ("MELT ERROR MSG [#%ld]::: %s - %s", melt_dbgcounter, ($cmsg),
	  melt_string_str((melt_ptr_t)($STRV)))}#
  )

;; to signal an inform in a  source with some additional string value
(defprimitive inform_strv (loc :cstring cmsg :value strv) :void
  :doc #{Show a notice at boxed location $LOC with raw message string $CMSG and string value $STRV.}#
  #{melt_inform_str((melt_ptr_t)($loc), ($cmsg), (melt_ptr_t)($strv))}#)
;; signal a plain inform in a  source
(defprimitive inform_plain (loc :cstring cmsg) :void
  :doc #{Show a plain warning at boxed location $LOC with raw message string $CMSG.}#
  #{melt_inform_str((melt_ptr_t)($loc), ($cmsg), (melt_ptr_t)0)}#)


(defprimitive informsg_plain (:cstring cmsg) :void
  :doc #{Show a plain notice with raw message string $CMSG.}#
  #{inform(UNKNOWN_LOCATION, "MELT INFORM [#%ld]: %s",  melt_dbgcounter, ($cmsg))}#
  )

(defprimitive informsg_strv (:cstring cmsg :value strv) :void
  :doc #{Show a plain notice with raw message string $CMSG and string value $STRV.}#
  #{inform(UNKNOWN_LOCATION, "MELT INFORM [#%ld]: %s - %s",  
			     melt_dbgcounter, ($CMSG), 
			     melt_string_str ((melt_ptr_t) ($STRV)))}#
  )

;;; citerator on integers
(defciterator foreach_long_upto
  (:long imin imax)			;start formals
  eachlong				;state
  (:long ix)				;local formals
  :doc #{The $FOREACH_LONG_UPTO c-iterator provides the usual
ascending integer iterator. Start formals are $IMIN, the minimum start
integer, and $IMAX, le maximal ending integer. Local formal is $IX,
the current index. The body is executed for each integer value $IX
from $IMIN to $IMAX included.}#
  					;before expansion
#{/*start $eachlong */
    long $eachlong#_min =  $imin;
    long $eachlong#_max = $imax;
    long $eachlong#_cur = 0;
    for ($eachlong#_cur = $eachlong#_min;
         $eachlong#_cur <= $eachlong#_max;
	 $eachlong#_cur ++) {
	    $ix = $eachlong#_cur;	    
}#
 					;after expansion
   #{ } /*end eachlong */}#
)
   
;;; match an integer i mutiple of a given number n and submatch the quotient
(defcmatcher some_integer_multiple
  (:long i n)				;match & ins
  (:long q)					;outs
  intmult				;statesymb
  :doc #{The $SOME_INTEGER_MULTIPLE matcher with input number $N matches an
integer $I if $N is positive and $I is multiple of $N and the quotient
matches the subpattern $Q.}#
  ;; test expansion
  #{ /*$INTMULT ?*/ ($N>0 && (($I) % ($N))==0) }#
  ;; fill expansion
  #{ /*$INTMULT !*/ $Q = ($I) / ($N); }#
  )

;;; match an integer i different from a given number n
(defcmatcher some_integer_different_from
  (:long i n)
  ()
  intdiffrom
  :doc #{The $SOME_INTEGER_DIFFRERENT_FROM matcher with input number $N matches
an integer $I if $I is different from $N.}#
  ;; test expansion
  #{ /*$INTDIFFROM ?*/ ($I != $N) }#
  ;; no fill expansion
)

;;; match an integer i equal to a given number n
(defcmatcher some_integer_equal_to
  (:long i n)
  ()
  intequalto
  :doc #{The $SOME_INTEGER_EQUAL_TO matcher with input number $N matches
an integer $I if $I is or equal to $N.}#
  ;; test expansion
  #{ /*$INTEQUALTO ?*/ ($I == $N) }#
  ;; no fill expansion
)

;;; match an integer i greater or equal to a given number n
(defcmatcher some_integer_greater_or_equal_to
  (:long i n)
  ()
  intgreatorequal
  :doc #{The $SOME_INTEGER_GREATER_OR_EQUAL_TO matcher with input number $N matches
an integer $I if $I is greater or equal to $N.}#
  ;; test expansion
  #{ /*$INTGREATOREQUAL ?*/ ($I >= $N) }#
  ;; no fill expansion
)

;;; match an integer i greater than a given number n
(defcmatcher some_integer_greater_than
  (:long i n)
  ()
  intgreathan
  :doc #{The $SOME_INTEGER_GREATER_THAN matcher with input number $N matches
an integer $I if $I is greater than $N.}#
  ;; test expansion
  #{ /*$INTGREATHAN ?*/ ($I > $N) }#
  ;; no fill expansion
)

;;; match an integer i lower or equal to a given number n
(defcmatcher some_integer_lower_or_equal_to
  (:long i n)
  ()
  intloworequal
  :doc #{The $SOME_INTEGER_LOWER_OR_EQUAL_TO matcher with input number $N matches
an integer $I if $I is lower or equal to $N.}#
  ;; test expansion
  #{ /*$INTLOWOREQUAL ?*/ ($I <= $N) }#
  ;; no fill expansion
)

;;; match an integer i lower than a given number n
(defcmatcher some_integer_lower_than
  (:long i n)
  ()
  intlowthan
  :doc #{The $SOME_INTEGER_LOWER_THAN matcher with input number $N matches
an integer $I if $I is lower than $N.}#
  ;; test expansion
  #{ /*$INTLOWTHAN ?*/ ($I < $N) }#
  ;; no fill expansion
)

;;; match a boxed string, and set strval component
(defcmatcher some_string_value 
  (:value v)
  (:value sv)
  somestrval
  :doc #{The $SOME_STRING_VALUE matches a string value $V and passes it to the output $SV.}#
  ;; test
  #{ /*$SOMESTRVAL? */ (($V) && melt_magic_discr((melt_ptr_t)($V)) == MELTOBMAG_STRING) }#
  ;; fill
  #{ /*$SOMESTRVAL! */ $SV = $V; }#
)
;;;;;;;;;;;;;;;;

(defprimitive outnewline_err () :void
  :doc #{Output on stderr a newline and flush.}#
  "melt_newlineflush(stderr)")

(defprimitive outstr_err (str) :void
  :doc #{Output on stderr a MELT string.}#
  #{melt_putstr(stderr, (melt_ptr_t)($str))}#)


(defprimitive message_dbg (:cstring msg) :void :doc #{Debug message $msg}#
  #{debugeputs(($msg))}#)
(defprimitive messagenum_dbg (:cstring msg :long i) :void 
  :doc #{Debug output with message $msg number $i}#
  #{debugnum(($msg), ($i))}#)

(defprimitive messageval_dbg (:cstring msg :value val) :void
  :doc #{Debug output with message $msg value $val}#
  #{debugvalue(($msg), ((void*)($val)))}#)

(defprimitive longbacktrace_dbg (:cstring msg :long maxdepth) :void
  :doc #{Detailed debug backtrace with message $MSG up to $MAXDEPTH.}#
  #{debugbacktrace(($MSG), (int)($MAXDEPTH))}#)


(defprimitive checkval_dbg (val :cstring msg) :void
  :doc #{Low-level costly check of value $VAL with message $MSG. Mostly useful for gurus.}#
  #{melt_checked_assignmsg ((melt_ptr_t) ($VAL),($MSG))}#)

(defprimitive debugcstring (:cstring msg str) :void
  :doc #{Debug cstring $MSG $STR.}#
  #{debugeprintf("debugcstring %s '%s'", $msg, $str)}#)

(defprimitive debuglong (:cstring msg :long num) :void
  :doc #{Debug long stuff with $MSG and number $NUM.}#
  #{debugeprintf("debuglong %s %ld", $msg, $num)}#)

;;;;;; STRBUF primitives
;; primitive to make a strbuf
(defprimitive make_strbuf (discr) :value
  :doc #{Make a new stringbuffer value of given $DISCR - or null if bad $DISCR.}#
  #{(melt_ptr_t) meltgc_new_strbuf((meltobject_ptr_t)($DISCR), (const char*)0)}#)

;; reserve space for optimization purposes
(defprimitive strbuf_reserve (sbuf :long siz) :void
  :doc #{Reserve extra space in stringbuffer $SBUF for $SIZ bytes.}#
  #{ if ($SIZ > 0) meltgc_strbuf_reserve ((melt_ptr_t)$SBUF, (unsigned)$SIZ); }#
)

(defprimitive strbuf_usedlength (sbuf) :long
  :doc #{Give the used length of given $SBUF string buffer or else 0.}#
  #{melt_strbuf_usedlength((melt_ptr_t)($sbuf))}#)

(defprimitive output_length (out) :long
  :doc #{Return the length of a given output $OUT (i.e. the used length if it is a string buffer, the file position if it is a file) or else 0.}#
  #{melt_output_length ((melt_ptr_t)$OUT)}#)

(defprimitive is_strbuf (v) :long
  :doc #{Test if value $V is a stringbuffer.}# 
  #{(melt_magic_discr((melt_ptr_t)($v)) == MELTOBMAG_STRBUF)}#)

;;; make a string
(defprimitive make_string (dis str) :value
  :doc #{Make a new string of discriminant $DIS from string value $STR.}#
  #{(meltgc_new_stringdup((meltobject_ptr_t)($DIS), 
			  melt_string_str((melt_ptr_t)($STR))))}#)

(defprimitive is_stringconst (str :cstring cs) :long
  :doc #{Test that value string $STR is the raw string constant $CS.}#
  #{(melt_is_string_const((melt_ptr_t)($str), ($cs)))}#)

(defprimitive string_length (str) :long
  :doc #{Give the length of string value $STR.}#
  #{melt_string_length((melt_ptr_t)($str))}#)

(defprimitive string_suffixed (sv :cstring cs) :long
  :doc #{Test that the string value $SV ends with the suffix $CS.}#
  #{/*string_suffixed:*/(melt_string_is_ending ((melt_ptr_t)$SV, $CS))}#)

(defprimitive string_dynloaded_suffixed (sv) :long
  :doc #{Test that the string value $SV ends with the MELT_DYNLOADED_SUFFIX.}#
  #{/*string_dynloaded_suffixed:*/ (melt_string_is_ending ((melt_ptr_t)$SV, 
							   MELT_DYNLOADED_SUFFIX))}#)


(defprimitive string_prefixed (sv :cstring cs) :long
  :doc #{Test that the string value $SV starts with the suffix $CS.}#
  #{(melt_string_is_starting ((melt_ptr_t)$SV, $CS))}#)

(defprimitive string_starts (sv1 sv2) :long
  :doc #{Test that the string value $SV1 starts with the string value $SV2.}#
  #{(melt_string_is_starting ((melt_ptr_t)$SV1, melt_string_str ((melt_ptr_t)$SV2)))}#)

(defprimitive string_ends (sv1 sv2) :long
  :doc #{Test that the string value $SV1 ends with the string value $SV2.}#
  #{(melt_string_is_ending ((melt_ptr_t)$SV1, melt_string_str ((melt_ptr_t)$SV2)))}#)

(defprimitive string_hex_md5sum_constpath (:cstring path) :value
  :doc #{Return a boxed string contained the hexadecimal md5sum of raw $PATH, or null.}#
  #{(meltgc_string_hex_md5sum_file($PATH))}#)

(defprimitive string_hex_md5sum_pathstrv (pathv) :value
  :doc #{Return a boxed string contained the hexadecimal md5sum of the string value  $PATHV, or null.}#
  #{(meltgc_string_hex_md5sum_file (melt_string_str((melt_ptr_t)$PATHV)))}#)

(defprimitive string_hex_md5sum_path_sequence (pathseq) :value
  :doc #{Return a boxed string contained the cumulated hexadecimal
  md5sum on paths inside tuple $PATHSEQ, or null.}#
  #{(meltgc_string_hex_md5sum_file_sequence ((melt_ptr_t) $PATHSEQ))}#)


(defprimitive split_string_space (dis s) :value
  :doc #{Split a string value $S into a list of space separated strings of
discriminant $DIS.}#
#{meltgc_new_split_string (melt_string_str ((melt_ptr_t) $S), ' ', (melt_ptr_t) $DIS)}#)

(defprimitive split_string_comma (dis s) :value
  :doc #{Split a string value $S into a list of comma separated strings of
discriminant $DIS.}#
#{meltgc_new_split_string (melt_string_str ((melt_ptr_t) $S), ',', (melt_ptr_t) $DIS)}#)

(defprimitive split_string_colon (dis s) :value
  :doc #{Split a string value $S into a list of colon separated strings of
discriminant $DIS.}#
#{meltgc_new_split_string (melt_string_str ((melt_ptr_t) $S), ':', (melt_ptr_t) $DIS)}#)

(defprimitive split_string_equal (dis s) :value
  :doc #{Split a string value $S into a list of equal separated strings of
discriminant $DIS.}#
#{meltgc_new_split_string (melt_string_str ((melt_ptr_t) $S), '=', (melt_ptr_t) $DIS)}#)

;;; convert a strbuf into a string
(defprimitive strbuf2string (dis sbuf) :value
  :doc #{make a string value of discriminant $DIS from the stringbuffer $SBUF.}#
  #{(meltgc_new_stringdup((meltobject_ptr_t)($dis), melt_strbuf_str((melt_ptr_t)($sbuf))))}#)

;;; compute the naked basename
(defprimitive make_string_nakedbasename (dis str) :value
  :doc #{make a string value of discriminant $DIS from the naked basename from file path $STR.}#
  #{(meltgc_new_string_nakedbasename((meltobject_ptr_t)($DIS), 
				     melt_string_str((melt_ptr_t)($STR))))}#)

;;; compute the naked temporary path for a basename with a suffix
(defprimitive make_string_tempname_suffixed (dis str :cstring suff) :value
  :doc #{make a naked temporary path of discriminant $DIS for a
  basename $STR with suffix $SUFF.}#
  #{(meltgc_new_string_tempname_suffixed((meltobject_ptr_t)($DIS),
					 melt_string_str((melt_ptr_t)($STR)),
					 ($SUFF)))}#)


;; remove a suffix from a string or else copy it
(defprimitive make_string_without_suffix (dis str :cstring suffix) :value
  :doc #{Make a fresh copy with discriminant $DIS of string $STR 
removing the given $SUFFIX if it ends with it, or else a copy of $STR.}#
  #{/*make_string_without_suffix*/
  (meltgc_new_string_without_suffix ((meltobject_ptr_t)($DIS),
				     melt_string_str ((melt_ptr_t)($STR)),
				     ($SUFFIX))) }#
)

;; remove the MELT_DYNLOADED_SUFFIX from a string or else copy it
(defprimitive make_string_without_dynloaded_suffix (dis str) :value
  :doc #{Make a fresh copy with discriminant $DIS of string $STR 
removing the MELT_DYNLOADED_SUFFIX if it ends with it, or else a copy of $STR.}#
  #{/*make_string_without_dynloaded_suffix*/
  (meltgc_new_string_without_suffix ((meltobject_ptr_t)($DIS),
				     melt_string_str ((melt_ptr_t)($STR)),
				     MELT_DYNLOADED_SUFFIX))}#
)

;; compute a generated C source file
(defprimitive make_string_generated_c_filename (dis basestr dirstr) :value
  :doc #{make a generated C file path of discriminant $DIS with base $BASESTR and directory $DIRSTR adding a .c suffix.}#
  #{(meltgc_new_string_generated_c_filename((meltobject_ptr_t)($DIS),
					    melt_string_str ((melt_ptr_t)($BASESTR)),
					    melt_string_str ((melt_ptr_t)($DIRSTR)),
					    0))}#)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; obsolete compilation primitives


;; generate a loadable module from a MELT generated C source file; the
;;  out is the dynloaded module without any MELT_DYNLOADED_SUFFIX 
(defprimitive generate_optimized_melt_module (src outnam) :void
  :doc #{Generate and load an optimized module whose source is named after $SRC 
and whose binary is named after $OUTNAM without any MELT_DYNLOADED_SUFFIX.}#
  #{melt_compile_source (melt_string_str ((melt_ptr_t)$SRC),
			 melt_string_str ((melt_ptr_t)$OUTNAM),
			 NULL,
			 "optimized"); /*generate_melt_module*/
  }#)

;; generate a loadable module from a MELT generated C source file; the
;;  out is the dynloaded module without any MELT_DYNLOADED_SUFFIX. 
(defprimitive generate_flavored_melt_module (src outnam flavor) :void
  :doc #{Generate and load a module of given $FLAVOR whose source is named after $SRC 
and whose binary is named after $OUTNAM without any MELT_DYNLOADED_SUFFIX.}#
  #{melt_compile_source (melt_string_str ((melt_ptr_t)$SRC),
			 melt_string_str ((melt_ptr_t)$OUTNAM),
			 NULL,
			 melt_string_str ((melt_ptr_t)$FLAVOR)); /*generate_flavored_melt_module*/
  }#)

;; generate a debug loadable module from a MELT generated C source file; the
;;  out is the dynloaded module without any MELT_DYNLOADED_SUFFIX.
(defprimitive generate_debug_melt_module (src outnam) :void
  :doc #{Generate and load a module whose source is named after $SRC 
and whose binary is named after $OUTNAM without any MELT_DYNLOADED_SUFFIX.}#
  #{melt_compile_source (melt_string_str ((melt_ptr_t)$SRC),
			 melt_string_str ((melt_ptr_t)$OUTNAM),
			 NULL,
			 "debugnoline"); /*generate_debug_melt_module*/
  }#
)

;; quickly generate a loadable module from a MELT generated C source file; the
;;  out is the dynloaded module without any MELT_DYNLOADED_SUFFIX. 
(defprimitive generate_quickly_melt_module (src outnam) :void
  :doc #{Generate and load a module whose source is named after $SRC 
and whose binary is named after $OUTNAM without any MELT_DYNLOADED_SUFFIX.}#
  #{melt_compile_source (melt_string_str ((melt_ptr_t)$SRC),
			 melt_string_str ((melt_ptr_t)$OUTNAM),
			 NULL,
			 "quicklybuilt"); /*generate_quickly_melt_module*/
  }#
)

;; primitive to load and initialize a module with a flavor in a given environement 
(defprimitive start_melt_module_of_flavor (env modname flavor) :value
  :doc #{start in environment $ENV  and load module of basename $MODNAME and $FLAVOR. Gives the new environment.}#
  #{meltgc_start_flavored_module ((melt_ptr_t)$ENV,
				  melt_string_str ((melt_ptr_t) $MODNAME),
				  melt_string_str ((melt_ptr_t) $FLAVOR));
  }#)


;;;;;;;;;;;;;;;; the melt version string
(defprimitive melt_version_str () :cstring
  :doc #{Gives the MELT version string.}#
  #{(melt_version_str())}#)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;; OBJECT primitives
;; primitive to get an object length
(defprimitive object_length (ob) :long 
  :doc #{Gives the length of object $OB.}#
  #{((long)melt_object_length((melt_ptr_t)($ob)))}#)
;; primitive to get the nth field of an object
(defprimitive object_nth_field (ob :long n) :value
  :doc #{Safely retrieve from object $OB its $N-th field or else null.}#
  #{(melt_field_object((melt_ptr_t)($ob), ($n)))}#)

(defprimitive subclass_of (cl1 cl2) :long
  :doc #{Safely test if class $CL1 is a sub-class of class $CL2.}#
  #{melt_is_subclass_of((meltobject_ptr_t)($cl1), (meltobject_ptr_t)($cl2))}#)
(defprimitive subclass_or_eq (cl1 cl2) :long
  :doc #{Safely test if class $CL1 is the same or a sub-class of class $CL2.}#
  #{(($cl1 == $cl2) || melt_is_subclass_of((meltobject_ptr_t)($cl1), (meltobject_ptr_t)($cl2)))}#)

(defprimitive is_multiple_or_null (mul) :long
  :doc #{Safely test if $MUL is a tuple or null.}#
  #{(($mul) == NULL || (melt_unsafe_magic_discr((melt_ptr_t)($mul)) == MELTOBMAG_MULTIPLE))}#)
;; primitive to build the subsequence of a multiple
(defprimitive subseq_multiple (mul :long startix endix) :value
  :doc #{Make a tuple from as subsequence of $MUL from indexes $STARTIX to $ENDIX.}#
 #{ meltgc_new_subseq_multiple((melt_ptr_t)($mul),
				  (int)($startix), (int)($endix)) }#)

;; is_multiple, make_multiple, multiple_nth, multiple_put_nth are in
;; warmelt-first

;; cmatcher for the tuple nth argument
(defcmatcher tuple_nth 
  (matchedtup :long matchedrk)				;match & ins
  (outcomp)				;out
  tupnth				;statesymb
  :doc #{The $TUPLE_NTH matcher with input number $MATCHEDRK matches a
tuple of length greater than $MATCHEDRK and retrieve the component
of that index, and matches it against the sub-pattern.}#
  ;;test expansion
   #{/*$TUPNTH ?*/ (melt_is_multiple_at_least(((melt_ptr_t)$matchedtup), 1+ (int)($matchedrk)))}#
   ;;fill expansion
  #{/*$TUPNTH !*/ $outcomp = melt_multiple_nth((melt_ptr_t)($matchedtup),(int)($matchedrk));
   }#
  ;; no operator expansion 
)


;; cmatcher for a tuple of a given exact size
(defcmatcher tuple_sized
  (tup :long ln)			;match & ins
  () 					;outs
  tupsiz				;statesymb
  :doc #{Match a tuple of given exact size.}#
  ;;test expansion
   #{(melt_is_multiple_of_length((melt_ptr_t)($tup), (int) ($ln)))}#
  ;; no fill expansion
  ;; no operator expansion
)


;; public comparator for named instances
(defun compare_named_alpha (n1 n2)
  :doc #{Alphanumerical compare of named instances $N1 and $N2. 
Returns a boxed integer.}#
  (cond 
   ( (== n1 n2) '0)
   ( (is_not_a n1 class_named) 
     '1)
   ( (is_not_a n2 class_named)
     '-1)
   (:else
    (let ( (sn1 (unsafe_get_field :named_name n1))
	   (sn2 (unsafe_get_field :named_name n2)) )
      (cond
       ( (string< sn1 sn2) 
	 '-1)
       ( (string> sn1 sn2)
	 '1)
       (:else
	'0))))))



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; test if MELT is bootstrapping
(defprimitive melt_is_bootstrapping () :long
  :doc #{Test if MELT is bootstrapping. Only for MELT implementation gurus.}#
  #{(melt_flag_bootstrapping)}#
)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; actually all the sbuf routines now take an outbuf argument, which can be either a string buffer of a file
(defprimitive is_out (v) :long
  :doc #{Test if value $V is a output value (a stringbuffer or a file).}# 
  #{ (melt_is_out ((melt_ptr_t) $v)) }#)

(defprimitive is_file (v) :long
  :doc #{Test if value $V is a file.}#
  #{ (melt_is_file ((melt_ptr_t) $V)) }#)

;; primitive to add a string const into a strbuf
(defprimitive add2sbuf_strconst (sbuf :cstring str) :void 
  :doc #{Add into stringbuffer $SBUF the constant string $STR.}#
  #{/*add2sbuf_strconst*/ meltgc_add_strbuf((melt_ptr_t)($SBUF), ($STR))}#)

;; primitive to add the MELT_DYNLOADED_SUFFIX into a strbuf
(defprimitive add2sbuf_dynloaded_suffix (sbuf) :void
  :doc #{Add into stringbuffer $SBUF the MELT_DYNLOADED_SUFFIX constant string.}#
  #{/*add2sbuf_dynloaded_suffix: */ meltgc_add_strbuf((melt_ptr_t)($SBUF), 
						      MELT_DYNLOADED_SUFFIX)}#)

;; primitive to add a string value into a strbuf
(defprimitive add2sbuf_string (sbuf str) :void 
  :doc #{Add into stringbuffer $SBUF the string value $STR.}#
  #{/*add2sbuf_string*/ meltgc_add_strbuf((melt_ptr_t)($SBUF), 
                      melt_string_str((melt_ptr_t)($STR)))}#)
;; primitive to add the location info of a mixedloc into a strbuf we
;; copy the location file name into a buffer, to avoid crashing if a
;; GC is called...
(defprimitive add2sbuf_mixloc (sbuf mixl) :void
  :doc #{Add into stringbuffer $SBUF the mixed loc $MIXL.}#
  #{/*add2sbufmixloc*/ if (melt_magic_discr((melt_ptr_t)($MIXL)) == MELTOBMAG_MIXLOC) {
    char smallcbuf[128];
    location_t loc = melt_location_mixloc ((melt_ptr_t)$MIXL);
    memset (smallcbuf, 0, sizeof(smallcbuf));
    snprintf (smallcbuf, sizeof (smallcbuf)-1, 
			"{%.120s:%d:%d}",
			LOCATION_FILE (loc), LOCATION_LINE (loc), LOCATION_COLUMN (loc));
    meltgc_add_strbuf_raw((melt_ptr_t)($SBUF), smallcbuf);
 } /*end add2sbufmixloc*/  }#)
;; primitive to add the short location info of a mixedloc into a strbuf
(defprimitive add2sbuf_short_mixloc (sbuf mixl) :void
  :doc #{Add into stringbuffer $SBUF the mixed loc $MIXL in short form.}#
  #{/*add2sbufshortmixloc*/  if (melt_magic_discr((melt_ptr_t)($mixl)) == MELTOBMAG_MIXLOC) {
  location_t loc = melt_location_mixloc((melt_ptr_t)$mixl);
  meltgc_strbuf_printf((melt_ptr_t)($sbuf), "{%s:%d:%d}", 
		       lbasename(LOCATION_FILE (loc)), 
		       LOCATION_LINE (loc), LOCATION_COLUMN (loc));
  } /*end add2sbufshortmixloc*/}#)
;; primitive to add the texi location info of a mixedloc into a strbuf
(defprimitive add2sbuf_texi_mixloc (sbuf mixl) :void
  :doc #{Add into stringbuffer $SBUF the mixed loc $MIXL in texinfo form.}#
  #{/*add2sbufteximixloc*/ if (melt_magic_discr((melt_ptr_t)($mixl)) == MELTOBMAG_MIXLOC) {
  location_t loc = melt_location_mixloc((melt_ptr_t)$mixl);
  meltgc_strbuf_printf((melt_ptr_t)($sbuf), "file @file{%s}, line %d", 
		       lbasename (LOCATION_FILE (loc)), 
		       LOCATION_LINE (loc)); 
  } /*end add2sbufteximixloc*/}#)

;; primitive to add an indentation or space into a strbuf
(defprimitive add2sbuf_indent (sbuf :long depth) :void
  :doc #{Add into stringbuffer $SBUF an indentation of given $DEPTH or a space.}#
  #{meltgc_strbuf_add_indent((melt_ptr_t)($sbuf), ($depth), 64)}#)


;; primitive to add an indented newline into a strbuf
(defprimitive add2sbuf_indentnl (sbuf :long depth) :void
  :doc #{Add into stringbuffer $SBUF an indented newline of given $DEPTH.}#
  #{meltgc_strbuf_add_indent((melt_ptr_t)($sbuf), ($depth), 0)}#)


;; primitive to add a strbuf into a strbuf
(defprimitive add2sbuf_sbuf (sbuf asbuf) :void 
  :doc #{Add into stringbuffer $SBUF the content of stringbuffer $ASBUF.}#
  #{/*add2sbuf_sbuf*/ meltgc_add_strbuf((melt_ptr_t)($SBUF), 
					melt_strbuf_str((melt_ptr_t)$ASBUF))}#)

;; primitive to add a string value, C encoded, into a strbuf
(defprimitive add2sbuf_cencstring (sbuf str) :void 
  :doc #{Add into stringbuffer $SBUF the content of string $STR with C encoding.}#
  #{meltgc_add_strbuf_cstr((melt_ptr_t)($SBUF), 
                           melt_string_str((melt_ptr_t)($STR)))}#)

;; primitive to add a strbuf, C encoded, into a strbuf
(defprimitive add2sbuf_cencstrbuf (sbuf asbuf) :void 
  :doc #{Add into stringbuffer $SBUF the content of stringbuffer $ASBUF with C encoding.}#
  #{meltgc_add_strbuf_cstr((melt_ptr_t)($sbuf), melt_strbuf_str((melt_ptr_t)($asbuf)))}#)

;; primitive to add a string value, Ccomment encoded, into a strbuf
(defprimitive add2sbuf_ccomstring (sbuf str) :void 
  :doc #{Add into stringbuffer $SBUF the content of string $STR with C-comment encoding, i.e. avoiding */.}#
  #{meltgc_add_strbuf_ccomment((melt_ptr_t)($SBUF), 
                               melt_string_str((melt_ptr_t)($STR)))}#)

;; primitive to add a strbuf, C encoded, into a strbuf
(defprimitive add2sbuf_ccomstrbuf (sbuf asbuf) :void 
  :doc #{Add into stringbuffer $SBUF the content of stringbuffer $ASBUF with C-comment encoding, i.e. avoiding */.}#
  #{meltgc_add_strbuf_ccomment((melt_ptr_t)($SBUF), 
			       melt_strbuf_str((melt_ptr_t)($ASBUF)))}#)

;; primitive to add a cstring const, Ccomment encoded, into a strbuf
(defprimitive add2sbuf_ccomconst (sbuf :cstring cstr) :void 
  :doc #{Add into stringbuffer $SBUF the constant string $CSTR with
 C-comment encoding so no */.}# 
 #{/*add2sbuf_ccomconst*/ meltgc_add_strbuf_ccomment((melt_ptr_t) ($SBUF), $CSTR)}#)

;; primitive to add into a strbuf a string as C ident (nonalphanum
;; replaced by _)
(defprimitive add2sbuf_cident (sbuf str) :void
  :doc #{Add into stringbuffer $SBUF the string $STR as a C identifier
  so nonalphanum replaced by _.}#
  #{meltgc_add_strbuf_cident((melt_ptr_t)($SBUF),
  melt_string_str((melt_ptr_t)($STR)))}#)

;; primitive to add into a strbuf the prefix of a string as C ident (nonalphanum
;; replaced by _) limited by a small length 
(defprimitive add2sbuf_cidentprefix  (sbuf str :long preflen) :void
  :doc #{Add into stringbuffer $SBUF the prefix string $STR as a C identifier
  so nonalphanum replaced by _ limited by $PREFLEN.}#
  #{meltgc_add_strbuf_cidentprefix((melt_ptr_t)($SBUF), 
                                   melt_string_str((melt_ptr_t)($STR)), ($PREFLEN))}#)

;; primitive to add a long in decimal into a strbuf
(defprimitive add2sbuf_longdec (sbuf :long num) :void
  :doc #{Add into stringbuffer $SBUF the number $NUM in decimal.}#
  #{meltgc_add_strbuf_dec((melt_ptr_t)($sbuf), ($num))}#)

;; primitive to add a long in hex into a strbuf
(defprimitive add2sbuf_longhex (sbuf :long num) :void
  :doc #{Add into stringbuffer $SBUF the number $NUM in hexa.}#
  #{meltgc_add_strbuf_hex((melt_ptr_t)($sbuf), ($num))}#)

;; primitive to add a routine descr into a strbuf
(defprimitive add2sbuf_routinedescr (sbuf rout) :void
  :doc #{Add into stringbuffer $SBUF the routine descriptor $ROUT.}#
  #{meltgc_add_strbuf((melt_ptr_t)($sbuf), melt_routine_descrstr((melt_ptr_t)($rout)))}#)

;;;;;;;;;;;;;;;;
;;; primitive to output a strbuf into a file named by a cstring
(defprimitive output_sbuf_strconst (sbuf :cstring nam) :void
  :doc #{Output into file named $NAM the content of strinbuffer $SBUF.}#
#{ /*output_sbuf_strconst*/ melt_output_strbuf_to_file((melt_ptr_t) ($SBUF), ($nam)) }#)
;;; primitive to output a strbuf into a file named by a stringval
(defprimitive output_sbuf_strval (sbuf vnam) :void
  :doc #{Output into file named by string value $VNAM the content of strinbuffer $SBUF.}#
#{ /*output_sbuf_strval*/ melt_output_strbuf_to_file((melt_ptr_t) ($SBUF), melt_string_str((melt_ptr_t) $VNAM)) }#)

;;; primitive to output a strbuf into a file named by a cstring
(defprimitive output_sbuf_no_overwrite_strconst (sbuf :cstring nam) :void
  :doc #{Output into file named $NAM the content of strinbuffer $SBUF, take care to not overwrite an file named $VNAM if it was the same.}#
#{ /*output_sbuf_no_overwrite_strconst*/ melt_output_strbuf_to_file_no_overwrite((melt_ptr_t)($SBUF), ($NAM)) }#)
;;; primitive to output a strbuf into a file named by a stringval
(defprimitive output_sbuf_no_overwrite_strval (sbuf vnam) :void
  :doc #{Output into file named by string value $VNAM the content of 
strinbuffer $SBUF, take care to not overwrite an old file named $VNAM if it was the same.}#
#{ /*output_sbuf_no_overwrite_strval*/ melt_output_strbuf_to_file_no_overwrite((melt_ptr_t)($SBUF), 
					   melt_string_str((melt_ptr_t) $VNAM)) }#)


;;;;;;;;;;;;;;;; variant for outbuf

;; primitive to add a string const into a outbuf
(defprimitive add2out_strconst (out :cstring str) :void 
  :doc #{Add to output $OUT the cstring $STR.}#
  #{meltgc_add_out((melt_ptr_t)($out), ($str))}#)
;; primitive to add a string value into a outbuf
(defprimitive add2out_string (out str) :void 
  :doc #{Add to output $OUT the string value $STR.}#
  #{meltgc_add_out((melt_ptr_t)($OUT), melt_string_str((melt_ptr_t)($STR)))}#)

;; primitive to add the location info of a mixedloc into a outbuf
(defprimitive add2out_mixloc (out mixl) :void
  :doc #{Add to output $OUT the mixed location $MIXL.}#
  #{/*add2outmixloc*/ if (melt_magic_discr((melt_ptr_t)($mixl)) == MELTOBMAG_MIXLOC) {
  char locbuf[256];
  location_t tloc = melt_location_mixloc((melt_ptr_t)$MIXL);
  memset (locbuf, 0, sizeof(locbuf));
  snprintf (locbuf, sizeof(locbuf)-1,
		    "{%.200s:%d}",
		    LOCATION_FILE (tloc),
		    LOCATION_LINE (tloc));
   meltgc_add_out_raw ((melt_ptr_t) $OUT, locbuf);
  } /*end add2outmixloc*/
}#)

;; primitive to add an indentation or space into a outbuf
(defprimitive add2out_indent (out :long depth) :void
  :doc #{Add to output $OUT the indentation $DEPTH or a space.}#
  #{meltgc_out_add_indent((melt_ptr_t)($OUT), ($depth), 64);}#
)


;; primitive to add an indented newline into a outbuf
(defprimitive add2out_indentnl (out :long depth) :void
  :doc #{Add to output $OUT the indented newline of given $DEPTH.}#
  #{meltgc_out_add_indent((melt_ptr_t)($OUT), ($depth), 0);}#
)


;; primitive to add a strbuf into a outbuf
(defprimitive add2out_sbuf (out asbuf) :void 
  :doc #{Add to output $OUT the stringbuffer $ASBUF.}#
  #{meltgc_add_out ((melt_ptr_t)($OUT), melt_strbuf_str ((melt_ptr_t) $ASBUF))}#)

;; primitive to add a string value, C encoded, into a outbuf
(defprimitive add2out_cencstring (out str) :void 
  :doc #{Add to output $OUT the C-encoded string value $STR.}#
  #{meltgc_add_out_cstr((melt_ptr_t)($OUT), 
			melt_string_str((melt_ptr_t)($STR)))}#)

;; primitive to add a substring value, C encoded, into a outbuf
(defprimitive add2out_cencsubstring (out str :long off slen) :void 
  :doc #{Add to output $OUT the C-encoded substring value $STR at offset $OFF of length $SLEN.}#
  #{meltgc_add_out_csubstr_len((melt_ptr_t)($OUT),
			       melt_string_str((melt_ptr_t)($STR)),
			       ($OFF), ($SLEN))}#)

;; primitive to add a strbuf, C encoded, into a outbuf
(defprimitive add2out_cencstrbuf (out asbuf) :void 
  :doc #{Add to output $OUT the C-encoded stringbuffer $ASBUF.}#
  #{meltgc_add_out_cstr((melt_ptr_t)($out), melt_strbuf_str((melt_ptr_t)($ASBUF)))}#)

;; primitive to add a string value, Ccomment encoded, into a outbuf
(defprimitive add2out_ccomstring (out str) :void 
  :doc #{Add to output $OUT the C-comment encoded string value $STR.}#
  #{meltgc_add_out_ccomment((melt_ptr_t)($OUT), 
                            melt_string_str((melt_ptr_t)($STR)))}#)

;; primitive to add a strbuf, C encoded, into a outbuf
(defprimitive add2out_ccomstrbuf (out asbuf) :void 
  :doc #{Add to $OUT the C-comment encoded stringbuffer $ASBUF.}#
  #{meltgc_add_out_ccomment((melt_ptr_t)($OUT), 
                            melt_strbuf_str((melt_ptr_t)($ASBUF)))}#)

;; primitive to add a cstring const, Ccomment encoded, into a outbuf
(defprimitive add2out_ccomconst (out :cstring cstr) :void 
  :doc #{Add to $OUT the constant C-comment encoded raw $CSTR.}#
  #{meltgc_add_out_ccomment(($out), $cstr)}#)

;; primitive to add into a outbuf a string as C ident (nonalphanum
;; replaced by _)
(defprimitive add2out_cident (out str) :void
  :doc #{Add to $OUT the MELT string $STR encocded as a C identifier, so
with every non-alnum character replaced with an underscore.}#
  #{meltgc_add_out_cident((melt_ptr_t)($OUT), 
			  melt_string_str((melt_ptr_t)($STR)))}#)

;; primitive to add into a outbuf the prefix of a string as C ident (nonalphanum
;; replaced by _) limited by a small length 
(defprimitive add2out_cidentprefix  (out str :long preflen) :void
  :doc #{Add to $OUT the prefix of a string encoded as a C identifier,
limited by a small length $PREFLEN.}#
  #{meltgc_add_out_cidentprefix((melt_ptr_t)($out), 
				melt_string_str((melt_ptr_t)($STR)), 
				($preflen))}#)

;; primitive to add a long in decimal into a outbuf
(defprimitive add2out_longdec (out :long num) :void
  :doc #{Add to $OUT the number $NUM in decimal.}#
  #{meltgc_add_out_dec((melt_ptr_t)($out), ($num))}#)

;; primitive to add a long in hex into a outbuf
(defprimitive add2out_longhex (out :long num) :void
  :doc #{Add to $OUT the number $NUM in hex.}#
  #{meltgc_add_out_hex((melt_ptr_t)($out), ($num))}#)

;; primitive to add a routine descr into a outbuf
(defprimitive add2out_routinedescr (out rout) :void
  :doc #{Add to $OUT the routine desscriptor $ROUT.}#
  #{meltgc_add_out((melt_ptr_t)($out), 
		   melt_routine_descrstr((melt_ptr_t)($rout)))}#)


(defselector add_to_out class_selector
  :doc #{The selector $ADD_TO_OUT add the reciever $RECV into the
output $OUT. It is called by the $ADD2OUT variadic function.}#
  :formals (recv out)
)

(defun add2out (out :rest)
  :doc #{Variadic function to add to an output $OUT (a file, a string buffer) 
  various things. Return the given $OUT. Use $ADD_TO_OUT selector for values. 
  Closure values are handled as manipulators for next thing.}#
  (if (not (is_out out))
      (return))
  (forever 
   argloop
   (variadic 
    ( ()
      (return out))
    ( (:value v)
      (if (is_closure v)
	  (variadic
	   ((:value vv)
	    (v out vv))
	   ((:long ll)
	    (v out ll))
	   ((:cstring ss)
	    (v out ss))
	   ((:tree tt)
	    (v out tt))
	   ((:gimple gg)
	    (v out gg))
	   ((:gimple_seq gs)
	    (v out gs))
	   ((:edge ee)
	    (v out ee))
	   ((:loop lo)
	    (v out lo))
	   (:else
	    (let ( (vcty (variadic_ctype 0))
		   )
	      (errormsg_strv "ADD2OUT with manipulator for unsupported ctype "
			    (get_field :named_name vcty))
	      (assert_msg "invalid variadic argument after closure to ADD2OUT" ())
	      (return)
	      )))
	(add_to_out v out)))
    ( (:long n)
      (add2out_longdec out n))
    ( (:cstring s)
      (add2out_strconst out s))
    ( :else
      (let ( (vcty (variadic_ctype 0))
	     )
	(errormsg_strv "ADD2OUT for unsupported ctype "
		       (get_field :named_name vcty))
	)
      (assert_msg "invalid variadic argument to ADD2OUT" ())
      (return out)
      ))))

;; read add2out4null as "add to out for null"
(defun add2out4null (v out)
  (assert_msg "check null v" (null v))
  (add2out_strconst out "*nil*"))
(install_method discr_null_receiver add_to_out add2out4null)

(defun add2out4integer (vn out)
  (assert_msg "check boxed number vn" (is_integerbox vn))
  (add2out_longdec out (get_int vn)))
(install_method discr_integer add_to_out add2out4integer)

(defun add2out4string (vs out)
  (assert_msg "check boxed string vs" (is_string vs))
  (add2out_string out vs))
(install_method discr_string add_to_out add2out4string)

(defun add2out4strbuf (vsbuf out)
  (assert_msg "check strbuf vsbuf" (is_strbuf vsbuf))
  (add2out_sbuf out vsbuf))
(install_method discr_strbuf add_to_out add2out4strbuf)

(defun add2out4clonedsymb (vc out)
  (match vc
	 (?(instance class_cloned_symbol
		     :named_name ?nvarnam
		     :csym_urank ?(integerbox_of ?nvarurank))
	   (assert_msg "check nvarnam" (is_string nvarnam))
	   (add2out_cident out nvarnam)
	   (add2out_strconst out "__")
	   (add2out_longdec out nvarurank))
	 (?_
	  (assert_msg "bad cloned symbol" ()))))
(install_method class_cloned_symbol add_to_out add2out4clonedsymb)

(defun add2out4named (vn out)
  (add2out_cident out (get_field :named_name vn)))
(install_method class_named add_to_out add2out4named)

(defun add2out4rootobject (vo out)
  (add2out_strconst out "*")
  (add2out_string out (get_field :named_name (discrim vo)))
  (add2out_strconst out "/")
  (add2out_longhex out (obj_hash vo))
  (add2out_strconst out "."))
(install_method class_root add_to_out add2out4rootobject)

(defun add2out4any (va out)
  (add2out_strconst out "*")
  (add2out_string out (get_field :named_name (discrim va))))
(install_method discr_any_receiver add_to_out add2out4any)



;;; cmatcher for a cstring of a given content
(defcmatcher cstring_same 
  (:cstring str cstr)
  ()
  strsam
  :doc #{The $CSTRING_SAME c-matcher matches a string $STR and test if
  it equals to the constant string $CSTR. The match fails if $STR is a
  null string or different from $CSTR.}# 

#{/*$strsam test*/ ($STR && $CSTR && !strcmp($STR, $CSTR)) }#
  ;; no fill or operator
)
;; cmatcher for a cstring starting with a given prefix
(defcmatcher cstring_prefixed 
  (:cstring str cstr)
  ()
  strprefixed
  :doc #{The $CSTRING_PREFIX c-matcher matches a string $STR and test if
  it starts with the constant string $CSTR. The match fails if $STR is a
  null string or not prefixed by $CSTR.}# 

#{/*$STRPREFIXED test*/ ($STR && $CSTR && !strncmp($STR, $CSTR, strlen ($CSTR))) }#
  ;; no fill or operator
)


;; primitive to compute the length of a cstring
(defprimitive cstring_length
  (:cstring cstr) :long
  :doc #{Compute safely the length a C-string $cstr. Gives 0 if null argument. }#
  #{(($cstr)?strlen($cstr):0)}#)

;;;;;;;;;;;;;;;;



;;; iterate fully in a map of strings
(defun mapstring_every (map f)
  :doc #{For a given hash-map of strings $MAP and a function $F,
apply $F to every attribute object and [perhaps allocated] string value. Returns
nil.}#
  (if (is_mapstring map)
      (if (is_closure f)
	  (foreach_in_mapstring
	   (map)
	   (curat curval)
	   (f curat curval)))))

;;; iterate & test over a map of strings - if the called f returns nil the
;;; iteration is stopped
(defun mapstring_iterate_test (map f)
  :doc #{For a given hash-map of strings $MAP and a function $F, apply
$F to every attribute object and string value. If it returns a null
value, with an other secundary value, gives the failing attribute, its
value, and the other.}#
  (if (is_mapstring map)
      (if (is_closure f)
	  (foreach_in_mapstring
	   (map)
	   (curat curval)
	   (multicall 
	    (test other)
	    (f curat curval)
	    (if (null test)
		(return curat curval other)
	   ))))))


;;;;;; MAPSTRINGs primitive

;; primitive to get the allocated size of a mapstring
(defprimitive mapstring_size (map) :long 
  :doc #{Safely return the current allocated size of a string-map $MAP or else 0.}#
  #{(melt_size_mapstrings((struct meltmapstrings_st*)($map)))}#)

;; primitive to get the attribute count of a mapstring
(defprimitive mapstring_count (map) :long
  :doc #{Safely return the current count of a string-map $MAP or else 0.}#
  #{(melt_count_mapstrings((struct meltmapstrings_st*)($map)))}#)


;; get an entry in a mapstring from a C string
(defprimitive mapstring_rawget (map :cstring cstr) :value
  :doc #{Safely get in a string-map $MAP the value associated with raw c-string $CSTR or else null.}#
  #{(melt_get_mapstrings((struct meltmapstrings_st*)($map), ($cstr)))}#)

;; primitive for putting into a map of strings
(defprimitive mapstring_rawput (map :cstring key :value val) :void
  :doc #{Safely put into a string-map $MAP the raw c-string $KEY associated to value $VAL.}#
  #{meltgc_put_mapstrings( (struct meltmapstrings_st *) ($map), ($key), (melt_ptr_t) ($val))}#)

;; primitives for removing from a map of strings
(defprimitive mapstring_rawremove (map :cstring key) :void
  :doc #{Safely remove from a string-map $MAP the value associated with raw c-string $KEY.}#
  #{meltgc_remove_mapstrings((struct meltmapstrings_st*) ($map), ($key))}#)


;;; full iterator on tuple - 
;;; the function is called with the component and its index
(defun multiple_every (tup f)
  :doc #{Apply to every component of tuple $TUP and its index the given
function $F. Return nil.}#
  (if (is_multiple tup)
      (if (is_closure f)
	  (foreach_in_multiple
	   (tup)
	   (comp :long ix)
	   (f comp ix)))))

;; full iterator backward
(defun multiple_backward_every (tup f)
  :doc #{Apply to every component (from last to first) of tuple $TUP
backwards, and its index the given function $F. Return nil.}#
  (if (is_multiple tup)
      (if (is_closure f)
	  (foreach_in_multiple_backward
	   (tup)
	   (comp :long ix)
	   (f comp ix)))))


;; iterator on two tuples
(defun multiple_every_both (tup1 tup2 f)
  :doc #{Given two tuples $TUP1 and $TUP2, apply function $F to every component of $TUP1 
with component of $TUP2 and index. Stop when either end is reached. Return nil.}#
  (if (is_multiple tup1)
      (if (is_multiple tup2)
	  (if (is_closure f)
	      (let ( (:long ln1 (multiple_length tup1))
		     (:long ln2 (multiple_length tup2))
		     (:long ix 0) )
		(forever tuploop
			 (if (>=i ix ln1) (exit tuploop))
			 (if (>=i ix ln2) (exit tuploop))
			 (f (multiple_nth tup1 ix) (multiple_nth tup2 ix) ix)
			 (setq ix (+i ix 1))))))))


;;;; MELT application depth & counter significant only when checking is enabled
(defprimitive melt_application_depth () :long 
  :doc #{Depth of MELT closures application - significant iff ENABLE_CHECKING.}#
  #{melt_application_depth()}#)

(defprimitive melt_application_shallower (:long maxdepth) :long
  :doc #{Test that the MELT application depth is less that $MAXDEPTH -
significant iff ENABLE_CHECKING.}# #{(melt_application_depth() <
  $MAXDEPTH)}#)

(defprimitive melt_application_count () :long
  :doc #{Count of MELT closures application - significant iff ENABLE_CHECKING.}#
  #{melt_application_count()}#)

(definstance melt_mode_container class_container
  :doc #{$MELT_MODE_CONTAINER is a container dedicated to share data at the mode level.}#)


;;; a private container for the list of closures for PLUGIN_PASS_EXECUTION
(definstance pass_execution_container class_container
  :container_value ()
  )

;;; private function to run all pass execution hooks
(defun run_all_pass_execution_hooks (hooklist passname :long passnum)
  ;; can't use debug_msg here!
  (foreach_in_list
   (hooklist)
   (curpair curhook)
   (curhook passname passnum)
   )
  (return)
)

;;; register a pass execution hook
(defun register_pass_execution_hook (fun)
  :doc #{Register closure $FUN as the hook for pass execution using
PLUGIN_PASS_EXECUTION. These hooks are called in order of
registration.  Their first argument is the boxed pass name string,
their second argument is the raw pass number stuff.  See also
$UNREGISTER_PASS_EXECUTION_HOOK.}#
  (if (is_closure fun)
      (let ( (hooklist (unsafe_get_field :container_value 
					 pass_execution_container))
	     )
	(if (null hooklist)
	    (progn
	      (setq hooklist (list))
	      (put_fields pass_execution_container :container_value hooklist)))
	(assert_msg "check hooklist" (is_list hooklist))
	;; check that the fun is not already registered
	(foreach_in_list
	 (hooklist)
	 (curpair curhook)
	 (if (== curhook fun)
	     (return))
	 )
	(list_append hooklist fun)
	(put_fields initial_system_data
		   :sysdata_passexec_hook 
		   (lambda (passname :long passnum)
		     (run_all_pass_execution_hooks hooklist passname passnum)))
	(return)
	)))

;;; unregister a pass execution hook 
(defun unregister_pass_execution_hook (fun)
  :doc #{Unregister a pass execution hook function $FUN previously
registered with $REGISTER_PASS_EXECUTION_HOOK.}#
  (if (is_closure fun)
      (let ( (oldhooklist (unsafe_get_field :container_value 
					    pass_execution_container))
	     (newhooklist (list))
	     )
	(foreach_in_list
	 (oldhooklist)
	 (curpair curhook)
	 (if (!= curhook fun)
	     (list_append newhooklist curhook))
	 )
	(if (is_non_empty_list newhooklist)
	    (put_fields initial_system_data
		       :sysdata_passexec_hook ())
	  (put_fields initial_system_data
		     :sysdata_passexec_hook 
		     (lambda (passname :long passnum)
		       (run_all_pass_execution_hooks newhooklist passname passnum))))
)))

;;register a new pragma handler.
(defun register_pragma_handler (lsthandler)
  :doc #{register a list of new pragma handlers.  As :sysdata_meltpragmas must
  be a tuple (we use an index to recognize handlers), we have to recreate this
  tuple each time we call this function.  That why $LSTHANDLER is a list of
  handlers (class_gcc_pragma) and not a single object.  }#
  (assert_msg "register_pragma_handler takes a list as argument." 
    (is_list lsthandler))
  (let ((oldtuple (get_field :sysdata_meltpragmas initial_system_data))
        (:long oldsize 0))
    (if notnull oldtuple)
      (setq oldsize (multiple_length oldtuple))
    (let ((:long newsize (+i (multiple_length oldtuple)
                          (list_length lsthandler)))
          (newtuple (make_multiple discr_multiple newsize))
          (:long i 0))
    ;;copy in oldhandlers in the newtuple
    (foreach_in_multiple
    (oldtuple)
    (curhander :long iunused)
      (multiple_put_nth newtuple i curhander)
      (setq i (+i i 1))
    )
    ;;add new handler from lsthandler
    (foreach_in_list
    (lsthandler)
    (curpair curhandler)
      (assert_msg "register_pragma_handler must be a list of class_gcc_pragma."
        (is_a curhandler class_gcc_pragma))
      (multiple_put_nth newtuple i curhandler)
      (setq i (+i i 1))
    )
    (put_fields initial_system_data :sysdata_meltpragmas newtuple)
    ))
)

;; private pregenericize queue
(definstance pregenericize_delayed_queue class_delayed_queue
  :named_name '"pregenericize_delayed_queue"
  :delqu_first ()
  :delqu_last ()
  )

(defun register_pre_genericize_hook_first (fun)
  :doc #{Use $REGISTER_PRE_GENERICIZE_HOOK_FIRST to register a function $FUN to
  be run at PLUGIN_PRE_GENERICIZE hook, in first place.  $FUN must be a closure
  which take 1 argument (the boxed tree of function declaration being parsed).}#
  (let ( (firstlist (get_field :delqu_first pregenericize_delayed_queue))
	     )
    (if (null firstlist)
	    (progn
	      (setq firstlist (make_list discr_list))
	      (put_fields
	        pregenericize_delayed_queue
	        :delqu_first firstlist
	        :delqu_last (make_list discr_list))
	      (put_fields
	        initial_system_data
	        :sysdata_pre_genericize pre_genericize_hook_runner)))
    (if (is_closure fun)
      (list_append firstlist fun)
      (errormsg_plain
        "Bad hook passed to register_pre_genericize_hook")
    ))
)

(defun register_pre_genericize_hook_last (fun)
  :doc #{Use $REGISTER_PRE_GENERICIZE_HOOK_LAST to register a function $FUN to
  be run at PLUGIN_PRE_GENERICIZE hook, in last place.  $FUN must be a closure
  which take 1 argument (the boxed tree of function declaration being parsed).}#
  (let ( (lastlist (get_field :delqu_first pregenericize_delayed_queue))
	     )
    (if (null lastlist)
	    (progn
	      (setq lastlist (make_list discr_list))
	      (put_fields
	        pregenericize_delayed_queue
	        :delqu_first lastlist
	        :delqu_last (make_list discr_list))
	      (put_fields
	        initial_system_data
	        :sysdata_pre_genericize pre_genericize_hook_runner)))
    (if (is_closure fun)
      (list_append lastlist fun)
      (errormsg_plain
        "Bad hook passed to register_pre_genericize_hook")
    ))
)

;; internal function to for PLUGIN_PRE_GENERICIZE
(defun pre_genericize_hook_runner (fndeclv)
  :doc #{Function to be runned when PLUGIN_PRE_GENERICIZE hook is invoked.  
  For each closure registered in the list :sysdata_pre_genericize of
  initial_system_data, call them with $fndeclv, the tree declaration of the
  parsed function.   }#
  (let ( (firstlist (get_field :delqu_first pregenericize_delayed_queue))
	 (lastlist (get_field :delqu_last pregenericize_delayed_queue))
	 (revlastlist (make_list discr_list))
	 (res ())
	 )
;;; call the first routines in natural order
    (foreach_in_list
     (firstlist)
     (firstpair firstproc)
     (setq res (firstproc fndeclv res))
     )
;;; reverse the last list
    (foreach_in_list
     (lastlist)
     (lastpair lastproc)
     (if (is_closure lastproc) (list_prepend revlastlist lastproc)))
;;; call the last routines in reverse order
    (foreach_in_list
     (revlastlist)
     (revlastpair revlastproc)
     (setq res (revlastproc fndeclv res))
    )))


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; private finishtype handling queue
(definstance finishtype_delayed_queue class_delayed_queue
  :named_name '"finishtype_delayed_queue"
  :delqu_first ()
  :delqu_last ()
  )

;; internal private primitive to notify the MELT runtime that
;; :sysdata_finishtype_hook has changed
(defprimitive melt_notify_finish_type () :void
  #{ /* melt_notify_finish_type */  meltgc_notify_finish_type_hook ();}#
)

;; internal private routine for PLUGIN_FINISH_TYPE 
(defun melt_finish_type_runner (boxtreev)
  (let ( (firstlist (get_field :delqu_first finishtype_delayed_queue))
	 (lastlist (get_field :delqu_last finishtype_delayed_queue))
	 (revlastlist (make_list discr_list))
	 (res ())
	 )
;;; call the first routines in natural order
    (foreach_in_list
     (firstlist)
     (firstpair firstproc)
     (setq res (firstproc boxtreev res))
     )
;;; reverse the last list
    (foreach_in_list
     (lastlist)
     (lastpair lastproc)
     (if (is_closure lastproc) (list_prepend revlastlist lastproc)))
;;; call the last routines in reverse order
    (foreach_in_list
     (revlastlist)
     (revlastpair revlastproc)
     (setq res (revlastproc boxtreev res))
    )))

(defun register_finish_type_hook_first (fun)
  :doc #{Use $REGISTER_FINISH_TYPE_HOOK_FIRST to register a function $FUN to
  be run at PLUGIN_FINISH_TYPE, in first place.  $FUN must be a closure
  which take 1 argument (the boxed tree of the parsed type).}#
  (if (is_closure fun)
      (let ( (firstlist (get_field :delqu_first finishtype_delayed_queue))
	    )
	(if (null firstlist)
	    (progn
	      (setq firstlist (make_list discr_list))
	      (put_fields
	        finishtype_delayed_queue
	        :delqu_first firstlist
	        :delqu_last (make_list discr_list))
	      (put_fields
	       initial_system_data
	       :sysdata_finishtype_hook melt_finish_type_runner)
	      (melt_notify_finish_type)
	      ))
	(list_append firstlist fun)
	)
    ;; fun not a closure
      (errormsg_plain
        "Bad function (non closure) passed to register_finish_type_hook_first")
    ))

(defun register_finish_type_hook_last (fun)
  :doc #{Use $REGISTER_FINISH_TYPE_HOOK_LAST to register a function $FUN to
  be run at PLUGIN_FINISH_TYPE, in last place.  $FUN must be a closure
  which take 1 argument (the boxed tree of the parsed type).}#
  (if (is_closure fun)
      (let ( (lastlist (get_field :delqu_last finishtype_delayed_queue))
	    )
	(if (null lastlist)
	    (progn
	      (setq lastlist (make_list discr_list))
	      (put_fields
	        finishtype_delayed_queue
	        :delqu_first (make_list discr_list)
	        :delqu_last lastlist)
	      (put_fields
	       initial_system_data
	       :sysdata_finishtype_hook melt_finish_type_runner)
	      (melt_notify_finish_type)
	      ))
	(list_append lastlist fun)
	)
    ;; fun not a closure
      (errormsg_plain
        "Bad function (non closure) passed to register_finish_type_hook_last")
))

;;;;;;;;;;;;;;;;
;; internal private primitive to notify the MELT runtime that
;; :sysdata_finishdecl_hook has changed
(defprimitive melt_notify_finish_decl () :void
  #{ /* melt_notify_finish_decl */  meltgc_notify_finish_decl_hook ();}#
)

;; private finishtype handling queue
(definstance finishdecl_delayed_queue class_delayed_queue
  :named_name '"finishdecl_delayed_queue"
  :delqu_first ()
  :delqu_last ()
  )

;; internal private routine for PLUGIN_FINISH_DECL 
(defun melt_finish_decl_runner (boxtreev)
  (let ( (firstlist (get_field :delqu_first finishdecl_delayed_queue))
	 (lastlist (get_field :delqu_last finishdecl_delayed_queue))
	 (revlastlist (make_list discr_list))
	 (res ())
	 )
;;; call the first routines in natural order
    (foreach_in_list
     (firstlist)
     (firstpair firstproc)
     (setq res (firstproc boxtreev res))
     )
;;; reverse the last list
    (foreach_in_list
     (lastlist)
     (lastpair lastproc)
     (if (is_closure lastproc) (list_prepend revlastlist lastproc)))
;;; call the last routines in reverse order
    (foreach_in_list
     (revlastlist)
     (revlastpair revlastproc)
     (setq res (revlastproc boxtreev res))
    )))

(defun register_finish_decl_hook_first (fun)
  :doc #{Use $REGISTER_FINISH_DECL_HOOK_FIRST to register a function
  $FUN to be run at PLUGIN_FINISH_DECL, in first place.  $FUN must be
  a closure which take 1 argument (the boxed tree of the parsed
  declaration). Only for GCC 4.7 or later.}#
  (if (is_closure fun)
      (let ( (firstlist (get_field :delqu_first finishdecl_delayed_queue))
	    )
	(if (null firstlist)
	    (progn
	      (setq firstlist (make_list discr_list))
	      (put_fields
	        finishdecl_delayed_queue
	        :delqu_first firstlist
	        :delqu_last (make_list discr_list))
	      (put_fields
	       initial_system_data
	       :sysdata_finishdecl_hook melt_finish_decl_runner)
	      (melt_notify_finish_decl)
	      ))
	(list_append firstlist fun)
	)
    ;; fun not a closure
      (errormsg_plain
        "Bad function (non closure) passed to register_finish_decl_hook_first")
    ))

(defun register_finish_decl_hook_last (fun)
  :doc #{Use $REGISTER_FINISH_DECL_HOOK_LAST to register a function
  $FUN to be run at PLUGIN_FINISH_DECL, in last place.  $FUN must be a
  closure which take 1 argument (the boxed tree of the parsed
  declaration). Only for GCC 4.7 or later.}#
  (if (is_closure fun)
      (let ( (lastlist (get_field :delqu_last finishdecl_delayed_queue))
	    )
	(if (null lastlist)
	    (progn
	      (setq lastlist (make_list discr_list))
	      (put_fields
	        finishdecl_delayed_queue
	        :delqu_first (make_list discr_list)
	        :delqu_last lastlist)
	      (put_fields
	       initial_system_data
	       :sysdata_finishdecl_hook melt_finish_decl_runner)
	      (melt_notify_finish_decl)
	      ))
	(list_append lastlist fun)
	)
    ;; fun not a closure
      (errormsg_plain
        "Bad function (non closure) passed to register_finish_decl_hook_last")
    ))





;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; handling PLUGIN_ALL_PASSES_START
;; private all_passes_start handling queue
(definstance all_passes_start_delayed_queue class_delayed_queue
  :named_name '"all_passes_start_delayed_queue"
  :delqu_first ()
  :delqu_last ()
  )

;; internal private routine for PLUGIN_ALL_PASSES_START 
(defun melt_all_passes_start_runner ()
  (let ( (firstlist (get_field :delqu_first finishdecl_delayed_queue))
	 (lastlist (get_field :delqu_last finishdecl_delayed_queue))
	 (revlastlist (make_list discr_list))
	 (res ())
	 )
;;; call the first routines in natural order
    (foreach_in_list
     (firstlist)
     (firstpair firstproc)
     (setq res (firstproc res))
     )
;;; reverse the last list
    (foreach_in_list
     (lastlist)
     (lastpair lastproc)
     (if (is_closure lastproc) (list_prepend revlastlist lastproc)))
;;; call the last routines in reverse order
    (foreach_in_list
     (revlastlist)
     (revlastpair revlastproc)
     (setq res (revlastproc res))
    )))

(defun register_all_passes_start_hook_first (fun)
  :doc #{Use $REGISTER_ALL_PASSES_START_HOOK_FIRST to register a function $FUN to
  be run at PLUGIN_ALL_PASSES_START, in first place.  $FUN must be a closure
  which take 1 argument (the boxed tree of the parsed declaration).}#
  (if (is_closure fun)
      (let ( (firstlist (get_field :delqu_first finishdecl_delayed_queue))
	    )
	(if (null firstlist)
	    (progn
	      (setq firstlist (make_list discr_list))
	      (put_fields
	        finishdecl_delayed_queue
	        :delqu_first firstlist
	        :delqu_last (make_list discr_list))
	      (put_fields
	       initial_system_data
	       :sysdata_all_passes_start_hook melt_all_passes_start_runner)
	      ))
	(list_append firstlist fun)
	)
    ;; fun not a closure
      (errormsg_plain
        "Bad function (non closure) passed to register_all_passes_start_hook_first")
    ))

(defun register_all_passes_start_hook_last (fun)
  :doc #{Use $REGISTER_ALL_PASSES_START_HOOK_LAST to register a function $FUN to
  be run at PLUGIN_ALL_PASSES_START, in last place.  $FUN must be a closure
  which take 1 argument (the boxed tree of the parsed declaration).}#
  (if (is_closure fun)
      (let ( (lastlist (get_field :delqu_last finishdecl_delayed_queue))
	    )
	(if (null lastlist)
	    (progn
	      (setq lastlist (make_list discr_list))
	      (put_fields
	        finishdecl_delayed_queue
	        :delqu_first (make_list discr_list)
	        :delqu_last lastlist)
	      (put_fields
	       initial_system_data
	       :sysdata_all_passes_start_hook melt_all_passes_start_runner)
	      ))
	(list_append lastlist fun)
	)
    ;; fun not a closure
      (errormsg_plain
        "Bad function (non closure) passed to register_all_passes_start_hook_last")
    ))


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; handling PLUGIN_ALL_PASSES_END
;; private all_passes_end handling queue
(definstance all_passes_end_delayed_queue class_delayed_queue
  :named_name '"all_passes_end_delayed_queue"
  :delqu_first ()
  :delqu_last ()
  )

;; internal private routine for PLUGIN_ALL_PASSES_END 
(defun melt_all_passes_end_runner ()
  (let ( (firstlist (get_field :delqu_first finishdecl_delayed_queue))
	 (lastlist (get_field :delqu_last finishdecl_delayed_queue))
	 (revlastlist (make_list discr_list))
	 (res ())
	 )
;;; call the first routines in natural order
    (foreach_in_list
     (firstlist)
     (firstpair firstproc)
     (setq res (firstproc res))
     )
;;; reverse the last list
    (foreach_in_list
     (lastlist)
     (lastpair lastproc)
     (if (is_closure lastproc) (list_prepend revlastlist lastproc)))
;;; call the last routines in reverse order
    (foreach_in_list
     (revlastlist)
     (revlastpair revlastproc)
     (setq res (revlastproc res))
    )))

(defun register_all_passes_end_hook_first (fun)
  :doc #{Use $REGISTER_ALL_PASSES_END_HOOK_FIRST to register a function $FUN to
  be run at PLUGIN_ALL_PASSES_END, in first place.  $FUN must be a closure
  which take 1 argument (the boxed tree of the parsed declaration).}#
  (if (is_closure fun)
      (let ( (firstlist (get_field :delqu_first finishdecl_delayed_queue))
	    )
	(if (null firstlist)
	    (progn
	      (setq firstlist (make_list discr_list))
	      (put_fields
	        finishdecl_delayed_queue
	        :delqu_first firstlist
	        :delqu_last (make_list discr_list))
	      (put_fields
	       initial_system_data
	       :sysdata_all_passes_end_hook melt_all_passes_end_runner)
	      ))
	(list_append firstlist fun)
	)
    ;; fun not a closure
      (errormsg_plain
        "Bad function (non closure) passed to register_all_passes_end_hook_first")
    ))

(defun register_all_passes_end_hook_last (fun)
  :doc #{Use $REGISTER_ALL_PASSES_END_HOOK_LAST to register a function $FUN to
  be run at PLUGIN_ALL_PASSES_END, in last place.  $FUN must be a closure
  which take 1 argument (the boxed tree of the parsed declaration).}#
  (if (is_closure fun)
      (let ( (lastlist (get_field :delqu_last finishdecl_delayed_queue))
	    )
	(if (null lastlist)
	    (progn
	      (setq lastlist (make_list discr_list))
	      (put_fields
	        finishdecl_delayed_queue
	        :delqu_first (make_list discr_list)
	        :delqu_last lastlist)
	      (put_fields
	       initial_system_data
	       :sysdata_all_passes_end_hook melt_all_passes_end_runner)
	      ))
	(list_append lastlist fun)
	)
    ;; fun not a closure
      (errormsg_plain
        "Bad function (non closure) passed to register_all_passes_end_hook_last")
    ))



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; handling PLUGIN_ALL_IPA_PASSES_START
;; private all_ipa_passes_start handling queue
(definstance all_ipa_passes_start_delayed_queue class_delayed_queue
  :named_name '"all_ipa_passes_start_delayed_queue"
  :delqu_first ()
  :delqu_last ()
  )

;; internal private routine for PLUGIN_ALL_IPA_PASSES_START 
(defun melt_all_ipa_passes_start_runner ()
  (let ( (firstlist (get_field :delqu_first finishdecl_delayed_queue))
	 (lastlist (get_field :delqu_last finishdecl_delayed_queue))
	 (revlastlist (make_list discr_list))
	 (res ())
	 )
;;; call the first routines in natural order
    (foreach_in_list
     (firstlist)
     (firstpair firstproc)
     (setq res (firstproc res))
     )
;;; reverse the last list
    (foreach_in_list
     (lastlist)
     (lastpair lastproc)
     (if (is_closure lastproc) (list_prepend revlastlist lastproc)))
;;; call the last routines in reverse order
    (foreach_in_list
     (revlastlist)
     (revlastpair revlastproc)
     (setq res (revlastproc res))
    )))

(defun register_all_ipa_passes_start_hook_first (fun)
  :doc #{Use $REGISTER_ALL_IPA_PASSES_START_HOOK_FIRST to register a function $FUN to
  be run at PLUGIN_ALL_IPA_PASSES_START, in first place.  $FUN must be a closure
  which take 1 argument (the boxed tree of the parsed declaration).}#
  (if (is_closure fun)
      (let ( (firstlist (get_field :delqu_first finishdecl_delayed_queue))
	    )
	(if (null firstlist)
	    (progn
	      (setq firstlist (make_list discr_list))
	      (put_fields
	        finishdecl_delayed_queue
	        :delqu_first firstlist
	        :delqu_last (make_list discr_list))
	      (put_fields
	       initial_system_data
	       :sysdata_all_ipa_passes_start_hook melt_all_ipa_passes_start_runner)
	      ))
	(list_append firstlist fun)
	)
    ;; fun not a closure
      (errormsg_plain
        "Bad function (non closure) passed to register_all_ipa_passes_start_hook_first")
    ))

(defun register_all_ipa_passes_start_hook_last (fun)
  :doc #{Use $REGISTER_ALL_IPA_PASSES_START_HOOK_LAST to register a function $FUN to
  be run at PLUGIN_ALL_IPA_PASSES_START, in last place.  $FUN must be a closure
  which take 1 argument (the boxed tree of the parsed declaration).}#
  (if (is_closure fun)
      (let ( (lastlist (get_field :delqu_last finishdecl_delayed_queue))
	    )
	(if (null lastlist)
	    (progn
	      (setq lastlist (make_list discr_list))
	      (put_fields
	        finishdecl_delayed_queue
	        :delqu_first (make_list discr_list)
	        :delqu_last lastlist)
	      (put_fields
	       initial_system_data
	       :sysdata_all_ipa_passes_start_hook melt_all_ipa_passes_start_runner)
	      ))
	(list_append lastlist fun)
	)
    ;; fun not a closure
      (errormsg_plain
        "Bad function (non closure) passed to register_all_ipa_passes_start_hook_last")
    ))


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; handling PLUGIN_ALL_IPA_PASSES_END
;; private all_ipa_passes_end handling queue
(definstance all_ipa_passes_end_delayed_queue class_delayed_queue
  :named_name '"all_ipa_passes_end_delayed_queue"
  :delqu_first ()
  :delqu_last ()
  )

;; internal private routine for PLUGIN_ALL_IPA_PASSES_END 
(defun melt_all_ipa_passes_end_runner ()
  (let ( (firstlist (get_field :delqu_first finishdecl_delayed_queue))
	 (lastlist (get_field :delqu_last finishdecl_delayed_queue))
	 (revlastlist (make_list discr_list))
	 (res ())
	 )
;;; call the first routines in natural order
    (foreach_in_list
     (firstlist)
     (firstpair firstproc)
     (setq res (firstproc res))
     )
;;; reverse the last list
    (foreach_in_list
     (lastlist)
     (lastpair lastproc)
     (if (is_closure lastproc) (list_prepend revlastlist lastproc)))
;;; call the last routines in reverse order
    (foreach_in_list
     (revlastlist)
     (revlastpair revlastproc)
     (setq res (revlastproc res))
    )))

(defun register_all_ipa_passes_end_hook_first (fun)
  :doc #{Use $REGISTER_ALL_IPA_PASSES_END_HOOK_FIRST to register a function $FUN to
  be run at PLUGIN_ALL_IPA_PASSES_END, in first place.  $FUN must be a closure
  which take 1 argument (the boxed tree of the parsed declaration).}#
  (if (is_closure fun)
      (let ( (firstlist (get_field :delqu_first finishdecl_delayed_queue))
	    )
	(if (null firstlist)
	    (progn
	      (setq firstlist (make_list discr_list))
	      (put_fields
	        finishdecl_delayed_queue
	        :delqu_first firstlist
	        :delqu_last (make_list discr_list))
	      (put_fields
	       initial_system_data
	       :sysdata_all_ipa_passes_end_hook melt_all_ipa_passes_end_runner)
	      ))
	(list_append firstlist fun)
	)
    ;; fun not a closure
      (errormsg_plain
        "Bad function (non closure) passed to register_all_ipa_passes_end_hook_first")
    ))

(defun register_all_ipa_passes_end_hook_last (fun)
  :doc #{Use $REGISTER_ALL_IPA_PASSES_END_HOOK_LAST to register a function $FUN to
  be run at PLUGIN_ALL_IPA_PASSES_END, in last place.  $FUN must be a closure
  which take 1 argument (the boxed tree of the parsed declaration).}#
  (if (is_closure fun)
      (let ( (lastlist (get_field :delqu_last finishdecl_delayed_queue))
	    )
	(if (null lastlist)
	    (progn
	      (setq lastlist (make_list discr_list))
	      (put_fields
	        finishdecl_delayed_queue
	        :delqu_first (make_list discr_list)
	        :delqu_last lastlist)
	      (put_fields
	       initial_system_data
	       :sysdata_all_ipa_passes_end_hook melt_all_ipa_passes_end_runner)
	      ))
	(list_append lastlist fun)
	)
    ;; fun not a closure
      (errormsg_plain
        "Bad function (non closure) passed to register_all_ipa_passes_end_hook_last")
    ))






;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; handling PLUGIN_EARLY_GIMPLE_PASSES_START
;; private early_gimple_passes_start handling queue
(definstance early_gimple_passes_start_delayed_queue class_delayed_queue
  :named_name '"early_gimple_passes_start_delayed_queue"
  :delqu_first ()
  :delqu_last ()
  )

;; internal private routine for PLUGIN_EARLY_GIMPLE_PASSES_START 
(defun melt_early_gimple_passes_start_runner ()
  (let ( (firstlist (get_field :delqu_first finishdecl_delayed_queue))
	 (lastlist (get_field :delqu_last finishdecl_delayed_queue))
	 (revlastlist (make_list discr_list))
	 (res ())
	 )
;;; call the first routines in natural order
    (foreach_in_list
     (firstlist)
     (firstpair firstproc)
     (setq res (firstproc res))
     )
;;; reverse the last list
    (foreach_in_list
     (lastlist)
     (lastpair lastproc)
     (if (is_closure lastproc) (list_prepend revlastlist lastproc)))
;;; call the last routines in reverse order
    (foreach_in_list
     (revlastlist)
     (revlastpair revlastproc)
     (setq res (revlastproc res))
    )))

(defun register_early_gimple_passes_start_hook_first (fun)
  :doc #{Use $REGISTER_EARLY_GIMPLE_PASSES_START_HOOK_FIRST to register a function $FUN to
  be run at PLUGIN_EARLY_GIMPLE_PASSES_START, in first place.  $FUN must be a closure
  which take 1 argument (the boxed tree of the parsed declaration).}#
  (if (is_closure fun)
      (let ( (firstlist (get_field :delqu_first finishdecl_delayed_queue))
	    )
	(if (null firstlist)
	    (progn
	      (setq firstlist (make_list discr_list))
	      (put_fields
	        finishdecl_delayed_queue
	        :delqu_first firstlist
	        :delqu_last (make_list discr_list))
	      (put_fields
	       initial_system_data
	       :sysdata_early_gimple_passes_start_hook melt_early_gimple_passes_start_runner)
	      ))
	(list_append firstlist fun)
	)
    ;; fun not a closure
      (errormsg_plain
        "Bad function (non closure) passed to register_early_gimple_passes_start_hook_first")
    ))

(defun register_early_gimple_passes_start_hook_last (fun)
  :doc #{Use $REGISTER_EARLY_GIMPLE_PASSES_START_HOOK_LAST to register a function $FUN to
  be run at PLUGIN_EARLY_GIMPLE_PASSES_START, in last place.  $FUN must be a closure
  which take 1 argument (the boxed tree of the parsed declaration).}#
  (if (is_closure fun)
      (let ( (lastlist (get_field :delqu_last finishdecl_delayed_queue))
	    )
	(if (null lastlist)
	    (progn
	      (setq lastlist (make_list discr_list))
	      (put_fields
	        finishdecl_delayed_queue
	        :delqu_first (make_list discr_list)
	        :delqu_last lastlist)
	      (put_fields
	       initial_system_data
	       :sysdata_early_gimple_passes_start_hook melt_early_gimple_passes_start_runner)
	      ))
	(list_append lastlist fun)
	)
    ;; fun not a closure
      (errormsg_plain
        "Bad function (non closure) passed to register_early_gimple_passes_start_hook_last")
    ))


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; handling PLUGIN_EARLY_GIMPLE_PASSES_END
;; private early_gimple_passes_end handling queue
(definstance early_gimple_passes_end_delayed_queue class_delayed_queue
  :named_name '"early_gimple_passes_end_delayed_queue"
  :delqu_first ()
  :delqu_last ()
  )

;; internal private routine for PLUGIN_EARLY_GIMPLE_PASSES_END 
(defun melt_early_gimple_passes_end_runner ()
  (let ( (firstlist (get_field :delqu_first finishdecl_delayed_queue))
	 (lastlist (get_field :delqu_last finishdecl_delayed_queue))
	 (revlastlist (make_list discr_list))
	 (res ())
	 )
;;; call the first routines in natural order
    (foreach_in_list
     (firstlist)
     (firstpair firstproc)
     (setq res (firstproc res))
     )
;;; reverse the last list
    (foreach_in_list
     (lastlist)
     (lastpair lastproc)
     (if (is_closure lastproc) (list_prepend revlastlist lastproc)))
;;; call the last routines in reverse order
    (foreach_in_list
     (revlastlist)
     (revlastpair revlastproc)
     (setq res (revlastproc res))
    )))

(defun register_early_gimple_passes_end_hook_first (fun)
  :doc #{Use $REGISTER_EARLY_GIMPLE_PASSES_END_HOOK_FIRST to register a function $FUN to
  be run at PLUGIN_EARLY_GIMPLE_PASSES_END, in first place.  $FUN must be a closure
  which take 1 argument (the boxed tree of the parsed declaration).}#
  (if (is_closure fun)
      (let ( (firstlist (get_field :delqu_first finishdecl_delayed_queue))
	    )
	(if (null firstlist)
	    (progn
	      (setq firstlist (make_list discr_list))
	      (put_fields
	        finishdecl_delayed_queue
	        :delqu_first firstlist
	        :delqu_last (make_list discr_list))
	      (put_fields
	       initial_system_data
	       :sysdata_early_gimple_passes_end_hook melt_early_gimple_passes_end_runner)
	      ))
	(list_append firstlist fun)
	)
    ;; fun not a closure
      (errormsg_plain
        "Bad function (non closure) passed to register_early_gimple_passes_end_hook_first")
    ))

(defun register_early_gimple_passes_end_hook_last (fun)
  :doc #{Use $REGISTER_EARLY_GIMPLE_PASSES_END_HOOK_LAST to register a function $FUN to
  be run at PLUGIN_EARLY_GIMPLE_PASSES_END, in last place.  $FUN must be a closure
  which take 1 argument (the boxed tree of the parsed declaration).}#
  (if (is_closure fun)
      (let ( (lastlist (get_field :delqu_last finishdecl_delayed_queue))
	    )
	(if (null lastlist)
	    (progn
	      (setq lastlist (make_list discr_list))
	      (put_fields
	        finishdecl_delayed_queue
	        :delqu_first (make_list discr_list)
	        :delqu_last lastlist)
	      (put_fields
	       initial_system_data
	       :sysdata_early_gimple_passes_end_hook melt_early_gimple_passes_end_runner)
	      ))
	(list_append lastlist fun)
	)
    ;; fun not a closure
      (errormsg_plain
        "Bad function (non closure) passed to register_early_gimple_passes_end_hook_last")
    ))


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; the descriptions of values which are not ctype related.
(defclass class_value_descriptor
  :doc #{The $CLASS_VALUE_DESCRIPTOR describes MELT values which are
  not ctype renated. $VALDESC_OBJMAGIC is the symbol MELTOBMAG_* of
  its magic number. $VALDESC_STRUCT is the GTY-ed struct
  name. $VALDESC_UNIONMEM is the union member name inside union
  melt_un. $VALDESC_MEMBCHUNK is the code chunk of the structure
  members after the discriminant. $VALDESC_DECLCHUNK is the code chunk
  for declarations, e.g. macros, outside of the GTY-ed
  structure. $VALDESC_GTY is the optional GTY
  argument. $VALDESC_COPYCHUNK is the code chunk copying src to an
  allocated dst. $VALDESC_FORWCHUNK is the code chunk formarding
  internal pointers. $VALDESC_CLONECHUNK is the code chunk to clone
  src, default to structure copy if :TRUE, used in the
  $CLONE_WITH_DISCRIMINANT primitive.}#
  :super class_named
  :fields (
	   valdesc_objmagic
	   valdesc_struct
	   valdesc_unionmem
	   valdesc_gty
	   valdesc_membchunk
	   valdesc_declchunk
	   valdesc_copychunk
	   valdesc_forwchunk
	   valdesc_clonechunk
	   )
)

(defclass class_varisized_value_descriptor
  :doc #{The $CLASS_VARISIZED_VALUE_DESCRIPTOR describes variable
  sized MELT values.}#
  :super class_value_descriptor
  :fields (
	   ))

(export_class
 class_value_descriptor 
 class_varisized_value_descriptor)


;; maybe set_content should become a macro for performance reasons...
(defun set_content (c v)
  :doc #{Safely put in a container $C instance of $CLASS_CONTAINER 
the field :CONTAINER_VALUE to $V. See also $CONTENT and $CONTAINER macros.}#
  (put_fields c :container_value v))


;;;;;;;;;;;;;;;;
(definstance value_descriptor_list_container
  class_container
  :container_value (make_list discr_list)
)

(defun install_value_descriptor (vd)
  (assert_msg "check vd" (is_a vd class_value_descriptor))
  (list_append (get_field :container_value value_descriptor_list_container) 
	       vd))

(defun retrieve_value_descriptor_list ()
  (get_field  :container_value value_descriptor_list_container))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;; object value
(definstance valdesc_object class_varisized_value_descriptor
  :doc #{$VALDESC_OBJECT describes object values.}#
  :named_name '"VALDESC_OBJECT"
  :valdesc_objmagic '"MELTOBMAG_OBJECT"
  :valdesc_struct '"meltobject_st"
  :valdesc_unionmem '"u_object"
  :valdesc_membchunk #{$' /* from VALDESC_OBJECT in warmelt-base.melt */
  unsigned obj_hash;		/* hash code of the object */
  unsigned short obj_num;
  unsigned short obj_len;
  melt_ptr_t GTY ((length ("%h.obj_len"))) obj_vartab[MELT_FLEXIBLE_DIM];
  }#
  :valdesc_declchunk #{$' /* decl VALDESC_OBJECT */
#define meltobj_class discr
#define meltobj_magic obj_num
#define MELT_OBJECT_STRUCT(N) {			\
  meltobject_ptr_t meltobj_class;		\
  unsigned obj_hash;				\
  unsigned short obj_num;			\
  unsigned short obj_len;			\
  melt_ptr_t* obj_vartab[N];			\
  long _gap; }
  }#
  :valdesc_copychunk #{$' /* from VALDESC_OBJECT */
  /* ggc_alloc_meltobject_st should be gengtype generated for VALDESC_OBJECT */
#ifndef ggc_alloc_meltobject_st
#define ggc_alloc_meltobject_st(SIZE) ((struct meltobject_st *)(ggc_internal_alloc_stat (SIZE MEM_STAT_INFO)))
#endif 
    int ix = 0;
    int oblen = (int) (src->obj_len);
    /* We don't need to clear at allocation, since the object is
       explicitly filled here! */
    dst = ggc_alloc_meltobject_st
      (oblen*sizeof(void*)
       + offsetof(struct meltobject_st, obj_vartab));
    /* we cannot copy the whole src, because MELT_FLEXIBLE_DIM might be 1 */
    dst->meltobj_class = src->meltobj_class;
    dst->obj_hash = src->obj_hash;
    dst->obj_num = src->obj_num;
    dst->obj_len = oblen;
    for (ix = 0; ix < oblen; ix++)
        dst->obj_vartab[ix] = src->obj_vartab[ix];
  }#
  :valdesc_clonechunk #{$' /* cloning, from VALDESC_OBJECT */
    unsigned newlen = 0;
    unsigned srclen = src->obj_len;
    unsigned slotix = 0;
    if (melt_is_subclass_of((meltobject_ptr_t)srcdiscrv, 
			    (meltobject_ptr_t)newdiscrv)) {
      newlen = 
        melt_multiple_length ((melt_ptr_t)
			      (((meltobject_ptr_t)newdiscrv)->obj_vartab[MELTFIELD_CLASS_FIELDS]));
      gcc_assert (newlen <= srclen);
      dst =  meltgc_new_raw_object ((meltobject_ptr_t)newdiscrv, newlen);
      for (slotix = 0; slotix < newlen; slotix++)
	dst->obj_vartab[slotix] = src->obj_vartab[slotix];
      dst->obj_num = src->obj_num;
    }
    else if (melt_is_subclass_of((meltobject_ptr_t)newdiscrv,
				 (meltobject_ptr_t)srcdiscrv)) {
      newlen = 
        melt_multiple_length ((melt_ptr_t)
			      (((meltobject_ptr_t)newdiscrv)->obj_vartab[MELTFIELD_CLASS_FIELDS]));      
      gcc_assert (newlen >= srclen);
      dst =  meltgc_new_raw_object ((meltobject_ptr_t)newdiscrv, newlen);
      for (slotix = 0; slotix < srclen; slotix++)
	dst->obj_vartab[slotix] = src->obj_vartab[slotix];
      dst->obj_num = src->obj_num;
    }
  }#
  :valdesc_forwchunk #{$' /* from VALDESC_OBJECT */
    int ix = 0;
    int oblen = (int) (src->obj_len);
    for (ix = 0; ix < oblen; ix++)
      MELT_FORWARDED (src->obj_vartab[ix]);
  }#
)
(install_value_descriptor valdesc_object)

;;;;;;;;;;;;;;;; objects map values

(definstance valdesc_mapobjects class_value_descriptor
  :doc #{$VALDESC_MAPOBJECTS describes object-keyed map values.}#
  :named_name '"VALDESC_MAPOBJECTS"
  :valdesc_objmagic '"MELTOBMAG_MAPOBJECTS"
  :valdesc_struct '"meltmapobjects_st"
  :valdesc_unionmem '"u_mapobjects"
  :valdesc_membchunk #{$' /* from VALDESC_MAPOBJECTS in warmelt-base.melt */
  unsigned count;
  unsigned char lenix;
  melt_ptr_t meltmap_aux;
  struct entryobjectsmelt_st *GTY ((length ("melt_primtab[%h.lenix]")))
    entab;
  /* the following field is usually the value of entab (for
     objects in the young zone), to allocate the object and its fields
     at once; hence its GTY-ed length is zero */
  struct entryobjectsmelt_st GTY ((length ("0"))) map_space[MELT_FLEXIBLE_DIM];
  }#
  :valdesc_declchunk #{$' /* decl VALDESC_MAPOBJECTS in warmelt-base.melt */
    typedef struct meltmapobjects_st* meltmapobjects_ptr_t;
  }#
  :valdesc_copychunk #{$' /* copy VALDESC_MAPOBJECTS in warmelt-base.melt */
/* ggc_alloc_meltmapobjects_st should be gengtype generated for VALDESC_MAPOBJECTS */
#ifndef ggc_alloc_meltmapobjects_st
#define ggc_alloc_meltmapobjects_st() ((struct meltmapobjects_st *)(ggc_internal_alloc_stat (sizeof (struct meltmapobjects_st) MEM_STAT_INFO)))
#endif
#ifndef ggc_alloc_vec_entryobjectsmelt_st
#define ggc_alloc_vec_entryobjectsmelt_st(N) ((struct entryobjectsmelt_st *) (ggc_internal_vec_alloc_stat (sizeof (struct entryobjectsmelt_st), N MEM_STAT_INFO)))
#endif
#ifndef  ggc_alloc_cleared_vec_entryobjectsmelt_st
#define ggc_alloc_cleared_vec_entryobjectsmelt_st(n) ((struct entryobjectsmelt_st *)(ggc_internal_cleared_vec_alloc_stat (sizeof (struct entryobjectsmelt_st), n MEM_STAT_INFO)))
#endif
     int siz = melt_primtab[src->lenix];
     dst = 
	  /* Don't need a cleared allocation.  */
	  ggc_alloc_meltmapobjects_st ();
     dst->discr = src->discr;
     dst->count = src->count;
     dst->lenix = src->lenix;
     dst->meltmap_aux = src->meltmap_aux;
     if (siz > 0 && src->entab)
       {
       /* Don't need a cleared allocation.  */
         dst->entab = ggc_alloc_vec_entryobjectsmelt_st (siz);
         memcpy (dst->entab, src->entab, siz * sizeof (dst->entab[0]));
       }
     else
       dst->entab = NULL;
  }#
  :valdesc_clonechunk #{$' /* cloning, from VALDESC_MAPOBJECTS */
     unsigned srccount = src->count;
     unsigned srclen = melt_primtab[src->lenix];
     unsigned newlen = 4*srccount/3+4;
     unsigned srcix = 0;
     dst = (struct meltmapobjects_st*) 
         meltgc_new_mapobjects ((meltobject_ptr_t)newdiscrv, newlen);
     resv = dst;
     dst->meltmap_aux = src->meltmap_aux;
     for (srcix = 0; srcix < srclen; srcix++) {
       meltobject_ptr_t curat = NULL;
       melt_ptr_t curva = NULL;
       src = (struct meltmapobjects_st*) srcvalv;
       curat = src->entab[srcix].e_at;
       curva = src->entab[srcix].e_va;
       if (!curat || curat == (meltobject_ptr_t) HTAB_DELETED_ENTRY
		  || !curva) 
         continue;
       meltgc_put_mapobjects((meltmapobjects_ptr_t)resv, curat, curva);
       /* update the dst, since it could have moved */
       dst =  (struct meltmapobjects_st*) resv;
     } /* end cloning, from VALDESC_MAPOBJECTS */
  }#
  :valdesc_forwchunk #{$' /* forwarding from VALDESC_MAPOBJECTS */
    int siz, ix;
    MELT_FORWARDED(src->meltmap_aux);
    if (!src->entab)
      break;
    siz = melt_primtab[src->lenix];
    gcc_assert (siz > 0);
    if (melt_is_young (src->entab))
      {
        struct entryobjectsmelt_st *newtab = 
          /* Don't need a cleared allocation!  */
          ggc_alloc_vec_entryobjectsmelt_st (siz);
        memcpy (newtab, src->entab,
                siz * sizeof (struct entryobjectsmelt_st));
        src->entab = newtab;
      }
    for (ix = 0; ix < siz; ix++)
      {
        meltobject_ptr_t at = src->entab[ix].e_at;
        if (!at || at == (void *) HTAB_DELETED_ENTRY)
          {
            src->entab[ix].e_va = NULL;
            continue;
          }
        MELT_FORWARDED (at);
        src->entab[ix].e_at = at;
        MELT_FORWARDED (src->entab[ix].e_va);
      }
    /* end forwarding from VALDESC_MAPOBJECTS */
  }#
)
(install_value_descriptor valdesc_mapobjects)

;;;;;;;;;;;;;;;; string map values
(definstance valdesc_mapstrings class_value_descriptor
  :doc #{$VALDESC_MAPSTRINGS describes string-keyed map values.}#
  :named_name '"VALDESC_MAPSTRINGS"
  :valdesc_objmagic '"MELTOBMAG_MAPSTRINGS"
  :valdesc_struct '"meltmapstrings_st"
  :valdesc_unionmem '"u_mapstrings"
  :valdesc_membchunk #{$' /* from VALDESC_MAPSTRINGS in warmelt-base.melt */
  unsigned count;
  unsigned char lenix;
  melt_ptr_t meltmap_aux;
  struct entrystringsmelt_st *GTY ((length ("melt_primtab[%h.lenix]")))
    entab;
  }#
  :valdesc_copychunk #{$' /* copy VALDESC_MAPSTRINGS in warmelt-base.melt */
/* ggc_alloc_meltmapstrings_st should be gengtype generated for VALDESC_MAPSTRINGS */
#ifndef ggc_alloc_meltmapstrings_st
#define ggc_alloc_meltmapstrings_st() ((struct meltmapstrings_st *)(ggc_internal_alloc_stat (sizeof (struct meltmapstrings_st) MEM_STAT_INFO)))
#endif
#ifndef ggc_alloc_vec_entrystringsmelt_st
#define ggc_alloc_vec_entrystringsmelt_st(n) ((struct entrystringsmelt_st *)(ggc_internal_vec_alloc_stat (sizeof (struct entrystringsmelt_st), n MEM_STAT_INFO)))
#endif
#ifndef ggc_alloc_cleared_vec_entrystringsmelt_st
#define ggc_alloc_cleared_vec_entrystringsmelt_st(n) ((struct entrystringsmelt_st *)(ggc_internal_cleared_vec_alloc_stat (sizeof (struct entrystringsmelt_st), n MEM_STAT_INFO)))
#endif
        int siz = melt_primtab[src->lenix];
	dst = 
	  /* Don't need a cleared allocation.  */
	  ggc_alloc_meltmapstrings_st ();
        dst->discr = src->discr;
        dst->count = src->count;
        dst->lenix = src->lenix;
        dst->meltmap_aux = src->meltmap_aux;
        if (siz > 0 && src->entab)
          {
          /* Don't need a cleared allocation.  */
            dst->entab = ggc_alloc_vec_entrystringsmelt_st (siz);
            memcpy (dst->entab, src->entab, siz * sizeof (dst->entab[0]));
          }
        else
          dst->entab = NULL;
  }#
  :valdesc_clonechunk #{$' /* cloning from VALDESC_MAPSTRINGS */
     unsigned srccount = src->count;
     unsigned srclen = melt_primtab[src->lenix];
     unsigned newlen = 4*srccount/3+4;
     unsigned srcix = 0;
     dst = (struct meltmapstrings_st*) meltgc_new_mapstrings ((meltobject_ptr_t)newdiscrv, newlen);
     resv = dst;
     dst->meltmap_aux = src->meltmap_aux;
     for (srcix = 0; srcix < srclen; srcix++) {
       const char* curat = NULL;
       melt_ptr_t curva = NULL;
       src = (struct meltmapstrings_st*) srcvalv;
       dst = (struct meltmapstrings_st*) resv;
       curat = src->entab[srcix].e_at;
       if (!curat || curat == (const char*) HTAB_DELETED_ENTRY || !curat[0])
         continue;
       curva = src->entab[srcix].e_va;
       if (!curva) 
         continue;
       meltgc_put_mapstrings (dst, curat, curva);
       dst = (struct meltmapstrings_st*) resv;
     }
     /* end  cloning from VALDESC_MAPSTRINGS */
  }#
  :valdesc_forwchunk #{$' /* forwarding from VALDESC_MAPSTRINGS */
     int ix, siz;
     MELT_FORWARDED(src->meltmap_aux);
     if (!src->entab)
       break;
     siz = melt_primtab[src->lenix];
     gcc_assert (siz > 0);
     if (melt_is_young (src->entab))
       {
         struct entrystringsmelt_st *newtab
           /* Don't need a cleared allocation!  */
           = ggc_alloc_vec_entrystringsmelt_st (siz);
         memcpy (newtab, src->entab,
                 siz * sizeof (struct entrystringsmelt_st));
         src->entab = newtab;
       }
     for (ix = 0; ix < siz; ix++)
       {
         const char *at = src->entab[ix].e_at;
         if (!at || at == (void *) HTAB_DELETED_ENTRY)
           {
             src->entab[ix].e_va = NULL;
             continue;
           }
         if (melt_is_young ((const void *) at))
           src->entab[ix].e_at = (const char *) ggc_strdup (at);
         MELT_FORWARDED (src->entab[ix].e_va);
       }
    /* end  forwarding from VALDESC_MAPSTRINGS */
  }#
)
(install_value_descriptor valdesc_mapstrings)


;;;;;;;;;;;;;;;; decaying value
(definstance valdesc_decay class_value_descriptor
  :doc #{$VALDESC_DECAY describes decaying values.}#
  :named_name '"VALDESC_DECAY"
  :valdesc_objmagic '"MELTOBMAG_DECAY"
  :valdesc_struct '"meltdecay_st"
  :valdesc_unionmem '"u_decay"
  :valdesc_gty #{$' mark_hook ("melt_mark_decay")}#
  :valdesc_membchunk #{$' /* from VALDESC_DECAY in warmelt-base.melt */
  melt_ptr_t val;
  unsigned remain;		/* remaining number of marking */
  }#
  :valdesc_copychunk #{$' /* from VALDESC_DECAY */
/* ggc_alloc_meltdecay_st should be gengtype generated for VALDESC_DECAY */
#ifndef ggc_alloc_meltdecay_st
#define ggc_alloc_meltdecay_st() ((struct meltdecay_st *)(ggc_internal_alloc_stat (sizeof (struct meltdecay_st) MEM_STAT_INFO)))
#endif
     dst = ggc_alloc_meltdecay_st ();
     *dst = *src;
  }#
  :valdesc_clonechunk :true
  :valdesc_forwchunk #{$' /* from VALDESC_DECAY */
     MELT_FORWARDED (src->val);
  }#
)
(install_value_descriptor valdesc_decay)
  

;;;;;;;;;;;;;;;; multiple value
(definstance valdesc_multiple class_varisized_value_descriptor
  :doc #{$VALDESC_MULTIPLE describes multiple values, i.e. tuples.}#
  :named_name '"VALDESC_MULTIPLE"
  :valdesc_objmagic '"MELTOBMAG_MULTIPLE"
  :valdesc_struct '"meltmultiple_st"
  :valdesc_unionmem '"u_multiple"
  :valdesc_membchunk #{$' /* from VALDESC_MULTIPLE in warmelt-base.melt */
    unsigned nbval;
    melt_ptr_t GTY ((length ("%h.nbval"))) tabval[MELT_FLEXIBLE_DIM];
  }#
  :valdesc_declchunk #{$'  /* decl VALDESC_MULTIPLE in warmelt-base.melt */
#define MELT_MULTIPLE_STRUCT(N) {               \
    meltobject_ptr_t discr;                     \
    unsigned nbval;                             \
    melt_ptr_t tabval[N];                       \
    long _gap; }
  typedef struct meltmultiple_st* meltmultiple_ptr_t;
  }#
  :valdesc_copychunk #{$'  /* copy chunk from VALDESC_MULTIPLE */
  /* ggc_alloc_meltmultiple_st should be gengtype generated for VALDESC_MULTIPLE */
#ifndef ggc_alloc_meltmultiple_st
#define ggc_alloc_meltmultiple_st(SIZE) ((struct meltmultiple_st *)(ggc_internal_alloc_stat (SIZE MEM_STAT_INFO)))
#endif
    int nbv = (int) src->nbval;
    int ix = 0;
    dst = 
      /* Don't need a cleared allocation!  */
      ggc_alloc_meltmultiple_st 
      (nbv*sizeof(void*) + offsetof(struct meltmultiple_st, tabval));
    /* we cannot copy the whole src, because MELT_FLEXIBLE_DIM might be
       1 and nbval could be 0 */
    dst->discr = src->discr;
    dst->nbval = src->nbval;
    for (ix = 0; ix < nbv; ix++)
      dst->tabval[ix] = src->tabval[ix];
    /* end copy chunk from VALDESC_MULTIPLE */
  }#
  :valdesc_clonechunk #{$' /* cloning from VALDESC_MULTIPLE */
    unsigned srclen = src->nbval;
    unsigned srcix = 0;
    resv = dst = 
       (struct meltmultiple_st*) meltgc_new_multiple ((meltobject_ptr_t)newdiscrv, srclen);
    src = (struct meltmultiple_st*) srcvalv; /* could have moved */
    for (srcix = 0; srcix < srclen; srcix++) 
      dst->tabval[srcix] = src->tabval[srcix];
  /* end cloning from VALDESC_MULTIPLE */
  }#
  :valdesc_forwchunk #{$' /* forwarding chunk from VALDESC_MULTIPLE */
     int nbval = (int) src->nbval;
     int ix = 0;
     for (ix = 0; ix < nbval; ix++)
       MELT_FORWARDED (src->tabval[ix]);
     /* end forwarding chunk from VALDESC_MULTIPLE */
  }#
)
(install_value_descriptor valdesc_multiple)

;;;;;;;;;;;;;;;; closure value
(definstance valdesc_closure class_varisized_value_descriptor
  :doc #{$VALDESC_CLOSURE describes closure values, i.e. functions.}#
  :named_name '"VALDESC_CLOSURE"
  :valdesc_objmagic '"MELTOBMAG_CLOSURE"
  :valdesc_struct '"meltclosure_st"
  :valdesc_unionmem '"u_closure"
  :valdesc_membchunk #{$' /* from VALDESC_CLOSURE in warmelt-base.melt */
    meltroutine_ptr_t rout;
    unsigned nbval;
    melt_ptr_t GTY ((length ("%h.nbval"))) tabval[MELT_FLEXIBLE_DIM];
  }#
  :valdesc_declchunk #{$' /* decl VALDESC_CLOSURE  in warmelt-base.melt */
#define MELT_CLOSURE_STRUCT(N) {                \
    meltobject_ptr_t discr;                     \
    meltroutine_ptr_t rout;			\
    unsigned nbval;                             \
    melt_ptr_t tabval[N];                       \
    long _gap; }
  }#
  :valdesc_copychunk #{$' /* copy VALDESC_CLOSURE in warmelt-base.melt  */
/* ggc_alloc_meltclosure_st should be gengtype generated for VALDESC_CLOSURE */
#ifndef ggc_alloc_meltclosure_st
#define ggc_alloc_meltclosure_st(SIZE) ((struct meltclosure_st *)(ggc_internal_alloc_stat (SIZE MEM_STAT_INFO)))
#endif
     int nbv = (int) src->nbval;
     int ix = 0;
     dst = 
   /* Don't need a cleared allocation!  */
       ggc_alloc_meltclosure_st 
         (nbv*sizeof(void*) + offsetof(struct meltclosure_st, tabval));
     dst->discr = src->discr;
     dst->rout = src->rout;
     dst->nbval = (unsigned) nbv;
     for (ix = 0; ix < nbv; ix++)
       dst->tabval[ix] = src->tabval[ix];
  }#
  :valdesc_forwchunk #{$' /* forwarding from VALDESC_CLOSURE */
     int nbval = (int) src->nbval;
     int ix = 0;
     MELT_FORWARDED (src->rout);
     for (ix = 0; ix < nbval; ix++)
       MELT_FORWARDED (src->tabval[ix]);
  }#
  :valdesc_clonechunk  #{$' /* cloning from VALDESC_CLOSURE */
     unsigned nbval = (int) src->nbval;
     unsigned ix = 0;
     dst
        = (struct meltclosure_st*)meltgc_allocate (sizeof(struct meltclosure_st),
						   nbval*sizeof(void*));
     src = (struct meltclosure_st*)srcvalv;
     dst->discr = (meltobject_ptr_t)newdiscrv;
     dst->rout = src->rout;
     for (ix = 0; ix < nbval; ix++)
       dst->tabval[ix] = src->tabval[ix];
     /* end cloning from VALDESC_CLOSURE */
  }#
)
(install_value_descriptor valdesc_closure)

;;;;;;;;;;;;;;;; routine value
(definstance valdesc_routine class_varisized_value_descriptor
  :doc #{$VALDESC_ROUTINE describes routine values.}#
  :named_name '"VALDESC_ROUTINE"
  :valdesc_objmagic '"MELTOBMAG_ROUTINE"
  :valdesc_struct '"meltroutine_st"
  :valdesc_unionmem '"u_routine"
  :valdesc_membchunk #{$' /* from VALDESC_ROUTINE in warmelt-base.melt */
    char routdescr[MELT_ROUTDESCR_LEN];
    meltroutfun_t* GTY ((skip)) routfunad;
    melt_ptr_t routdata;
    unsigned nbval;
    melt_ptr_t GTY ((length ("%h.nbval"))) tabval[MELT_FLEXIBLE_DIM];
  }#
  :valdesc_declchunk #{$' /* decl VALDESC_ROUTINE */
#ifndef meltroutine_ptr_t_TYPEDEFINED
typedef struct meltroutine_st *meltroutine_ptr_t;
#define  meltroutine_ptr_t_TYPEDEFINED
#endif /*meltroutine_ptr_t_TYPEDEFINED from VALDESC_ROUTINE */

/* unsafely set inside the meltroutine_st pointed by Rptr the
   routine function pointer to Rout */
#define MELT_ROUTINE_SET_ROUTCODE(Rptr,Rout) do {	\
  ((struct meltroutine_st*)(Rptr))->routfunad		\
     = (Rout);						\
} while(0)

#define MELT_ROUTINE_STRUCT(N) {		\
  meltobject_ptr_t discr;			\
  char routdescr[MELT_ROUTDESCR_LEN];		\
  meltroutfun_t* routfunad;			\
  melt_ptr_t routdata;				\
  unsigned nbval;				\
  melt_ptr_t tabval[N];				\
  long _gap; }
  }#
  :valdesc_copychunk #{$' /* from VALDESC_ROUTINE */
  /* ggc_alloc_meltroutine_st should be gengtype generated for VALDESC_ROUTINE */
#ifndef ggc_alloc_meltroutine_st
#define ggc_alloc_meltroutine_st(SIZE) ((struct meltroutine_st *)(ggc_internal_alloc_stat (SIZE MEM_STAT_INFO)))
#endif 
     int nbv = (int) src->nbval;
     int ix = 0;
     dst =
       /* Don't need a cleared allocation!  */
       ggc_alloc_meltroutine_st
       (nbv*sizeof(void*) + offsetof(struct meltroutine_st, tabval));
     dst->discr = src->discr;
     strncpy (dst->routdescr, src->routdescr, MELT_ROUTDESCR_LEN);
     dst->routdescr[MELT_ROUTDESCR_LEN - 1] = 0;
     dst->nbval = (unsigned) nbv;
     dst->routfunad = src->routfunad;
     for (ix = 0; ix < nbv; ix++)
       dst->tabval[ix] = src->tabval[ix];
     dst->routdata = src->routdata;
  }#
  ;; don't clone routines!
  :valdesc_forwchunk #{$' /* from VALDESC_ROUTINE */
     int nbval = (int) src->nbval;
     int ix = 0;
     for (ix = 0; ix < nbval; ix++)
       MELT_FORWARDED (src->tabval[ix]);
  }#
)
(install_value_descriptor valdesc_routine)



;;;;;;;;;;;;;;;; long bucket values
(definstance valdesc_bucketlongs class_varisized_value_descriptor
  :doc #{$VALDESC_BUCKETLONGS describe internal long-keyed buckets inside long bighashtables.}#
  :named_name '"VALDESC_BUCKETLONGS"
  :valdesc_objmagic '"MELTOBMAG_BUCKETLONGS"
  :valdesc_struct '"meltbucketlongs_st"
  :valdesc_unionmem '"u_bucketlongs"
  ;;;
  :valdesc_membchunk #{$' /* from VALDESC_BUCKETLONGS in warmelt-base.melt */ 
     melt_ptr_t buckl_aux; /* auxiliary data */
     unsigned char buckl_lenix; /* index in melt_primtab for allocated length */
     int buckl_xnum; /* extra number */
     unsigned buckl_ucount;     /* used count of bucket entries */
     struct melt_bucketlongentry_st GTY ((length("melt_primtab[%h.buckl_lenix]")))
        buckl_entab[MELT_FLEXIBLE_DIM]; /* sorted by increasing ebl_at */
  }#
  ;;;
  :valdesc_declchunk #{$' /* decl VALDESC_BUCKETLONGS  in warmelt-base.melt */ 
  typedef struct meltbucketlongs_st* meltbucketlongs_ptr_t;
#ifndef ggc_alloc_meltbucketlongs_st
#define ggc_alloc_meltbucketlongs_st(SIZE) ((struct meltbucketlongs_st *)(ggc_internal_alloc_stat (SIZE MEM_STAT_INFO)))
#endif
  }#
  ;;;
  :valdesc_copychunk #{$' /* copy chunk from  VALDESC_BUCKETLONGS  in warmelt-base.melt */
  /* ggc_alloc_meltbucketlongs_st should be gengtype generated for VALDESC_BUCKETLONGS */
   unsigned lnix = src->buckl_lenix;
   unsigned len = melt_primtab[lnix];
   unsigned ucnt = 0;
   unsigned ix = 0;
   dst = /* Don't need a cleared allocation! */
     ggc_alloc_meltbucketlongs_st (len*sizeof (struct melt_bucketlongentry_st) 
				   + offsetof(struct meltbucketlongs_st, buckl_entab));
   dst->discr = src->discr;
   dst->buckl_aux = src->buckl_aux;
   dst->buckl_xnum = src->buckl_xnum;
   ucnt = dst->buckl_ucount = src->buckl_ucount;
   for (ix = 0; ix < ucnt; ix++)
     dst->buckl_entab[ix] = src->buckl_entab[ix];
   for (ix = ucnt; ix < len; ix++) {
     dst->buckl_entab[ix].ebl_at = 0L;
     dst->buckl_entab[ix].ebl_va = NULL;
   }
   /* end copy chunk VALDESC_BUCKETLONGS */
  }#
  :valdesc_clonechunk #{$' /* cloning chunk  from VALDESC_BUCKETLONGS in warmelt-base.melt */
   unsigned lnix = src->buckl_lenix;
   unsigned len = melt_primtab[lnix];
   unsigned cnt = src->buckl_ucount;
   unsigned dstlen = 0;
   unsigned ix = 0;
   gcc_assert (cnt <= len);
   dst = (struct meltbucketlongs_st*)
      meltgc_new_longsbucket ((meltobject_ptr_t)newdiscrv, cnt + cnt/8 + 2);
   dstlen = melt_primtab[dst->buckl_lenix];
   dst->buckl_aux = src->buckl_aux;
   dst->buckl_xnum = src->buckl_xnum;
   for (ix = 0; ix < cnt; ix++)
     dst->buckl_entab[ix] = src->buckl_entab[ix];
   for (ix = cnt; ix < dstlen; ix++) {
     dst->buckl_entab[ix].ebl_at = 0L;
     dst->buckl_entab[ix].ebl_va = NULL;
   }
   /* end clone chunk VALDESC_BUCKETLONGS */
  }#
  ;;
  :valdesc_forwchunk #{$' /* forwarding chunk from VALDESC_BUCKETLONGS in warmelt-base.melt */
   unsigned lnix = src->buckl_lenix;
   unsigned len = melt_primtab[lnix];
   unsigned ucnt = src->buckl_ucount;
   unsigned ix = 0;
   MELT_FORWARDED (src->buckl_aux);
   gcc_assert (ucnt <= len);
   for (ix = 0; ix < ucnt; ix++)
      MELT_FORWARDED (src->buckl_entab[ix].ebl_va);
  /* end forwarding VALDESC_BUCKETLONGS */
  }#
  )
(install_value_descriptor valdesc_bucketlongs)


;;;;;;;;;;;;;;;; string value
(definstance valdesc_string class_varisized_value_descriptor
  :doc #{$VALDESC_STRING describes string values.}#
  :named_name '"VALDESC_STRING"
  :valdesc_objmagic '"MELTOBMAG_STRING"
  :valdesc_struct '"meltstring_st"
  :valdesc_unionmem '"u_string"
  :valdesc_membchunk #{$' /* from VALDESC_STRING in warmelt-base.melt */  
    char val[MELT_FLEXIBLE_DIM];	/* null terminated */
  }#
  :valdesc_declchunk #{$' /* decl VALDESC_STRING from warmelt-base.melt */
#define MELT_STRING_STRUCT(N) {			\
  meltobject_ptr_t discr;			\
  char val[(N)+1];	/* null terminated */	\
  long _gap; }
  }#
  :valdesc_copychunk #{$' /* copy from VALDESC_STRING file warmelt-base.melt*/  
/* ggc_alloc_meltstring_st should be gengtype generated for VALDESC_STRING */
#ifndef ggc_alloc_meltstring_st
#define ggc_alloc_meltstring_st(SIZE) ((struct meltstring_st *)(ggc_internal_alloc_stat (SIZE MEM_STAT_INFO)))
#endif
     int srclen = (src->val)?strlen (src->val):0;
     dst = 
       /* Don't need a cleared allocation.  */
       ggc_alloc_meltstring_st 
         (offsetof(struct meltstring_st, val) + (srclen+1));
     dst->discr = src->discr;
     memcpy (dst->val, src->val, srclen);
     dst->val[srclen] = (char)0;
      /* end copy from VALDESC_STRING */
  }#
  :valdesc_clonechunk #{$' /* clone from VALDESC_STRING  */
     dst = (struct meltstring_st*)
          meltgc_new_stringdup ((meltobject_ptr_t)newdiscrv, 
				src->val);
     /* end clone from VALDESC_STRING  */
  }#
)
(install_value_descriptor valdesc_string)

;;;;;;;;;;;;;;;; string buffer value
(definstance valdesc_strbuf class_value_descriptor
  :doc #{$VALDESC_STRBUF describes string buffers values}#
  :named_name '"VALDESC_STRBUF"
  :valdesc_objmagic '"MELTOBMAG_STRBUF"
  :valdesc_struct '"meltstrbuf_st"
  :valdesc_unionmem '"u_strbuf"
  :valdesc_membchunk #{$' /* from VALDESC_STRBUF in warmelt-base.melt */  
  char *GTY ((length ("1+melt_primtab[%h.buflenix]"))) bufzn;
  unsigned char buflenix;	/* allocated length index of
				   buffer */
  unsigned bufstart;
  unsigned bufend;		/* start & end useful positions */
  /* the following field is usually the value of buf (for
     objects in the young zone), to allocate the object and its fields
     at once; hence its GTY-ed length is zero */
  char GTY ((length ("0"))) buf_space[MELT_FLEXIBLE_DIM];
  }#
  :valdesc_copychunk #{$' /* copy chunk from VALDESC_STRBUF */
/* ggc_alloc_meltstrbuf_st should be gengtype gengtype for VALDESC_STRBUF */
#ifndef ggc_alloc_meltstrbuf_st
#define ggc_alloc_meltstrbuf_st() ((struct meltstrbuf_st *)(ggc_internal_alloc_stat (sizeof (struct meltstrbuf_st) MEM_STAT_INFO)))
#endif
     unsigned blen = melt_primtab[src->buflenix];
     dst = 
       /* Don't need a cleared allocation.  */
       ggc_alloc_meltstrbuf_st ();
     dst->discr = src->discr;
     dst->bufstart = src->bufstart;
     dst->bufend = src->bufend;
     dst->buflenix = src->buflenix;
     if (blen > 0)
        {
#if BUILDING_GCC_VERSION > 4005
          dst->bufzn = CONST_CAST (char *, ggc_alloc_string (src->bufzn, blen+1));
#else /*GCC 4.5*/ 
          dst->bufzn = (char *) ggc_alloc_cleared (1 + blen);
          memcpy (dst->bufzn, src->bufzn, blen);
#endif  /*!GCC 4.5*/
          dst->bufzn[blen] = (char)0;
        }
      else
        dst->bufzn = NULL;
    /* end copy chunk from VALDESC_STRBUF */
  }#
  :valdesc_clonechunk #{$' /* clone chunk from VALDESC_STRBUF */
    resv = dst = (struct meltstrbuf_st*) 
       meltgc_new_strbuf ((meltobject_ptr_t)newdiscrv, NULL);
    src = (struct meltstrbuf_st*)srcvalv;
    meltgc_add_strbuf ((melt_ptr_t) dst, melt_strbuf_str ((melt_ptr_t)src));
    /* end clone chunk from VALDESC_STRBUF */
  }#
)
(install_value_descriptor valdesc_strbuf)


;;;;;;;;;;;;;;;; pair value
(definstance valdesc_pair class_value_descriptor
  :doc #{$VALDESC_PAIR describes pair values inside lists.}#
  :named_name '"VALDESC_PAIR"
  :valdesc_objmagic '"MELTOBMAG_PAIR"
  :valdesc_struct '"meltpair_st"
  :valdesc_unionmem '"u_pair"
  :valdesc_gty #{$' chain_next ("%h.tl")}#
  :valdesc_declchunk #{$' /* decl VALDESC_PAIR in warmelt-base.melt */
  typedef struct meltpair_st *meltpair_ptr_t;
  }#
  :valdesc_membchunk #{$' /* from VALDESC_PAIR in warmelt-base.melt */
    melt_ptr_t hd;
    struct meltpair_st *tl;
  }#
  :valdesc_copychunk #{$' /* copy VALDESC_PAIR in warmelt-base.melt */
  /* ggc_alloc_meltpair_st should be gengtype gengtype for VALDESC_PAIR */
#ifndef ggc_alloc_meltpair_st
#define ggc_alloc_meltpair_st() ((struct meltpair_st *)(ggc_internal_alloc_stat (sizeof (struct meltpair_st) MEM_STAT_INFO)))
#endif
    dst = /* Don't need a cleared allocation.  */
	  ggc_alloc_meltpair_st ();
    *dst = *src;
  }#
  :valdesc_clonechunk :true
  :valdesc_forwchunk #{$' /* forward VALDESC_PAIR in warmelt-base.melt */
     MELT_FORWARDED (src->hd);
     MELT_FORWARDED (src->tl);
  }#
)
(install_value_descriptor valdesc_pair)
  

;;;;;;;;;;;;;;;; list value
(definstance valdesc_list class_value_descriptor
  :doc #{$VALDESC_LIST describes list values containing pairs.}#
  :named_name '"VALDESC_LIST"
  :valdesc_objmagic '"MELTOBMAG_LIST"
  :valdesc_struct '"meltlist_st"
  :valdesc_unionmem '"u_list"
  :valdesc_membchunk #{$' /* from VALDESC_LIST in warmelt-base.melt */
    struct meltpair_st *first;
    struct meltpair_st *last;
  }#
  :valdesc_declchunk #{$' /* decl VALDESC_LIST in warmelt-base.melt */
  typedef struct meltlist_st *meltlist_ptr_t;
  }#
  :valdesc_copychunk #{$' /* copy chunk from VALDESC_LIST */
/* ggc_alloc_meltlist_st should be gengtype gengtype for VALDESC_LIST */
#ifndef ggc_alloc_meltlist_st
#define ggc_alloc_meltlist_st() ((struct meltlist_st *)(ggc_internal_alloc_stat (sizeof (struct meltlist_st) MEM_STAT_INFO)))
#endif
     dst = 
	  /* Don't need a cleared allocation!  */
	 ggc_alloc_meltlist_st ();
     *dst = *src;
     /* end chunk from VALDESC_LIST */
  }#
  :valdesc_clonechunk #{$' /* cloning from VALDESC_LIST */
     struct meltpair_st* curpair = NULL;
     resv = dst = (struct meltlist_st*) meltgc_new_list ((meltobject_ptr_t)newdiscrv);
     src = (struct meltlist_st*) srcvalv;
     for (curpair = ((struct meltlist_st *) src)->first;
          melt_magic_discr ((melt_ptr_t) curpair) == MELTOBMAG_PAIR; 
          curpair = (struct meltpair_st *) (curpair->tl)) {
     src = (struct meltlist_st*) srcvalv; 
     dst = (struct meltlist_st*) resv;
     compv = curpair;
     meltgc_append_list ((melt_ptr_t) resv, curpair->hd);
     /* copy, because GC might have moved values. */
     curpair = (struct meltpair_st*) compv;
     src = (struct meltlist_st*) srcvalv; 
     dst = (struct meltlist_st*) resv;
    }
     /* end cloning from VALDESC_LIST */
  }#
  :valdesc_forwchunk #{$' /* from VALDESC_LIST */
     MELT_FORWARDED (src->first);
     MELT_FORWARDED (src->last);
  }#

)
(install_value_descriptor valdesc_list)

;;;;;;;;;;;;;;;; int value
(definstance valdesc_int class_value_descriptor
  :doc #{$VALDESC_INT describes int values boxing long integers.}#
  :named_name '"VALDESC_INT"
  :valdesc_objmagic '"MELTOBMAG_INT"
  :valdesc_struct '"meltint_st"
  :valdesc_unionmem '"u_int"
  :valdesc_membchunk #{$' /* from VALDESC_INT in warmelt-base.melt */
    long val;
  }#
  :valdesc_declchunk #{$' /* decl VALDESC_INT in warmelt-base.melt */
  typedef struct meltint_st *meltint_ptr_t;
  #define melt_unsafe_boxed_int_value(V) (((meltint_ptr_t)(V))->val)
  static inline long melt_boxed_int_value(melt_ptr_t v)
  { return (melt_magic_discr(v)==MELTOBMAG_INT)? melt_unsafe_boxed_int_value(v) : 0L; }
  }#
  :valdesc_copychunk #{$' /* from VALDESC_INT */
/* ggc_alloc_meltint_st should be gengtype generated for VALDESC_INT */
#ifndef ggc_alloc_meltint_st
#define ggc_alloc_meltint_st() ((struct meltint_st *)(ggc_internal_alloc_stat (sizeof (struct meltint_st) MEM_STAT_INFO)))
#endif
     dst = 
        /* Don't need a cleared allocation.  */
	  ggc_alloc_meltint_st ();
     *dst = *src;
  }#
  :valdesc_clonechunk :true
)
(install_value_descriptor valdesc_int)

;;;;;;;;;;;;;;;; mixint value
(definstance valdesc_mixint class_value_descriptor
  :doc #{$VALDESC_MIXINT describes mixint values mixing integers with a value.}#
  :named_name '"VALDESC_MIXINT"
  :valdesc_objmagic '"MELTOBMAG_MIXINT"
  :valdesc_struct '"meltmixint_st"
  :valdesc_unionmem '"u_mixint"
  :valdesc_membchunk #{$' /* from VALDESC_MIXINT in warmelt-base.melt */
    melt_ptr_t ptrval;
    long intval;
  }#
  :valdesc_copychunk #{$' /* from VALDESC_MIXINT */
/* ggc_alloc_meltmixint_st should be gengtype generated for VALDESC_MIXINT */
#ifndef ggc_alloc_meltmixint_st
#define ggc_alloc_meltmixint_st() ((struct meltmixint_st *)(ggc_internal_alloc_stat (sizeof (struct meltmixint_st) MEM_STAT_INFO)))
#endif
    dst = 
      /* Don't need a cleared allocation.  */
        ggc_alloc_meltmixint_st ();
    *dst = *src;
  }#
  :valdesc_clonechunk :true
  :valdesc_forwchunk #{$' /* from VALDESC_MIXINT */
    MELT_FORWARDED (src->ptrval);
  }#
)
(install_value_descriptor valdesc_mixint)

;;;;;;;;;;;;;;;; mixloc value
(definstance valdesc_mixloc class_value_descriptor
  :doc #{$VALDESC_MIXLOC describes mixloc values mixing locations with a value.}#
  :named_name '"VALDESC_MIXLOC"
  :valdesc_objmagic '"MELTOBMAG_MIXLOC"
  :valdesc_struct '"meltmixloc_st"
  :valdesc_unionmem '"u_mixloc"
  :valdesc_membchunk #{$' /* from VALDESC_MIXLOC in warmelt-base.melt.melt */
    melt_ptr_t ptrval;
    long intval;
    location_t locval;
  }#
  :valdesc_copychunk #{$' /* from VALDESC_MIXLOC */
/* ggc_alloc_meltmixloc_st should be gengtype generated for VALDESC_MIXLOC */
#ifndef ggc_alloc_meltmixloc_st
#define ggc_alloc_meltmixloc_st() ((struct meltmixloc_st *)(ggc_internal_alloc_stat (sizeof (struct meltmixloc_st) MEM_STAT_INFO)))
#endif
    dst = 
       /* Don't need a cleared allocation.  */
       ggc_alloc_meltmixloc_st ();
    *dst = *src;
  }#
  :valdesc_clonechunk :true
  :valdesc_forwchunk #{$' /* from VALDESC_MIXLOC */
    MELT_FORWARDED (src->ptrval);
  }#
)
(install_value_descriptor valdesc_mixloc)

;;;;;;;;;;;;;;;; mixbigint value
(definstance valdesc_mixbigint class_varisized_value_descriptor
  :doc #{$VALDESC_MIXBIGINT describes mixbigint values.}#
  :named_name '"VALDESC_MIXBIGINT"
  :valdesc_objmagic '"MELTOBMAG_MIXBIGINT"
  :valdesc_struct '"meltmixbigint_st"
  :valdesc_unionmem '"u_mixbigint"
  :valdesc_membchunk #{$' /* from VALDESC_MIXBIGINT in warmelt-base.melt */
/* an exported array mpz compatible; since we use an exported mpz format, 
   the value can be copied and trashed by MELT garbage collector without 
   harm. */
    melt_ptr_t ptrval;
    bool negative;
    unsigned biglen;
    long GTY ((length ("%h.biglen"))) tabig[MELT_FLEXIBLE_DIM];
  }#
  :valdesc_copychunk #{$' /* from VALDESC_MIXBIGINT */
/* ggc_alloc_meltmixbigint_st should be gengtype generated for VALDESC_MIXBIGINT */
#ifndef ggc_alloc_meltmixbigint_st
#define ggc_alloc_meltmixbigint_st(SIZE) ((struct meltmixbigint_st *)(ggc_internal_alloc_stat (SIZE MEM_STAT_INFO)))
#endif
     unsigned blen = src->biglen;
     dst = 
       /* Don't need a cleared allocation.  */
       ggc_alloc_meltmixbigint_st 
       (blen*sizeof(long) + offsetof(struct meltmixbigint_st, tabig));
     dst->discr = src->discr;
     dst->ptrval = src->ptrval;
     dst->negative = src->negative;
     dst->biglen = blen;
     memcpy (dst->tabig, src->tabig, blen*sizeof(dst->tabig[0]));
  }#
  :valdesc_forwchunk #{$' /* from VALDESC_MIXBIGINT */
    MELT_FORWARDED (src->ptrval);
  }#
)
(install_value_descriptor valdesc_mixbigint)

;;;;;;;;;;;;;;;; real value
(definstance valdesc_real class_value_descriptor
  :doc #{$VALDESC_REAL describes real values.}#
  :named_name '"VALDESC_REAL"
  :valdesc_objmagic '"MELTOBMAG_REAL"
  :valdesc_struct '"meltreal_st"
  :valdesc_unionmem '"u_real"
  :valdesc_membchunk #{$' /* from VALDESC_REAL in warmelt-base.melt */
    REAL_VALUE_TYPE val;
  }#
  :valdesc_clonechunk :true
  :valdesc_copychunk #{$' /* from VALDESC_REAL */
/* ggc_alloc_meltreal_st should be gengtype generated for VALDESC_REAL */
#ifndef ggc_alloc_meltreal_st
#define ggc_alloc_meltreal_st() ((struct meltreal_st *)(ggc_internal_alloc_stat (sizeof (struct meltreal_st) MEM_STAT_INFO)))
#endif
    dst =
        /* Don't need a cleared allocation.  */
	ggc_alloc_meltreal_st ();
    *dst = *src;
  }#
)
(install_value_descriptor valdesc_real)

;;;;;;;;;;;;;;;; ****************** SPECIAL VALUES
;;;;;;;;;;;;;;;; special file value
(definstance valdesc_special_file class_value_descriptor
  :doc #{$VALDESC_SPECIAL_FILE describes special file values.}#
  :named_name '"VALDESC_SPECIAL_FILE"
  :valdesc_objmagic '"MELTOBMAG_SPEC_FILE"
  :valdesc_struct '"meltspecialfile_st"
  :valdesc_unionmem '"u_special_file"
  :valdesc_gty #{$' mark_hook ("melt_mark_special")}#
  :valdesc_membchunk #{$' /* from VALDESC_SPECIAL_FILE in warmelt-base.melt */
    int mark;
    struct meltspecial_st *GTY ((skip)) nextspec;
    union melt_special_un GTY ((skip)) val;
  }#
  :valdesc_copychunk #{$' /* from VALDESC_SPECIAL_FILE */
/* ggc_alloc_meltspecialfile_st should be gengtype generated for VALDESC_SPECIAL_FILE */
#ifndef ggc_alloc_meltspecialfile_st
#define ggc_alloc_meltspecialfile_st() ((struct meltspecialfile_st *)(ggc_internal_alloc_stat (sizeof (struct meltspecialfile_st) MEM_STAT_INFO)))
#endif
    dst = ggc_alloc_meltspecialfile_st ();
    *dst = *src;
    /* mark the new copy! */
    dst->mark = 1;
    /* add the new copy to the old (major) special list */
    dst->nextspec = melt_oldspeclist;
    melt_oldspeclist = (struct meltspecial_st*)dst;
  }#
  :valdesc_forwchunk #{$' /* from VALDESC_SPECIAL_FILE */
    src->mark = 1;
  }#

)
(install_value_descriptor valdesc_special_file)

;;;;;;;;;;;;;;;; special raw file value
(definstance valdesc_special_raw_file class_value_descriptor
  :doc #{$VALDESC_SPECIAL_RAW_FILE describes special raw file values.}#
  :named_name '"VALDESC_SPECIAL_RAW_FILE"
  :valdesc_objmagic '"MELTOBMAG_SPEC_RAWFILE"
  :valdesc_struct '"meltspecialrawfile_st"
  :valdesc_unionmem '"u_special_rawfile"
  :valdesc_gty #{$' mark_hook ("melt_mark_special")}#
  :valdesc_membchunk #{$' /* from VALDESC_SPECIAL_RAW_FILE in warmelt-base.melt */
    int mark;
    struct meltspecial_st *GTY ((skip)) nextspec;
    union melt_special_un GTY ((skip)) val;
  }#
  :valdesc_copychunk #{$' /* from VALDESC_SPECIAL_RAW_FILE */
/* ggc_alloc_meltspecialrawfile_st should be gengtype generated for VALDESC_SPECIAL_RAW_FILE */
#ifndef ggc_alloc_meltspecialrawfile_st
#define ggc_alloc_meltspecialrawfile_st() ((struct meltspecialrawfile_st *)(ggc_internal_alloc_stat (sizeof (struct meltspecialrawfile_st) MEM_STAT_INFO)))
#endif
    dst = ggc_alloc_meltspecialrawfile_st ();
    *dst = *src;
    /* mark the new copy! */
    dst->mark = 1;
    /* add the new copy to the old (major) special list */
    dst->nextspec = melt_oldspeclist;
    melt_oldspeclist = (struct meltspecial_st*)dst;
  }#
  :valdesc_forwchunk #{$' /* from VALDESC_SPECIAL_RAW_FILE */
    src->mark = 1;
  }#
)
(install_value_descriptor valdesc_special_raw_file)

;;;;;;;;;;;;;;;; special mpfr value
(definstance valdesc_special_mpfr class_value_descriptor
  :doc #{$VALDESC_SPECIAL_MPFR describes special MPFR values.}#
  :named_name '"VALDESC_SPECIAL_MPFR"
  :valdesc_objmagic '"MELTOBMAG_SPEC_MPFR"
  :valdesc_struct '"meltspecialmpfr_st"
  :valdesc_unionmem '"u_special_mpfr"
  :valdesc_gty #{$' mark_hook ("melt_mark_special")}#
  :valdesc_membchunk #{$' /* from VALDESC_SPECIAL_MPFR in warmelt-base.melt */
    int mark;
    struct meltspecial_st *GTY ((skip)) nextspec;
    union melt_special_un GTY ((skip)) val;
  }#
  :valdesc_copychunk #{$' /* from VALDESC_SPECIAL_MPFR */
/* ggc_alloc_meltspecialmpfr_st should be gengtype generated for VALDESC_SPECIAL_MPFR */
#ifndef ggc_alloc_meltspecialmpfr_st
#define ggc_alloc_meltspecialmpfr_st() ((struct meltspecialmpfr_st *)(ggc_internal_alloc_stat (sizeof (struct meltspecialmpfr_st) MEM_STAT_INFO)))
#endif
    dst = ggc_alloc_meltspecialmpfr_st ();
    *dst = *src;
    /* mark the new copy! */
    dst->mark = 1;
    /* add the new copy to the old (major) special list */
    dst->nextspec = melt_oldspeclist;
    melt_oldspeclist = (struct meltspecial_st*)dst;
  }#
  :valdesc_forwchunk #{$' /* from VALDESC_SPECIAL_MPFR */
    src->mark = 1;
  }#
)
(install_value_descriptor valdesc_special_mpfr)

;;;;;;;;;;;;;;;; special PPL coefficient value
(definstance valdesc_special_ppl_coefficient class_value_descriptor
  :doc #{$VALDESC_SPECIAL_PPL_COEFFICIENT describes special PPL coefficient values.}#
  :named_name '"VALDESC_SPECIAL_PPL_COEFFICIENT"
  :valdesc_objmagic '"MELTOBMAG_SPECPPL_COEFFICIENT"
  :valdesc_struct '"meltspecialpplcoefficient_st"
  :valdesc_unionmem '"u_special_ppl_coefficient"
  :valdesc_gty #{$' mark_hook ("melt_mark_special")}#
  :valdesc_membchunk #{$' /* from VALDESC_SPECIAL_PPL_COEFFICIENT in warmelt-base.melt */
    int mark;
    struct meltspecial_st *GTY ((skip)) nextspec;
    union melt_special_un GTY ((skip)) val;
  }#
  :valdesc_copychunk #{$' /* from VALDESC_SPECIAL_PPL_COEFFICIENT */
/* ggc_alloc_meltspecialpplcoefficient_st should be gengtype generated for VALDESC_SPECIAL_PPL_COEFFICIENT */
#ifndef ggc_alloc_meltspecialpplcoefficient_st
#define ggc_alloc_meltspecialpplcoefficient_st() ((struct meltspecialpplcoefficient_st *)(ggc_internal_alloc_stat (sizeof (struct meltspecialpplcoefficient_st) MEM_STAT_INFO)))
#endif
    dst = ggc_alloc_meltspecialpplcoefficient_st ();
    *dst = *src;
    /* mark the new copy! */
    dst->mark = 1;
    /* add the new copy to the old (major) special list */
    dst->nextspec = melt_oldspeclist;
    melt_oldspeclist = (struct meltspecial_st*)dst;
  }#
  :valdesc_forwchunk #{$' /* from VALDESC_SPECIAL_PPL_COEFFICIENT */
    src->mark = 1;
  }#
)
(install_value_descriptor valdesc_special_ppl_coefficient)

;;;;;;;;;;;;;;;; special PPL linear expression value
(definstance valdesc_special_ppl_linear_expression class_value_descriptor
  :doc #{$VALDESC_SPECIAL_PPL_LINEAR_EXPRESSION describes special PPL 
linear expression values.}#
  :named_name '"VALDESC_SPECIAL_PPL_LINEAR_EXPRESSION"
  :valdesc_objmagic '"MELTOBMAG_SPECPPL_LINEAR_EXPRESSION"
  :valdesc_struct '"meltspecialppllinearexpression_st"
  :valdesc_unionmem '"u_special_ppl_linear_expression"
  :valdesc_gty #{$' mark_hook ("melt_mark_special")}#
  :valdesc_membchunk #{$' /* from VALDESC_SPECIAL_PPL_LINEAR_EXPRESSION in warmelt-base.melt*/
    int mark;
    struct meltspecial_st *GTY ((skip)) nextspec;
    union melt_special_un GTY ((skip)) val;
  }#
  :valdesc_copychunk #{$' /* from VALDESC_SPECIAL_PPL_LINEAR_EXPRESSION */
/* ggc_alloc_meltspecialppllinearexpression_st should be gengtype generated for VALDESC_SPECIAL_PPL_LINEAR_EXPRESSION */
#ifndef ggc_alloc_meltspecialppllinearexpression_st
#define ggc_alloc_meltspecialppllinearexpression_st() ((struct meltspecialppllinearexpression_st *)(ggc_internal_alloc_stat (sizeof (struct meltspecialppllinearexpression_st) MEM_STAT_INFO)))
#endif
    dst = ggc_alloc_meltspecialppllinearexpression_st ();
    *dst = *src;
    /* mark the new copy! */
    dst->mark = 1;
    /* add the new copy to the old (major) special list */
    dst->nextspec = melt_oldspeclist;
    melt_oldspeclist = (struct meltspecial_st*)dst;
  }#
  :valdesc_forwchunk #{$' /* from VALDESC_SPECIAL_PPL_LINEAR_EXPRESSION */
    src->mark = 1;
  }#
)
(install_value_descriptor valdesc_special_ppl_linear_expression)

;;;;;;;;;;;;;;;; special PPL constraint value
(definstance valdesc_special_ppl_constraint class_value_descriptor
  :doc #{$VALDESC_SPECIAL_PPL_CONSTRAINT describes special PPL 
constraints values.}#
  :named_name '"VALDESC_SPECIAL_PPL_CONSTRAINT"
  :valdesc_objmagic '"MELTOBMAG_SPECPPL_CONSTRAINT"
  :valdesc_struct '"meltspecialpplconstraint_st"
  :valdesc_unionmem '"u_special_ppl_constraint"
  :valdesc_gty #{$' mark_hook ("melt_mark_special")}#
  :valdesc_membchunk #{$' /* from VALDESC_SPECIAL_PPL_CONSTRAINT in warmelt-base.melt*/
    int mark;
    struct meltspecial_st *GTY ((skip)) nextspec;
    union melt_special_un GTY ((skip)) val;
  }#
  :valdesc_copychunk #{$' /* from VALDESC_SPECIAL_PPL_CONSTRAINT */
/* ggc_alloc_meltspecialpplconstraint_st should be gengtype gengtype for VALDESC_SPECIAL_PPL_CONSTRAINT */
#ifndef ggc_alloc_meltspecialpplconstraint_st
#define ggc_alloc_meltspecialpplconstraint_st() ((struct meltspecialpplconstraint_st *)(ggc_internal_alloc_stat (sizeof (struct meltspecialpplconstraint_st) MEM_STAT_INFO)))
#endif
    dst = ggc_alloc_meltspecialpplconstraint_st ();
    *dst = *src;
    /* mark the new copy! */
    dst->mark = 1;
    /* add the new copy to the old (major) special list */
    dst->nextspec = melt_oldspeclist;
    melt_oldspeclist = (struct meltspecial_st*)dst;
  }#
  :valdesc_forwchunk #{$' /* from VALDESC_SPECIAL_PPL_CONSTRAINT */
    src->mark = 1;
  }#
)
(install_value_descriptor valdesc_special_ppl_constraint)

;;;;;;;;;;;;;;;; special PPL constraint system value
(definstance valdesc_special_ppl_constraint_system class_value_descriptor
  :doc #{$VALDESC_SPECIAL_PPL_CONSTRAINT_SYSTEM describes special PPL 
constraint systems values.}#
  :named_name '"VALDESC_SPECIAL_PPL_CONSTRAINT_SYSTEM"
  :valdesc_objmagic '"MELTOBMAG_SPECPPL_CONSTRAINT_SYSTEM"
  :valdesc_struct '"meltspecialpplconstraintsystem_st"
  :valdesc_unionmem '"u_special_ppl_constraint_system"
  :valdesc_gty #{$' mark_hook ("melt_mark_special")}#
  :valdesc_membchunk #{$' /* from VALDESC_SPECIAL_PPL_CONSTRAINT_SYSTEM in warmelt-base.melt */
    int mark;
    struct meltspecial_st *GTY ((skip)) nextspec;
    union melt_special_un GTY ((skip)) val;
  }#
  :valdesc_copychunk #{$' /* from VALDESC_SPECIAL_PPL_CONSTRAINT_SYSTEM */
  /* ggc_alloc_meltspecialpplconstraintsystem_st should be gengtype generated for VALDESC_SPECIAL_PPL_CONSTRAINT_SYSTEM */
#ifndef ggc_alloc_meltspecialpplconstraintsystem_st
#define ggc_alloc_meltspecialpplconstraintsystem_st() ((struct meltspecialpplconstraintsystem_st *)(ggc_internal_alloc_stat (sizeof (struct meltspecialpplconstraintsystem_st) MEM_STAT_INFO)))
#endif
    dst = ggc_alloc_meltspecialpplconstraintsystem_st ();
    *dst = *src;
    /* mark the new copy! */
    dst->mark = 1;
    /* add the new copy to the old (major) special list */
    dst->nextspec = melt_oldspeclist;
    melt_oldspeclist = (struct meltspecial_st*)dst;
  }#
  :valdesc_forwchunk #{$' /* from VALDESC_SPECIAL_PPL_CONSTRAINT_SYSTEM */
    src->mark = 1;
  }#
)
(install_value_descriptor valdesc_special_ppl_constraint_system)

;;;;;;;;;;;;;;;; special PPL generator value
(definstance valdesc_special_ppl_generator class_value_descriptor
  :doc #{$VALDESC_SPECIAL_PPL_GENERATOR describes special PPL 
generators values.}#
  :named_name '"VALDESC_SPECIAL_PPL_GENERATOR"
  :valdesc_objmagic '"MELTOBMAG_SPECPPL_GENERATOR"
  :valdesc_struct '"meltspecialpplgenerator_st"
  :valdesc_unionmem '"u_special_ppl_generator"
  :valdesc_gty #{$' mark_hook ("melt_mark_special")}#
  :valdesc_membchunk #{$' /* from VALDESC_SPECIAL_PPL_GENERATOR in warmelt-base.melt */
    int mark;
    struct meltspecial_st *GTY ((skip)) nextspec;
    union melt_special_un GTY ((skip)) val;
  }#
  :valdesc_copychunk #{$' /* from VALDESC_SPECIAL_PPL_GENERATOR */
/* ggc_alloc_meltspecialpplgenerator_st should be gengtype generated for VALDESC_SPECIAL_PPL_GENERATOR */
#ifndef ggc_alloc_meltspecialpplgenerator_st
#define ggc_alloc_meltspecialpplgenerator_st() ((struct meltspecialpplgenerator_st *)(ggc_internal_alloc_stat (sizeof (struct meltspecialpplgenerator_st) MEM_STAT_INFO)))
#endif
    dst = ggc_alloc_meltspecialpplgenerator_st ();
    *dst = *src;
    /* mark the new copy! */
    dst->mark = 1;
    /* add the new copy to the old (major) special list */
    dst->nextspec = melt_oldspeclist;
    melt_oldspeclist = (struct meltspecial_st*)dst;
  }#
  :valdesc_forwchunk #{$' /* from VALDESC_SPECIAL_PPL_GENERATOR */
    src->mark = 1;
  }#
)
(install_value_descriptor valdesc_special_ppl_generator)

;;;;;;;;;;;;;;;; special PPL generator system value
(definstance valdesc_special_ppl_generator_system class_value_descriptor
  :doc #{$VALDESC_SPECIAL_PPL_GENERATOR_SYSTEM describes special PPL 
generator systems values.}#
  :named_name '"VALDESC_SPECIAL_PPL_GENERATOR_SYSTEM"
  :valdesc_objmagic '"MELTOBMAG_SPECPPL_GENERATOR_SYSTEM"
  :valdesc_struct '"meltspecialpplgeneratorsystem_st"
  :valdesc_unionmem '"u_special_ppl_generator_system"
  :valdesc_gty #{$'mark_hook ("melt_mark_special")}#
  :valdesc_membchunk #{$' /* from VALDESC_SPECIAL_PPL_GENERATOR_SYSTEM in warmelt-base.melt */
    int mark;
    struct meltspecial_st *GTY ((skip)) nextspec;
    union melt_special_un GTY ((skip)) val;
  }#
  :valdesc_copychunk #{$' /* from VALDESC_SPECIAL_PPL_GENERATOR_SYSTEM */
/*  ggc_alloc_meltspecialpplgeneratorsystem_st should be gengtype generated for VALDESC_SPECIAL_PPL_GENERATOR_SYSTEM */
#ifndef ggc_alloc_meltspecialpplgeneratorsystem_st
#define ggc_alloc_meltspecialpplgeneratorsystem_st() ((struct meltspecialpplgeneratorsystem_st *)(ggc_internal_alloc_stat (sizeof (struct meltspecialpplgeneratorsystem_st) MEM_STAT_INFO)))
#endif
    dst = ggc_alloc_meltspecialpplgeneratorsystem_st ();
    *dst = *src;
    /* mark the new copy! */
    dst->mark = 1;
    /* add the new copy to the old (major) special list */
    dst->nextspec = melt_oldspeclist;
    melt_oldspeclist = (struct meltspecial_st*)dst;
  }#
  :valdesc_forwchunk #{$' /* from VALDESC_SPECIAL_PPL_GENERATOR_SYSTEM */
    src->mark = 1;
  }#
)
(install_value_descriptor valdesc_special_ppl_generator_system)

;;;;;;;;;;;;;;;; special PPL polyhedron value
(definstance valdesc_special_ppl_polyhedron class_value_descriptor
  :doc #{$VALDESC_SPECIAL_PPL_POLYHEDRON describes special PPL 
polyhedron values.}#
  :named_name '"VALDESC_SPECIAL_PPL_POLYHEDRON"
  :valdesc_objmagic '"MELTOBMAG_SPECPPL_POLYHEDRON"
  :valdesc_struct '"meltspecialpplpolyhedron_st"
  :valdesc_unionmem '"u_special_ppl_polyhedron"
  :valdesc_gty #{$'mark_hook ("melt_mark_special")}#
  :valdesc_membchunk #{$' /* from VALDESC_SPECIAL_PPL_POLYHEDRON in warmelt-base.melt */
    int mark;
    struct meltspecial_st *GTY ((skip)) nextspec;
    union melt_special_un GTY ((skip)) val;
  }#
  :valdesc_copychunk #{$' /* from VALDESC_SPECIAL_PPL_POLYHEDRON */
/* ggc_alloc_meltspecialpplpolyhedron_st should be gengtype generated for VALDESC_SPECIAL_PPL_POLYHEDRON */
#ifndef ggc_alloc_meltspecialpplpolyhedron_st
#define ggc_alloc_meltspecialpplpolyhedron_st() ((struct meltspecialpplpolyhedron_st *)(ggc_internal_alloc_stat (sizeof (struct meltspecialpplpolyhedron_st) MEM_STAT_INFO)))
#endif
    dst = ggc_alloc_meltspecialpplpolyhedron_st ();
    *dst = *src;
    /* mark the new copy! */
    dst->mark = 1;
    /* add the new copy to the old (major) special list */
    dst->nextspec = melt_oldspeclist;
    melt_oldspeclist = (struct meltspecial_st*)dst;
  }#
  :valdesc_forwchunk #{$' /* from VALDESC_SPECIAL_PPL_POLYHEDRON */
    src->mark = 1;
  }#
)
(install_value_descriptor valdesc_special_ppl_polyhedron)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; variadic related utilities

;; the index of variadic argument
(defprimitive variadic_index () :long
  :doc #{Returns the current index of variadic argument, or -1 outside
  of variadic functions.}#
;; the melt_variadic_index macro is defined by code emitted in function
;; outpucod_procroutine of file warmelt-outobj.melt
  #{ /*variadic_index*/
#ifdef melt_variadic_index
  (melt_variadic_index)
#else
  -1
#endif /*melt_variadic_index*/
}#)

;; the length or count of variadic arguments
(defprimitive variadic_length () :long
  :doc #{Returns the length of variadic arguments, or -1 outside
  of variadic functions.}#
;; the melt_variadic_length macro is defined by code emitted in function
;; outpucod_procroutine of file warmelt-outobj.melt
  #{ /*variadic_length*/
#ifdef melt_variadic_length
  (melt_variadic_length)
#else
  -1
#endif /*melt_variadic_length*/
}#)


;; skip some variadic arguments
(defprimitive variadic_skip (:long delta) :void
  :doc #{Skip some variadic arguments, by incrementing appropriately the variadic index.}#
;; the melt_variadic_index & melt_variadic_length macros are defined
;; by code emitted in function outpucod_procroutine of file
;; warmelt-outobj.melt
  #{ /*variadic_skip*/
#ifdef melt_variadic_index
  melt_variadic_index += (int) ($DELTA);
  if (melt_variadic_index < 0) 
     melt_variadic_index = 0;
  else if (melt_variadic_index > melt_variadic_length) 
     melt_variadic_index = melt_variadic_length;
#else
  /* no variadic_skip outside of variadic functions */
  (void) ($DELTA);
#endif /*melt_variadic_index*/
}#)



(defprimitive variadic_type_code (:long delta) :long
  :doc #{Return the type code, i.e. an integer from the MELTBPAR_*
  enumeration, of the variadic argument at offset $DELTA, or else
  [outside of variadic functions, or index out of bounds] 0, that is
  MELTBPAR__NONE. See also $VARIADIC_CTYPE.}#
#{ /*variadic_type_code*/
#ifdef melt_variadic_index
  (((melt_variadic_index + $DELTA) >= 0
    && (melt_variadic_index + $DELTA) < melt_variadic_length) 
  ? (long) (meltxargdescr_[melt_variadic_index + $DELTA] & MELT_ARGDESCR_MAX)
  : 0)
#else
  0 /* no variadic_type_code outside of variadic functions */
#endif /*melt_variadic_index*/
}#)

(defprimitive variadic_ctype  (:long delta) :value
  :doc #{Return the ctype of the variadic argument at offset $DELTA,
  or else Nil. See also $VARIADIC_TYPE_CODE.}#
#{ /*variadic_type_code*/
#ifdef melt_variadic_index
  (((melt_variadic_index + $DELTA) >= 0
    && (melt_variadic_index + $DELTA) < melt_variadic_length) 
  ?  melt_code_to_ctype (meltxargdescr_[melt_variadic_index + $DELTA] 
			 & MELT_ARGDESCR_MAX)
  : NULL)
#else
  NULL /* no variadic_ctype outside of variadic functions */
#endif /*melt_variadic_index*/
}#)


(defprimitive increment (:long left incr) :void
  :doc #{Increment $LEFT (when variable) with $INCR.}#
  #{ /*increment*/ $LEFT += $INCR; 
  }#)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(export_values
 ;; keep the alphanumerical order
		
 !=i
 *i
 -i
 <=i
 ==i

 +iv
 -iv
 *iv
 /iv
 %iv

 <iv
 <=iv
 =iv
 !=iv
 >iv 
 >=iv

 <ivi
 <=ivi
 =ivi
 !=ivi
 >ivi
 >=ivi

 +ivi
 -ivi
 *ivi
 /ivi
 %ivi

 add2out
 add2out_ccomconst
 add2out_ccomstrbuf
 add2out_ccomstring 
 add2out_cencstrbuf
 add2out_cencstring
 add2out_cencsubstring
 add2out_cident
 add2out_cidentprefix
 add2out_indent
 add2out_indentnl
 add2out_longdec
 add2out_longhex
 add2out_mixloc
 add2out_routinedescr
 add2out_sbuf
 add2out_strconst
 add2out_string
 add2sbuf_ccomconst
 add2sbuf_ccomstrbuf
 add2sbuf_ccomstring 
 add2sbuf_cencstrbuf
 add2sbuf_cencstring
 add2sbuf_cident
 add2sbuf_cidentprefix
 add2sbuf_dynloaded_suffix
 add2sbuf_indent
 add2sbuf_indentnl
 add2sbuf_longdec
 add2sbuf_longhex
 add2sbuf_mixloc
 add2sbuf_routinedescr
 add2sbuf_sbuf
 add2sbuf_short_mixloc
 add2sbuf_strconst
 add2sbuf_string
 add2sbuf_texi_mixloc
 add_to_out
 andi
 c_clock
 c_time
 cbreak_msg
 checkcallstack_msg
 checkval_dbg
 clone_with_discriminant
 compare_named_alpha
 cstring_length
 cstring_prefixed
 cstring_same
 debugcstring
 debuglong
 error_plain
 error_strv
 errormsg_plain
 errormsg_strv
 foreach_long_upto
 full_garbcoll
 generate_debug_melt_module
 generate_optimized_melt_module
 generate_quickly_melt_module
 generate_flavored_melt_module
 get_globpredef
 ignore
 increment
 inform_plain
 inform_strv
 informsg_plain
 informsg_strv
 is_file
 is_mixbigint
 is_mixint
 is_mixloc
 is_multiple_or_null
 is_not_object
 is_out
 is_strbuf
 is_stringconst
 longbacktrace_dbg
 make_mixint
 make_mixloc
 make_pair
 make_strbuf
 make_string
 make_string_generated_c_filename
 make_string_mixloc_file
 make_string_nakedbasename
 make_string_tempname_suffixed
 make_string_without_dynloaded_suffix
 make_string_without_suffix
 mapstring_count
 mapstring_every
 mapstring_iterate_test	
 mapstring_rawget
 mapstring_rawput
 mapstring_rawremove
 mapstring_size
 maxi
 melt_application_count
 melt_application_depth
 melt_application_shallower
 melt_increment_dbgcounter
 melt_is_bootstrapping
 melt_mode_container
 melt_version_str
 message_dbg
 messagenum_dbg 
 messageval_dbg
 mini
 minor_garbcoll
 mixbigint_val
 mixint_val
 mixloc_location
 mixloc_locbasefile 
 mixloc_locfile
 mixloc_locline
 mixloc_val
 multiple_backward_every
 multiple_every
 multiple_every_both
 negi
 nonzero_hash
 noti
 notnull
 obj_hash
 obj_len
 obj_num
 object_length
 object_nth_field
 ori
 outcstring_dbg
 outcstring_err	
 outnewline_dbg
 outnewline_err
 outnum_dbg
 outnum_err
 output_length
 output_sbuf_no_overwrite_strconst
 output_sbuf_no_overwrite_strval
 output_sbuf_strconst
 output_sbuf_strval
 outstr_dbg
 outstr_err
 outstrbuf_dbg
 outstrbuf_err
 pair_listlength
 pair_set_head 
 ppstrbuf_mixbigint
 read_file
 read_strv
 register_all_ipa_passes_end_hook_first
 register_all_ipa_passes_end_hook_last
 register_all_ipa_passes_start_hook_first
 register_all_ipa_passes_start_hook_last
 register_all_passes_end_hook_first
 register_all_passes_end_hook_last
 register_all_passes_start_hook_first
 register_all_passes_start_hook_last
 register_early_gimple_passes_end_hook_first
 register_early_gimple_passes_end_hook_last
 register_early_gimple_passes_start_hook_first
 register_early_gimple_passes_start_hook_last
 register_finish_decl_hook_first
 register_finish_decl_hook_last
 register_finish_type_hook_first
 register_finish_type_hook_last
 register_pass_execution_hook
 register_pragma_handler
 register_pre_genericize_hook_first
 register_pre_genericize_hook_last
 retrieve_value_descriptor_list
 set_content
 some_integer_different_from
 some_integer_equal_to
 some_integer_greater_or_equal_to
 some_integer_greater_than
 some_integer_lower_or_equal_to
 some_integer_lower_than
 some_integer_multiple
 some_string_value
 split_string_colon
 split_string_comma
 split_string_equal
 split_string_space 
 start_melt_module_of_flavor 
 strbuf2string
 strbuf_reserve
 strbuf_usedlength
 string_dynloaded_suffixed
 string_ends
 string_hex_md5sum_constpath 
 string_hex_md5sum_path_sequence
 string_hex_md5sum_pathstrv
 string_length
 string_prefixed
 string_starts
 string_suffixed
 subclass_of
 subclass_or_eq
 subseq_multiple
 tuple_nth
 tuple_sized
 unregister_pass_execution_hook
 valdesc_bucketlongs
 valdesc_closure
 valdesc_decay
 valdesc_int
 valdesc_list
 valdesc_mapobjects
 valdesc_mapstrings
 valdesc_mixbigint
 valdesc_mixint
 valdesc_mixloc
 valdesc_multiple
 valdesc_object
 valdesc_pair
 valdesc_real
 valdesc_routine
 valdesc_special_file
 valdesc_special_file
 valdesc_special_mpfr
 valdesc_special_ppl_coefficient
 valdesc_special_ppl_constraint
 valdesc_special_ppl_constraint_system
 valdesc_special_ppl_generator
 valdesc_special_ppl_generator_system
 valdesc_special_ppl_linear_expression
 valdesc_special_ppl_polyhedron
 valdesc_special_raw_file
 valdesc_strbuf
 valdesc_string
 variadic_ctype
 variadic_index
 variadic_length
 variadic_skip
 variadic_type_code
 void
 warning_plain
 warning_strv
 warningmsg_plain
 warningmsg_strv
 xori
 zerop

 )

(export_synonym generate_melt_module generate_optimized_melt_module)
;;;; eof warmelt-base.melt