File: tct3drv.h

package info (click to toggle)
qtads 2.1.6-1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 16,156 kB
  • ctags: 18,767
  • sloc: cpp: 133,078; ansic: 26,048; xml: 18; makefile: 11
file content (2341 lines) | stat: -rw-r--r-- 68,360 bytes parent folder | download | duplicates (7)
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
/* $Header: d:/cvsroot/tads/tads3/TCT3DRV.H,v 1.4 1999/07/11 00:46:57 MJRoberts Exp $ */

/* 
 *   Copyright (c) 1999, 2002 Michael J. Roberts.  All Rights Reserved.
 *   
 *   Please see the accompanying license file, LICENSE.TXT, for information
 *   on using and copying this software.  
 */
/*
Name
  tct3drv.h - derived final T3-specific parse node classes
Function
  
Notes
  
Modified
  05/10/99 MJRoberts  - Creation
*/

#ifndef TCT3DRV_H
#define TCT3DRV_H

#include <assert.h>

/* include our T3-specific intermediate classes */
#include "tct3int.h"

/* include the target-independent derived classes */
#include "tcpndrv.h"


/* ------------------------------------------------------------------------ */
/*
 *   "self" 
 */
class CTPNSelf: public CTPNSelfBase
{
public:
    /* generate code */
    void gen_code(int discard, int for_condition);

    /* generate a member expression */
    void gen_code_member(int discard,
                         class CTcPrsNode *prop_expr, int prop_is_expr,
                         int argc, int varargs,
                         struct CTcNamedArgs *named_args);

    /* get the object value for a '.' expression */
    vm_obj_id_t gen_code_obj_predot(int *is_self);
};

/* ------------------------------------------------------------------------ */
/*
 *   "replaced" 
 */
class CTPNReplaced: public CTPNReplacedBase
{
public:
    /* generate code */
    void gen_code(int discard, int for_condition);

    /* generate a function call expression */
    void gen_code_call(int discard, int argc, int varargs,
                       struct CTcNamedArgs *named_args);
};

/* ------------------------------------------------------------------------ */
/*
 *   "targetprop" 
 */
class CTPNTargetprop: public CTPNTargetpropBase
{
public:
    /* generate code */
    void gen_code(int discard, int for_condition);
};


/* ------------------------------------------------------------------------ */
/*
 *   "targetobj" 
 */
class CTPNTargetobj: public CTPNTargetobjBase
{
public:
    /* generate code */
    void gen_code(int discard, int for_condition);
};


/* ------------------------------------------------------------------------ */
/*
 *   "definingobj" 
 */
class CTPNDefiningobj: public CTPNDefiningobjBase
{
public:
    /* generate code */
    void gen_code(int discard, int for_condition);
};


/* ------------------------------------------------------------------------ */
/*
 *   "invokee" 
 */
class CTPNInvokee: public CTPNInvokeeBase
{
public:
    /* generate code */
    void gen_code(int discard, int for_condition);
};


/* ------------------------------------------------------------------------ */
/*
 *   "inherited" 
 */
class CTPNInh: public CTPNInhBase
{
public:
    /* generate code */
    void gen_code(int discard, int for_condition);

    /* generate a member expression */
    void gen_code_member(int discard,
                         class CTcPrsNode *prop_expr, int prop_is_expr,
                         int argc, int varargs,
                         struct CTcNamedArgs *named_args);

protected:
    /* generate a multi-method inherited() call */
    void gen_code_mminh(CTcSymFunc *func, int discard,
                        class CTcPrsNode *prop_expr, int prop_is_expr,
                        int argc, int varargs, struct CTcNamedArgs *named_args);
};

/*
 *   "inherited" with explicit superclass 
 */
class CTPNInhClass: public CTPNInhClassBase
{
public:
    CTPNInhClass(const char *sym, size_t len)
        : CTPNInhClassBase(sym, len) { }

    /* generate code */
    void gen_code(int discard, int for_condition);

    /* generate a member expression */
    void gen_code_member(int discard,
                         class CTcPrsNode *prop_expr, int prop_is_expr,
                         int argc, int varargs,
                         struct CTcNamedArgs *named_args);
};

/*
 *   "delegated" 
 */
class CTPNDelegated: public CTPNDelegatedBase
{
public:
    CTPNDelegated(CTcPrsNode *delegatee)
        : CTPNDelegatedBase(delegatee) { }

    /* generate code */
    void gen_code(int discard, int for_condition);

    /* generate a member expression */
    void gen_code_member(int discard,
                         class CTcPrsNode *prop_expr, int prop_is_expr,
                         int argc, int varargs,
                         struct CTcNamedArgs *named_args);
};

/* ------------------------------------------------------------------------ */
/*
 *   "argcount" node 
 */
class CTPNArgc: public CTPNArgcBase
{
public:
    void gen_code(int discard, int for_condition);
};


/* ------------------------------------------------------------------------ */
/* 
 *   constant node 
 */
class CTPNConst: public CTPNConstBase
{
public:
    CTPNConst(const CTcConstVal *val) : CTPNConstBase(val) { }

    /* generate code for the constant */
    void gen_code(int discard, int for_condition);

    /* generate code for operator 'new' applied to this expression */
    void gen_code_new(int discard, int argc, int varargs,
                      struct CTcNamedArgs *named_args,
                      int from_call, int is_transient);

    /* generate code for assigning to this expression */
    int gen_code_asi(int discard, int phase, tc_asitype_t typ, const char *op,
                     CTcPrsNode *rhs, 
                     int ignore_errors, int xplicit, void **ctx);

    /* evaluate a property ID */
    vm_prop_id_t gen_code_propid(int check_only, int is_expr);

    /* generate a member expression */
    void gen_code_member(int discard,
                         class CTcPrsNode *prop_expr, int prop_is_expr,
                         int argc, int varargs,
                         struct CTcNamedArgs *named_args);

    /* generate a function call expression */
    void gen_code_call(int discard, int argc, int varargs,
                       struct CTcNamedArgs *named_args);

    /* get the object value for a '.' expression */
    vm_obj_id_t gen_code_obj_predot(int *is_self);

    /* generate code to push an integer constant */
    static void s_gen_code_int(long intval);

    /* generate code to push a string constant */
    static void s_gen_code_str(const CTcConstVal *val);
    static void s_gen_code_str(const char *str, size_t len);

    /* generate code to push a symbol's name as a string constant */
    static void s_gen_code_str(const class CTcSymbol *sym);

    /* 
     *   generate code to push a string, using the correct code for the
     *   current compilation mode (static vs dynamic) 
     */
    static void s_gen_code_str_by_mode(const class CTcSymbol *sym);
};

/*
 *   Debugger constant node 
 */
class CTPNDebugConst: public CTPNConst
{
public:
    CTPNDebugConst(CTcConstVal *val) : CTPNConst(val) { }

    /* debugger constants aren't actual constants - they require code gen */
    CTcConstVal *get_const_val() { return 0; }

    /* generate code for the constant */
    void gen_code(int discard, int for_condition);

    /* generate a constant string */
    static void s_gen_code_str(const char *str, size_t len);
};

/* ------------------------------------------------------------------------ */
/*
 *   Unary Operators 
 */

/* bitwise NOT */
CTPNUnary_def(CTPNBNot);

/* arithmetic positive */
CTPNUnary_def(CTPNPos);

/* arithmetic negative */
CTPNUnary_def(CTPNNeg);

/* pre-increment */
CTPNUnary_side_def(CTPNPreInc);
void CTPNPreInc_gen_code(class CTcPrsNode *sub, int discard);

/* pre-decrement */
CTPNUnary_side_def(CTPNPreDec);

/* post-increment */
CTPNUnary_side_def(CTPNPostInc);

/* post-decrement */
CTPNUnary_side_def(CTPNPostDec);

/* delete */
CTPNUnary_side_def(CTPNDelete);

/* boolean-ize */
CTPNUnary_def(CTPNBoolize);

/* ------------------------------------------------------------------------ */
/*
 *   NEW operator 
 */
class CTPNNew: public CTPNUnary
{ 
public:
    CTPNNew(class CTcPrsNode *sub, int is_transient)
        : CTPNUnary(sub)
    {
        /* remember 'transient' status */
        transient_ = is_transient;
    }

    /* generate code */
    void gen_code(int discard, int for_condition);

    /* note that we have side effects */
    virtual int has_side_effects() const { return TRUE; }

protected:
    /* flag: it's a 'new transient' operator */
    int transient_;
};


/* ------------------------------------------------------------------------ */
/*
 *   NOT operator 
 */
class CTPNNot: public CTPNNotBase
{
public:
    CTPNNot(CTcPrsNode *sub) : CTPNNotBase(sub) { }

    /* generate code */
    void gen_code(int discard, int for_condition);
};


/* ------------------------------------------------------------------------ */
/* 
 *   Binary Operators 
 */

class CTPNComma: public CTPNCommaBase
{
public:
    CTPNComma(class CTcPrsNode *lhs, class CTcPrsNode *rhs)
        : CTPNCommaBase(lhs, rhs) { }

    /* generate code */
    void gen_code(int discard, int for_condition);
};

/* bitwise OR */
CTPNBin_def(CTPNBOr);

/* bitwise AND */
CTPNBin_def(CTPNBAnd);

/* bitwise XOR */
CTPNBin_def(CTPNBXor);

/* greater than */
CTPNBin_cmp_def(CTPNGt);

/* greater or equal */
CTPNBin_cmp_def(CTPNGe);

/* less than */
CTPNBin_cmp_def(CTPNLt);

/* less or equal */
CTPNBin_cmp_def(CTPNLe);

/* bit shift left */
CTPNBin_def(CTPNShl);

/* arithmetic shift right */
CTPNBin_def(CTPNAShr);

/* logical shift right */
CTPNBin_def(CTPNLShr);

/* multiply */
CTPNBin_def(CTPNMul);

/* divide */
CTPNBin_def(CTPNDiv);

/* modulo */
CTPNBin_def(CTPNMod);

/* ------------------------------------------------------------------------ */
/*
 *   Addition 
 */

class CTPNAdd: public CTPNAddBase
{
public:
    CTPNAdd(class CTcPrsNode *left, class CTcPrsNode *right)
        : CTPNAddBase(left, right) { }

    /* generate code */
    void gen_code(int discard, int for_condition);
};


/* ------------------------------------------------------------------------ */
/*
 *   Subtraction
 */

class CTPNSub: public CTPNSubBase
{
public:
    CTPNSub(class CTcPrsNode *left, class CTcPrsNode *right)
        : CTPNSubBase(left, right) { }

    /* generate code */
    void gen_code(int discard, int for_condition);
};

/* ------------------------------------------------------------------------ */
/*
 *   Equality Comparison
 */

class CTPNEq: public CTPNEqBase
{
public:
    CTPNEq(class CTcPrsNode *left, class CTcPrsNode *right)
        : CTPNEqBase(left, right) { }

    /* generate code */
    void gen_code(int discard, int for_condition);
};


/* ------------------------------------------------------------------------ */
/*
 *   Inequality Comparison
 */

class CTPNNe: public CTPNNeBase
{
public:
    CTPNNe(class CTcPrsNode *left, class CTcPrsNode *right)
        : CTPNNeBase(left, right) { }

    /* generate code */
    void gen_code(int discard, int for_condition);
};

/* ------------------------------------------------------------------------ */
/*
 *   'is in' 
 */

class CTPNIsIn: public CTPNIsInBase
{
public:
    CTPNIsIn(class CTcPrsNode *left, class CTPNArglist *right)
        : CTPNIsInBase(left, right) { }

    /* generate code */
    void gen_code(int discard, int for_condition);
};


/* ------------------------------------------------------------------------ */
/*
 *   'not in' 
 */

class CTPNNotIn: public CTPNNotInBase
{
public:
    CTPNNotIn(class CTcPrsNode *left, class CTPNArglist *right)
        : CTPNNotInBase(left, right) { }

    /* generate code */
    void gen_code(int discard, int for_condition);
};


/* ------------------------------------------------------------------------ */
/*
 *   Logical AND (short-circuit logic)
 */

class CTPNAnd: public CTPNAndBase
{
public:
    CTPNAnd(class CTcPrsNode *left, class CTcPrsNode *right)
        : CTPNAndBase(left, right) { }

    /* generate code */
    void gen_code(int discard, int for_condition);

    /* generate a condition */
    virtual void gen_code_cond(struct CTcCodeLabel *then_label,
                               struct CTcCodeLabel *else_label);
};


/* ------------------------------------------------------------------------ */
/*
 *   Logical OR (short-circuit logic)
 */

class CTPNOr: public CTPNOrBase
{
public:
    CTPNOr(class CTcPrsNode *left, class CTcPrsNode *right)
        : CTPNOrBase(left, right) { }

    /* generate code */
    void gen_code(int discard, int for_condition);

    /* generate a condition */
    virtual void gen_code_cond(struct CTcCodeLabel *then_label,
                               struct CTcCodeLabel *else_label);
};


/* ------------------------------------------------------------------------ */
/*
 *   Assignment Operators 
 */

/* simple assignment */
class CTPNAsi: public CTPNAsiBase
{
public:
    CTPNAsi(class CTcPrsNode *left, class CTcPrsNode *right)
        : CTPNAsiBase(left, right) { }

    /* generate code */
    void gen_code(int discard, int for_condition);
};

/* add and assign */
CTPNBin_side_def(CTPNAddAsi);
void CTPNAddAsi_gen_code(class CTcPrsNode *left, class CTcPrsNode *right,
                         int discard);

/* subtract and assign */
CTPNBin_side_def(CTPNSubAsi);

/* multiple and assign */
CTPNBin_side_def(CTPNMulAsi);

/* divide and assign */
CTPNBin_side_def(CTPNDivAsi);

/* modulo and assign */
CTPNBin_side_def(CTPNModAsi);

/* bitwise AND and assign */
CTPNBin_side_def(CTPNBAndAsi);

/* bitwise OR and assign */
CTPNBin_side_def(CTPNBOrAsi);

/* bitwise XOR and assign */
CTPNBin_side_def(CTPNBXorAsi);

/* bit shift left and assign */
CTPNBin_side_def(CTPNShlAsi);

/* arithmetic shift right and assign */
CTPNBin_side_def(CTPNAShrAsi);

/* logical shift right and assign */
CTPNBin_side_def(CTPNLShrAsi);

/* ------------------------------------------------------------------------ */
/*
 *   Array/list Subscript 
 */
class CTPNSubscript: public CTPNSubscriptBase
{
public:
    CTPNSubscript(CTcPrsNode *lhs, CTcPrsNode *rhs)
        : CTPNSubscriptBase(lhs, rhs) { }

    /* generate code */
    void gen_code(int discard, int for_condition);

    /* generate code to assign a value to the symbol */
    int gen_code_asi(int discard, int phase, tc_asitype_t typ, const char *op,
                     CTcPrsNode *rhs,
                     int ignore_errors, int xplicit, void **ctx);
};


/* ------------------------------------------------------------------------ */
/*
 *   Address-of Operator 
 */

class CTPNAddr: public CTPNAddrBase
{
public:
    CTPNAddr(CTcPrsNode *sub)
        : CTPNAddrBase(sub) { }

    /* generate code */
    void gen_code(int discard, int for_condition)
    {
        /* 
         *   if we're not discarding the value, tell the subnode to
         *   generate its address; if the value is being discarded, do
         *   nothing, since taking an address has no side effects 
         */
        if (!discard)
            sub_->gen_code_addr();
    }

    /* generate a member expression */
    void gen_code_member(int discard,
                         class CTcPrsNode *prop_expr, int prop_is_expr,
                         int argc, int varargs,
                         struct CTcNamedArgs *named_args)
    {
        /* 
         *   let the subnode do the work, since "&obj" is the same as
         *   "obj" in any context 
         */
        sub_->gen_code_member(discard, prop_expr, prop_is_expr,
                              argc, varargs, named_args);
    }

    /* evaluate a property ID */
    vm_prop_id_t gen_code_propid(int check_only, int is_expr)
    {
        /* 
         *   let the subexpression handle it, so that we treat "x.&prop"
         *   the same as "x.prop" 
         */
        return sub_->gen_code_propid(check_only, is_expr);
    }

    /* get the object value for a '.' expression */
    vm_obj_id_t gen_code_obj_predot(int *is_self)
    {
        /* 
         *   let the subexpression handle it, since "x.&prop" is the same
         *   as "x.prop" 
         */
        return sub_->gen_code_obj_predot(is_self);
    }
};

/* ------------------------------------------------------------------------ */
/*
 *   If-nil operator ??
 */
class CTPNIfnil: public CTPNIfnilBase
{
public:
    CTPNIfnil(class CTcPrsNode *first, class CTcPrsNode *second)
        : CTPNIfnilBase(first, second) { }

    /* generate code for the conditional */
    void gen_code(int discard, int for_condition);
};

/* ------------------------------------------------------------------------ */
/*
 *   Conditional Operator 
 */
class CTPNIf: public CTPNIfBase
{
public:
    CTPNIf(class CTcPrsNode *first, class CTcPrsNode *second,
           class CTcPrsNode *third)
        : CTPNIfBase(first, second, third) { }

    /* generate code for the conditional */
    void gen_code(int discard, int for_condition);
};

/* ------------------------------------------------------------------------ */
/*
 *   Symbol node 
 */
class CTPNSym: public CTPNSymBase
{
public:
    CTPNSym(const char *sym, size_t len)
        : CTPNSymBase(sym, len) { }

    /* generate code for the symbol evaluated as an rvalue */
    void gen_code(int discard, int for_condition);

    /* generate code to assign a value to the symbol */
    int gen_code_asi(int discard, int phase, tc_asitype_t typ, const char *op,
                     CTcPrsNode *rhs,
                     int ignore_errors, int xplicit, void **ctx);

    /* generate code to take the address of the symbol */
    void gen_code_addr();

    /* generate code to call the symbol */
    void gen_code_call(int discard, int argc, int varargs,
                       struct CTcNamedArgs *named_args);

    /* generate code for operator 'new' applied to this expression */
    void gen_code_new(int discard, int argc, int varargs,
                      struct CTcNamedArgs *named_args,
                      int from_call, int is_transient);

    /* evaluate a property ID */
    vm_prop_id_t gen_code_propid(int check_only, int is_expr);

    /* generate a member expression */
    void gen_code_member(int discard,
                         class CTcPrsNode *prop_expr, int prop_is_expr,
                         int argc, int varargs,
                         struct CTcNamedArgs *named_args);

    /* get the object value for a '.' expression */
    vm_obj_id_t gen_code_obj_predot(int *is_self);
};

/* ------------------------------------------------------------------------ */
/*
 *   Resolved symbol 
 */
class CTPNSymResolved: public CTPNSymResolvedBase
{
public:
    CTPNSymResolved(CTcSymbol *sym)
        : CTPNSymResolvedBase(sym) { }

    /* generate code for the symbol evaluated as an rvalue */
    void gen_code(int discard, int for_condition);

    /* generate code to assign a value to the symbol */
    int gen_code_asi(int discard, int phase, tc_asitype_t typ, const char *op,
                     CTcPrsNode *rhs,
                     int ignore_errors, int xplicit, void **ctx);

    /* generate code to take the address of the symbol */
    void gen_code_addr();

    /* generate code to call the symbol */
    void gen_code_call(int discard, int argc, int varargs,
                       struct CTcNamedArgs *named_args);

    /* generate code for operator 'new' applied to this expression */
    void gen_code_new(int discard, int argc, int varargs,
                      struct CTcNamedArgs *named_args,
                      int from_call, int is_transient);

    /* evaluate a property ID */
    vm_prop_id_t gen_code_propid(int check_only, int is_expr);

    /* generate a member expression */
    void gen_code_member(int discard,
                         class CTcPrsNode *prop_expr, int prop_is_expr,
                         int argc, int varargs,
                         struct CTcNamedArgs *named_args);

    /* get the object value for a '.' expression */
    vm_obj_id_t gen_code_obj_predot(int *is_self);
};

/* ------------------------------------------------------------------------ */
/*
 *   Resolved debugger local variable symbol 
 */
class CTPNSymDebugLocal: public CTPNSymDebugLocalBase
{
public:
    CTPNSymDebugLocal(const struct tcprsdbg_sym_info *info)
        : CTPNSymDebugLocalBase(info)
    {
    }

    /* generate code */
    void gen_code(int discard, int for_condition);

    /* generate code for assigning into this node */
    int gen_code_asi(int discard, int phase, tc_asitype_t typ, const char *op,
                     class CTcPrsNode *rhs,
                     int ignore_errors, int xplicit, void **ctx);
};

/* ------------------------------------------------------------------------ */
/*
 *   double-quoted string expression 
 */
class CTPNDstr: public CTPNDstrBase
{
public:
    CTPNDstr(const char *str, size_t len)
        : CTPNDstrBase(str, len) { }

    void gen_code(int discard, int for_condition);
};

/*
 *   debug version of string 
 */
class CTPNDebugDstr: public CTPNDstr
{
public:
    CTPNDebugDstr(const char *str, size_t len)
        : CTPNDstr(str, len) { }

    void gen_code(int discard, int for_condition);
};

/*
 *   double-quoted string embedding 
 */
class CTPNDstrEmbed: public CTPNDstrEmbedBase
{
public:
    CTPNDstrEmbed(CTcPrsNode *sub);

    void gen_code(int discard, int for_condition);
};

/* ------------------------------------------------------------------------ */
/*
 *   Embedded <<one of>> list in a string 
 */
class CTPNStrOneOf: public CTPNStrOneOfBase
{
public:
    CTPNStrOneOf(int dstr, class CTPNList *lst, class CTcSymObj *state_obj)
        : CTPNStrOneOfBase(dstr, lst, state_obj) { }

    void gen_code(int discard, int for_condition);
};

/* ------------------------------------------------------------------------ */
/*
 *   Argument List 
 */
class CTPNArglist: public CTPNArglistBase
{
public:
    CTPNArglist(int argc, class CTPNArg *list_head)
        : CTPNArglistBase(argc, list_head) { }

    void gen_code(int, int)
    {
        /* 
         *   this isn't used - we always generate explicitly via
         *   gen_code_arglist() 
         */
        assert(FALSE);
    }

    /* generate code for an argument list */
    void gen_code_arglist(int *varargs, struct CTcNamedArgs &named_args);
};

/*
 *   Argument List Entry 
 */
class CTPNArg: public CTPNArgBase
{
public:
    CTPNArg(CTcPrsNode *expr)
        : CTPNArgBase(expr) { }

    void gen_code(int discard, int for_condition);
};

/* ------------------------------------------------------------------------ */
/*
 *   Function/method call 
 */
class CTPNCall: public CTPNCallBase
{
public:
    CTPNCall(CTcPrsNode *func, class CTPNArglist *arglist);

    /* generate code */
    void gen_code(int discard, int for_condition);

    /* generate code for operator 'new' applied to this expression */
    void gen_code_new(int discard, int argc, int varargs,
                      struct CTcNamedArgs *named_args,
                      int from_call, int is_transient);

    /* generate code for a call to 'rand' */
    int gen_code_rand(int discard, int for_condition);
};


/* ------------------------------------------------------------------------ */
/*
 *   Member expression with no arguments 
 */
class CTPNMember: public CTPNMemberBase
{
public:
    CTPNMember(CTcPrsNode *lhs, CTcPrsNode *rhs, int rhs_is_expr)
        : CTPNMemberBase(lhs, rhs, rhs_is_expr) { }

    /* generate code */
    void gen_code(int discard, int for_condition);

    /* generate code to assign a value to the symbol */
    int gen_code_asi(int discard, int phase, tc_asitype_t typ, const char *op,
                     CTcPrsNode *rhs,
                     int ignore_errors, int xplicit, void **ctx);
};

/*
 *   Member evaluation with argument list 
 */
class CTPNMemArg: public CTPNMemArgBase
{
public:
    CTPNMemArg(CTcPrsNode *obj_expr, CTcPrsNode *prop_expr, int prop_is_expr,
               class CTPNArglist *arglist)
        : CTPNMemArgBase(obj_expr, prop_expr, prop_is_expr, arglist) { }

    void gen_code(int discard, int for_condition);
};


/* ------------------------------------------------------------------------ */
/*
 *   List 
 */
class CTPNList: public CTPNListBase
{
public:
    void gen_code(int discard, int for_condition);
};

/*
 *   List Element 
 */
class CTPNListEle: public CTPNListEleBase
{
public:
    CTPNListEle(CTcPrsNode *expr)
        : CTPNListEleBase(expr) { }

    void gen_code(int discard, int for_condition);
};

/* ------------------------------------------------------------------------ */
/*
 *   Derived T3-specific symbol classes 
 */

/*
 *   undefined symbol 
 */
class CTcSymUndef: public CTcSymUndefBase
{
public:
    CTcSymUndef(const char *str, size_t len, int copy)
        : CTcSymUndefBase(str, len, copy) { }

    /* 
     *   generate code to evaluate the symbol; since it's undefined, this
     *   doesn't generate any code at all 
     */
    virtual void gen_code(int) { }

    /* 
     *   Generate code to assign to the symbol.  The symbol is undefined,
     *   so we can't generate any code; but we'll indicate to the caller
     *   that the assignment is fully processed anyway, since there's no
     *   need for the caller to try generating any code either. 
     */
    virtual int gen_code_asi(int, int phase, tc_asitype_t, const char *,
                             class CTcPrsNode *, int, int, void **)
    {
        return TRUE;
    }

    /* 
     *   Generate code for taking the address of the symbol.  The symbol
     *   has no address, so this generates no code. 
     */
    virtual void gen_code_addr() { }

    /* 
     *   generate code to call the symbol - we can't generate any code for
     *   this, but don't bother issuing an error since we will have shown
     *   an error for the undefined symbol in the first place 
     */
    virtual void gen_code_call(int, int, int, struct CTcNamedArgs *) { }

    /* 
     *   generate code for operator 'new' applied to this expression - we
     *   can't generate any code, but suppress errors as usual 
     */
    void gen_code_new(int, int, int, struct CTcNamedArgs *, int) { }

    /* generate a member expression */
    void gen_code_member(int, class CTcPrsNode *, int, int, int,
                         struct CTcNamedArgs *) { }

    /* get the object value for a '.' expression */
    vm_obj_id_t gen_code_obj_predot(int *is_self)
    {
        *is_self = FALSE;
        return VM_INVALID_OBJ;
    }
};


/*
 *   function 
 */
class CTcSymFunc: public CTcSymFuncBase
{
public:
    CTcSymFunc(const char *str, size_t len, int copy,
               int argc, int opt_argc, int varargs, int has_retval,
               int is_multimethod, int is_mm_base,
               int is_extern, int has_proto)
        : CTcSymFuncBase(str, len, copy, argc, opt_argc, varargs, has_retval,
                         is_multimethod, is_mm_base, is_extern, has_proto)
    {
        /* 
         *   we don't have a valid absolute address - by default, we use
         *   the anchor 
         */
        abs_addr_valid_ = FALSE;
        abs_addr_ = 0;
    }

    /* generate code to evaluate the symbol */
    virtual void gen_code(int discard);

    /* we can take the address of this symbol type */
    virtual void gen_code_addr();

    /* generate a call */
    virtual void gen_code_call(int discard, int argc, int varargs,
                               struct CTcNamedArgs *named_args);

    /* 
     *   Get my code pool address.  This is valid only after the linking
     *   phase has been completed and all fixups have been applied.  (The
     *   normal use for this is to generate image file elements not
     *   subject to fixup, such as the entrypoint record.  Normally,
     *   references to the symbol that require the code pool address would
     *   simply generate a fixup rather than asking for the true address,
     *   since a fixup can be generated at any time during code
     *   generation.)
     */
    ulong get_code_pool_addr() const;

    /* write the symbol to an image file's global symbol table */
    int write_to_image_file_global(class CVmImageWriter *image_writer);

    /*
     *   Set the absolute code pool address.  This can only be used when
     *   the symbol is loaded from a fully-linked image file; in most
     *   cases, this routine is not needed, because the function's address
     *   will be kept with its associated anchor to allow for relocation
     *   of the function during the linking process.  
     */
    void set_abs_addr(uint32_t addr)
    {
        /* remember the address */
        abs_addr_ = addr;

        /* note that the absolute address is valid */
        abs_addr_valid_ = TRUE;
    }

    /* add a runtime symbol table entry */
    void add_runtime_symbol(class CVmRuntimeSymbols *symtab);
    
protected:
    /*
     *   Absolute code pool address, and a flag indicating whether the
     *   address is valid.  When we load a function symbol from a
     *   fully-linked image file (specifically, when we load the symbol
     *   from the debug records of an image file), the address of the
     *   function is fully resolved and doesn't require fixups via the
     *   anchor mechanism.  In these cases, we'll simply remember the
     *   resolved address here.  
     */
    ulong abs_addr_;
    uint abs_addr_valid_ : 1;
};

/*
 *   metaclass 
 */
class CTcSymMetaclass: public CTcSymMetaclassBase
{
public:
    CTcSymMetaclass(const char *str, size_t len, int copy, int meta_idx,
                    tctarg_obj_id_t class_obj)
        : CTcSymMetaclassBase(str, len, copy, meta_idx, class_obj)
    {
    }

    /* generate code to evaluate the symbol */
    virtual void gen_code(int discard);

    /* generate code for operator 'new' */
    void gen_code_new(int discard, int argc, int varargs,
                      struct CTcNamedArgs *named_args,
                      int is_transient);

    /* generate a member expression */
    void gen_code_member(int discard,
                         class CTcPrsNode *prop_expr, int prop_is_expr,
                         int argc, int varargs,
                         struct CTcNamedArgs *named_args);

    /* get the object value for a '.' expression */
    vm_obj_id_t gen_code_obj_predot(int *is_self)
    {
        /* simply generate our code as normal */
        gen_code(FALSE);

        /* indicate that the caller must use generated code */
        *is_self = FALSE;
        return VM_INVALID_OBJ;
    }

    /* write the symbol to an image file's global symbol table */
    int write_to_image_file_global(class CVmImageWriter *image_writer);

    /* 
     *   fix up the inheritance chain in the modifier objects - each
     *   object file has its own independent inheritance list, so we can
     *   only build the complete and connected list after loading them all 
     */
    void fix_mod_obj_sc_list();

    /* add a runtime symbol table entry */
    void add_runtime_symbol(class CVmRuntimeSymbols *symtab);
};

/*
 *   object 
 */
class CTcSymObj: public CTcSymObjBase
{
public:
    CTcSymObj(const char *str, size_t len, int copy, vm_obj_id_t obj_id,
              int is_extern, tc_metaclass_t meta, class CTcDictEntry *dict)
        : CTcSymObjBase(str, len, copy, obj_id, is_extern, meta, dict)
    {
    }

    /* we have a valid object value */
    virtual vm_obj_id_t get_val_obj() const { return get_obj_id(); }

    /* generate code to evaluate the symbol */
    virtual void gen_code(int discard);

    /* we can take the address of this symbol type */
    virtual void gen_code_addr();

    /* generate code for operator 'new' */
    void gen_code_new(int discard, int argc, int varargs,
                      struct CTcNamedArgs *named_args,
                      int is_transient);

    /* static code to generate code for 'new' */
    static void s_gen_code_new(int discard, vm_obj_id_t obj_id,
                               tc_metaclass_t meta,
                               int argc, int varargs,
                               struct CTcNamedArgs *named_args,
                               int is_transient);

    /* generate a member expression */
    void gen_code_member(int discard,
                         class CTcPrsNode *prop_expr, int prop_is_expr,
                         int argc, int varargs,
                         struct CTcNamedArgs *named_args);

    /* static code to generate a member expression */
    static void s_gen_code_member(int discard,
                                  class CTcPrsNode *prop_expr,
                                  int prop_is_expr, int argc,
                                  vm_obj_id_t obj_id,
                                  int varargs, struct CTcNamedArgs *named_args);

    /* get the object value for a '.' expression */
    vm_obj_id_t gen_code_obj_predot(int *is_self);

    /* delete a property from our modified base classes */
    virtual void delete_prop_from_mod_base(tctarg_prop_id_t prop_id);

    /* mark the compiled data for the object as a 'class' object */
    virtual void mark_compiled_as_class();

    /* write the symbol to an image file's global symbol table */
    int write_to_image_file_global(class CVmImageWriter *image_writer);

    /* build my dictionary */
    virtual void build_dictionary();

    /* add a runtime symbol table entry */
    void add_runtime_symbol(class CVmRuntimeSymbols *symtab);
};

/*
 *   Function-like object symbol.  This is an object that's invokable as a
 *   function, such as an anonymous function object or a DynamicFunc
 *   instance.  These occur in the dynamic compiler only.  
 */
class CTcSymFuncObj: public CTcSymObj
{
public:
    CTcSymFuncObj(const char *str, size_t len, int copy, vm_obj_id_t obj_id,
                  int is_extern, tc_metaclass_t meta, class CTcDictEntry *dict)
        : CTcSymObj(str, len, copy, obj_id, is_extern, meta, dict)
    {
    }

    /* generate a call */
    virtual void gen_code_call(int discard, int argc, int varargs,
                               struct CTcNamedArgs *named_args);
};

/*
 *   property 
 */
class CTcSymProp: public CTcSymPropBase
{
public:
    CTcSymProp(const char *str, size_t len, int copy, tctarg_prop_id_t prop)
        : CTcSymPropBase(str, len, copy, prop) { }

    /* generate code to evaluate the symbol */
    virtual void gen_code(int discard);

    /* we can take the address of this symbol type */
    virtual void gen_code_addr();

    /* assign to the property */
    virtual int gen_code_asi(int discard, int phase,
                             tc_asitype_t typ, const char *op,
                             class CTcPrsNode *rhs,
                             int ignore_errors, int xplicit, void **ctx);

    /* generate a call */
    virtual void gen_code_call(int discard, int argc, int varargs,
                               struct CTcNamedArgs *named_args);

    /* evaluate a property ID */
    vm_prop_id_t gen_code_propid(int check_only, int is_expr);

    /* generate a member expression */
    void gen_code_member(int discard,
                         class CTcPrsNode *prop_expr, int prop_is_expr,
                         int argc, int varargs,
                         struct CTcNamedArgs *named_args);

    /* get the object value for a '.' expression */
    vm_obj_id_t gen_code_obj_predot(int *is_self)
    {
        /* simply generate our code as normal */
        gen_code(FALSE);

        /* indicate that the caller must use generated code */
        *is_self = FALSE;
        return VM_INVALID_OBJ;
    }

    /* write the symbol to an image file's global symbol table */
    int write_to_image_file_global(class CVmImageWriter *image_writer);

    /* add a runtime symbol table entry */
    void add_runtime_symbol(class CVmRuntimeSymbols *symtab);
};

/*
 *   Enumerator 
 */
class CTcSymEnum: public CTcSymEnumBase
{
public:
    CTcSymEnum(const char *str, size_t len, int copy, ulong id, int is_token)
        : CTcSymEnumBase(str, len, copy, id, is_token)
    {
    }

    /* generate code */
    virtual void gen_code(int discard);

    /* write the symbol to an image file's global symbol table */
    int write_to_image_file_global(class CVmImageWriter *image_writer);

    /* add a runtime symbol table entry */
    void add_runtime_symbol(class CVmRuntimeSymbols *symtab);
};

/*
 *   local variable/parameter 
 */
class CTcSymLocal: public CTcSymLocalBase
{
public:
    CTcSymLocal(const char *str, size_t len, int copy,
                int is_param, int var_num)
        : CTcSymLocalBase(str, len, copy, is_param, var_num) { }

    /* generate code to evaluate the symbol */
    virtual void gen_code(int discard);

    /* generate code to store the value at top of stack in the variable */
    void gen_code_setlcl_stk() { s_gen_code_setlcl_stk(var_num_, is_param_); }

    /* generate code to get a local with a given ID */
    static void s_gen_code_getlcl(int local_id, int is_param);

    /* generate code to store a local with a given ID */
    static void s_gen_code_setlcl_stk(int local_id, int is_param);

    /* generate code to store the value at top of stack in the local */
    void gen_code_setlcl();

    /* assign to the variable */
    virtual int gen_code_asi(int discard, int phase,
                             tc_asitype_t typ, const char *op,
                             class CTcPrsNode *rhs,
                             int ignore_errors, int xplicit,
                             void **ctx);

    /* 
     *   generate a call - invoking a local as a function assumes that the
     *   local contains a method or function pointer 
     */
    virtual void gen_code_call(int discard, int argc, int varargs,
                               struct CTcNamedArgs *named_args);

    /* evaluate a property ID */
    vm_prop_id_t gen_code_propid(int check_only, int is_expr);

    /* generate a member expression */
    void gen_code_member(int discard,
                         class CTcPrsNode *prop_expr, int prop_is_expr,
                         int argc, int varargs,
                         struct CTcNamedArgs *named_args);

    /* get the object value for a '.' expression */
    vm_obj_id_t gen_code_obj_predot(int *is_self)
    {
        /* simply generate our code as normal */
        gen_code(FALSE);

        /* indicate that the caller must use generated code */
        *is_self = FALSE;
        return VM_INVALID_OBJ;
    }

    /* write the symbol to a debug frame */
    virtual int write_to_debug_frame(int test_only);
};

/*
 *   Run-time dynamic code local variable symbol.  This is the symbol type
 *   for a local accessed via a StackFrameRef object, for use in DynamicFunc
 *   compilations.  
 */
class CTcSymDynLocal: public CTcSymDynLocalBase
{
public:
    CTcSymDynLocal(const char *str, size_t len, int copy,
                   tctarg_obj_id_t fref, int varnum, int ctxidx)
        : CTcSymDynLocalBase(str, len, copy, fref, varnum, ctxidx)
    {
    }

    /* generate code */
    void gen_code(int discard);

    /* generate code for assigning into this node */
    int gen_code_asi(int discard, int phase, tc_asitype_t typ, const char *op,
                     class CTcPrsNode *rhs,
                     int ignore_errors, int xplicit, void **ctx);
};

/*
 *   built-in function 
 */
class CTcSymBif: public CTcSymBifBase
{
public:
    CTcSymBif(const char *str, size_t len, int copy,
              ushort func_set_id, ushort func_idx, int has_retval,
              int min_argc, int max_argc, int varargs)
        : CTcSymBifBase(str, len, copy, func_set_id, func_idx,
                        has_retval, min_argc, max_argc, varargs) { }

    /* generate code to evaluate the symbol */
    virtual void gen_code(int discard);

    /* generate a call */
    virtual void gen_code_call(int discard, int argc, int varargs,
                               struct CTcNamedArgs *named_args);

    /* generate code for an address '&' operator */
    virtual void gen_code_addr();

    /* write the symbol to an image file's global symbol table */
    int write_to_image_file_global(class CVmImageWriter *image_writer);

    /* add a runtime symbol table entry */
    void add_runtime_symbol(class CVmRuntimeSymbols *symtab);

};

/*
 *   external function 
 */
class CTcSymExtfn: public CTcSymExtfnBase
{
public:
    CTcSymExtfn(const char *str, size_t len, int copy,
                int argc, int varargs, int has_retval)
        : CTcSymExtfnBase(str, len, copy, argc, varargs, has_retval) { }

    /* generate code to evaluate the symbol */
    virtual void gen_code(int discard);

    /* generate a call */
    virtual void gen_code_call(int discard, int argc, int varargs,
                               struct CTcNamedArgs *named_args);

    /* write the symbol to an image file's global symbol table */
    int write_to_image_file_global(class CVmImageWriter *image_writer);
};

/*
 *   code label 
 */
class CTcSymLabel: public CTcSymLabelBase
{
public:
    CTcSymLabel(const char *str, size_t len, int copy)
        : CTcSymLabelBase(str, len, copy) { }

    /* generate code to evaluate the symbol */
    virtual void gen_code(int discard);
};

/* ------------------------------------------------------------------------ */
/*
 *   Anonymous function 
 */
class CTPNAnonFunc: public CTPNAnonFuncBase
{
public:
    CTPNAnonFunc(class CTPNCodeBody *code_body, int has_retval, int is_method)
        : CTPNAnonFuncBase(code_body, has_retval, is_method)
    {
    }

    /* generate code */
    virtual void gen_code(int discard, int for_condition);
};

/* ------------------------------------------------------------------------ */
/*
 *   Code Body 
 */
class CTPNCodeBody: public CTPNCodeBodyBase
{
public:
    CTPNCodeBody(class CTcPrsSymtab *lcltab, class CTcPrsSymtab *gototab,
                 class CTPNStm *stm, int argc, int opt_argc, int varargs,
                 int varargs_list, class CTcSymLocal *varargs_list_local,
                 int local_cnt, int self_valid,
                 struct CTcCodeBodyRef *enclosing_code_body)
        : CTPNCodeBodyBase(lcltab, gototab, stm, argc, opt_argc, varargs,
                           varargs_list, varargs_list_local,
                           local_cnt, self_valid, enclosing_code_body)
    {
        /* presume I'm not a constructor */
        is_constructor_ = FALSE;

        /* presume I won't need a 'finally' return value holder local */
        allocated_fin_ret_lcl_ = FALSE;
        fin_ret_lcl_ = 0;

        /* presume it won't be static */
        is_static_ = FALSE;

        /* no nested symbol table list yet */
        first_nested_symtab_ = 0;

        /* no named argument tables yet */
        named_arg_tables_ = 0;
    }

    /* 
     *   Mark the code body as belonging to a constructor.  A constructor
     *   must return its 'self' object as the return value.  
     */
    void set_constructor(int f) { is_constructor_ = f; }

    /* 
     *   mark the code body as static - this indicates that it is a static
     *   initializer
     */
    void set_static() { is_static_ = TRUE; }

    /* generate code */
    virtual void gen_code(int discard, int for_condition);

    /* check locals */
    virtual void check_locals();

    /*
     *   Allocate a local variable for temporarily saving the expression
     *   value of a 'return' statement while calling the enclosing
     *   'finally' block(s).  Returns the variable ID.  Only one such
     *   local is needed per code body, so if we've already allocated one
     *   for another 'return' statement, we'll just return the same one we
     *   allocated previously.  
     */
    uint alloc_fin_ret_lcl()
    {
        /* if we haven't allocated it yet, do so now */
        if (!allocated_fin_ret_lcl_)
        {
            /* use the next available local */
            fin_ret_lcl_ = local_cnt_++;

            /* note that we've allocated it */
            allocated_fin_ret_lcl_ = TRUE;
        }

        /* return the local ID */
        return fin_ret_lcl_;
    }

    /* 
     *   Add a named argument table to the code body.  Each call that has
     *   named arguments requires one of these tables.  We keep a list of
     *   tables, and generate them all at the end of the method.  Returns a
     *   label that can be used to write a forward reference offset to the
     *   table's offset in the code stream.  
     */
    struct CTcCodeLabel *add_named_arg_tab(
        const struct CTcNamedArgs *named_args);

protected:
    /* 
     *   callback for enumerating local frame symbol table entries - write
     *   each entry to the code stream as a debug record 
     */
    static void write_local_to_debug_frame(void *ctx, class CTcSymbol *sym);

    /* 
     *   enumerator for checking for parameter symbols that belong in the
     *   local context 
     */
    static void enum_for_param_ctx(void *ctx, class CTcSymbol *sym);

    /* enumerator for generating named parameter bindings */
    static void enum_for_named_params(void *ctx, class CTcSymbol *sym);

    /* write the debug information table to the code stream */
    void build_debug_table(ulong start_ofs, int include_lines);

    /* show disassembly */
    void show_disassembly(unsigned long start_ofs,
                          unsigned long code_start_ofs,
                          unsigned long code_end_ofs);

    /* head of list of nested symbol tables */
    class CTcPrsSymtab *first_nested_symtab_;

    /* head of list of named argument tables */
    struct CTcNamedArgTab *named_arg_tables_;

    /* 
     *   ID of local variable for temporarily storing the expression value
     *   of a 'return' statement while calling the enclosing 'finally'
     *   block(s); valid only when allocated_fin_ret_lcl_ is true 
     */
    uint fin_ret_lcl_;

    /* flag: I'm a constructor */
    uint is_constructor_ : 1;

    /* 
     *   flag: I've allocated a local for saving the expression value of a
     *   'return' statement while calling the enclosing 'finally' block(s) 
     */
    uint allocated_fin_ret_lcl_ : 1;

    /* flag: I'm a static property initializer */
    uint is_static_ : 1;
};

/* ------------------------------------------------------------------------ */
/*
 *   Compound Statement
 */
class CTPNStmComp: public CTPNStmCompBase
{
public:
    CTPNStmComp(class CTPNStm *first_stm, class CTcPrsSymtab *symtab)
        : CTPNStmCompBase(first_stm, symtab) { }
};

/* ------------------------------------------------------------------------ */
/*
 *   Null statement 
 */
class CTPNStmNull: public CTPNStmNullBase
{
public:
    CTPNStmNull() { }
};

/* ------------------------------------------------------------------------ */
/*
 *   Expression statement 
 */
class CTPNStmExpr: public CTPNStmExprBase
{
public:
    CTPNStmExpr(class CTcPrsNode *expr)
        : CTPNStmExprBase(expr) { }
};

/* ------------------------------------------------------------------------ */
/*
 *   Static property initializer statement
 */
class CTPNStmStaticPropInit: public CTPNStmStaticPropInitBase
{
public:
    CTPNStmStaticPropInit(class CTcPrsNode *expr,
                          tctarg_prop_id_t prop)
        : CTPNStmStaticPropInitBase(expr, prop) { }

    /* generate code */
    virtual void gen_code(int discard, int for_condition);
};

/* ------------------------------------------------------------------------ */
/*
 *   'if' statement 
 */
class CTPNStmIf: public CTPNStmIfBase
{
public:
    CTPNStmIf(class CTcPrsNode *cond_expr,
              class CTPNStm *then_part, class CTPNStm *else_part)
        : CTPNStmIfBase(cond_expr, then_part, else_part) { }
    
    /* generate code */
    virtual void gen_code(int discard, int for_condition);
};

/* ------------------------------------------------------------------------ */
/*
 *   'for' statement 
 */
class CTPNStmFor: public CTPNStmForBase
{
public:
    CTPNStmFor(class CTcPrsNode *init_expr,
               class CTcPrsNode *cond_expr,
               class CTcPrsNode *reinit_expr,
               class CTPNForIn *in_exprs,
               class CTcPrsSymtab *symtab,
               class CTPNStmEnclosing *enclosing_stm)
        : CTPNStmForBase(init_expr, cond_expr, reinit_expr, in_exprs,
                         symtab, enclosing_stm)
    {
    }

    /* generate code */
    virtual void gen_code(int discard, int for_condition);

    /* generate code for 'break' */
    virtual int gen_code_break(const textchar_t *lbl, size_t lbl_len)
        { return gen_code_break_loop(break_lbl_, lbl, lbl_len); }

    /* generate code for 'continue' */
    virtual int gen_code_labeled_continue()
        { return gen_code_continue_loop(cont_lbl_, 0, 0); }

    /* generate code for a labeled 'continue' */
    virtual int gen_code_continue(const textchar_t *lbl, size_t lbl_len)
        { return gen_code_continue_loop(cont_lbl_, lbl, lbl_len); }

protected:
    /* our 'break' label */
    struct CTcCodeLabel *break_lbl_;

    /* our 'continue' label */
    struct CTcCodeLabel *cont_lbl_;
};

/* ------------------------------------------------------------------------ */
/*
 *   '<variable> in <expression>' node, for 'for' statements 
 */
class CTPNVarIn: public CTPNVarInBase
{
public:
    CTPNVarIn(class CTcPrsNode *lval, class CTcPrsNode *expr,
              int iter_local_id)
        : CTPNVarInBase(lval, expr, iter_local_id) { }

    /* generate code */
    virtual void gen_code(int discard, int for_condition);

    /* generate the condition part of the 'for' */
    virtual void gen_forstm_cond(struct CTcCodeLabel *endlbl);

    /* generate the reinit part of the 'for' */
    virtual void gen_forstm_reinit();

    /* 
     *   Generate the iterator initializer.  This is a static method so that
     *   it can be shared by for..in and foreach..in.  'kw' is the keyword
     *   for the statement type that we're generating ("for" or "foreach"),
     *   so that we can show the appropriate statement type in any error
     *   messages.  
     */
    static void gen_iter_init(class CTcPrsNode *coll_expr, int iter_local_id,
                              const char *kw);

    /* 
     *   Generate the iterator condition.  This is a static method so that it
     *   can be shared by for..in and foreach..in. 
     */
    static void gen_iter_cond(class CTcPrsNode *lval, int iter_local_id,
                              struct CTcCodeLabel *&endlbl, const char *kw);
};

/*
 *   '<variable> in <from> .. <to>' node, for 'for' statements 
 */
class CTPNVarInRange: public CTPNVarInRangeBase
{
public:
    CTPNVarInRange(class CTcPrsNode *lval,
                   class CTcPrsNode *from_expr,
                   class CTcPrsNode *to_expr,
                   class CTcPrsNode *step_expr,
                   int to_local_id, int step_local_id)
        : CTPNVarInRangeBase(lval, from_expr, to_expr, step_expr,
                             to_local_id, step_local_id)
    { }

    /* generate code */
    virtual void gen_code(int discard, int for_condition);

    /* generate the condition part of the 'for' */
    virtual void gen_forstm_cond(struct CTcCodeLabel *endlbl);

    /* generate the reinit part of the 'for' */
    virtual void gen_forstm_reinit();
};


/* ------------------------------------------------------------------------ */
/*
 *   'for' statement 
 */
class CTPNStmForeach: public CTPNStmForeachBase
{
public:
    CTPNStmForeach(class CTcPrsNode *iter_expr,
                   class CTcPrsNode *coll_expr,
                   class CTcPrsSymtab *symtab,
                   class CTPNStmEnclosing *enclosing_stm,
                   int iter_local_id)
        : CTPNStmForeachBase(iter_expr, coll_expr, symtab, enclosing_stm,
                             iter_local_id)
    {
    }

    /* generate code */
    virtual void gen_code(int discard, int for_condition);

    /* generate code for 'break' */
    virtual int gen_code_break(const textchar_t *lbl, size_t lbl_len)
        { return gen_code_break_loop(break_lbl_, lbl, lbl_len); }

    /* generate code for 'continue' */
    virtual int gen_code_labeled_continue()
        { return gen_code_continue_loop(cont_lbl_, 0, 0); }

    /* generate code for a labeled 'continue' */
    virtual int gen_code_continue(const textchar_t *lbl, size_t lbl_len)
        { return gen_code_continue_loop(cont_lbl_, lbl, lbl_len); }

protected:
    /* our 'break' label */
    struct CTcCodeLabel *break_lbl_;

    /* our 'continue' label */
    struct CTcCodeLabel *cont_lbl_;
};

/* ------------------------------------------------------------------------ */
/*
 *   'break' statement 
 */
class CTPNStmBreak: public CTPNStmBreakBase
{
public:
    CTPNStmBreak() { }

    /* generate code */
    virtual void gen_code(int discard, int for_condition);
};

/* ------------------------------------------------------------------------ */
/*
 *   'continue' statement 
 */
class CTPNStmContinue: public CTPNStmContinueBase
{
public:
    CTPNStmContinue() { }

    /* generate code */
    virtual void gen_code(int discard, int for_condition);
};

/* ------------------------------------------------------------------------ */
/*
 *   'while' statement 
 */
class CTPNStmWhile: public CTPNStmWhileBase
{
public:
    CTPNStmWhile(class CTcPrsNode *cond_expr,
                 class CTPNStmEnclosing *enclosing_stm)
        : CTPNStmWhileBase(cond_expr, enclosing_stm) { }

    /* generate code */
    virtual void gen_code(int discard, int for_condition);

    /* generate code for 'break' */
    virtual int gen_code_break(const textchar_t *lbl, size_t lbl_len)
        { return gen_code_break_loop(break_lbl_, lbl, lbl_len); }

    /* generate code for 'continue' */
    virtual int gen_code_labeled_continue()
        { return gen_code_continue_loop(cont_lbl_, 0, 0); }

    /* generate code for a labeled 'continue' */
    virtual int gen_code_continue(const textchar_t *lbl, size_t lbl_len)
        { return gen_code_continue_loop(cont_lbl_, lbl, lbl_len); }

protected:
    /* our 'break' label */
    struct CTcCodeLabel *break_lbl_;

    /* our 'continue' label */
    struct CTcCodeLabel *cont_lbl_;
};

/* ------------------------------------------------------------------------ */
/*
 *   'do-while' statement 
 */
class CTPNStmDoWhile: public CTPNStmDoWhileBase
{
public:
    CTPNStmDoWhile(class CTPNStmEnclosing *enclosing_stm)
        : CTPNStmDoWhileBase(enclosing_stm) { }

    /* generate code */
    virtual void gen_code(int discard, int for_condition);

    /* generate code for 'break' */
    virtual int gen_code_break(const textchar_t *lbl, size_t lbl_len)
        { return gen_code_break_loop(break_lbl_, lbl, lbl_len); }

    /* generate code for 'continue' */
    virtual int gen_code_labeled_continue()
        { return gen_code_continue_loop(cont_lbl_, 0, 0); }

    /* generate code for a labeled 'continue' */
    virtual int gen_code_continue(const textchar_t *lbl, size_t lbl_len)
        { return gen_code_continue_loop(cont_lbl_, lbl, lbl_len); }

protected:
    /* our 'break' label */
    struct CTcCodeLabel *break_lbl_;

    /* our 'continue' label */
    struct CTcCodeLabel *cont_lbl_;
};

/* ------------------------------------------------------------------------ */
/*
 *   'return' statement 
 */
class CTPNStmReturn: public CTPNStmReturnBase
{
public:
    CTPNStmReturn(class CTcPrsNode *expr)
        : CTPNStmReturnBase(expr) { }

    /* generate code */
    virtual void gen_code(int discard, int for_condition);
};

/* ------------------------------------------------------------------------ */
/*
 *   'switch' statement 
 */
class CTPNStmSwitch: public CTPNStmSwitchBase
{
public:
    CTPNStmSwitch(class CTPNStmEnclosing *enclosing_stm)
        : CTPNStmSwitchBase(enclosing_stm)
    {
        /* the 'case' and 'default' slot pointers aren't valid yet */
        case_slot_ofs_ = 0;
        default_slot_ofs_ = 0;
    }

    /* generate code */
    virtual void gen_code(int discard, int for_condition);

    /* 
     *   Get the next case slot offset, and consume the slot.  Each call
     *   consumes one slot.  This is valid only during code generation in
     *   the switch body; 'case' labels use this to figure out where to
     *   write their data.  
     */
    ulong alloc_case_slot()
    {
        ulong ret;

        /* note the value to return */
        ret = case_slot_ofs_;

        /* move our internal counter to the next slot */
        case_slot_ofs_ += VMB_DATAHOLDER + VMB_UINT2;

        /* return the allocated slot */
        return ret;
    }

    /* get the code offset of the 'default' case slot */
    ulong get_default_slot() const { return default_slot_ofs_; }

    /* generate code for 'break' */
    virtual int gen_code_break(const textchar_t *lbl, size_t lbl_len)
    {
        /* 
         *   if there's no label, and we don't have a 'break' label
         *   ourselves, it must mean that we're processing an unreachable
         *   'break' - we can simply do nothing in this case and pretend we
         *   succeeded 
         */
        if (lbl == 0 && break_lbl_ == 0)
            return TRUE;

        /* break to our break label */
        return gen_code_break_loop(break_lbl_, lbl, lbl_len);
    }

protected:
    /* 
     *   code offset of the next 'case' slot to be allocated from the
     *   switch's case table - this is only valid during generation of the
     *   body, because we set this up during generation of the switch
     *   itself 
     */
    ulong case_slot_ofs_;

    /* code offset of the 'default' slot */
    ulong default_slot_ofs_;

    /* our 'break' label */
    struct CTcCodeLabel *break_lbl_;
};


/* ------------------------------------------------------------------------ */
/*
 *   code label statement 
 */
class CTPNStmLabel: public CTPNStmLabelBase
{
public:
    CTPNStmLabel(class CTcSymLabel *lbl, class CTPNStmEnclosing *enclosing);

    /* generate code */
    virtual void gen_code(int discard, int for_condition);

    /* generate code for 'break' */
    virtual int gen_code_break(const textchar_t *lbl, size_t lbl_len);

    /* generate code for 'continue' */
    virtual int gen_code_continue(const textchar_t *lbl, size_t lbl_len);

    /* 
     *   Generate code for a labeled 'continue'.  We'll simply generate
     *   code for a labeled continue in our enclosed statement.
     *   
     *   (This is normally a routine that *we* call on our contained
     *   statement in response to a 'continue' being targeted at this
     *   label.  This can be invoked on us, however, when a statement has
     *   multiple labels, and the outer label is mentioned in the 'break'
     *   -- the outer label will call this routine on the inner label,
     *   which is us, so we simply need to pass it along to the enclosed
     *   statement.)  
     */
    virtual int gen_code_labeled_continue()
        { return (stm_ != 0 ? stm_->gen_code_labeled_continue() : FALSE); }

    /* get my 'goto' label */
    struct CTcCodeLabel *get_goto_label();

protected:
    /* the byte label to jump to this statement */
    struct CTcCodeLabel *goto_label_;

    /* the byte label to break from this statement */
    struct CTcCodeLabel *break_label_;
};

/* ------------------------------------------------------------------------ */
/*
 *   'case' label statement 
 */
class CTPNStmCase: public CTPNStmCaseBase
{
public:
    CTPNStmCase() { }

    /* generate code */
    virtual void gen_code(int discard, int for_condition);
};

/* ------------------------------------------------------------------------ */
/*
 *   'default' label statement 
 */
class CTPNStmDefault: public CTPNStmDefaultBase
{
public:
    CTPNStmDefault() { }

    /* generate code */
    virtual void gen_code(int discard, int for_condition);
};

/* ------------------------------------------------------------------------ */
/*
 *   'try' block 
 */
class CTPNStmTry: public CTPNStmTryBase
{
public:
    CTPNStmTry(class CTPNStmEnclosing *enclosing)
        : CTPNStmTryBase(enclosing)
    {
    }

    /* generate code */
    virtual void gen_code(int discard, int for_condition);

    /* generate code for 'break' */
    virtual int gen_code_break(const textchar_t *lbl, size_t lbl_len);

    /* generate code for 'continue' */
    virtual int gen_code_continue(const textchar_t *lbl, size_t lbl_len);

    /* 
     *   Generate the code necessary to unwind for returning.  We must
     *   generate a call to our 'finally' code, then unwind any enclosing
     *   statements. 
     */
    virtual void gen_code_unwind_for_return()
    {
        /* call 'finally' on the way out */
        gen_jsr_finally();

        /* inherit default to unwind enclosing statements */
        CTPNStmTryBase::gen_code_unwind_for_return();
    }

    /* determine if we'll generate code for unwinding from a return */
    virtual int will_gen_code_unwind_for_return() const
    {
        /* we'll generate a call to our 'finally' block if we have one */
        if (finally_stm_ != 0)
            return TRUE;

        /* we'll also generate code if any enclosing statement does */
        return CTPNStmTryBase::will_gen_code_unwind_for_return();
    }

    /* generate the code necessary to transfer out of the block */
    virtual void gen_code_for_transfer_out()
    {
        /* call 'finally' on the way out */
        gen_jsr_finally();
    }

    /* 
     *   generate a local subroutine call to our 'finally' block, if we
     *   have a 'finally' block - this should be invoked whenever code
     *   within the protected block or a 'catch' block executes a break,
     *   continue, return, or goto out of the protected region, or when
     *   merely falling off the end of the protected block or a 'catch'
     *   block.  
     */
    void gen_jsr_finally();

    /* get my 'finally' label */
    struct CTcCodeLabel *get_finally_lbl() const { return finally_lbl_; }
    
protected:
    /* our 'finally' label */
    struct CTcCodeLabel *finally_lbl_;
};

/* ------------------------------------------------------------------------ */
/*
 *   'catch'
 */
class CTPNStmCatch: public CTPNStmCatchBase
{
public:
    CTPNStmCatch() { }

    /* generate code */
    virtual void gen_code(int discard, int for_condition);

    /* generate code for the 'catch' clause */
    virtual void gen_code_catch(ulong protected_start_ofs,
                                ulong protected_end_ofs);
};

/* ------------------------------------------------------------------------ */
/*
 *   'finally' 
 */
class CTPNStmFinally: public CTPNStmFinallyBase
{
public:
    CTPNStmFinally(CTPNStmEnclosing *enclosing,
                   int exc_local_id, int jsr_local_id)
        : CTPNStmFinallyBase(enclosing, exc_local_id, jsr_local_id)
    {
    }

    /* generate code */
    virtual void gen_code(int discard, int for_condition);

    /* generate code for the 'finally' clause */
    virtual void gen_code_finally(ulong protected_start_ofs,
                                  ulong protected_end_ofs,
                                  class CTPNStmTry *try_stm);

    /* check for transfer in via 'goto' statements */
    virtual int check_enter_by_goto(class CTPNStmGoto *goto_stm,
                                    class CTPNStmLabel *target);
};


/* ------------------------------------------------------------------------ */
/*
 *   'throw' statement 
 */
class CTPNStmThrow: public CTPNStmThrowBase
{
public:
    CTPNStmThrow(class CTcPrsNode *expr)
        : CTPNStmThrowBase(expr)
    {
    }
    
    /* generate code */
    virtual void gen_code(int discard, int for_condition);
};


/* ------------------------------------------------------------------------ */
/*
 *   'goto' statement 
 */
class CTPNStmGoto: public CTPNStmGotoBase
{
public:
    CTPNStmGoto(const textchar_t *lbl, size_t lbl_len)
        : CTPNStmGotoBase(lbl, lbl_len)
    {
    }

    /* generate code */
    virtual void gen_code(int discard, int for_condition);
};

/* ------------------------------------------------------------------------ */
/*
 *   'dictionary' statement 
 */
class CTPNStmDict: public CTPNStmDictBase
{
public:
    CTPNStmDict(class CTcDictEntry *dict)
        : CTPNStmDictBase(dict)
    {
    }

    /* generate code */
    virtual void gen_code(int, int) { }
};

/* ------------------------------------------------------------------------ */
/*
 *   Object Definition 
 */
class CTPNStmObject: public CTPNStmObjectBase
{
public:
    CTPNStmObject(class CTcSymObj *obj_sym, int is_class)
        : CTPNStmObjectBase(obj_sym, is_class)
    {
    }

    /* generate code */
    virtual void gen_code(int discard, int for_condition);

    /* check locals */
    virtual void check_locals();

    /* 
     *   given the stream offset for the start of the object data in the
     *   stream, get information on the object from the stream data:
     *   
     *.  - get the number of properties in the stream data 
     *.  - set the number of properties in the stream data, updating the
     *   stored data size in the metaclass header in the stream; returns
     *   the new data size
     *.  - get the number of superclasses in the stream data
     *.  - get a superclass object ID
     *.  - get the offset of the first property in the stream data
     *.  - get the offset of the property at the given index
     *.  - get the ID of the object's property at the given index
     *.  - set the ID of the object's property at the given index
     *.  - get the object flags from the tads-object header
     *.  - set the object flags in the tads-object heade 
     */
    static uint get_stream_prop_cnt(class CTcDataStream *stream,
                                    ulong obj_ofs);
    static size_t set_stream_prop_cnt(class CTcDataStream *stream,
                                      ulong obj_ofs, uint prop_cnt);
    static uint get_stream_sc_cnt(class CTcDataStream *stream,
                                  ulong obj_ofs);
    static vm_obj_id_t get_stream_sc(class CTcDataStream *stream,
                                     ulong obj_ofs, uint sc_idx);
    static void set_stream_sc(class CTcDataStream *stream,
                              ulong obj_ofs, uint sc_idx, vm_obj_id_t new_sc);
    static ulong get_stream_first_prop_ofs(class CTcDataStream *stream,
                                           ulong obj_ofs);
    static ulong get_stream_prop_ofs(class CTcDataStream *stream,
                                     ulong obj_ofs, uint prop_idx);
    static vm_prop_id_t get_stream_prop_id(class CTcDataStream *stream,
                                           ulong obj_ofs, uint prop_idx);
    static enum vm_datatype_t
        get_stream_prop_type(class CTcDataStream *stream,
                             ulong obj_ofs, uint prop_idx);
    static ulong get_stream_prop_val_ofs(class CTcDataStream *stream,
                                         ulong obj_ofs, uint prop_idx);
    static void set_stream_prop_id(class CTcDataStream *stream,
                                   ulong obj_ofs, uint prop_idx,
                                   vm_prop_id_t new_id);
    static uint get_stream_obj_flags(class CTcDataStream *stream,
                                     ulong obj_ofs);
    static void set_stream_obj_flags(class CTcDataStream *stream,
                                     ulong obj_ofs, uint flags);
};

/*
 *   Inline object definition (defined within an expression)
 */
class CTPNInlineObject: public CTPNInlineObjectBase
{
public:
    /* generate code */
    virtual void gen_code(int discard, int for_condition);
};


/*
 *   Property Value list entry 
 */
class CTPNObjProp: public CTPNObjPropBase
{
public:
    CTPNObjProp(class CTPNObjDef *objdef, class CTcSymProp *prop_sym,
                class CTcPrsNode *expr, class CTPNCodeBody *code_body,
                class CTPNAnonFunc *inline_method, int is_static)
        : CTPNObjPropBase(
            objdef, prop_sym, expr, code_body, inline_method, is_static)
    {
    }
    
    /* generate code */
    virtual void gen_code(int discard, int for_condition);

    /* generate code for an inline object instantiation */
    void gen_code_inline_obj();

    /* check locals */
    void check_locals();

protected:
    /* generate a setMethod() call for inline object creation */
    void gen_setMethod();
};

/*
 *   Implicit constructor 
 */
class CTPNStmImplicitCtor: public CTPNStmImplicitCtorBase
{
public:
    CTPNStmImplicitCtor(class CTPNStmObject *obj_stm)
        : CTPNStmImplicitCtorBase(obj_stm)
    {
    }

    /* generate code */
    virtual void gen_code(int discard, int for_condition);
};


#endif /* TCT3DRV_H */