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
|
Index: utils/warnings.ml
===================================================================
RCS file: /net/yquem/devel/caml/repository/csl/utils/warnings.ml,v
retrieving revision 1.23
diff -u -r1.23 warnings.ml
--- utils/warnings.ml 15 Sep 2005 03:09:26 -0000 1.23
+++ utils/warnings.ml 5 Apr 2006 02:25:59 -0000
@@ -26,7 +26,7 @@
| Statement_type (* S *)
| Unused_match (* U *)
| Unused_pat
- | Hide_instance_variable of string (* V *)
+ | Instance_variable_override of string (* V *)
| Illegal_backslash (* X *)
| Implicit_public_methods of string list
| Unerasable_optional_argument
@@ -54,7 +54,7 @@
| Statement_type -> 's'
| Unused_match
| Unused_pat -> 'u'
- | Hide_instance_variable _ -> 'v'
+ | Instance_variable_override _ -> 'v'
| Illegal_backslash
| Implicit_public_methods _
| Unerasable_optional_argument
@@ -126,9 +126,9 @@
String.concat " "
("the following methods are overridden \
by the inherited class:\n " :: slist)
- | Hide_instance_variable lab ->
- "this definition of an instance variable " ^ lab ^
- " hides a previously\ndefined instance variable of the same name."
+ | Instance_variable_override lab ->
+ "the instance variable " ^ lab ^ " is overridden.\n" ^
+ "The behaviour changed in ocaml 3.10 (previous behaviour was hiding.)"
| Partial_application ->
"this function application is partial,\n\
maybe some arguments are missing."
Index: utils/warnings.mli
===================================================================
RCS file: /net/yquem/devel/caml/repository/csl/utils/warnings.mli,v
retrieving revision 1.16
diff -u -r1.16 warnings.mli
--- utils/warnings.mli 15 Sep 2005 03:09:26 -0000 1.16
+++ utils/warnings.mli 5 Apr 2006 02:25:59 -0000
@@ -26,7 +26,7 @@
| Statement_type (* S *)
| Unused_match (* U *)
| Unused_pat
- | Hide_instance_variable of string (* V *)
+ | Instance_variable_override of string (* V *)
| Illegal_backslash (* X *)
| Implicit_public_methods of string list
| Unerasable_optional_argument
Index: parsing/parser.mly
===================================================================
RCS file: /net/yquem/devel/caml/repository/csl/parsing/parser.mly,v
retrieving revision 1.123
diff -u -r1.123 parser.mly
--- parsing/parser.mly 23 Mar 2005 03:08:37 -0000 1.123
+++ parsing/parser.mly 5 Apr 2006 02:25:59 -0000
@@ -623,6 +623,8 @@
{ [] }
| class_fields INHERIT class_expr parent_binder
{ Pcf_inher ($3, $4) :: $1 }
+ | class_fields VAL virtual_value
+ { Pcf_valvirt $3 :: $1 }
| class_fields VAL value
{ Pcf_val $3 :: $1 }
| class_fields virtual_method
@@ -638,14 +640,20 @@
AS LIDENT
{ Some $2 }
| /* empty */
- {None}
+ { None }
+;
+virtual_value:
+ MUTABLE VIRTUAL label COLON core_type
+ { $3, Mutable, $5, symbol_rloc () }
+ | VIRTUAL mutable_flag label COLON core_type
+ { $3, $2, $5, symbol_rloc () }
;
value:
- mutable_flag label EQUAL seq_expr
- { $2, $1, $4, symbol_rloc () }
- | mutable_flag label type_constraint EQUAL seq_expr
- { $2, $1, (let (t, t') = $3 in ghexp(Pexp_constraint($5, t, t'))),
- symbol_rloc () }
+ mutable_flag label EQUAL seq_expr
+ { $2, $1, $4, symbol_rloc () }
+ | mutable_flag label type_constraint EQUAL seq_expr
+ { $2, $1, (let (t, t') = $3 in ghexp(Pexp_constraint($5, t, t'))),
+ symbol_rloc () }
;
virtual_method:
METHOD PRIVATE VIRTUAL label COLON poly_type
@@ -711,8 +719,12 @@
| class_sig_fields CONSTRAINT constrain { Pctf_cstr $3 :: $1 }
;
value_type:
- mutable_flag label COLON core_type
- { $2, $1, Some $4, symbol_rloc () }
+ VIRTUAL mutable_flag label COLON core_type
+ { $3, $2, Virtual, $5, symbol_rloc () }
+ | MUTABLE virtual_flag label COLON core_type
+ { $3, Mutable, $2, $5, symbol_rloc () }
+ | label COLON core_type
+ { $1, Immutable, Concrete, $3, symbol_rloc () }
;
method_type:
METHOD private_flag label COLON poly_type
Index: parsing/parsetree.mli
===================================================================
RCS file: /net/yquem/devel/caml/repository/csl/parsing/parsetree.mli,v
retrieving revision 1.42
diff -u -r1.42 parsetree.mli
--- parsing/parsetree.mli 23 Mar 2005 03:08:37 -0000 1.42
+++ parsing/parsetree.mli 5 Apr 2006 02:25:59 -0000
@@ -152,7 +152,7 @@
and class_type_field =
Pctf_inher of class_type
- | Pctf_val of (string * mutable_flag * core_type option * Location.t)
+ | Pctf_val of (string * mutable_flag * virtual_flag * core_type * Location.t)
| Pctf_virt of (string * private_flag * core_type * Location.t)
| Pctf_meth of (string * private_flag * core_type * Location.t)
| Pctf_cstr of (core_type * core_type * Location.t)
@@ -179,6 +179,7 @@
and class_field =
Pcf_inher of class_expr * string option
+ | Pcf_valvirt of (string * mutable_flag * core_type * Location.t)
| Pcf_val of (string * mutable_flag * expression * Location.t)
| Pcf_virt of (string * private_flag * core_type * Location.t)
| Pcf_meth of (string * private_flag * expression * Location.t)
Index: parsing/printast.ml
===================================================================
RCS file: /net/yquem/devel/caml/repository/csl/parsing/printast.ml,v
retrieving revision 1.29
diff -u -r1.29 printast.ml
--- parsing/printast.ml 4 Jan 2006 16:55:50 -0000 1.29
+++ parsing/printast.ml 5 Apr 2006 02:25:59 -0000
@@ -353,10 +353,11 @@
| Pctf_inher (ct) ->
line i ppf "Pctf_inher\n";
class_type i ppf ct;
- | Pctf_val (s, mf, cto, loc) ->
+ | Pctf_val (s, mf, vf, ct, loc) ->
line i ppf
- "Pctf_val \"%s\" %a %a\n" s fmt_mutable_flag mf fmt_location loc;
- option i core_type ppf cto;
+ "Pctf_val \"%s\" %a %a %a\n" s
+ fmt_mutable_flag mf fmt_virtual_flag vf fmt_location loc;
+ core_type (i+1) ppf ct;
| Pctf_virt (s, pf, ct, loc) ->
line i ppf
"Pctf_virt \"%s\" %a %a\n" s fmt_private_flag pf fmt_location loc;
@@ -428,6 +429,10 @@
line i ppf "Pcf_inher\n";
class_expr (i+1) ppf ce;
option (i+1) string ppf so;
+ | Pcf_valvirt (s, mf, ct, loc) ->
+ line i ppf
+ "Pcf_valvirt \"%s\" %a %a\n" s fmt_mutable_flag mf fmt_location loc;
+ core_type (i+1) ppf ct;
| Pcf_val (s, mf, e, loc) ->
line i ppf
"Pcf_val \"%s\" %a %a\n" s fmt_mutable_flag mf fmt_location loc;
Index: typing/btype.ml
===================================================================
RCS file: /net/yquem/devel/caml/repository/csl/typing/btype.ml,v
retrieving revision 1.38
diff -u -r1.38 btype.ml
--- typing/btype.ml 4 Jan 2006 16:55:50 -0000 1.38
+++ typing/btype.ml 5 Apr 2006 02:25:59 -0000
@@ -330,7 +330,7 @@
let unmark_class_signature sign =
unmark_type sign.cty_self;
- Vars.iter (fun l (m, t) -> unmark_type t) sign.cty_vars
+ Vars.iter (fun l (m, v, t) -> unmark_type t) sign.cty_vars
let rec unmark_class_type =
function
Index: typing/ctype.ml
===================================================================
RCS file: /net/yquem/devel/caml/repository/csl/typing/ctype.ml,v
retrieving revision 1.200
diff -u -r1.200 ctype.ml
--- typing/ctype.ml 6 Jan 2006 02:16:24 -0000 1.200
+++ typing/ctype.ml 5 Apr 2006 02:25:59 -0000
@@ -857,7 +857,7 @@
Tcty_signature
{cty_self = copy sign.cty_self;
cty_vars =
- Vars.map (function (mut, ty) -> (mut, copy ty)) sign.cty_vars;
+ Vars.map (function (m, v, ty) -> (m, v, copy ty)) sign.cty_vars;
cty_concr = sign.cty_concr;
cty_inher =
List.map (fun (p,tl) -> (p, List.map copy tl)) sign.cty_inher}
@@ -2354,10 +2354,11 @@
| CM_Val_type_mismatch of string * (type_expr * type_expr) list
| CM_Meth_type_mismatch of string * (type_expr * type_expr) list
| CM_Non_mutable_value of string
+ | CM_Non_concrete_value of string
| CM_Missing_value of string
| CM_Missing_method of string
| CM_Hide_public of string
- | CM_Hide_virtual of string
+ | CM_Hide_virtual of string * string
| CM_Public_method of string
| CM_Private_method of string
| CM_Virtual_method of string
@@ -2390,8 +2391,8 @@
end)
pairs;
Vars.iter
- (fun lab (mut, ty) ->
- let (mut', ty') = Vars.find lab sign1.cty_vars in
+ (fun lab (mut, v, ty) ->
+ let (mut', v', ty') = Vars.find lab sign1.cty_vars in
try moregen true type_pairs env ty' ty with Unify trace ->
raise (Failure [CM_Val_type_mismatch
(lab, expand_trace env trace)]))
@@ -2437,7 +2438,7 @@
end
in
if Concr.mem lab sign1.cty_concr then err
- else CM_Hide_virtual lab::err)
+ else CM_Hide_virtual ("method", lab) :: err)
miss1 []
in
let missing_method = List.map (fun (m, _, _) -> m) miss2 in
@@ -2455,11 +2456,13 @@
in
let error =
Vars.fold
- (fun lab (mut, ty) err ->
+ (fun lab (mut, vr, ty) err ->
try
- let (mut', ty') = Vars.find lab sign1.cty_vars in
+ let (mut', vr', ty') = Vars.find lab sign1.cty_vars in
if mut = Mutable && mut' <> Mutable then
CM_Non_mutable_value lab::err
+ else if vr = Concrete && vr' <> Concrete then
+ CM_Non_concrete_value lab::err
else
err
with Not_found ->
@@ -2467,6 +2470,14 @@
sign2.cty_vars error
in
let error =
+ Vars.fold
+ (fun lab (_,vr,_) err ->
+ if vr = Virtual && not (Vars.mem lab sign2.cty_vars) then
+ CM_Hide_virtual ("instance variable", lab) :: err
+ else err)
+ sign1.cty_vars error
+ in
+ let error =
List.fold_right
(fun e l ->
if List.mem e missing_method then l else CM_Virtual_method e::l)
@@ -2516,8 +2527,8 @@
end)
pairs;
Vars.iter
- (fun lab (mut, ty) ->
- let (mut', ty') = Vars.find lab sign1.cty_vars in
+ (fun lab (_, _, ty) ->
+ let (_, _, ty') = Vars.find lab sign1.cty_vars in
try eqtype true type_pairs subst env ty ty' with Unify trace ->
raise (Failure [CM_Val_type_mismatch
(lab, expand_trace env trace)]))
@@ -2554,7 +2565,7 @@
end
in
if Concr.mem lab sign1.cty_concr then err
- else CM_Hide_virtual lab::err)
+ else CM_Hide_virtual ("method", lab) :: err)
miss1 []
in
let missing_method = List.map (fun (m, _, _) -> m) miss2 in
@@ -2578,11 +2589,13 @@
in
let error =
Vars.fold
- (fun lab (mut, ty) err ->
+ (fun lab (mut, vr, ty) err ->
try
- let (mut', ty') = Vars.find lab sign1.cty_vars in
+ let (mut', vr', ty') = Vars.find lab sign1.cty_vars in
if mut = Mutable && mut' <> Mutable then
CM_Non_mutable_value lab::err
+ else if vr = Concrete && vr' <> Concrete then
+ CM_Non_concrete_value lab::err
else
err
with Not_found ->
@@ -2590,6 +2603,14 @@
sign2.cty_vars error
in
let error =
+ Vars.fold
+ (fun lab (_,vr,_) err ->
+ if vr = Virtual && not (Vars.mem lab sign2.cty_vars) then
+ CM_Hide_virtual ("instance variable", lab) :: err
+ else err)
+ sign1.cty_vars error
+ in
+ let error =
List.fold_right
(fun e l ->
if List.mem e missing_method then l else CM_Virtual_method e::l)
@@ -3279,7 +3300,7 @@
let nondep_class_signature env id sign =
{ cty_self = nondep_type_rec env id sign.cty_self;
cty_vars =
- Vars.map (function (m, t) -> (m, nondep_type_rec env id t))
+ Vars.map (function (m, v, t) -> (m, v, nondep_type_rec env id t))
sign.cty_vars;
cty_concr = sign.cty_concr;
cty_inher =
Index: typing/ctype.mli
===================================================================
RCS file: /net/yquem/devel/caml/repository/csl/typing/ctype.mli,v
retrieving revision 1.53
diff -u -r1.53 ctype.mli
--- typing/ctype.mli 9 Dec 2004 12:40:53 -0000 1.53
+++ typing/ctype.mli 5 Apr 2006 02:25:59 -0000
@@ -170,10 +170,11 @@
| CM_Val_type_mismatch of string * (type_expr * type_expr) list
| CM_Meth_type_mismatch of string * (type_expr * type_expr) list
| CM_Non_mutable_value of string
+ | CM_Non_concrete_value of string
| CM_Missing_value of string
| CM_Missing_method of string
| CM_Hide_public of string
- | CM_Hide_virtual of string
+ | CM_Hide_virtual of string * string
| CM_Public_method of string
| CM_Private_method of string
| CM_Virtual_method of string
Index: typing/includeclass.ml
===================================================================
RCS file: /net/yquem/devel/caml/repository/csl/typing/includeclass.ml,v
retrieving revision 1.7
diff -u -r1.7 includeclass.ml
--- typing/includeclass.ml 6 Mar 2000 22:11:57 -0000 1.7
+++ typing/includeclass.ml 5 Apr 2006 02:25:59 -0000
@@ -78,14 +78,17 @@
| CM_Non_mutable_value lab ->
fprintf ppf
"@[The non-mutable instance variable %s cannot become mutable@]" lab
+ | CM_Non_concrete_value lab ->
+ fprintf ppf
+ "@[The virtual instance variable %s cannot become concrete@]" lab
| CM_Missing_value lab ->
fprintf ppf "@[The first class type has no instance variable %s@]" lab
| CM_Missing_method lab ->
fprintf ppf "@[The first class type has no method %s@]" lab
| CM_Hide_public lab ->
fprintf ppf "@[The public method %s cannot be hidden@]" lab
- | CM_Hide_virtual lab ->
- fprintf ppf "@[The virtual method %s cannot be hidden@]" lab
+ | CM_Hide_virtual (k, lab) ->
+ fprintf ppf "@[The virtual %s %s cannot be hidden@]" k lab
| CM_Public_method lab ->
fprintf ppf "@[The public method %s cannot become private" lab
| CM_Virtual_method lab ->
Index: typing/oprint.ml
===================================================================
RCS file: /net/yquem/devel/caml/repository/csl/typing/oprint.ml,v
retrieving revision 1.22
diff -u -r1.22 oprint.ml
--- typing/oprint.ml 23 Mar 2005 03:08:37 -0000 1.22
+++ typing/oprint.ml 5 Apr 2006 02:25:59 -0000
@@ -291,8 +291,10 @@
fprintf ppf "@[<2>method %s%s%s :@ %a@]"
(if priv then "private " else "") (if virt then "virtual " else "")
name !out_type ty
- | Ocsg_value (name, mut, ty) ->
- fprintf ppf "@[<2>val %s%s :@ %a@]" (if mut then "mutable " else "")
+ | Ocsg_value (name, mut, vr, ty) ->
+ fprintf ppf "@[<2>val %s%s%s :@ %a@]"
+ (if mut then "mutable " else "")
+ (if vr then "virtual " else "")
name !out_type ty
let out_class_type = ref print_out_class_type
Index: typing/outcometree.mli
===================================================================
RCS file: /net/yquem/devel/caml/repository/csl/typing/outcometree.mli,v
retrieving revision 1.14
diff -u -r1.14 outcometree.mli
--- typing/outcometree.mli 23 Mar 2005 03:08:37 -0000 1.14
+++ typing/outcometree.mli 5 Apr 2006 02:25:59 -0000
@@ -71,7 +71,7 @@
and out_class_sig_item =
| Ocsg_constraint of out_type * out_type
| Ocsg_method of string * bool * bool * out_type
- | Ocsg_value of string * bool * out_type
+ | Ocsg_value of string * bool * bool * out_type
type out_module_type =
| Omty_abstract
Index: typing/printtyp.ml
===================================================================
RCS file: /net/yquem/devel/caml/repository/csl/typing/printtyp.ml,v
retrieving revision 1.140
diff -u -r1.140 printtyp.ml
--- typing/printtyp.ml 4 Jan 2006 16:55:50 -0000 1.140
+++ typing/printtyp.ml 5 Apr 2006 02:26:00 -0000
@@ -650,7 +650,7 @@
Ctype.flatten_fields (Ctype.object_fields sign.cty_self)
in
List.iter (fun met -> mark_loops (method_type met)) fields;
- Vars.iter (fun _ (_, ty) -> mark_loops ty) sign.cty_vars
+ Vars.iter (fun _ (_, _, ty) -> mark_loops ty) sign.cty_vars
| Tcty_fun (_, ty, cty) ->
mark_loops ty;
prepare_class_type params cty
@@ -682,13 +682,15 @@
csil (tree_of_constraints params)
in
let all_vars =
- Vars.fold (fun l (m, t) all -> (l, m, t) :: all) sign.cty_vars [] in
+ Vars.fold (fun l (m, v, t) all -> (l, m, v, t) :: all) sign.cty_vars []
+ in
(* Consequence of PR#3607: order of Map.fold has changed! *)
let all_vars = List.rev all_vars in
let csil =
List.fold_left
- (fun csil (l, m, t) ->
- Ocsg_value (l, m = Mutable, tree_of_typexp sch t) :: csil)
+ (fun csil (l, m, v, t) ->
+ Ocsg_value (l, m = Mutable, v = Virtual, tree_of_typexp sch t)
+ :: csil)
csil all_vars
in
let csil =
@@ -763,7 +765,9 @@
List.exists
(fun (lab, _, ty) ->
not (lab = dummy_method || Concr.mem lab sign.cty_concr))
- fields in
+ fields
+ || Vars.fold (fun _ (_,vr,_) b -> vr = Virtual || b) sign.cty_vars false
+ in
Osig_class_type
(virt, Ident.name id,
Index: typing/subst.ml
===================================================================
RCS file: /net/yquem/devel/caml/repository/csl/typing/subst.ml,v
retrieving revision 1.49
diff -u -r1.49 subst.ml
--- typing/subst.ml 4 Jan 2006 16:55:50 -0000 1.49
+++ typing/subst.ml 5 Apr 2006 02:26:00 -0000
@@ -178,7 +178,8 @@
let class_signature s sign =
{ cty_self = typexp s sign.cty_self;
- cty_vars = Vars.map (function (m, t) -> (m, typexp s t)) sign.cty_vars;
+ cty_vars =
+ Vars.map (function (m, v, t) -> (m, v, typexp s t)) sign.cty_vars;
cty_concr = sign.cty_concr;
cty_inher =
List.map (fun (p, tl) -> (type_path s p, List.map (typexp s) tl))
Index: typing/typeclass.ml
===================================================================
RCS file: /net/yquem/devel/caml/repository/csl/typing/typeclass.ml,v
retrieving revision 1.85
diff -u -r1.85 typeclass.ml
--- typing/typeclass.ml 22 Jul 2005 06:42:36 -0000 1.85
+++ typing/typeclass.ml 5 Apr 2006 02:26:00 -0000
@@ -24,7 +24,7 @@
type error =
Unconsistent_constraint of (type_expr * type_expr) list
- | Method_type_mismatch of string * (type_expr * type_expr) list
+ | Field_type_mismatch of string * string * (type_expr * type_expr) list
| Structure_expected of class_type
| Cannot_apply of class_type
| Apply_wrong_label of label
@@ -36,7 +36,7 @@
| Unbound_class_type_2 of Longident.t
| Abbrev_type_clash of type_expr * type_expr * type_expr
| Constructor_type_mismatch of string * (type_expr * type_expr) list
- | Virtual_class of bool * string list
+ | Virtual_class of bool * string list * string list
| Parameter_arity_mismatch of Longident.t * int * int
| Parameter_mismatch of (type_expr * type_expr) list
| Bad_parameters of Ident.t * type_expr * type_expr
@@ -49,6 +49,7 @@
| Non_collapsable_conjunction of
Ident.t * Types.class_declaration * (type_expr * type_expr) list
| Final_self_clash of (type_expr * type_expr) list
+ | Mutability_mismatch of string * mutable_flag
exception Error of Location.t * error
@@ -90,7 +91,7 @@
generalize_class_type cty
| Tcty_signature {cty_self = sty; cty_vars = vars; cty_inher = inher} ->
Ctype.generalize sty;
- Vars.iter (fun _ (_, ty) -> Ctype.generalize ty) vars;
+ Vars.iter (fun _ (_, _, ty) -> Ctype.generalize ty) vars;
List.iter (fun (_,tl) -> List.iter Ctype.generalize tl) inher
| Tcty_fun (_, ty, cty) ->
Ctype.generalize ty;
@@ -152,7 +153,7 @@
| Tcty_signature sign ->
Ctype.closed_schema sign.cty_self
&&
- Vars.fold (fun _ (_, ty) cc -> Ctype.closed_schema ty && cc)
+ Vars.fold (fun _ (_, _, ty) cc -> Ctype.closed_schema ty && cc)
sign.cty_vars
true
| Tcty_fun (_, ty, cty) ->
@@ -172,7 +173,7 @@
limited_generalize rv cty
| Tcty_signature sign ->
Ctype.limited_generalize rv sign.cty_self;
- Vars.iter (fun _ (_, ty) -> Ctype.limited_generalize rv ty)
+ Vars.iter (fun _ (_, _, ty) -> Ctype.limited_generalize rv ty)
sign.cty_vars;
List.iter (fun (_, tl) -> List.iter (Ctype.limited_generalize rv) tl)
sign.cty_inher
@@ -201,11 +202,25 @@
Env.add_value id {val_type = ty; val_kind = Val_unbound} par_env)
(* Enter an instance variable in the environment *)
-let enter_val cl_num vars lab mut ty val_env met_env par_env =
- let (id, val_env, met_env, par_env) as result =
- enter_met_env lab (Val_ivar (mut, cl_num)) ty val_env met_env par_env
+let enter_val cl_num vars inh lab mut virt ty val_env met_env par_env loc =
+ let (id, virt) =
+ try
+ let (id, mut', virt', ty') = Vars.find lab !vars in
+ if mut' <> mut then raise (Error(loc, Mutability_mismatch(lab, mut)));
+ Ctype.unify val_env (Ctype.instance ty) (Ctype.instance ty');
+ (if not inh then Some id else None),
+ (if virt' = Concrete then virt' else virt)
+ with
+ Ctype.Unify tr ->
+ raise (Error(loc, Field_type_mismatch("instance variable", lab, tr)))
+ | Not_found -> None, virt
+ in
+ let (id, _, _, _) as result =
+ match id with Some id -> (id, val_env, met_env, par_env)
+ | None ->
+ enter_met_env lab (Val_ivar (mut, cl_num)) ty val_env met_env par_env
in
- vars := Vars.add lab (id, mut, ty) !vars;
+ vars := Vars.add lab (id, mut, virt, ty) !vars;
result
let inheritance self_type env concr_meths warn_meths loc parent =
@@ -218,7 +233,7 @@
with Ctype.Unify trace ->
match trace with
_::_::_::({desc = Tfield(n, _, _, _)}, _)::rem ->
- raise(Error(loc, Method_type_mismatch (n, rem)))
+ raise(Error(loc, Field_type_mismatch ("method", n, rem)))
| _ ->
assert false
end;
@@ -243,7 +258,7 @@
in
let ty = transl_simple_type val_env false sty in
try Ctype.unify val_env ty ty' with Ctype.Unify trace ->
- raise(Error(loc, Method_type_mismatch (lab, trace)))
+ raise(Error(loc, Field_type_mismatch ("method", lab, trace)))
let delayed_meth_specs = ref []
@@ -253,7 +268,7 @@
in
let unif ty =
try Ctype.unify val_env ty ty' with Ctype.Unify trace ->
- raise(Error(loc, Method_type_mismatch (lab, trace)))
+ raise(Error(loc, Field_type_mismatch ("method", lab, trace)))
in
match sty.ptyp_desc, priv with
Ptyp_poly ([],sty), Public ->
@@ -279,6 +294,15 @@
(*******************************)
+let add_val env loc lab (mut, virt, ty) val_sig =
+ let virt =
+ try
+ let (mut', virt', ty') = Vars.find lab val_sig in
+ if virt' = Concrete then virt' else virt
+ with Not_found -> virt
+ in
+ Vars.add lab (mut, virt, ty) val_sig
+
let rec class_type_field env self_type meths (val_sig, concr_meths, inher) =
function
Pctf_inher sparent ->
@@ -293,25 +317,12 @@
parent
in
let val_sig =
- Vars.fold
- (fun lab (mut, ty) val_sig -> Vars.add lab (mut, ty) val_sig)
- cl_sig.cty_vars val_sig
- in
+ Vars.fold (add_val env sparent.pcty_loc) cl_sig.cty_vars val_sig in
(val_sig, concr_meths, inher)
- | Pctf_val (lab, mut, sty_opt, loc) ->
- let (mut, ty) =
- match sty_opt with
- None ->
- let (mut', ty) =
- try Vars.find lab val_sig with Not_found ->
- raise(Error(loc, Unbound_val lab))
- in
- (if mut = Mutable then mut' else Immutable), ty
- | Some sty ->
- mut, transl_simple_type env false sty
- in
- (Vars.add lab (mut, ty) val_sig, concr_meths, inher)
+ | Pctf_val (lab, mut, virt, sty, loc) ->
+ let ty = transl_simple_type env false sty in
+ (add_val env loc lab (mut, virt, ty) val_sig, concr_meths, inher)
| Pctf_virt (lab, priv, sty, loc) ->
declare_method env meths self_type lab priv sty loc;
@@ -397,7 +408,7 @@
let rec class_field cl_num self_type meths vars
(val_env, met_env, par_env, fields, concr_meths, warn_meths,
- inh_vals, inher) =
+ warn_vals, inher) =
function
Pcf_inher (sparent, super) ->
let parent = class_expr cl_num val_env par_env sparent in
@@ -411,18 +422,23 @@
parent.cl_type
in
(* Variables *)
- let (val_env, met_env, par_env, inh_vars, inh_vals) =
+ let (val_env, met_env, par_env, inh_vars, warn_vals) =
Vars.fold
- (fun lab (mut, ty) (val_env, met_env, par_env, inh_vars, inh_vals) ->
+ (fun lab info (val_env, met_env, par_env, inh_vars, warn_vals) ->
+ let mut, vr, ty = info in
let (id, val_env, met_env, par_env) =
- enter_val cl_num vars lab mut ty val_env met_env par_env
+ enter_val cl_num vars true lab mut vr ty val_env met_env par_env
+ sparent.pcl_loc
in
- if StringSet.mem lab inh_vals then
- Location.prerr_warning sparent.pcl_loc
- (Warnings.Hide_instance_variable lab);
- (val_env, met_env, par_env, (lab, id) :: inh_vars,
- StringSet.add lab inh_vals))
- cl_sig.cty_vars (val_env, met_env, par_env, [], inh_vals)
+ let warn_vals =
+ if vr = Virtual then warn_vals else
+ if StringSet.mem lab warn_vals then
+ (Location.prerr_warning sparent.pcl_loc
+ (Warnings.Instance_variable_override lab); warn_vals)
+ else StringSet.add lab warn_vals
+ in
+ (val_env, met_env, par_env, (lab, id) :: inh_vars, warn_vals))
+ cl_sig.cty_vars (val_env, met_env, par_env, [], warn_vals)
in
(* Inherited concrete methods *)
let inh_meths =
@@ -443,11 +459,26 @@
in
(val_env, met_env, par_env,
lazy(Cf_inher (parent, inh_vars, inh_meths))::fields,
- concr_meths, warn_meths, inh_vals, inher)
+ concr_meths, warn_meths, warn_vals, inher)
+
+ | Pcf_valvirt (lab, mut, styp, loc) ->
+ if !Clflags.principal then Ctype.begin_def ();
+ let ty = Typetexp.transl_simple_type val_env false styp in
+ if !Clflags.principal then begin
+ Ctype.end_def ();
+ Ctype.generalize_structure ty
+ end;
+ let (id, val_env, met_env', par_env) =
+ enter_val cl_num vars false lab mut Virtual ty
+ val_env met_env par_env loc
+ in
+ (val_env, met_env', par_env,
+ lazy(Cf_val (lab, id, None, met_env' == met_env)) :: fields,
+ concr_meths, warn_meths, StringSet.remove lab warn_vals, inher)
| Pcf_val (lab, mut, sexp, loc) ->
- if StringSet.mem lab inh_vals then
- Location.prerr_warning loc (Warnings.Hide_instance_variable lab);
+ if StringSet.mem lab warn_vals then
+ Location.prerr_warning loc (Warnings.Instance_variable_override lab);
if !Clflags.principal then Ctype.begin_def ();
let exp =
try type_exp val_env sexp with Ctype.Unify [(ty, _)] ->
@@ -457,17 +488,19 @@
Ctype.end_def ();
Ctype.generalize_structure exp.exp_type
end;
- let (id, val_env, met_env, par_env) =
- enter_val cl_num vars lab mut exp.exp_type val_env met_env par_env
- in
- (val_env, met_env, par_env, lazy(Cf_val (lab, id, exp)) :: fields,
- concr_meths, warn_meths, inh_vals, inher)
+ let (id, val_env, met_env', par_env) =
+ enter_val cl_num vars false lab mut Concrete exp.exp_type
+ val_env met_env par_env loc
+ in
+ (val_env, met_env', par_env,
+ lazy(Cf_val (lab, id, Some exp, met_env' == met_env)) :: fields,
+ concr_meths, warn_meths, StringSet.add lab warn_vals, inher)
| Pcf_virt (lab, priv, sty, loc) ->
virtual_method val_env meths self_type lab priv sty loc;
let warn_meths = Concr.remove lab warn_meths in
(val_env, met_env, par_env, fields, concr_meths, warn_meths,
- inh_vals, inher)
+ warn_vals, inher)
| Pcf_meth (lab, priv, expr, loc) ->
let (_, ty) =
@@ -493,7 +526,7 @@
end
| _ -> assert false
with Ctype.Unify trace ->
- raise(Error(loc, Method_type_mismatch (lab, trace)))
+ raise(Error(loc, Field_type_mismatch ("method", lab, trace)))
end;
let meth_expr = make_method cl_num expr in
(* backup variables for Pexp_override *)
@@ -510,12 +543,12 @@
Cf_meth (lab, texp)
end in
(val_env, met_env, par_env, field::fields,
- Concr.add lab concr_meths, Concr.add lab warn_meths, inh_vals, inher)
+ Concr.add lab concr_meths, Concr.add lab warn_meths, warn_vals, inher)
| Pcf_cstr (sty, sty', loc) ->
type_constraint val_env sty sty' loc;
(val_env, met_env, par_env, fields, concr_meths, warn_meths,
- inh_vals, inher)
+ warn_vals, inher)
| Pcf_let (rec_flag, sdefs, loc) ->
let (defs, val_env) =
@@ -545,7 +578,7 @@
([], met_env, par_env)
in
(val_env, met_env, par_env, lazy(Cf_let(rec_flag, defs, vals))::fields,
- concr_meths, warn_meths, inh_vals, inher)
+ concr_meths, warn_meths, warn_vals, inher)
| Pcf_init expr ->
let expr = make_method cl_num expr in
@@ -562,7 +595,7 @@
Cf_init texp
end in
(val_env, met_env, par_env, field::fields,
- concr_meths, warn_meths, inh_vals, inher)
+ concr_meths, warn_meths, warn_vals, inher)
and class_structure cl_num final val_env met_env loc (spat, str) =
(* Environment for substructures *)
@@ -616,7 +649,7 @@
Ctype.unify val_env self_type (Ctype.newvar ());
let sign =
{cty_self = public_self;
- cty_vars = Vars.map (function (id, mut, ty) -> (mut, ty)) !vars;
+ cty_vars = Vars.map (fun (id, mut, vr, ty) -> (mut, vr, ty)) !vars;
cty_concr = concr_meths;
cty_inher = inher} in
let methods = get_methods self_type in
@@ -628,7 +661,11 @@
be modified after this point *)
Ctype.close_object self_type;
let mets = virtual_methods {sign with cty_self = self_type} in
- if mets <> [] then raise(Error(loc, Virtual_class(true, mets)));
+ let vals =
+ Vars.fold
+ (fun name (mut, vr, ty) l -> if vr = Virtual then name :: l else l)
+ sign.cty_vars [] in
+ if mets <> [] then raise(Error(loc, Virtual_class(true, mets, vals)));
let self_methods =
List.fold_right
(fun (lab,kind,ty) rem ->
@@ -1135,9 +1172,14 @@
in
if cl.pci_virt = Concrete then begin
- match virtual_methods (Ctype.signature_of_class_type typ) with
- [] -> ()
- | mets -> raise(Error(cl.pci_loc, Virtual_class(define_class, mets)))
+ let sign = Ctype.signature_of_class_type typ in
+ let mets = virtual_methods sign in
+ let vals =
+ Vars.fold
+ (fun name (mut, vr, ty) l -> if vr = Virtual then name :: l else l)
+ sign.cty_vars [] in
+ if mets <> [] || vals <> [] then
+ raise(Error(cl.pci_loc, Virtual_class(true, mets, vals)));
end;
(* Misc. *)
@@ -1400,10 +1442,10 @@
Printtyp.report_unification_error ppf trace
(fun ppf -> fprintf ppf "Type")
(fun ppf -> fprintf ppf "is not compatible with type")
- | Method_type_mismatch (m, trace) ->
+ | Field_type_mismatch (k, m, trace) ->
Printtyp.report_unification_error ppf trace
(function ppf ->
- fprintf ppf "The method %s@ has type" m)
+ fprintf ppf "The %s %s@ has type" k m)
(function ppf ->
fprintf ppf "but is expected to have type")
| Structure_expected clty ->
@@ -1451,15 +1493,20 @@
fprintf ppf "The expression \"new %s\" has type" c)
(function ppf ->
fprintf ppf "but is used with type")
- | Virtual_class (cl, mets) ->
+ | Virtual_class (cl, mets, vals) ->
let print_mets ppf mets =
List.iter (function met -> fprintf ppf "@ %s" met) mets in
let cl_mark = if cl then "" else " type" in
+ let missings =
+ match mets, vals with
+ [], _ -> "variables"
+ | _, [] -> "methods"
+ | _ -> "methods and variables"
+ in
fprintf ppf
- "@[This class%s should be virtual@ \
- @[<2>The following methods are undefined :%a@]
- @]"
- cl_mark print_mets mets
+ "@[This class%s should be virtual.@ \
+ @[<2>The following %s are undefined :%a@]@]"
+ cl_mark missings print_mets (mets @ vals)
| Parameter_arity_mismatch(lid, expected, provided) ->
fprintf ppf
"@[The class constructor %a@ expects %i type argument(s),@ \
@@ -1532,3 +1579,10 @@
fprintf ppf "This object is expected to have type")
(function ppf ->
fprintf ppf "but has actually type")
+ | Mutability_mismatch (lab, mut) ->
+ let mut1, mut2 =
+ if mut = Immutable then "mutable", "immutable"
+ else "immutable", "mutable" in
+ fprintf ppf
+ "@[The instance variable is %s,@ it cannot be redefined as %s@]"
+ mut1 mut2
Index: typing/typeclass.mli
===================================================================
RCS file: /net/yquem/devel/caml/repository/csl/typing/typeclass.mli,v
retrieving revision 1.18
diff -u -r1.18 typeclass.mli
--- typing/typeclass.mli 1 Dec 2003 00:32:11 -0000 1.18
+++ typing/typeclass.mli 5 Apr 2006 02:26:00 -0000
@@ -49,7 +49,7 @@
type error =
Unconsistent_constraint of (type_expr * type_expr) list
- | Method_type_mismatch of string * (type_expr * type_expr) list
+ | Field_type_mismatch of string * string * (type_expr * type_expr) list
| Structure_expected of class_type
| Cannot_apply of class_type
| Apply_wrong_label of label
@@ -61,7 +61,7 @@
| Unbound_class_type_2 of Longident.t
| Abbrev_type_clash of type_expr * type_expr * type_expr
| Constructor_type_mismatch of string * (type_expr * type_expr) list
- | Virtual_class of bool * string list
+ | Virtual_class of bool * string list * string list
| Parameter_arity_mismatch of Longident.t * int * int
| Parameter_mismatch of (type_expr * type_expr) list
| Bad_parameters of Ident.t * type_expr * type_expr
@@ -74,6 +74,7 @@
| Non_collapsable_conjunction of
Ident.t * Types.class_declaration * (type_expr * type_expr) list
| Final_self_clash of (type_expr * type_expr) list
+ | Mutability_mismatch of string * mutable_flag
exception Error of Location.t * error
Index: typing/typecore.ml
===================================================================
RCS file: /net/yquem/devel/caml/repository/csl/typing/typecore.ml,v
retrieving revision 1.178
diff -u -r1.178 typecore.ml
--- typing/typecore.ml 6 Jan 2006 02:25:37 -0000 1.178
+++ typing/typecore.ml 5 Apr 2006 02:26:00 -0000
@@ -611,11 +611,11 @@
List.for_all
(function
Cf_meth _ -> true
- | Cf_val (_,_,e) -> incr count; is_nonexpansive e
+ | Cf_val (_,_,e,_) -> incr count; is_nonexpansive_opt e
| Cf_init e -> is_nonexpansive e
| Cf_inher _ | Cf_let _ -> false)
fields &&
- Vars.fold (fun _ (mut,_) b -> decr count; b && mut = Immutable)
+ Vars.fold (fun _ (mut,_,_) b -> decr count; b && mut = Immutable)
vars true &&
!count = 0
| _ -> false
@@ -1356,7 +1356,7 @@
(path_self, _) ->
let type_override (lab, snewval) =
begin try
- let (id, _, ty) = Vars.find lab !vars in
+ let (id, _, _, ty) = Vars.find lab !vars in
(Path.Pident id, type_expect env snewval (instance ty))
with
Not_found ->
Index: typing/typecore.mli
===================================================================
RCS file: /net/yquem/devel/caml/repository/csl/typing/typecore.mli,v
retrieving revision 1.37
diff -u -r1.37 typecore.mli
--- typing/typecore.mli 4 Mar 2005 14:51:31 -0000 1.37
+++ typing/typecore.mli 5 Apr 2006 02:26:00 -0000
@@ -38,7 +38,8 @@
string -> type_expr -> Env.t -> Env.t -> Env.t -> Parsetree.pattern ->
Typedtree.pattern *
(Ident.t * type_expr) Meths.t ref *
- (Ident.t * Asttypes.mutable_flag * type_expr) Vars.t ref *
+ (Ident.t * Asttypes.mutable_flag * Asttypes.virtual_flag * type_expr)
+ Vars.t ref *
Env.t * Env.t * Env.t
val type_expect:
?in_function:(Location.t * type_expr) ->
Index: typing/typedtree.ml
===================================================================
RCS file: /net/yquem/devel/caml/repository/csl/typing/typedtree.ml,v
retrieving revision 1.36
diff -u -r1.36 typedtree.ml
--- typing/typedtree.ml 25 Nov 2003 09:20:43 -0000 1.36
+++ typing/typedtree.ml 5 Apr 2006 02:26:00 -0000
@@ -106,7 +106,7 @@
and class_field =
Cf_inher of class_expr * (string * Ident.t) list * (string * Ident.t) list
- | Cf_val of string * Ident.t * expression
+ | Cf_val of string * Ident.t * expression option * bool
| Cf_meth of string * expression
| Cf_let of rec_flag * (pattern * expression) list *
(Ident.t * expression) list
@@ -140,7 +140,8 @@
| Tstr_recmodule of (Ident.t * module_expr) list
| Tstr_modtype of Ident.t * module_type
| Tstr_open of Path.t
- | Tstr_class of (Ident.t * int * string list * class_expr) list
+ | Tstr_class of
+ (Ident.t * int * string list * class_expr * virtual_flag) list
| Tstr_cltype of (Ident.t * cltype_declaration) list
| Tstr_include of module_expr * Ident.t list
Index: typing/typedtree.mli
===================================================================
RCS file: /net/yquem/devel/caml/repository/csl/typing/typedtree.mli,v
retrieving revision 1.34
diff -u -r1.34 typedtree.mli
--- typing/typedtree.mli 25 Nov 2003 09:20:43 -0000 1.34
+++ typing/typedtree.mli 5 Apr 2006 02:26:00 -0000
@@ -107,7 +107,8 @@
and class_field =
Cf_inher of class_expr * (string * Ident.t) list * (string * Ident.t) list
(* Inherited instance variables and concrete methods *)
- | Cf_val of string * Ident.t * expression
+ | Cf_val of string * Ident.t * expression option * bool
+ (* None = virtual, true = override *)
| Cf_meth of string * expression
| Cf_let of rec_flag * (pattern * expression) list *
(Ident.t * expression) list
@@ -141,7 +142,8 @@
| Tstr_recmodule of (Ident.t * module_expr) list
| Tstr_modtype of Ident.t * module_type
| Tstr_open of Path.t
- | Tstr_class of (Ident.t * int * string list * class_expr) list
+ | Tstr_class of
+ (Ident.t * int * string list * class_expr * virtual_flag) list
| Tstr_cltype of (Ident.t * cltype_declaration) list
| Tstr_include of module_expr * Ident.t list
Index: typing/typemod.ml
===================================================================
RCS file: /net/yquem/devel/caml/repository/csl/typing/typemod.ml,v
retrieving revision 1.73
diff -u -r1.73 typemod.ml
--- typing/typemod.ml 8 Aug 2005 09:41:51 -0000 1.73
+++ typing/typemod.ml 5 Apr 2006 02:26:00 -0000
@@ -17,6 +17,7 @@
open Misc
open Longident
open Path
+open Asttypes
open Parsetree
open Types
open Typedtree
@@ -667,8 +668,9 @@
let (classes, new_env) = Typeclass.class_declarations env cl in
let (str_rem, sig_rem, final_env) = type_struct new_env srem in
(Tstr_class
- (List.map (fun (i, _,_,_,_,_,_,_, s, m, c) ->
- (i, s, m, c)) classes) ::
+ (List.map (fun (i, d, _,_,_,_,_,_, s, m, c) ->
+ let vf = if d.cty_new = None then Virtual else Concrete in
+ (i, s, m, c, vf)) classes) ::
Tstr_cltype
(List.map (fun (_,_, i, d, _,_,_,_,_,_,_) -> (i, d)) classes) ::
Tstr_type
Index: typing/types.ml
===================================================================
RCS file: /net/yquem/devel/caml/repository/csl/typing/types.ml,v
retrieving revision 1.25
diff -u -r1.25 types.ml
--- typing/types.ml 9 Dec 2004 12:40:53 -0000 1.25
+++ typing/types.ml 5 Apr 2006 02:26:00 -0000
@@ -90,7 +90,8 @@
| Val_prim of Primitive.description (* Primitive *)
| Val_ivar of mutable_flag * string (* Instance variable (mutable ?) *)
| Val_self of (Ident.t * type_expr) Meths.t ref *
- (Ident.t * Asttypes.mutable_flag * type_expr) Vars.t ref *
+ (Ident.t * Asttypes.mutable_flag *
+ Asttypes.virtual_flag * type_expr) Vars.t ref *
string * type_expr
(* Self *)
| Val_anc of (string * Ident.t) list * string
@@ -156,7 +157,8 @@
and class_signature =
{ cty_self: type_expr;
- cty_vars: (Asttypes.mutable_flag * type_expr) Vars.t;
+ cty_vars:
+ (Asttypes.mutable_flag * Asttypes.virtual_flag * type_expr) Vars.t;
cty_concr: Concr.t;
cty_inher: (Path.t * type_expr list) list }
Index: typing/types.mli
===================================================================
RCS file: /net/yquem/devel/caml/repository/csl/typing/types.mli,v
retrieving revision 1.25
diff -u -r1.25 types.mli
--- typing/types.mli 9 Dec 2004 12:40:53 -0000 1.25
+++ typing/types.mli 5 Apr 2006 02:26:00 -0000
@@ -91,7 +91,8 @@
| Val_prim of Primitive.description (* Primitive *)
| Val_ivar of mutable_flag * string (* Instance variable (mutable ?) *)
| Val_self of (Ident.t * type_expr) Meths.t ref *
- (Ident.t * Asttypes.mutable_flag * type_expr) Vars.t ref *
+ (Ident.t * Asttypes.mutable_flag *
+ Asttypes.virtual_flag * type_expr) Vars.t ref *
string * type_expr
(* Self *)
| Val_anc of (string * Ident.t) list * string
@@ -158,7 +159,8 @@
and class_signature =
{ cty_self: type_expr;
- cty_vars: (Asttypes.mutable_flag * type_expr) Vars.t;
+ cty_vars:
+ (Asttypes.mutable_flag * Asttypes.virtual_flag * type_expr) Vars.t;
cty_concr: Concr.t;
cty_inher: (Path.t * type_expr list) list }
Index: typing/unused_var.ml
===================================================================
RCS file: /net/yquem/devel/caml/repository/csl/typing/unused_var.ml,v
retrieving revision 1.5
diff -u -r1.5 unused_var.ml
--- typing/unused_var.ml 4 Jan 2006 16:55:50 -0000 1.5
+++ typing/unused_var.ml 5 Apr 2006 02:26:00 -0000
@@ -245,7 +245,7 @@
match cf with
| Pcf_inher (ce, _) -> class_expr ppf tbl ce;
| Pcf_val (_, _, e, _) -> expression ppf tbl e;
- | Pcf_virt _ -> ()
+ | Pcf_virt _ | Pcf_valvirt _ -> ()
| Pcf_meth (_, _, e, _) -> expression ppf tbl e;
| Pcf_cstr _ -> ()
| Pcf_let (recflag, pel, _) -> let_pel ppf tbl recflag pel None;
Index: bytecomp/translclass.ml
===================================================================
RCS file: /net/yquem/devel/caml/repository/csl/bytecomp/translclass.ml,v
retrieving revision 1.38
diff -u -r1.38 translclass.ml
--- bytecomp/translclass.ml 13 Aug 2005 20:59:37 -0000 1.38
+++ bytecomp/translclass.ml 5 Apr 2006 02:26:00 -0000
@@ -133,10 +133,10 @@
(fun _ -> lambda_unit) cl
in
(inh_init, lsequence obj_init' obj_init, true)
- | Cf_val (_, id, exp) ->
+ | Cf_val (_, id, Some exp, _) ->
(inh_init, lsequence (set_inst_var obj id exp) obj_init,
has_init)
- | Cf_meth _ ->
+ | Cf_meth _ | Cf_val _ ->
(inh_init, obj_init, has_init)
| Cf_init _ ->
(inh_init, obj_init, true)
@@ -213,27 +213,17 @@
if len < 2 && nvals = 0 then Meths.fold (bind_method tbl) meths cl_init else
if len = 0 && nvals < 2 then transl_vals tbl true vals cl_init else
let ids = Ident.create "ids" in
- let i = ref len in
- let getter, names, cl_init =
- match vals with [] -> "get_method_labels", [], cl_init
- | (_,id0)::vals' ->
- incr i;
- let i = ref (List.length vals) in
- "new_methods_variables",
- [transl_meth_list (List.map fst vals)],
- Llet(Strict, id0, lfield ids 0,
- List.fold_right
- (fun (name,id) rem ->
- decr i;
- Llet(Alias, id, Lprim(Poffsetint !i, [Lvar id0]), rem))
- vals' cl_init)
+ let i = ref (len + nvals) in
+ let getter, names =
+ if nvals = 0 then "get_method_labels", [] else
+ "new_methods_variables", [transl_meth_list (List.map fst vals)]
in
Llet(StrictOpt, ids,
Lapply (oo_prim getter,
[Lvar tbl; transl_meth_list (List.map fst methl)] @ names),
List.fold_right
(fun (lab,id) lam -> decr i; Llet(StrictOpt, id, lfield ids !i, lam))
- methl cl_init)
+ (methl @ vals) cl_init)
let output_methods tbl methods lam =
match methods with
@@ -283,8 +273,9 @@
(vals, meths_super cla str.cl_meths meths)
inh_init cl_init msubst top cl in
(inh_init, cl_init, [], values)
- | Cf_val (name, id, exp) ->
- (inh_init, cl_init, methods, (name, id)::values)
+ | Cf_val (name, id, exp, over) ->
+ let values = if over then values else (name, id) :: values in
+ (inh_init, cl_init, methods, values)
| Cf_meth (name, exp) ->
let met_code = msubst true (transl_exp exp) in
let met_code =
@@ -342,27 +333,24 @@
assert (Path.same path path');
let lpath = transl_path path in
let inh = Ident.create "inh"
- and inh_vals = Ident.create "vals"
- and inh_meths = Ident.create "meths"
+ and ofs = List.length vals + 1
and valids, methids = super in
let cl_init =
List.fold_left
(fun init (nm, id, _) ->
- Llet(StrictOpt, id, lfield inh_meths (index nm concr_meths),
+ Llet(StrictOpt, id, lfield inh (index nm concr_meths + ofs),
init))
cl_init methids in
let cl_init =
List.fold_left
(fun init (nm, id) ->
- Llet(StrictOpt, id, lfield inh_vals (index nm vals), init))
+ Llet(StrictOpt, id, lfield inh (index nm vals + 1), init))
cl_init valids in
(inh_init,
Llet (Strict, inh,
Lapply(oo_prim "inherits", narrow_args @
[lpath; Lconst(Const_pointer(if top then 1 else 0))]),
- Llet(StrictOpt, obj_init, lfield inh 0,
- Llet(Alias, inh_vals, lfield inh 1,
- Llet(Alias, inh_meths, lfield inh 2, cl_init)))))
+ Llet(StrictOpt, obj_init, lfield inh 0, cl_init)))
| _ ->
let core cl_init =
build_class_init cla true super inh_init cl_init msubst top cl
@@ -397,12 +385,16 @@
XXX Il devrait etre peu couteux d'ecrire des classes :
class c x y = d e f
*)
-let rec transl_class_rebind obj_init cl =
+let rec transl_class_rebind obj_init cl vf =
match cl.cl_desc with
Tclass_ident path ->
+ if vf = Concrete then begin
+ try if (Env.find_class path cl.cl_env).cty_new = None then raise Exit
+ with Not_found -> raise Exit
+ end;
(path, obj_init)
| Tclass_fun (pat, _, cl, partial) ->
- let path, obj_init = transl_class_rebind obj_init cl in
+ let path, obj_init = transl_class_rebind obj_init cl vf in
let build params rem =
let param = name_pattern "param" [pat, ()] in
Lfunction (Curried, param::params,
@@ -414,14 +406,14 @@
Lfunction (Curried, params, rem) -> build params rem
| rem -> build [] rem)
| Tclass_apply (cl, oexprs) ->
- let path, obj_init = transl_class_rebind obj_init cl in
+ let path, obj_init = transl_class_rebind obj_init cl vf in
(path, transl_apply obj_init oexprs)
| Tclass_let (rec_flag, defs, vals, cl) ->
- let path, obj_init = transl_class_rebind obj_init cl in
+ let path, obj_init = transl_class_rebind obj_init cl vf in
(path, Translcore.transl_let rec_flag defs obj_init)
| Tclass_structure _ -> raise Exit
| Tclass_constraint (cl', _, _, _) ->
- let path, obj_init = transl_class_rebind obj_init cl' in
+ let path, obj_init = transl_class_rebind obj_init cl' vf in
let rec check_constraint = function
Tcty_constr(path', _, _) when Path.same path path' -> ()
| Tcty_fun (_, _, cty) -> check_constraint cty
@@ -430,21 +422,21 @@
check_constraint cl.cl_type;
(path, obj_init)
-let rec transl_class_rebind_0 self obj_init cl =
+let rec transl_class_rebind_0 self obj_init cl vf =
match cl.cl_desc with
Tclass_let (rec_flag, defs, vals, cl) ->
- let path, obj_init = transl_class_rebind_0 self obj_init cl in
+ let path, obj_init = transl_class_rebind_0 self obj_init cl vf in
(path, Translcore.transl_let rec_flag defs obj_init)
| _ ->
- let path, obj_init = transl_class_rebind obj_init cl in
+ let path, obj_init = transl_class_rebind obj_init cl vf in
(path, lfunction [self] obj_init)
-let transl_class_rebind ids cl =
+let transl_class_rebind ids cl vf =
try
let obj_init = Ident.create "obj_init"
and self = Ident.create "self" in
let obj_init0 = lapply (Lvar obj_init) [Lvar self] in
- let path, obj_init' = transl_class_rebind_0 self obj_init0 cl in
+ let path, obj_init' = transl_class_rebind_0 self obj_init0 cl vf in
if not (Translcore.check_recursive_lambda ids obj_init') then
raise(Error(cl.cl_loc, Illegal_class_expr));
let id = (obj_init' = lfunction [self] obj_init0) in
@@ -592,9 +584,9 @@
*)
-let transl_class ids cl_id arity pub_meths cl =
+let transl_class ids cl_id arity pub_meths cl vflag =
(* First check if it is not only a rebind *)
- let rebind = transl_class_rebind ids cl in
+ let rebind = transl_class_rebind ids cl vflag in
if rebind <> lambda_unit then rebind else
(* Prepare for heavy environment handling *)
@@ -696,9 +688,7 @@
(* Simplest case: an object defined at toplevel (ids=[]) *)
if top && ids = [] then llets (ltable cla (ldirect obj_init)) else
- let concrete =
- ids = [] ||
- Typeclass.virtual_methods (Ctype.signature_of_class_type cl.cl_type) = []
+ let concrete = (vflag = Concrete)
and lclass lam =
let cl_init = llets (Lfunction(Curried, [cla], cl_init)) in
Llet(Strict, class_init, cl_init, lam (free_variables cl_init))
@@ -800,11 +790,11 @@
(* Wrapper for class compilation *)
-let transl_class ids cl_id arity pub_meths cl =
- oo_wrap cl.cl_env false (transl_class ids cl_id arity pub_meths) cl
+let transl_class ids cl_id arity pub_meths cl vf =
+ oo_wrap cl.cl_env false (transl_class ids cl_id arity pub_meths cl) vf
let () =
- transl_object := (fun id meths cl -> transl_class [] id 0 meths cl)
+ transl_object := (fun id meths cl -> transl_class [] id 0 meths cl Concrete)
(* Error report *)
Index: bytecomp/translclass.mli
===================================================================
RCS file: /net/yquem/devel/caml/repository/csl/bytecomp/translclass.mli,v
retrieving revision 1.11
diff -u -r1.11 translclass.mli
--- bytecomp/translclass.mli 12 Aug 2004 12:55:11 -0000 1.11
+++ bytecomp/translclass.mli 5 Apr 2006 02:26:00 -0000
@@ -16,7 +16,8 @@
open Lambda
val transl_class :
- Ident.t list -> Ident.t -> int -> string list -> class_expr -> lambda;;
+ Ident.t list -> Ident.t ->
+ int -> string list -> class_expr -> Asttypes.virtual_flag -> lambda;;
type error = Illegal_class_expr | Tags of string * string
Index: bytecomp/translmod.ml
===================================================================
RCS file: /net/yquem/devel/caml/repository/csl/bytecomp/translmod.ml,v
retrieving revision 1.51
diff -u -r1.51 translmod.ml
--- bytecomp/translmod.ml 12 Aug 2004 12:55:11 -0000 1.51
+++ bytecomp/translmod.ml 5 Apr 2006 02:26:00 -0000
@@ -317,10 +317,10 @@
| Tstr_open path :: rem ->
transl_structure fields cc rootpath rem
| Tstr_class cl_list :: rem ->
- let ids = List.map (fun (i, _, _, _) -> i) cl_list in
+ let ids = List.map (fun (i, _, _, _, _) -> i) cl_list in
Lletrec(List.map
- (fun (id, arity, meths, cl) ->
- (id, transl_class ids id arity meths cl))
+ (fun (id, arity, meths, cl, vf) ->
+ (id, transl_class ids id arity meths cl vf))
cl_list,
transl_structure (List.rev ids @ fields) cc rootpath rem)
| Tstr_cltype cl_list :: rem ->
@@ -414,11 +414,11 @@
| Tstr_open path :: rem ->
transl_store subst rem
| Tstr_class cl_list :: rem ->
- let ids = List.map (fun (i, _, _, _) -> i) cl_list in
+ let ids = List.map (fun (i, _, _, _, _) -> i) cl_list in
let lam =
Lletrec(List.map
- (fun (id, arity, meths, cl) ->
- (id, transl_class ids id arity meths cl))
+ (fun (id, arity, meths, cl, vf) ->
+ (id, transl_class ids id arity meths cl vf))
cl_list,
store_idents ids) in
Lsequence(subst_lambda subst lam,
@@ -485,7 +485,7 @@
| Tstr_modtype(id, decl) :: rem -> defined_idents rem
| Tstr_open path :: rem -> defined_idents rem
| Tstr_class cl_list :: rem ->
- List.map (fun (i, _, _, _) -> i) cl_list @ defined_idents rem
+ List.map (fun (i, _, _, _, _) -> i) cl_list @ defined_idents rem
| Tstr_cltype cl_list :: rem -> defined_idents rem
| Tstr_include(modl, ids) :: rem -> ids @ defined_idents rem
@@ -603,14 +603,14 @@
| Tstr_class cl_list ->
(* we need to use unique names for the classes because there might
be a value named identically *)
- let ids = List.map (fun (i, _, _, _) -> i) cl_list in
+ let ids = List.map (fun (i, _, _, _, _) -> i) cl_list in
List.iter set_toplevel_unique_name ids;
Lletrec(List.map
- (fun (id, arity, meths, cl) ->
- (id, transl_class ids id arity meths cl))
+ (fun (id, arity, meths, cl, vf) ->
+ (id, transl_class ids id arity meths cl vf))
cl_list,
make_sequence
- (fun (id, _, _, _) -> toploop_setvalue_id id)
+ (fun (id, _, _, _, _) -> toploop_setvalue_id id)
cl_list)
| Tstr_cltype cl_list ->
lambda_unit
Index: driver/main_args.ml
===================================================================
RCS file: /net/yquem/devel/caml/repository/csl/driver/main_args.ml,v
retrieving revision 1.48
diff -u -r1.48 main_args.ml
--- driver/main_args.ml 4 Jan 2006 16:55:49 -0000 1.48
+++ driver/main_args.ml 5 Apr 2006 02:26:00 -0000
@@ -136,11 +136,11 @@
\032 E/e enable/disable fragile match\n\
\032 F/f enable/disable partially applied function\n\
\032 L/l enable/disable labels omitted in application\n\
- \032 M/m enable/disable overridden method\n\
+ \032 M/m enable/disable overridden methods\n\
\032 P/p enable/disable partial match\n\
\032 S/s enable/disable non-unit statement\n\
\032 U/u enable/disable unused match case\n\
- \032 V/v enable/disable hidden instance variable\n\
+ \032 V/v enable/disable overridden instance variables\n\
\032 Y/y enable/disable suspicious unused variables\n\
\032 Z/z enable/disable all other unused variables\n\
\032 X/x enable/disable all other warnings\n\
Index: driver/optmain.ml
===================================================================
RCS file: /net/yquem/devel/caml/repository/csl/driver/optmain.ml,v
retrieving revision 1.87
diff -u -r1.87 optmain.ml
--- driver/optmain.ml 4 Jan 2006 16:55:49 -0000 1.87
+++ driver/optmain.ml 5 Apr 2006 02:26:00 -0000
@@ -173,7 +173,7 @@
\032 P/p enable/disable partial match\n\
\032 S/s enable/disable non-unit statement\n\
\032 U/u enable/disable unused match case\n\
- \032 V/v enable/disable hidden instance variables\n\
+ \032 V/v enable/disable overridden instance variables\n\
\032 Y/y enable/disable suspicious unused variables\n\
\032 Z/z enable/disable all other unused variables\n\
\032 X/x enable/disable all other warnings\n\
Index: stdlib/camlinternalOO.ml
===================================================================
RCS file: /net/yquem/devel/caml/repository/csl/stdlib/camlinternalOO.ml,v
retrieving revision 1.14
diff -u -r1.14 camlinternalOO.ml
--- stdlib/camlinternalOO.ml 25 Oct 2005 18:34:07 -0000 1.14
+++ stdlib/camlinternalOO.ml 5 Apr 2006 02:26:00 -0000
@@ -206,7 +206,11 @@
(table.methods_by_name, table.methods_by_label, table.hidden_meths,
table.vars, virt_meth_labs, vars)
:: table.previous_states;
- table.vars <- Vars.empty;
+ table.vars <-
+ Vars.fold
+ (fun lab info tvars ->
+ if List.mem lab vars then Vars.add lab info tvars else tvars)
+ table.vars Vars.empty;
let by_name = ref Meths.empty in
let by_label = ref Labs.empty in
List.iter2
@@ -255,9 +259,11 @@
index
let new_variable table name =
- let index = new_slot table in
- table.vars <- Vars.add name index table.vars;
- index
+ try Vars.find name table.vars
+ with Not_found ->
+ let index = new_slot table in
+ table.vars <- Vars.add name index table.vars;
+ index
let to_array arr =
if arr = Obj.magic 0 then [||] else arr
@@ -265,16 +271,17 @@
let new_methods_variables table meths vals =
let meths = to_array meths in
let nmeths = Array.length meths and nvals = Array.length vals in
- let index = new_variable table vals.(0) in
- let res = Array.create (nmeths + 1) index in
- for i = 1 to nvals - 1 do ignore (new_variable table vals.(i)) done;
+ let res = Array.create (nmeths + nvals) 0 in
for i = 0 to nmeths - 1 do
- res.(i+1) <- get_method_label table meths.(i)
+ res.(i) <- get_method_label table meths.(i)
+ done;
+ for i = 0 to nvals - 1 do
+ res.(i+nmeths) <- new_variable table vals.(i)
done;
res
let get_variable table name =
- Vars.find name table.vars
+ try Vars.find name table.vars with Not_found -> assert false
let get_variables table names =
Array.map (get_variable table) names
@@ -315,9 +322,12 @@
let init =
if top then super cla env else Obj.repr (super cla) in
widen cla;
- (init, Array.map (get_variable cla) (to_array vals),
- Array.map (fun nm -> get_method cla (get_method_label cla nm))
- (to_array concr_meths))
+ Array.concat
+ [[| repr init |];
+ magic (Array.map (get_variable cla) (to_array vals) : int array);
+ Array.map
+ (fun nm -> repr (get_method cla (get_method_label cla nm) : closure))
+ (to_array concr_meths) ]
let make_class pub_meths class_init =
let table = create_table pub_meths in
Index: stdlib/camlinternalOO.mli
===================================================================
RCS file: /net/yquem/devel/caml/repository/csl/stdlib/camlinternalOO.mli,v
retrieving revision 1.9
diff -u -r1.9 camlinternalOO.mli
--- stdlib/camlinternalOO.mli 25 Oct 2005 18:34:07 -0000 1.9
+++ stdlib/camlinternalOO.mli 5 Apr 2006 02:26:00 -0000
@@ -46,8 +46,7 @@
val init_class : table -> unit
val inherits :
table -> string array -> string array -> string array ->
- (t * (table -> obj -> Obj.t) * t * obj) -> bool ->
- (Obj.t * int array * closure array)
+ (t * (table -> obj -> Obj.t) * t * obj) -> bool -> Obj.t array
val make_class :
string array -> (table -> Obj.t -> t) ->
(t * (table -> Obj.t -> t) * (Obj.t -> t) * Obj.t)
@@ -79,6 +78,7 @@
(** {6 Builtins to reduce code size} *)
+(*
val get_const : t -> closure
val get_var : int -> closure
val get_env : int -> int -> closure
@@ -103,6 +103,7 @@
val send_var : tag -> int -> int -> closure
val send_env : tag -> int -> int -> int -> closure
val send_meth : tag -> label -> int -> closure
+*)
type impl =
GetConst
Index: stdlib/sys.ml
===================================================================
RCS file: /net/yquem/devel/caml/repository/csl/stdlib/sys.ml,v
retrieving revision 1.142
diff -u -r1.142 sys.ml
--- stdlib/sys.ml 22 Mar 2006 12:39:39 -0000 1.142
+++ stdlib/sys.ml 5 Apr 2006 02:26:00 -0000
@@ -78,4 +78,4 @@
(* OCaml version string, must be in the format described in sys.mli. *)
-let ocaml_version = "3.10+dev4 (2006-03-22)";;
+let ocaml_version = "3.10+dev5 (2006-04-05)";;
Index: tools/depend.ml
===================================================================
RCS file: /net/yquem/devel/caml/repository/csl/tools/depend.ml,v
retrieving revision 1.9
diff -u -r1.9 depend.ml
--- tools/depend.ml 23 Mar 2005 03:08:37 -0000 1.9
+++ tools/depend.ml 5 Apr 2006 02:26:00 -0000
@@ -87,7 +87,7 @@
and add_class_type_field bv = function
Pctf_inher cty -> add_class_type bv cty
- | Pctf_val(_, _, oty, _) -> add_opt add_type bv oty
+ | Pctf_val(_, _, _, ty, _) -> add_type bv ty
| Pctf_virt(_, _, ty, _) -> add_type bv ty
| Pctf_meth(_, _, ty, _) -> add_type bv ty
| Pctf_cstr(ty1, ty2, _) -> add_type bv ty1; add_type bv ty2
@@ -280,6 +280,7 @@
and add_class_field bv = function
Pcf_inher(ce, _) -> add_class_expr bv ce
| Pcf_val(_, _, e, _) -> add_expr bv e
+ | Pcf_valvirt(_, _, ty, _)
| Pcf_virt(_, _, ty, _) -> add_type bv ty
| Pcf_meth(_, _, e, _) -> add_expr bv e
| Pcf_cstr(ty1, ty2, _) -> add_type bv ty1; add_type bv ty2
Index: tools/ocamlprof.ml
===================================================================
RCS file: /net/yquem/devel/caml/repository/csl/tools/ocamlprof.ml,v
retrieving revision 1.38
diff -u -r1.38 ocamlprof.ml
--- tools/ocamlprof.ml 24 Mar 2005 17:20:54 -0000 1.38
+++ tools/ocamlprof.ml 5 Apr 2006 02:26:00 -0000
@@ -328,7 +328,7 @@
rewrite_patexp_list iflag spat_sexp_list
| Pcf_init sexp ->
rewrite_exp iflag sexp
- | Pcf_virt _ | Pcf_cstr _ -> ()
+ | Pcf_valvirt _ | Pcf_virt _ | Pcf_cstr _ -> ()
and rewrite_class_expr iflag cexpr =
match cexpr.pcl_desc with
Index: otherlibs/labltk/browser/searchpos.ml
===================================================================
RCS file: /net/yquem/devel/caml/repository/csl/otherlibs/labltk/browser/searchpos.ml,v
retrieving revision 1.48
diff -u -r1.48 searchpos.ml
--- otherlibs/labltk/browser/searchpos.ml 23 Mar 2005 03:08:37 -0000 1.48
+++ otherlibs/labltk/browser/searchpos.ml 5 Apr 2006 02:26:01 -0000
@@ -141,9 +141,8 @@
List.iter cfl ~f:
begin function
Pctf_inher cty -> search_pos_class_type cty ~pos ~env
- | Pctf_val (_, _, Some ty, loc) ->
+ | Pctf_val (_, _, _, ty, loc) ->
if in_loc loc ~pos then search_pos_type ty ~pos ~env
- | Pctf_val _ -> ()
| Pctf_virt (_, _, ty, loc) ->
if in_loc loc ~pos then search_pos_type ty ~pos ~env
| Pctf_meth (_, _, ty, loc) ->
@@ -675,7 +674,7 @@
| Tstr_modtype _ -> ()
| Tstr_open _ -> ()
| Tstr_class l ->
- List.iter l ~f:(fun (id, _, _, cl) -> search_pos_class_expr cl ~pos)
+ List.iter l ~f:(fun (id, _, _, cl, _) -> search_pos_class_expr cl ~pos)
| Tstr_cltype _ -> ()
| Tstr_include (m, _) -> search_pos_module_expr m ~pos
end
@@ -685,7 +684,8 @@
begin function
Cf_inher (cl, _, _) ->
search_pos_class_expr cl ~pos
- | Cf_val (_, _, exp) -> search_pos_expr exp ~pos
+ | Cf_val (_, _, Some exp, _) -> search_pos_expr exp ~pos
+ | Cf_val _ -> ()
| Cf_meth (_, exp) -> search_pos_expr exp ~pos
| Cf_let (_, pel, iel) ->
List.iter pel ~f:
Index: ocamldoc/Makefile
===================================================================
RCS file: /net/yquem/devel/caml/repository/csl/ocamldoc/Makefile,v
retrieving revision 1.61
diff -u -r1.61 Makefile
--- ocamldoc/Makefile 4 Jan 2006 16:55:49 -0000 1.61
+++ ocamldoc/Makefile 5 Apr 2006 02:26:01 -0000
@@ -31,7 +31,7 @@
MKDIR=mkdir -p
CP=cp -f
OCAMLDOC=ocamldoc
-OCAMLDOC_RUN=sh ./runocamldoc $(SUPPORTS_SHARED_LIBRARIES)
+OCAMLDOC_RUN=./ocamldoc.opt #sh ./runocamldoc $(SUPPORTS_SHARED_LIBRARIES)
OCAMLDOC_OPT=$(OCAMLDOC).opt
OCAMLDOC_LIBCMA=odoc_info.cma
OCAMLDOC_LIBCMI=odoc_info.cmi
@@ -188,12 +188,12 @@
../otherlibs/num/num.mli
all: exe lib
- $(MAKE) manpages
exe: $(OCAMLDOC)
lib: $(OCAMLDOC_LIBCMA) $(OCAMLDOC_LIBCMI) $(ODOC_TEST)
opt.opt: exeopt libopt
+ $(MAKE) manpages
exeopt: $(OCAMLDOC_OPT)
libopt: $(OCAMLDOC_LIBCMXA) $(OCAMLDOC_LIBCMI)
debug:
Index: ocamldoc/odoc_ast.ml
===================================================================
RCS file: /net/yquem/devel/caml/repository/csl/ocamldoc/odoc_ast.ml,v
retrieving revision 1.27
diff -u -r1.27 odoc_ast.ml
--- ocamldoc/odoc_ast.ml 4 Jan 2006 16:55:49 -0000 1.27
+++ ocamldoc/odoc_ast.ml 5 Apr 2006 02:26:01 -0000
@@ -88,7 +88,7 @@
ident_type_decl_list
| Typedtree.Tstr_class info_list ->
List.iter
- (fun ((id,_,_,_) as ci) ->
+ (fun ((id,_,_,_,_) as ci) ->
Hashtbl.add table (C (Name.from_ident id))
(Typedtree.Tstr_class [ci]))
info_list
@@ -146,7 +146,7 @@
let search_class_exp table name =
match Hashtbl.find table (C name) with
- | (Typedtree.Tstr_class [(_,_,_,ce)]) ->
+ | (Typedtree.Tstr_class [(_,_,_,ce,_)]) ->
(
try
let type_decl = search_type_declaration table name in
@@ -184,7 +184,7 @@
let rec iter = function
| [] ->
raise Not_found
- | Typedtree.Cf_val (_, ident, exp) :: q
+ | Typedtree.Cf_val (_, ident, Some exp, _) :: q
when Name.from_ident ident = name ->
exp.Typedtree.exp_type
| _ :: q ->
@@ -523,7 +523,8 @@
p_clexp.Parsetree.pcl_loc.Location.loc_end.Lexing.pos_cnum
q
- | (Parsetree.Pcf_val (label, mutable_flag, expression, loc)) :: q ->
+ | (Parsetree.Pcf_val (label, mutable_flag, _, loc) |
+ Parsetree.Pcf_valvirt (label, mutable_flag, _, loc)) :: q ->
let complete_name = Name.concat current_class_name label in
let (info_opt, ele_comments) = get_comments_in_class last_pos loc.Location.loc_start.Lexing.pos_cnum in
let type_exp =
Index: ocamldoc/odoc_sig.ml
===================================================================
RCS file: /net/yquem/devel/caml/repository/csl/ocamldoc/odoc_sig.ml,v
retrieving revision 1.37
diff -u -r1.37 odoc_sig.ml
--- ocamldoc/odoc_sig.ml 4 Jan 2006 16:55:50 -0000 1.37
+++ ocamldoc/odoc_sig.ml 5 Apr 2006 02:26:01 -0000
@@ -107,7 +107,7 @@
| _ -> assert false
let search_attribute_type name class_sig =
- let (_, type_expr) = Types.Vars.find name class_sig.Types.cty_vars in
+ let (_, _, type_expr) = Types.Vars.find name class_sig.Types.cty_vars in
type_expr
let search_method_type name class_sig =
@@ -269,7 +269,7 @@
[] -> pos_limit
| ele2 :: _ ->
match ele2 with
- Parsetree.Pctf_val (_, _, _, loc)
+ Parsetree.Pctf_val (_, _, _, _, loc)
| Parsetree.Pctf_virt (_, _, _, loc)
| Parsetree.Pctf_meth (_, _, _, loc)
| Parsetree.Pctf_cstr (_, _, loc) -> loc.Location.loc_start.Lexing.pos_cnum
@@ -330,7 +330,7 @@
in
([], ele_comments)
- | Parsetree.Pctf_val (name, mutable_flag, _, loc) :: q ->
+ | Parsetree.Pctf_val (name, mutable_flag, _, _, loc) :: q ->
(* of (string * mutable_flag * core_type option * Location.t)*)
let (comment_opt, eles_comments) = get_comments_in_class last_pos loc.Location.loc_start.Lexing.pos_cnum in
let complete_name = Name.concat current_class_name name in
Index: camlp4/camlp4/ast2pt.ml
===================================================================
RCS file: /net/yquem/devel/caml/repository/csl/camlp4/camlp4/ast2pt.ml,v
retrieving revision 1.36
diff -u -r1.36 ast2pt.ml
--- camlp4/camlp4/ast2pt.ml 29 Jun 2005 04:11:26 -0000 1.36
+++ camlp4/camlp4/ast2pt.ml 5 Apr 2006 02:26:01 -0000
@@ -244,6 +244,7 @@
;
value mkmutable m = if m then Mutable else Immutable;
value mkprivate m = if m then Private else Public;
+value mkvirtual m = if m then Virtual else Concrete;
value mktrecord (loc, n, m, t) =
(n, mkmutable m, ctyp (mkpolytype t), mkloc loc);
value mkvariant (loc, c, tl) = (c, List.map ctyp tl, mkloc loc);
@@ -862,8 +863,8 @@
| CgInh loc ct -> [Pctf_inher (class_type ct) :: l]
| CgMth loc s pf t ->
[Pctf_meth (s, mkprivate pf, ctyp (mkpolytype t), mkloc loc) :: l]
- | CgVal loc s b t ->
- [Pctf_val (s, mkmutable b, Some (ctyp t), mkloc loc) :: l]
+ | CgVal loc s b v t ->
+ [Pctf_val (s, mkmutable b, mkvirtual v, ctyp t, mkloc loc) :: l]
| CgVir loc s b t ->
[Pctf_virt (s, mkprivate b, ctyp (mkpolytype t), mkloc loc) :: l] ]
and class_expr =
@@ -907,7 +908,9 @@
[Pcf_meth (s, mkprivate b, e, mkloc loc) :: l]
| CrVal loc s b e -> [Pcf_val (s, mkmutable b, expr e, mkloc loc) :: l]
| CrVir loc s b t ->
- [Pcf_virt (s, mkprivate b, ctyp (mkpolytype t), mkloc loc) :: l] ]
+ [Pcf_virt (s, mkprivate b, ctyp (mkpolytype t), mkloc loc) :: l]
+ | CrVvr loc s b t ->
+ [Pcf_valvirt (s, mkmutable b, ctyp t, mkloc loc) :: l] ]
;
value interf ast = List.fold_right sig_item ast [];
Index: camlp4/camlp4/mLast.mli
===================================================================
RCS file: /net/yquem/devel/caml/repository/csl/camlp4/camlp4/mLast.mli,v
retrieving revision 1.18
diff -u -r1.18 mLast.mli
--- camlp4/camlp4/mLast.mli 29 Jun 2005 04:11:26 -0000 1.18
+++ camlp4/camlp4/mLast.mli 5 Apr 2006 02:26:01 -0000
@@ -180,7 +180,7 @@
| CgDcl of loc and list class_sig_item
| CgInh of loc and class_type
| CgMth of loc and string and bool and ctyp
- | CgVal of loc and string and bool and ctyp
+ | CgVal of loc and string and bool and bool and ctyp
| CgVir of loc and string and bool and ctyp ]
and class_expr =
[ CeApp of loc and class_expr and expr
@@ -196,7 +196,8 @@
| CrIni of loc and expr
| CrMth of loc and string and bool and expr and option ctyp
| CrVal of loc and string and bool and expr
- | CrVir of loc and string and bool and ctyp ]
+ | CrVir of loc and string and bool and ctyp
+ | CrVvr of loc and string and bool and ctyp ]
;
external loc_of_ctyp : ctyp -> loc = "%field0";
Index: camlp4/camlp4/reloc.ml
===================================================================
RCS file: /net/yquem/devel/caml/repository/csl/camlp4/camlp4/reloc.ml,v
retrieving revision 1.18
diff -u -r1.18 reloc.ml
--- camlp4/camlp4/reloc.ml 29 Jun 2005 04:11:26 -0000 1.18
+++ camlp4/camlp4/reloc.ml 5 Apr 2006 02:26:01 -0000
@@ -350,7 +350,7 @@
| CgDcl loc x1 -> let nloc = floc loc in CgDcl nloc (List.map (class_sig_item floc sh) x1)
| CgInh loc x1 -> let nloc = floc loc in CgInh nloc (class_type floc sh x1)
| CgMth loc x1 x2 x3 -> let nloc = floc loc in CgMth nloc x1 x2 (ctyp floc sh x3)
- | CgVal loc x1 x2 x3 -> let nloc = floc loc in CgVal nloc x1 x2 (ctyp floc sh x3)
+ | CgVal loc x1 x2 x3 x4 -> let nloc = floc loc in CgVal nloc x1 x2 x3 (ctyp floc sh x4)
| CgVir loc x1 x2 x3 -> let nloc = floc loc in CgVir nloc x1 x2 (ctyp floc sh x3) ]
and class_expr floc sh =
self where rec self =
@@ -377,5 +377,6 @@
| CrMth loc x1 x2 x3 x4 ->
let nloc = floc loc in CrMth nloc x1 x2 (expr floc sh x3) (option_map (ctyp floc sh) x4)
| CrVal loc x1 x2 x3 -> let nloc = floc loc in CrVal nloc x1 x2 (expr floc sh x3)
- | CrVir loc x1 x2 x3 -> let nloc = floc loc in CrVir nloc x1 x2 (ctyp floc sh x3) ]
+ | CrVir loc x1 x2 x3 -> let nloc = floc loc in CrVir nloc x1 x2 (ctyp floc sh x3)
+ | CrVvr loc x1 x2 x3 -> let nloc = floc loc in CrVvr nloc x1 x2 (ctyp floc sh x3) ]
;
Index: camlp4/etc/pa_o.ml
===================================================================
RCS file: /net/yquem/devel/caml/repository/csl/camlp4/etc/pa_o.ml,v
retrieving revision 1.66
diff -u -r1.66 pa_o.ml
--- camlp4/etc/pa_o.ml 29 Jun 2005 04:11:26 -0000 1.66
+++ camlp4/etc/pa_o.ml 5 Apr 2006 02:26:01 -0000
@@ -1037,8 +1037,14 @@
class_str_item:
[ [ "inherit"; ce = class_expr; pb = OPT [ "as"; i = LIDENT -> i ] ->
<:class_str_item< inherit $ce$ $opt:pb$ >>
- | "val"; mf = OPT "mutable"; lab = label; e = cvalue_binding ->
- <:class_str_item< value $opt:o2b mf$ $lab$ = $e$ >>
+ | "val"; "mutable"; lab = label; e = cvalue_binding ->
+ <:class_str_item< value mutable $lab$ = $e$ >>
+ | "val"; lab = label; e = cvalue_binding ->
+ <:class_str_item< value $lab$ = $e$ >>
+ | "val"; "mutable"; "virtual"; lab = label; ":"; t = ctyp ->
+ <:class_str_item< value virtual mutable $lab$ : $t$ >>
+ | "val"; "virtual"; mf = OPT "mutable"; lab = label; ":"; t = ctyp ->
+ <:class_str_item< value virtual $opt:o2b mf$ $lab$ : $t$ >>
| "method"; "private"; "virtual"; l = label; ":"; t = poly_type ->
<:class_str_item< method virtual private $l$ : $t$ >>
| "method"; "virtual"; "private"; l = label; ":"; t = poly_type ->
@@ -1087,8 +1093,9 @@
;
class_sig_item:
[ [ "inherit"; cs = class_signature -> <:class_sig_item< inherit $cs$ >>
- | "val"; mf = OPT "mutable"; l = label; ":"; t = ctyp ->
- <:class_sig_item< value $opt:o2b mf$ $l$ : $t$ >>
+ | "val"; mf = OPT "mutable"; vf = OPT "virtual";
+ l = label; ":"; t = ctyp ->
+ <:class_sig_item< value $opt:o2b mf$ $opt:o2b vf$ $l$ : $t$ >>
| "method"; "private"; "virtual"; l = label; ":"; t = poly_type ->
<:class_sig_item< method virtual private $l$ : $t$ >>
| "method"; "virtual"; "private"; l = label; ":"; t = poly_type ->
Index: camlp4/etc/pr_o.ml
===================================================================
RCS file: /net/yquem/devel/caml/repository/csl/camlp4/etc/pr_o.ml,v
retrieving revision 1.51
diff -u -r1.51 pr_o.ml
--- camlp4/etc/pr_o.ml 5 Jan 2006 10:44:29 -0000 1.51
+++ camlp4/etc/pr_o.ml 5 Apr 2006 02:26:01 -0000
@@ -1768,10 +1768,11 @@
[: `S LR "method"; private_flag pf; `label lab;
`S LR ":" :];
`ctyp t "" k :]
- | MLast.CgVal _ lab mf t ->
+ | MLast.CgVal _ lab mf vf t ->
fun curr next dg k ->
[: `HVbox
- [: `S LR "val"; mutable_flag mf; `label lab; `S LR ":" :];
+ [: `S LR "val"; mutable_flag mf; virtual_flag vf;
+ `label lab; `S LR ":" :];
`ctyp t "" k :]
| MLast.CgVir _ lab pf t ->
fun curr next dg k ->
Index: camlp4/meta/pa_r.ml
===================================================================
RCS file: /net/yquem/devel/caml/repository/csl/camlp4/meta/pa_r.ml,v
retrieving revision 1.64
diff -u -r1.64 pa_r.ml
--- camlp4/meta/pa_r.ml 29 Jun 2005 04:11:26 -0000 1.64
+++ camlp4/meta/pa_r.ml 5 Apr 2006 02:26:01 -0000
@@ -658,7 +658,9 @@
| "inherit"; ce = class_expr; pb = OPT as_lident ->
<:class_str_item< inherit $ce$ $opt:pb$ >>
| "value"; mf = OPT "mutable"; lab = label; e = cvalue_binding ->
- <:class_str_item< value $opt:o2b mf$ $lab$ = $e$ >>
+ <:class_str_item< value $opt:o2b mf$ $lab$ = $e$ >>
+ | "value"; "virtual"; mf = OPT "mutable"; l = label; ":"; t = ctyp ->
+ <:class_str_item< value virtual $opt:o2b mf$ $l$ : $t$ >>
| "method"; "virtual"; pf = OPT "private"; l = label; ":"; t = ctyp ->
<:class_str_item< method virtual $opt:o2b pf$ $l$ : $t$ >>
| "method"; pf = OPT "private"; l = label; topt = OPT polyt;
@@ -701,8 +703,9 @@
[ [ "declare"; st = LIST0 [ s = class_sig_item; ";" -> s ]; "end" ->
<:class_sig_item< declare $list:st$ end >>
| "inherit"; cs = class_type -> <:class_sig_item< inherit $cs$ >>
- | "value"; mf = OPT "mutable"; l = label; ":"; t = ctyp ->
- <:class_sig_item< value $opt:o2b mf$ $l$ : $t$ >>
+ | "value"; mf = OPT "mutable"; vf = OPT "virtual";
+ l = label; ":"; t = ctyp ->
+ <:class_sig_item< value $opt:o2b mf$ $opt:o2b vf$ $l$ : $t$ >>
| "method"; "virtual"; pf = OPT "private"; l = label; ":"; t = ctyp ->
<:class_sig_item< method virtual $opt:o2b pf$ $l$ : $t$ >>
| "method"; pf = OPT "private"; l = label; ":"; t = ctyp ->
Index: camlp4/meta/q_MLast.ml
===================================================================
RCS file: /net/yquem/devel/caml/repository/csl/camlp4/meta/q_MLast.ml,v
retrieving revision 1.60
diff -u -r1.60 q_MLast.ml
--- camlp4/meta/q_MLast.ml 29 Jun 2005 04:11:26 -0000 1.60
+++ camlp4/meta/q_MLast.ml 5 Apr 2006 02:26:01 -0000
@@ -947,6 +947,8 @@
Qast.Node "CrDcl" [Qast.Loc; st]
| "inherit"; ce = class_expr; pb = SOPT as_lident ->
Qast.Node "CrInh" [Qast.Loc; ce; pb]
+ | "value"; "virtual"; mf = SOPT "mutable"; l = label; ":"; t = ctyp ->
+ Qast.Node "CrVvr" [Qast.Loc; l; o2b mf; t]
| "value"; mf = SOPT "mutable"; lab = label; e = cvalue_binding ->
Qast.Node "CrVal" [Qast.Loc; lab; o2b mf; e]
| "method"; "virtual"; pf = SOPT "private"; l = label; ":"; t = ctyp ->
@@ -992,8 +994,9 @@
[ [ "declare"; st = SLIST0 [ s = class_sig_item; ";" -> s ]; "end" ->
Qast.Node "CgDcl" [Qast.Loc; st]
| "inherit"; cs = class_type -> Qast.Node "CgInh" [Qast.Loc; cs]
- | "value"; mf = SOPT "mutable"; l = label; ":"; t = ctyp ->
- Qast.Node "CgVal" [Qast.Loc; l; o2b mf; t]
+ | "value"; mf = SOPT "mutable"; vf = SOPT "virtual";
+ l = label; ":"; t = ctyp ->
+ Qast.Node "CgVal" [Qast.Loc; l; o2b mf; o2b vf; t]
| "method"; "virtual"; pf = SOPT "private"; l = label; ":"; t = ctyp ->
Qast.Node "CgVir" [Qast.Loc; l; o2b pf; t]
| "method"; pf = SOPT "private"; l = label; ":"; t = ctyp ->
Index: camlp4/ocaml_src/camlp4/ast2pt.ml
===================================================================
RCS file: /net/yquem/devel/caml/repository/csl/camlp4/ocaml_src/camlp4/ast2pt.ml,v
retrieving revision 1.36
diff -u -r1.36 ast2pt.ml
--- camlp4/ocaml_src/camlp4/ast2pt.ml 29 Jun 2005 04:11:26 -0000 1.36
+++ camlp4/ocaml_src/camlp4/ast2pt.ml 5 Apr 2006 02:26:01 -0000
@@ -227,6 +227,7 @@
;;
let mkmutable m = if m then Mutable else Immutable;;
let mkprivate m = if m then Private else Public;;
+let mkvirtual m = if m then Virtual else Concrete;;
let mktrecord (loc, n, m, t) =
n, mkmutable m, ctyp (mkpolytype t), mkloc loc
;;
@@ -878,8 +879,8 @@
| CgInh (loc, ct) -> Pctf_inher (class_type ct) :: l
| CgMth (loc, s, pf, t) ->
Pctf_meth (s, mkprivate pf, ctyp (mkpolytype t), mkloc loc) :: l
- | CgVal (loc, s, b, t) ->
- Pctf_val (s, mkmutable b, Some (ctyp t), mkloc loc) :: l
+ | CgVal (loc, s, b, v, t) ->
+ Pctf_val (s, mkmutable b, mkvirtual v, ctyp t, mkloc loc) :: l
| CgVir (loc, s, b, t) ->
Pctf_virt (s, mkprivate b, ctyp (mkpolytype t), mkloc loc) :: l
and class_expr =
@@ -923,6 +924,8 @@
| CrVal (loc, s, b, e) -> Pcf_val (s, mkmutable b, expr e, mkloc loc) :: l
| CrVir (loc, s, b, t) ->
Pcf_virt (s, mkprivate b, ctyp (mkpolytype t), mkloc loc) :: l
+ | CrVvr (loc, s, b, t) ->
+ Pcf_valvirt (s, mkmutable b, ctyp t, mkloc loc) :: l
;;
let interf ast = List.fold_right sig_item ast [];;
Index: camlp4/ocaml_src/camlp4/mLast.mli
===================================================================
RCS file: /net/yquem/devel/caml/repository/csl/camlp4/ocaml_src/camlp4/mLast.mli,v
retrieving revision 1.20
diff -u -r1.20 mLast.mli
--- camlp4/ocaml_src/camlp4/mLast.mli 29 Jun 2005 04:11:26 -0000 1.20
+++ camlp4/ocaml_src/camlp4/mLast.mli 5 Apr 2006 02:26:01 -0000
@@ -180,7 +180,7 @@
| CgDcl of loc * class_sig_item list
| CgInh of loc * class_type
| CgMth of loc * string * bool * ctyp
- | CgVal of loc * string * bool * ctyp
+ | CgVal of loc * string * bool * bool * ctyp
| CgVir of loc * string * bool * ctyp
and class_expr =
CeApp of loc * class_expr * expr
@@ -197,6 +197,7 @@
| CrMth of loc * string * bool * expr * ctyp option
| CrVal of loc * string * bool * expr
| CrVir of loc * string * bool * ctyp
+ | CrVvr of loc * string * bool * ctyp
;;
external loc_of_ctyp : ctyp -> loc = "%field0";;
Index: camlp4/ocaml_src/camlp4/reloc.ml
===================================================================
RCS file: /net/yquem/devel/caml/repository/csl/camlp4/ocaml_src/camlp4/reloc.ml,v
retrieving revision 1.20
diff -u -r1.20 reloc.ml
--- camlp4/ocaml_src/camlp4/reloc.ml 29 Jun 2005 04:11:26 -0000 1.20
+++ camlp4/ocaml_src/camlp4/reloc.ml 5 Apr 2006 02:26:01 -0000
@@ -430,8 +430,8 @@
let nloc = floc loc in CgInh (nloc, class_type floc sh x1)
| CgMth (loc, x1, x2, x3) ->
let nloc = floc loc in CgMth (nloc, x1, x2, ctyp floc sh x3)
- | CgVal (loc, x1, x2, x3) ->
- let nloc = floc loc in CgVal (nloc, x1, x2, ctyp floc sh x3)
+ | CgVal (loc, x1, x2, x3, x4) ->
+ let nloc = floc loc in CgVal (nloc, x1, x2, x3, ctyp floc sh x4)
| CgVir (loc, x1, x2, x3) ->
let nloc = floc loc in CgVir (nloc, x1, x2, ctyp floc sh x3)
in
@@ -478,6 +478,8 @@
let nloc = floc loc in CrVal (nloc, x1, x2, expr floc sh x3)
| CrVir (loc, x1, x2, x3) ->
let nloc = floc loc in CrVir (nloc, x1, x2, ctyp floc sh x3)
+ | CrVvr (loc, x1, x2, x3) ->
+ let nloc = floc loc in CrVvr (nloc, x1, x2, ctyp floc sh x3)
in
self
;;
Index: camlp4/ocaml_src/meta/pa_r.ml
===================================================================
RCS file: /net/yquem/devel/caml/repository/csl/camlp4/ocaml_src/meta/pa_r.ml,v
retrieving revision 1.59
diff -u -r1.59 pa_r.ml
--- camlp4/ocaml_src/meta/pa_r.ml 29 Jun 2005 04:11:26 -0000 1.59
+++ camlp4/ocaml_src/meta/pa_r.ml 5 Apr 2006 02:26:01 -0000
@@ -2161,6 +2161,15 @@
(fun (t : 'ctyp) _ (l : 'label) (pf : string option) _ _
(_loc : Lexing.position * Lexing.position) ->
(MLast.CrVir (_loc, l, o2b pf, t) : 'class_str_item));
+ [Gramext.Stoken ("", "value"); Gramext.Stoken ("", "virtual");
+ Gramext.Sopt (Gramext.Stoken ("", "mutable"));
+ Gramext.Snterm (Grammar.Entry.obj (label : 'label Grammar.Entry.e));
+ Gramext.Stoken ("", ":");
+ Gramext.Snterm (Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e))],
+ Gramext.action
+ (fun (t : 'ctyp) _ (l : 'label) (mf : string option) _ _
+ (_loc : Lexing.position * Lexing.position) ->
+ (MLast.CrVvr (_loc, l, o2b mf, t) : 'class_str_item));
[Gramext.Stoken ("", "value");
Gramext.Sopt (Gramext.Stoken ("", "mutable"));
Gramext.Snterm (Grammar.Entry.obj (label : 'label Grammar.Entry.e));
@@ -2338,13 +2347,15 @@
(MLast.CgVir (_loc, l, o2b pf, t) : 'class_sig_item));
[Gramext.Stoken ("", "value");
Gramext.Sopt (Gramext.Stoken ("", "mutable"));
+ Gramext.Sopt (Gramext.Stoken ("", "virtual"));
Gramext.Snterm (Grammar.Entry.obj (label : 'label Grammar.Entry.e));
Gramext.Stoken ("", ":");
Gramext.Snterm (Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e))],
Gramext.action
- (fun (t : 'ctyp) _ (l : 'label) (mf : string option) _
+ (fun (t : 'ctyp) _ (l : 'label) (vf : string option)
+ (mf : string option) _
(_loc : Lexing.position * Lexing.position) ->
- (MLast.CgVal (_loc, l, o2b mf, t) : 'class_sig_item));
+ (MLast.CgVal (_loc, l, o2b mf, o2b vf, t) : 'class_sig_item));
[Gramext.Stoken ("", "inherit");
Gramext.Snterm
(Grammar.Entry.obj (class_type : 'class_type Grammar.Entry.e))],
Index: camlp4/ocaml_src/meta/q_MLast.ml
===================================================================
RCS file: /net/yquem/devel/caml/repository/csl/camlp4/ocaml_src/meta/q_MLast.ml,v
retrieving revision 1.65
diff -u -r1.65 q_MLast.ml
--- camlp4/ocaml_src/meta/q_MLast.ml 12 Jan 2006 08:54:21 -0000 1.65
+++ camlp4/ocaml_src/meta/q_MLast.ml 5 Apr 2006 02:26:01 -0000
@@ -3152,9 +3152,9 @@
Gramext.action
(fun (x : string)
(_loc : Lexing.position * Lexing.position) ->
- (Qast.Str x : 'e__17))])],
+ (Qast.Str x : 'e__18))])],
Gramext.action
- (fun (a : 'e__17 option)
+ (fun (a : 'e__18 option)
(_loc : Lexing.position * Lexing.position) ->
(Qast.Option a : 'a_opt));
[Gramext.Snterm
@@ -3191,9 +3191,9 @@
Gramext.action
(fun (x : string)
(_loc : Lexing.position * Lexing.position) ->
- (Qast.Str x : 'e__16))])],
+ (Qast.Str x : 'e__17))])],
Gramext.action
- (fun (a : 'e__16 option)
+ (fun (a : 'e__17 option)
(_loc : Lexing.position * Lexing.position) ->
(Qast.Option a : 'a_opt));
[Gramext.Snterm
@@ -3216,9 +3216,9 @@
Gramext.action
(fun (x : string)
(_loc : Lexing.position * Lexing.position) ->
- (Qast.Str x : 'e__15))])],
+ (Qast.Str x : 'e__16))])],
Gramext.action
- (fun (a : 'e__15 option)
+ (fun (a : 'e__16 option)
(_loc : Lexing.position * Lexing.position) ->
(Qast.Option a : 'a_opt));
[Gramext.Snterm
@@ -3235,6 +3235,31 @@
(_loc : Lexing.position * Lexing.position) ->
(Qast.Node ("CrVal", [Qast.Loc; lab; o2b mf; e]) :
'class_str_item));
+ [Gramext.Stoken ("", "value"); Gramext.Stoken ("", "virtual");
+ Gramext.srules
+ [[Gramext.Sopt
+ (Gramext.srules
+ [[Gramext.Stoken ("", "mutable")],
+ Gramext.action
+ (fun (x : string)
+ (_loc : Lexing.position * Lexing.position) ->
+ (Qast.Str x : 'e__15))])],
+ Gramext.action
+ (fun (a : 'e__15 option)
+ (_loc : Lexing.position * Lexing.position) ->
+ (Qast.Option a : 'a_opt));
+ [Gramext.Snterm
+ (Grammar.Entry.obj (a_opt : 'a_opt Grammar.Entry.e))],
+ Gramext.action
+ (fun (a : 'a_opt) (_loc : Lexing.position * Lexing.position) ->
+ (a : 'a_opt))];
+ Gramext.Snterm (Grammar.Entry.obj (label : 'label Grammar.Entry.e));
+ Gramext.Stoken ("", ":");
+ Gramext.Snterm (Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e))],
+ Gramext.action
+ (fun (t : 'ctyp) _ (l : 'label) (mf : 'a_opt) _ _
+ (_loc : Lexing.position * Lexing.position) ->
+ (Qast.Node ("CrVvr", [Qast.Loc; l; o2b mf; t]) : 'class_str_item));
[Gramext.Stoken ("", "inherit");
Gramext.Snterm
(Grammar.Entry.obj (class_expr : 'class_expr Grammar.Entry.e));
@@ -3366,9 +3391,9 @@
Gramext.action
(fun _ (csf : 'class_sig_item)
(_loc : Lexing.position * Lexing.position) ->
- (csf : 'e__18))])],
+ (csf : 'e__19))])],
Gramext.action
- (fun (a : 'e__18 list)
+ (fun (a : 'e__19 list)
(_loc : Lexing.position * Lexing.position) ->
(Qast.List a : 'a_list));
[Gramext.Snterm
@@ -3446,9 +3471,9 @@
Gramext.action
(fun (x : string)
(_loc : Lexing.position * Lexing.position) ->
- (Qast.Str x : 'e__22))])],
+ (Qast.Str x : 'e__24))])],
Gramext.action
- (fun (a : 'e__22 option)
+ (fun (a : 'e__24 option)
(_loc : Lexing.position * Lexing.position) ->
(Qast.Option a : 'a_opt));
[Gramext.Snterm
@@ -3471,9 +3496,9 @@
Gramext.action
(fun (x : string)
(_loc : Lexing.position * Lexing.position) ->
- (Qast.Str x : 'e__21))])],
+ (Qast.Str x : 'e__23))])],
Gramext.action
- (fun (a : 'e__21 option)
+ (fun (a : 'e__23 option)
(_loc : Lexing.position * Lexing.position) ->
(Qast.Option a : 'a_opt));
[Gramext.Snterm
@@ -3496,9 +3521,26 @@
Gramext.action
(fun (x : string)
(_loc : Lexing.position * Lexing.position) ->
- (Qast.Str x : 'e__20))])],
+ (Qast.Str x : 'e__21))])],
Gramext.action
- (fun (a : 'e__20 option)
+ (fun (a : 'e__21 option)
+ (_loc : Lexing.position * Lexing.position) ->
+ (Qast.Option a : 'a_opt));
+ [Gramext.Snterm
+ (Grammar.Entry.obj (a_opt : 'a_opt Grammar.Entry.e))],
+ Gramext.action
+ (fun (a : 'a_opt) (_loc : Lexing.position * Lexing.position) ->
+ (a : 'a_opt))];
+ Gramext.srules
+ [[Gramext.Sopt
+ (Gramext.srules
+ [[Gramext.Stoken ("", "virtual")],
+ Gramext.action
+ (fun (x : string)
+ (_loc : Lexing.position * Lexing.position) ->
+ (Qast.Str x : 'e__22))])],
+ Gramext.action
+ (fun (a : 'e__22 option)
(_loc : Lexing.position * Lexing.position) ->
(Qast.Option a : 'a_opt));
[Gramext.Snterm
@@ -3510,9 +3552,10 @@
Gramext.Stoken ("", ":");
Gramext.Snterm (Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e))],
Gramext.action
- (fun (t : 'ctyp) _ (l : 'label) (mf : 'a_opt) _
+ (fun (t : 'ctyp) _ (l : 'label) (vf : 'a_opt) (mf : 'a_opt) _
(_loc : Lexing.position * Lexing.position) ->
- (Qast.Node ("CgVal", [Qast.Loc; l; o2b mf; t]) : 'class_sig_item));
+ (Qast.Node ("CgVal", [Qast.Loc; l; o2b mf; o2b vf; t]) :
+ 'class_sig_item));
[Gramext.Stoken ("", "inherit");
Gramext.Snterm
(Grammar.Entry.obj (class_type : 'class_type Grammar.Entry.e))],
@@ -3531,9 +3574,9 @@
Gramext.action
(fun _ (s : 'class_sig_item)
(_loc : Lexing.position * Lexing.position) ->
- (s : 'e__19))])],
+ (s : 'e__20))])],
Gramext.action
- (fun (a : 'e__19 list)
+ (fun (a : 'e__20 list)
(_loc : Lexing.position * Lexing.position) ->
(Qast.List a : 'a_list));
[Gramext.Snterm
@@ -3556,9 +3599,9 @@
Gramext.action
(fun (x : string)
(_loc : Lexing.position * Lexing.position) ->
- (Qast.Str x : 'e__23))])],
+ (Qast.Str x : 'e__25))])],
Gramext.action
- (fun (a : 'e__23 option)
+ (fun (a : 'e__25 option)
(_loc : Lexing.position * Lexing.position) ->
(Qast.Option a : 'a_opt));
[Gramext.Snterm
@@ -3593,9 +3636,9 @@
Gramext.action
(fun (x : string)
(_loc : Lexing.position * Lexing.position) ->
- (Qast.Str x : 'e__24))])],
+ (Qast.Str x : 'e__26))])],
Gramext.action
- (fun (a : 'e__24 option)
+ (fun (a : 'e__26 option)
(_loc : Lexing.position * Lexing.position) ->
(Qast.Option a : 'a_opt));
[Gramext.Snterm
@@ -3713,9 +3756,9 @@
Gramext.action
(fun (x : string)
(_loc : Lexing.position * Lexing.position) ->
- (Qast.Str x : 'e__25))])],
+ (Qast.Str x : 'e__27))])],
Gramext.action
- (fun (a : 'e__25 option)
+ (fun (a : 'e__27 option)
(_loc : Lexing.position * Lexing.position) ->
(Qast.Option a : 'a_opt));
[Gramext.Snterm
@@ -3922,9 +3965,9 @@
Gramext.action
(fun (x : string)
(_loc : Lexing.position * Lexing.position) ->
- (Qast.Str x : 'e__26))])],
+ (Qast.Str x : 'e__28))])],
Gramext.action
- (fun (a : 'e__26 option)
+ (fun (a : 'e__28 option)
(_loc : Lexing.position * Lexing.position) ->
(Qast.Option a : 'a_opt));
[Gramext.Snterm
@@ -4390,9 +4433,9 @@
Gramext.action
(fun _ (e : 'expr)
(_loc : Lexing.position * Lexing.position) ->
- (e : 'e__29))])],
+ (e : 'e__31))])],
Gramext.action
- (fun (a : 'e__29 list)
+ (fun (a : 'e__31 list)
(_loc : Lexing.position * Lexing.position) ->
(Qast.List a : 'a_list));
[Gramext.Snterm
@@ -4425,9 +4468,9 @@
Gramext.action
(fun _ (e : 'expr)
(_loc : Lexing.position * Lexing.position) ->
- (e : 'e__28))])],
+ (e : 'e__30))])],
Gramext.action
- (fun (a : 'e__28 list)
+ (fun (a : 'e__30 list)
(_loc : Lexing.position * Lexing.position) ->
(Qast.List a : 'a_list));
[Gramext.Snterm
@@ -4454,9 +4497,9 @@
Gramext.action
(fun _ (e : 'expr)
(_loc : Lexing.position * Lexing.position) ->
- (e : 'e__27))])],
+ (e : 'e__29))])],
Gramext.action
- (fun (a : 'e__27 list)
+ (fun (a : 'e__29 list)
(_loc : Lexing.position * Lexing.position) ->
(Qast.List a : 'a_list));
[Gramext.Snterm
@@ -4547,9 +4590,9 @@
Gramext.action
(fun _ (cf : 'class_str_item)
(_loc : Lexing.position * Lexing.position) ->
- (cf : 'e__30))])],
+ (cf : 'e__32))])],
Gramext.action
- (fun (a : 'e__30 list)
+ (fun (a : 'e__32 list)
(_loc : Lexing.position * Lexing.position) ->
(Qast.List a : 'a_list));
[Gramext.Snterm
@@ -4592,9 +4635,9 @@
Gramext.action
(fun _ (csf : 'class_sig_item)
(_loc : Lexing.position * Lexing.position) ->
- (csf : 'e__32))])],
+ (csf : 'e__34))])],
Gramext.action
- (fun (a : 'e__32 list)
+ (fun (a : 'e__34 list)
(_loc : Lexing.position * Lexing.position) ->
(Qast.List a : 'a_list));
[Gramext.Snterm
@@ -4623,9 +4666,9 @@
Gramext.action
(fun _ (csf : 'class_sig_item)
(_loc : Lexing.position * Lexing.position) ->
- (csf : 'e__31))])],
+ (csf : 'e__33))])],
Gramext.action
- (fun (a : 'e__31 list)
+ (fun (a : 'e__33 list)
(_loc : Lexing.position * Lexing.position) ->
(Qast.List a : 'a_list));
[Gramext.Snterm
Index: camlp4/top/rprint.ml
===================================================================
RCS file: /net/yquem/devel/caml/repository/csl/camlp4/top/rprint.ml,v
retrieving revision 1.18
diff -u -r1.18 rprint.ml
--- camlp4/top/rprint.ml 29 Jun 2005 04:11:26 -0000 1.18
+++ camlp4/top/rprint.ml 5 Apr 2006 02:26:01 -0000
@@ -288,8 +288,9 @@
fprintf ppf "@[<2>method %s%s%s :@ %a;@]"
(if priv then "private " else "") (if virt then "virtual " else "")
name Toploop.print_out_type.val ty
- | Ocsg_value name mut ty ->
- fprintf ppf "@[<2>value %s%s :@ %a;@]" (if mut then "mutable " else "")
+ | Ocsg_value name mut virt ty ->
+ fprintf ppf "@[<2>value %s%s%s :@ %a;@]"
+ (if mut then "mutable " else "") (if virt then "virtual " else "")
name Toploop.print_out_type.val ty ]
;
|