compil.h
60.8 KB
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
/* compil.h ********************************************************
Anubis.
The Anubis compiler header file.
*******************************************************************/
/*
This file is the global header for the Anubis compiler.
*/
#include "AnubisSupport.h"
#ifdef _DEBUG
# define _DEBUG_
#endif
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
/* expressions */
typedef unsigned int Expr;
//#define mallocz(n) (printf("mallocz(%d) at %s line %d\n",n,__FILE__,__LINE__),mallocz1(n))
//#define reallocz(p,n) (printf("reallocz(_,%d) at %s line %d\n",n,__FILE__,__LINE__),reallocz1(p,n))
#ifdef __cplusplus
extern "C" {
#endif
#define mallocz(n) mallocz1(n)
#define reallocz(p,n) reallocz1(p,n)
#define max_already_included (1024)
/* general */
extern int make_shell_file;
extern int pre_polish;
extern int polish;
extern int tab_width;
extern char * ext_com;
extern int ext_com_index;
extern int ext_com_size;
extern int file_id;
extern int dct;
extern int dcti;
extern int check_all;
extern int error_banner_sent;
extern int par_seen;
extern bigtime_t par_start_time;
extern int reading_predef;
extern int make_strong_file;
extern int no_preemption;
extern FILE * predef_aux;
extern FILE * predef_npd_aux; /* version of predef.aux that avoids the use of predef.dat */
extern FILE * predef_dat;
extern FILE * strong_file;
extern int yyerror (char *s);
extern FILE * yyin;
extern char * current_file_abs_path; /* relative path of current source file */
extern const char * home_directory;
extern char start_dir[];
extern const char * anubis_directory;
extern const char * my_anubis_directory;
extern char * djed;
extern const char * my_shells_directory;
extern const char * library_directory;
extern const char * my_library_directory;
extern int stop_after;
extern char * abs_file_paths_stack[];
extern char * include_dir[];
extern int include_lines[];
extern char * already_included[];
extern int next_already_included;
extern void initialize_visibility(void);
extern void check_head(Expr head); // for visibility of subterms
extern int symcode_option;
extern int show_reads;
extern FILE * show_reads_file;
extern int show_to_do;
extern void finish_show_reads(void);
extern int is_visible(char *filename); // visibility from current file
extern int current_par_line;
extern void show_missing_reads(void);
extern void add_missing_read(int which);
extern int configure;
extern FILE * symcode_txt;
extern int show_brackets;
extern int verbose;
extern int cverbose;
extern int malloc_secure;
extern int public_decs_src_file;
extern int profiling;
extern int more;
extern int initializing;
extern void _add_to_already_included(const char *name, int line, const char *srcfile);
#define add_to_already_included(name) _add_to_already_included(name, __LINE__, __FILE__)
extern int is_already_included(char *name);
extern int _get_file_id(const char *name, int line, const char *file);
#define get_file_id(name) _get_file_id(name, __LINE__, __FILE__)
extern int yyparse(void);
extern int anb_yylex(void);
extern int C_struct_id(Expr name);
extern int unput_token;
extern void end_of_par(void);
extern int all_errors;
extern int errors;
extern int incorrect_pars;
extern int types_only;
extern int currently_debugging;
extern void * mallocz1(int);
extern void * reallocz1(void *, size_t);
extern void freez(void *);
extern char * strdupz(const char *);
extern char * strduppz(const char *, const char *);
extern char * strdupppz(const char *, const char *, const char *);
extern FILE * fopenz(const char *name, const char *mode);
extern FILE * fopensrc(const char *name);
void mkdirz(const char *dirname);
extern int lineno;
extern int colno;
extern void do_predefinitions1(void);
extern void do_predefinitions2(void);
extern void read_predef_dat(void);
extern int * offsets;
extern int offsets_size;
extern int check_only;
extern int with_types;
extern int first_user_op;
extern int first_user_type;
extern int include_stack_ptr;
extern void produce_index(void);
extern void make_public_decs_src_file(FILE *fp);
extern void make_global_index(int argc, const char **argv);
extern char * current_name;
extern int gindex;
extern int warn_alert;
extern int dump_used;
extern int dump_unused;
extern int read1;
extern char str_buf[];
extern Expr to_bigits_10000(char *text);
extern int anb_exit(int);
extern void begin_CONFCOM(void);
extern void begin_INITIAL(void);
extern int phase;
extern int optimization_flags;
#define opt_flag_grp (1)
#define opt_flag_gc (2)
#define opt_flag_copy (4)
extern Expr optimize_definition_code(Expr);
extern Expr optimize_del_code(Expr);
extern char * fopensrc_cur_dir;
extern int is_absolute_path(const char *);
extern void NormalizeFileName(char *pathName);
/* getting the filename, line or column packed in an integer:
The 32 bits in a packed integer are as follows (most significant on the left):
ffff ffff llll llll llll lllc cccc ccc0
where f is the id of the file name (8 bits),
l the line number (15 bits)
c the column number (8 bits)
*/
//#define file_in(x) (assert(((int)((x)>>24)) < max_already_included), already_included[(x)>>24])
//#define line_in(x) (((x)>>9)&0x7FFF)
//#define col_in(x) (((x)>>1)&0xFF)
/*
New representation of file+line+column. Instead of a LISP integer, we now have a mcons3
of the form mcons3(file,line,col) where file, line and col Lisp integers.
*/
#define file_in(x) (assert(((int)(integer_value(car(x)))) < max_already_included), already_included[integer_value(car(x))])
#define line_in(x) integer_value(second(x))
#define col_in(x) integer_value(cdr2(x))
#define dummy_lc mcons3(0,0,0)
#define mw (32) /* width of machine */
/* miscellaneous */
extern void dump(void);
#define sup(x,y) ((x)<(y)?(y):(x))
#define inf(x,y) ((x)<(y)?(x):(y))
/* classification of expressions:
0 mod 2 ---------------------------------> (signed) integers
1 mod 2 ---> 1 mod 32 ------------------> tags
3 mod 32 ------------------> temporary pairs
5 mod 32 ------------------> strings
7 mod 32 ---> 7 mod 64 ---> user defined type variables
39 mod 64 ---> internal type variables (unknowns)
9 mod 32 ------------------> permanent pairs
*/
extern Expr linecol(void);
#define is_integer(expr) (((expr)&1)==0)
#define is_tag(expr) (((expr)&31)==1)
#define is_tpair(expr) (((expr)&31)==3)
#define is_string(expr) (((expr)&31)==5)
#define is_type_variable(expr) (((expr)&31)==7)
#define is_user_type_variable(expr) (((expr)&63)==7)
#define is_unknown(expr) (((expr)&63)==39)
#define is_ppair(expr) (((expr)&31)==9)
#define new_integer(n) ((n)<<1)
/* keep the sign bit */
#define integer_value(expr) (((expr)>>1)|((expr)&(0x80000000)))
#define new_tag(i) (((i)<<5)|1)
#include "bytecode.h"
#define address_types_list\
item(type_RStream)\
item(type_WStream)\
item(type_RWStream)\
item(type_GAddr)\
item(type_Var)\
item(type_MVar)\
item(pseudo_type_MVar_Slot)\
#define tag_list\
primitive_types_list\
item(type_Listener)\
address_types_list\
syscall_list\
syscall32_list\
item(nil)\
item(alert)\
item(used)\
item(not_used)\
item(debug_avm)\
item(avm)\
item(terminal)\
item(start_debug_avm)\
item(stop_debug_avm)\
item(header)\
item(app)\
item(cond)\
item(type_by_id)\
item(else_case)\
item(select_cond)\
item(select_cond_interp)\
item(select_index_direct)\
item(select_index_indirect)\
item(operation)\
item(small_datum)\
item(of_type)\
item(local)\
item(micro_local)\
item(rel)\
item(apply)\
item(symbol)\
item(integer_10)\
item(integer_16)\
item(fpnum)\
item(anb_int32)\
item(glue)\
item(glue_index)\
item(push)\
item(pop1)\
item(swap)\
item(push_pointer)\
item(collapse)\
item(segment)\
item(app_ts)\
item(not_unifiable)\
item(key_not_found)\
item(constructor)\
item(type_scheme)\
item(tuple_type)\
item(noname)\
item(anb_read)\
item(anb_write)\
item(anb_exchange)\
item(string)\
item(no_term)\
item(small_type)\
item(mixed_type)\
item(large_type)\
item(small_alt)\
item(mixed_alt)\
item(large_alt)\
item(with)\
item(functype)\
item(power_type)\
item(set)\
item(op_addr)\
item(peek)\
item(call)\
item(label)\
item(ret_point)\
item(ret)\
item(invalid)\
item(del_index_direct)\
item(del_index_indirect)\
item(eq)\
item(eq_string)\
item(eq_byte_array)\
item(eq_int)\
item(jmp)\
item(unload)\
item(index_direct)\
item(index_indirect)\
item(_switch)\
item(address)\
item(store)\
item(store_0)\
item(store_1)\
item(store_2)\
item(store_4)\
item(store_index)\
item(alloc)\
item(jmp_eq)\
item(jmp_false)\
item(true_jmp)\
item(eq_indexes_indirect)\
item(end_of_code)\
item(no_instr)\
item(unglue)\
item(unstore)\
item(jmp_neq_indexes_mixed)\
item(jmp_neq_indexes_large)\
item(jmp_neq_string)\
item(jmp_neq_byte_array)\
item(jmp_neq_int)\
item(jmp_eq_stack)\
item(jmp_neq)\
item(push_eq_data)\
item(false_jmp)\
item(increment_eq)\
item(increment_del)\
item(indirect_del)\
item(indirect_del_mixed)\
item(indirect_del_ptr)\
item(indirect_del_conn)\
item(indirect_del_var)\
item(indirect_del_mvar)\
item(indirect_del_struct_ptr)\
item(indirect_del_function)\
item(del)\
item(del_var)\
item(copy_mixed)\
item(copy_ptr)\
item(copy_function)\
item(vcopy_mixed)\
item(vcopy_ptr)\
item(vcopy_function)\
item(vcopy_null)\
item(del_ptr)\
item(del_function)\
item(del_conn)\
item(del_struct_ptr)\
item(unstore_copy_mixed)\
item(unstore_copy_ptr)\
item(unstore_copy_function)\
item(check_stack)\
item(push_addr)\
item(del_stack)\
item(del_stack_mixed)\
item(del_stack_ptr)\
item(del_stack_conn)\
item(del_stack_var)\
item(del_stack_struct_ptr)\
item(del_stack_function)\
item(del_stack_mvar)\
item(glue_mixed_index)\
item(del_mixed)\
item(load_word32)\
item(load_int_small)\
item(load_int_big)\
item(load_float)\
item(free_seg_0)\
item(free_seg_1_pop2_ret)\
item(comment)\
item(context)\
item(code_for)\
item(argument)\
item(wait_for)\
item(connect_to_file)\
item(connect_to_IP)\
item(give_up)\
item(delegate)\
item(start)\
item(finish)\
item(copy_stack_ptr)\
item(copy_stack_mixed)\
item(copy_stack_function)\
item(free_var_seg)\
item(free_mvar_seg)\
item(pending_event)\
item(implies)\
item(forall)\
item(exists)\
item(exists_unique)\
item(description)\
item(omega_true)\
item(omega_false)\
item(type_list)\
item(global_variable)\
item(create_var)\
item(create_mvar)\
item(xchg_gvv)\
item(get_gvv)\
item(xchg_vv)\
item(get_vv)\
item(location)\
item(init_gv)\
item(del_gv)\
item(type_0)\
item(type_8)\
item(type_16)\
item(type_32)\
item(type_small_alt)\
item(type_mixed)\
item(type_large)\
item(indirect_type_0)\
item(indirect_type_8)\
item(indirect_type_16)\
item(indirect_type_32)\
item(indirect_type_mixed)\
item(indirect_type_large)\
item(type_mixed_switch)\
item(type_large_switch)\
item(serialize)\
item(unserialize)\
item(revert_to_computing)\
item(indirect_type_RStream)\
item(indirect_type_WStream)\
item(indirect_type_RWStream)\
item(indirect_type_GAddr)\
item(indirect_type_Var)\
item(indirect_type_MVar)\
item(indirect_type_String)\
item(indirect_type_ByteArray)\
item(indirect_type_Int32)\
item(indirect_type_Int)\
item(indirect_type_Float)\
item(indirect_type_Listener)\
item(mixed_alt_begin)\
item(large_alt_begin)\
item(mixed_alt_end)\
item(large_alt_end)\
item(success)\
item(type_rep)\
item(type_struct_ptr)\
item(bit_width)\
item(vcopy)\
item(dec3)\
item(pop3)\
item(indirect_type)\
item(func)\
item(type_def)\
item(alt)\
item(define)\
item(protect)\
item(unprotect)\
item(lock)\
item(unlock)\
item(alt_number)\
item(alt_number_direct)\
item(alt_number_indirect)\
item(program)\
item(lambda)\
item(closure)\
item(gv_address)\
item(create_vars)\
item(initialization_address)\
item(variables_deletion_address)\
item(already_seen)\
item(defined_type)\
item(kill_next_instr)\
item(proof_type)\
item(ret_if_zero)\
item(get_var_handler)\
item(get_var_monitors)\
item(f_micro_ctxt)\
item(odd_align)\
item(put_closure_labels)\
item(micro_peek)\
item(put_copy_direct)\
item(put_copy_indirect)\
item(put_copy_mixed)\
item(put_copy_function)\
item(put_micro_copy_direct)\
item(put_micro_copy_indirect)\
item(put_micro_copy_mixed)\
item(put_micro_copy_function)\
item(we_have)\
item(assume)\
item(let)\
item(enough)\
item(anb_public)\
item(remove_monitor)\
item(mvar_slots_del)\
item(mvar_slots_del_mixed)\
item(mvar_slots_del_ptr)\
item(mvar_slots_del_conn)\
item(mvar_slots_del_var)\
item(mvar_slots_del_mvar)\
item(mvar_slots_del_function)\
item(mvar_slots_del_struct_ptr)\
item(push_mvar_length)\
item(mvar_access)\
item(get_mvar_handler)\
item(get_mvar_monitors)\
item(xchg_mvv)\
item(get_mvv)\
item(rec_lambda)\
item(type_desc)\
item(type_desc_interp)\
item(indirect_type_Omega)\
item(type_Proof)\
item(i_of_type)\
item(i_no_case_cond)\
item(not_a_sum)\
item(non_singleton_nested_head)\
item(finished)\
item(anb_int_10)\
item(anb_int_16)\
item(del_stack_int)\
item(unstore_copy_int)\
item(copy_int)\
item(vcopy_int)\
item(del_int)\
item(copy_stack_int)\
item(put_micro_copy_int)\
item(put_copy_int)\
item(mvar_slots_del_int)\
item(indirect_del_int)\
item(begin_op)\
item(end_op)\
item(word_64)\
item(word_128)\
item(nop)\
item(forall_type)\
item(term_forall_type)\
item(i_forall_type)\
item(type_alias)\
item(peek_copy_push_ptr)\
item(peek_copy_push_function)\
item(peek_copy_push_int)\
item(peek_copy_push_mixed)\
item(peek_copy_ptr)\
item(peek_copy_function)\
item(peek_copy_int)\
item(peek_copy_mixed)\
item(micro_peek_copy_push_ptr)\
item(micro_peek_copy_push_function)\
item(micro_peek_copy_push_int)\
item(micro_peek_copy_push_mixed)\
item(micro_peek_copy_ptr)\
item(micro_peek_copy_function)\
item(micro_peek_copy_int)\
item(micro_peek_copy_mixed)\
item(load_int_small_push)\
item(load_int_big_push)\
item(string_push)\
item(word_64_push)\
item(word_128_push)\
item(mcollapse)\
item(peek_push)\
item(micro_peek_push)\
item(jmpf)\
item(incr_indirect_del)\
item(incr_indirect_del_ptr)\
item(incr_indirect_del_function)\
item(incr_indirect_del_conn)\
item(incr_indirect_del_int)\
item(incr_indirect_del_mvar)\
item(incr_indirect_del_struct_ptr)\
item(incr_indirect_del_mixed)\
item(not_serializable)\
item(type_Opaque)\
item(indirect_type_Opaque)\
item(tempserialize)\
item(tempunserialize)\
item(type_description)\
item(execute_module)\
item(function)\
/* true 'dynamic' modules and 'load_adm' (added in version 1.13) */
extern const char * lisp_like_module_type(U32 *size, /* size of resulting string including the trailing zero */
Expr type);
/* declaration of tag indexes */
#define item(n) ind_##n,
#define sc_item(n,f) ind_##n,
#define sc32_item(n,f) ind_##n,
enum {
tag_list
ind_dummy };
#undef item
#undef sc_item
#undef sc32_item
/* tag declarations */
#define item(n) n = new_tag(ind_##n),
#define sc_item(n,f) n = new_tag(ind_##n),
#define sc32_item(n,f) n = new_tag(ind_##n),
enum {
tag_list
dummy = new_tag(ind_dummy)};
#undef item
#undef sc_item
#undef sc32_item
#define index2pair(i) (((i)<<5)|3)
#define index2ppair(i) (((i)<<5)|9)
#define consp(expr) (is_tpair(expr)||is_ppair(expr))
#define index2string(i) (((i)<<5)|5)
#define string_content(expr) (strings[(expr)>>5])
/* type variables */
#define index2utvar(i) (((i)<<6)|7)
#define utvar2index(expr) ((expr)>>6)
#define index2itvar(i) (((i)<<6)|39)
#define itvar2index(expr) ((expr)>>6)
#define fresh_unknown() (index2itvar(next_itvar++))
extern int word32_value(Expr bigits);
/* counter for internal type variables */
extern unsigned int next_itvar;
extern Expr C_constr_types_list;
/* user defined type variables */
extern char ** utvar_names; /* names of user defined type variables (without $) */
extern int max_utvar;
extern int next_utvar;
#define utvar_name(expr) (utvar_names[(expr)>>6])
extern Expr new_utvar(char *name);
extern Expr fresh_utvar(void);
extern Expr pseudo_instanciate_term(Expr);
/* pairs */
struct Pair_struct {
Expr first;
Expr second;
};
extern int max_pair;
extern int max_pair_limit;
extern int next_pair;
extern int max_string;
extern int next_string;
extern struct Pair_struct *pairs; /* temporary pairs */
extern struct Pair_struct *ppairs; /* permanent pairs */
extern char **strings;
extern int max_ppair;
extern int next_ppair;
#ifdef _DEBUG
#define car(x) _car(x,__LINE__,__FILE__)
#define cdr(x) _cdr(x,__LINE__,__FILE__)
extern Expr _car(Expr, int, const char *);
extern Expr _cdr(Expr, int, const char *);
#else
#define car(x) _car(x)
#define cdr(x) _cdr(x)
extern Expr _car(Expr);
extern Expr _cdr(Expr);
#endif
extern void rplaca(Expr, Expr);
extern void rplacd(Expr, Expr);
extern Expr new_string(const char *);
extern Expr var_change_code_label;
extern Expr mvar_change_code_label;
/* predefined strings */
#define predef_strings\
item(nil,"[]")\
item(cons,"[.]")\
item(plus,"+")\
item(doublecolon,"::")\
item(minus,"-")\
item(abs_minus,"|-|")\
item(star,"*")\
item(caret,"^")\
item(or,"|")\
item(zero,"zero")\
item(one,"one")\
item(slash,"/")\
item(backslash,"\\")\
item(less,"<")\
item(sless,"-<")\
item(uless,"+<")\
item(non_equal,"/=")\
item(lessoreq,"=<")\
item(slessoreq,"-=<")\
item(ulessoreq,"+=<")\
item(mod,"mod")\
item(and,"&")\
item(colon,":")\
item(left_shift,"<<")\
item(right_shift,">>")\
item(implies,"=>")\
item(forall,"?")\
item(exists,"!")\
item(exists_unique,"!!")\
item(description,"#!")\
item(List,"List")\
item(Bool,"Bool")\
item(Char,"Char")\
item(true,"true")\
item(false,"false")\
item(arrow,"->")\
item(ndarrow,"-->")\
item(null,"")\
item(stderr,"stderr")\
item(stdin,"stdin")\
item(stdout,"stdout")\
item(del,"del")\
item(void,"void")\
item(Bit,"Bit")\
item(String,"String")\
item(print_string,"print_string")\
item(print_int32,"print_int32")\
item(string_less,"string_less")\
item(_,"_")\
item(0,"0")\
item(1,"1")\
item(qm,"?")\
item(Empty,"Empty")\
item(eq,"=")\
item(small_eq,"_small_eq")\
item(Maybe,"Maybe")\
item(failure,"failure")\
item(success,"success")\
item(string_to_integer,"string_to_integer")\
item(string_to_float,"string_to_float")\
item(integer_to_string,"integer_to_string")\
item(integer_to_float,"integer_to_float")\
item(float_to_string,"float_to_string")\
item(constant_string,"constant_string")\
item(sub_string,"sub_string")\
item(length,"length")\
item(nth,"nth")\
item(closed,"closed")\
item(iconified,"iconified")\
item(restored,"restored")\
item(repaint_me,"repaint_me")\
item(mouse_move,"mouse_move")\
item(mouse_click,"mouse_click")\
item(keyboard_click,"keyboard_click")\
item(MouseButton,"MouseButton")\
item(KeyboardState,"KeyboardState")\
item(keyboard_state,"keyboard_state")\
item(left_button_down,"left_button_down")\
item(left_button_up,"left_button_up")\
item(middle_button_down,"middle_button_down")\
item(middle_button_up,"middle_button_up")\
item(right_button_down,"right_button_down")\
item(right_button_up,"right_button_up")\
item(One,"One")\
item(unique,"unique")\
item(Result,"Result")\
item(error,"error")\
item(ok,"ok")\
item(paint_pixel,"paint_pixel")\
item(paint_rectangle,"paint_rectangle")\
item(paint_image,"paint_image")\
item(image,"image")\
item(ScreenPaintTicket,"ScreenPaintTicket")\
item(connect,"connect")\
item(_0,"_0")\
item(_1,"_1")\
item(_2,"_2")\
item(_3,"_3")\
item(_4,"_4")\
item(_5,"_5")\
item(_6,"_6")\
item(_7,"_7")\
item(Word8,"Word8")\
item(implode,"implode")\
item(explode,"explode")\
item(exp,"exp")\
item(log,"log")\
item(sin,"sin")\
item(cos,"cos")\
item(tan,"tan")\
item(asin,"asin")\
item(acos,"acos")\
item(atan,"atan")\
item(Date_and_Time,"Date_and_Time")\
item(date_and_time,"date_and_time")\
item(now,"now")\
item(convert_time,"convert_time")\
item(NetworkConnectError,"NetworkConnectError")\
item(predef_anubis,"predefined.anubis")\
item(sharp_tuple,"£tuple")\
item(alert_handler,"£alert_handler")\
item(SaveResult,"SaveResult")\
item(RetrieveResult,"RetrieveResult")\
item(ByteArray,"ByteArray")\
item(Expr_Type,"Expr_Type")\
item(Expr_Term,"Expr_Term")\
item(Expr_Paragraph,"Expr_Paragraph")\
item(d,"d")\
item(input,"input")\
item(output,"output")\
item(index,"index")\
item(remove,"remove")\
item(random,"random")\
item(millisecond,"millisecond")\
item(milliseconds,"milliseconds")\
item(SSL,"SSL")\
item(X509,"X509")\
item(HostWindow,"HostWindow")\
item(HostImage,"HostImage")\
item(HostGC,"HostGC")\
item(RGBAArray,"RGBAArray")\
item(RGBArray,"RGBArray")\
item(GreyScaleArray,"GreyScaleArray")\
item(BitMapArray,"BitMapArray")\
item(pound,"£")\
item(empty_string,"")\
item(Int32,"Int32")\
item(Float,"Float")\
item(TempByteArray,"TempByteArray")\
item(RStream,"RStream")\
item(WStream,"WStream")\
item(RWStream,"RWStream")\
item(Listener,"£Listener")\
item(Var,"Var")\
item(MVar,"MVar")\
item(StructPtr,"£StructPtr")\
item(alert,"alert")\
item(anb_write,"<-")\
item(checking,"£checking")\
item(wait_for,"£wait_for")\
item(juxt,"£juxt")\
item(mapsto,"|->")\
item(voidpars,"()")\
item(MonitoringTicket,"MonitoringTicket")\
item(MySQL,"MySQL")\
item(MySQL_Result,"MySQL_Result")\
item(tilde,"~")\
item(SysFont,"SysFont")\
item(SSL_CTX,"SSL_CTX")\
item(LoadModuleResult,"LoadModuleResult")\
item(Omega,"Omega")\
item(Exec,"Exec")\
item(percent,"%%")\
item(SQLite3,"SQLite3")\
item(SQLite3Stmt,"SQLite3Stmt")\
item(dotdot,"..")\
item(exclam_equal,"!=")\
item(dotsup,".>")\
item(dot,".")\
item(Word4,"Word4")\
item(Word8,"Word8")\
item(Word16,"Word16")\
item(Word32,"Word32")\
item(Word64,"Word64")\
item(Word128,"Word128")\
item(Opaque,"Opaque")\
item(Library,"Library")\
item(should_not_happen,"£should_not_happen")\
item(default_snh_callback,"£default_snh_callback")\
item(DB,"DB")\
item(DbStmt,"DbStmt")\
/* declarations of Expr variable containing predefined strings */
#define item(sym,str) extern Expr pdstr_##sym;
predef_strings
#undef item
extern Expr cons(Expr,Expr);
extern Expr save(Expr);
extern void clean_up_pairs(void);
extern void forget_privates(char *filename);
extern void remember_all(void);
extern int max_tpair_load;
#define pcons3(x,y,z) pcons(x,pcons(y,z))
#define pcons4(x,y,z,t) pcons(x,pcons(y,pcons(z,t)))
#define mcons3(x,y,z) cons(x,cons(y,z))
#define mcons4(x,y,z,t) cons(x,mcons3(y,z,t))
#define mcons5(x,y,z,t,u) cons(x,mcons4(y,z,t,u))
#define mcons6(x,y,z,t,u,v) cons(x,mcons5(y,z,t,u,v))
#define mcons7(x,y,z,t,u,v,a) cons(x,mcons6(y,z,t,u,v,a))
#define mcons8(x,y,z,t,u,v,a,b) cons(x,mcons7(y,z,t,u,v,a,b))
#define list1(x) cons(x,nil)
#define list2(x,y) cons(x,list1(y))
#define list3(x,y,z) cons(x,list2(y,z))
#define list4(x,y,z,t) cons(x,list3(y,z,t))
#define list5(x,y,z,t,u) cons(x,list4(y,z,t,u))
#define list6(x,y,z,t,u,v) cons(x,list5(y,z,t,u,v))
#define list7(x,y,z,t,u,v,w) cons(x,list6(y,z,t,u,v,w))
#define list8(x,y,z,t,u,v,w,a) cons(x,list7(y,z,t,u,v,w,a))
#define list9(x,y,z,t,u,v,w,a,b) cons(x,list8(y,z,t,u,v,w,a,b))
#define first(x) (car(x))
#define second(x) (car(cdr(x)))
#define third(x) (car(cdr2(x)))
#define forth(x) (car(cdr3(x)))
#define fifth(x) (car(cdr4(x)))
#define sixth(x) (car(cdr5(x)))
#define seventh(x) (car(cdr6(x)))
#define car2(x) (car(car(x)))
#define car3(x) (car(car2(x)))
#define cdr2(x) (cdr(cdr(x)))
#define cdr3(x) (cdr(cdr2(x)))
#define cdr4(x) (cdr(cdr3(x)))
#define cdr5(x) (cdr(cdr4(x)))
#define cdr6(x) (cdr(cdr5(x)))
#define cdr7(x) (cdr(cdr6(x)))
extern Expr nthcdr(Expr n, Expr l); // get n-th cdr of l
#define term_switch(term,name)\
switch(car(term)) {\
case alt_number: goto alt_number_##name;\
case protect: goto protect_##name;\
case lock: goto lock_##name;\
case alert: goto alert_##name;\
case debug_avm: goto debug_avm_##name;\
case terminal: goto terminal_##name;\
case integer: goto integer_##name;\
case fpnum: goto fpnum_##name;\
case symbol: goto symbol_##name;\
case of_type: goto of_type_##name;\
case constructor: goto constructor_##name;\
case lambda: goto lambda_##name;\
case app: goto app_##name;\
case cond: goto cond_##name;\
case select_cond: goto select_cond_##name;\
case with: goto with_##name;\
case string: goto string_##name;\
case anb_read: goto anb_read_##name;\
case anb_write: goto anb_write_##name;\
case connect_to_file: goto connect_to_file_##name;\
case connect_to_IP: goto connect_to_IP_##name;\
case wait_for: goto wait_for_##name;\
case delegate: goto delegate_##name;\
case set: goto set_##name;\
case omega_true: goto omega_true_##name;\
case omega_false: goto omega_false_##name;\
case serialize: goto serialize_##name;\
case unserialize: goto unserialize_##name;\
case bit_width: goto bit_width_##name;\
case indirect_type: goto indirect_type_##name;\
case vcopy: goto vcopy_##name;\
default: internal_error("Unknown term",term); }\
#define interp_switch(head,name)\
switch(car(head)) {\
case alt_number: goto alt_number_##name;\
case protect: goto protect_##name;\
case lock: goto lock_##name;\
case avm: goto avm_##name;\
case debug_avm: goto debug_avm_##name;\
case terminal: goto terminal_##name;\
case operation: goto operation_##name;\
case string: goto string_##name;\
case anb_int32: goto int32_##name;\
case small_datum: goto small_datum_##name;\
case fpnum: goto fpnum_##name;\
case local: goto local_##name;\
case app: goto app_##name;\
case cond: goto cond_##name;\
case select_cond_interp: goto select_cond_interp_##name;\
case with: goto with_##name;\
case constructor: goto constructor_##name;\
case anb_read: goto anb_read_##name;\
case anb_write: goto anb_write_##name;\
case connect_file_R: goto connect_file_R_##name;\
case connect_file_W: goto connect_file_W_##name;\
case connect_file_RW: goto connect_file_RW_##name;\
case connect_IP_RW: goto connect_IP_RW_##name;\
case wait_for: goto wait_for_##name;\
case delegate: goto delegate_##name;\
case serialize: goto serialize_##name;\
case unserialize: goto unserialize_##name;\
case bit_width: goto bit_width_##name;\
case indirect_type: goto indirect_type_##name;\
case vcopy: goto vcopy_##name;\
default: internal_error("Unknown interpretation head",head); }\
extern int length(Expr list);
extern Expr merge_lists(Expr, Expr);
extern Expr remove_from_list(Expr list, Expr element);
extern Expr hard_reverse(Expr list);
extern Expr append(Expr list_1,
Expr list_2);
extern Expr rappend(Expr list_1,
Expr list_2);
extern Expr nth(Expr rank, Expr l);
extern Expr first_elements(Expr rank, Expr l);
#define reverse(x) rappend(x,nil)
extern void put32(FILE *fp, U32 n);
extern int member(Expr element, /* true if element belongs to list */
Expr list);
extern int find(Expr x, Expr t); /* find atom x in tree t */
extern int has_repetition(Expr list);
extern Expr assoc(Expr key, /* returns value associated to key */
Expr A_list);
extern int is_key_of(Expr A_list,
Expr key);
extern void print_expr(FILE *fp,
Expr expr);
extern int sprint_expr(char *fp,
Expr expr);
extern int have_common_element(Expr list1,
Expr llist2);
extern Expr from_basis_10000_to_basis_256(Expr);
extern Expr from_basis_256_to_basis_10000(Expr);
extern int equal(Expr,Expr);
extern Expr substitute(Expr expr, Expr a_list);
extern Expr mapcar(Expr);
extern Expr mapcdr(Expr);
extern Expr mapcdrcdr(Expr);
#ifdef _DEBUG
#define same_type(x,e,y,f) _same_type(x,e,y,f,__FILE__,__LINE__)
extern int _same_type(Expr type1, Expr env1, Expr type2, Expr env2, char *filename, int line);
#else
#define same_type(x,e,y,f) _same_type(x,e,y,f)
extern int _same_type(Expr type1, Expr env1, Expr type2, Expr env2);
#endif
extern int same_op_instance(int opid1,
Expr types1,
Expr u_env1,
int opid2,
Expr types2,
Expr u_env2);
/* type representation */
struct Type_struct {
Expr name; /* name of type */
Expr abs_file_path; /* absolute path of file containing this type definition */
Expr line;
Expr parms; /* parameters (list of type variables) */
Expr def; /* definition of type */
Expr typerefs;
char * offline_comment;
unsigned int global:8;
unsigned int C_dump:1;
unsigned int completed:1; /* 1 when definition has been completed */
unsigned int mark:1;
unsigned int infinite:1;
unsigned int used:1;
};
extern struct Type_struct *types; /* array of all type representations */
extern int next_type;
extern int max_type;
extern char infinite_flags_reliable;
/* 'global' flag values */
#define op_private (0) /* operation (or type) which is private to a file */
#define op_public (1) /* operation (or type) that may be referenced from another file */
#define op_adm (2) /* will produce a dynamic module (opname.adm) */
#define inline_flag (4) /* may be ORed with one of the above */
#define secondary_adm (8) /* if set, adm is secondary */
#define public_mask (3) /* used for separating the public status */
#define inline_mask (4) /* used for separating the inline status */
/* 'checked' flag values */
#define not_checked (0)
#define checked_correct (1)
#define checked_incorrect (2)
/* operation representation */
struct Operation_struct {
Expr names; /* names of operation */
Expr abs_file_path; /* absolute path of file containing this definition */
Expr line;
Expr parms;
Expr signature; /* (source_type ... source_type) */
Expr target_type; /* target type */
char * offline_comment;
int narg; /* number of arguments */
//unsigned int crypted:1;
unsigned int global:8; /* global flag */
unsigned int deterministic:1;
unsigned int is_destructor:1;
unsigned int used:1;
unsigned int checked:2;
U32 destructor_tid;
Expr ctxt; /* for compiling the body */
Expr definition; /* of body */
};
extern struct Operation_struct *operations; /* array of all operations */
extern int next_operation;
extern int max_operation;
extern int eq_scheme_op_id;
struct ClosureCode_struct {
Expr name;
Expr offline_code;
};
extern struct ClosureCode_struct *closure_codes;
extern int max_closure_code;
extern int next_closure_code;
struct Variable_struct {
Expr lc;
Expr abs_file_path; /* absolute path of file containing this variable declaration */
Expr name;
Expr type;
Expr init;
char * offline_comment;
unsigned int global:8;
unsigned int used:1;
};
extern struct Variable_struct * variables;
extern int next_variable;
extern int max_variable;
/* operation instances */
struct Compiled_op_struct {
int op_id; /* operation scheme identifier */
Expr lc; /* line and column of instance */
Expr abs_file_path; /* taken from the definition */
Expr types; /* values of parameters (same order as 'parms' field) */
Expr env; /* environment for interpretation of these values */
Expr addr; /* address name of generated code */
Expr offline_code; /* generated offline code */
Expr inline_code; /* generated code or nil if no inline code available */
U8 sha1_digest[20]; /* made from the name, target type and signature (with unknowns substituted) */
unsigned int global:8;
};
/* array of operation instances */
extern struct Compiled_op_struct * compiled_ops;
extern int next_compiled_op;
extern int max_compiled_op;
extern int small_eq_op_id;
extern int float_eq_op_id;
extern int string_eq_op_id;
extern int byte_array_eq_op_id;
extern int int_eq_op_id;
extern int get_eq_code_id(Expr lc, Expr type, Expr env);
struct Del_code_struct {
Expr type;
Expr env;
Expr addr;
Expr offline_code;
U8 sha1_digest[20];
};
extern struct Del_code_struct * del_codes;
extern int next_del_code;
extern int max_del_code;
struct MCtxtDelCode_struct {
Expr name;
Expr offline_code;
};
extern struct MCtxtDelCode_struct *mctxt_del_codes;
extern int max_mctxt_del_code;
extern int next_mctxt_del_code;
extern Expr get_del_code_addr(Expr type, Expr env);
extern Expr get_del_stack_instr(Expr type,
Expr env,
Expr depth);
extern Expr read_code(Expr type, Expr env, Expr ctxt);
extern Expr write_code(Expr type, Expr env, Expr ctxt);
struct Implem_struct {
Expr type;
Expr env;
Expr implem;
Expr addr; /* address name of implementation description (pseudo-code) */
Expr offline_code;
int temp_implem_id; /* used to generate absolute descriptions */
};
extern struct Implem_struct *implems;
extern int max_implem;
extern int next_implem;
extern void board(void);
extern void board_headers(void);
extern void reset_temp_implem_ids(void);
extern Expr abs_implem_from_implem(Expr implem);
extern Expr abs_implem_from_id(int implem_id);
#define accessible_type(tid,fname) (((types[tid].global)&op_public) || ((fname) == types[tid].abs_file_path))
#define accessible_op(opid,fname) (((operations[opid].global)&op_public) || ((fname) == operations[opid].abs_file_path))
#define accessible_var(vid,fname) (((variables[vid].global)&op_public) || ((fname) == variables[vid].abs_file_path))
#define dereference_type(type,env) do { while (is_unknown(type)) { \
type = assoc(type,env); \
assert(type != key_not_found); } } while(0)
extern Expr dereference_aliases(Expr type);
#define soft_dereference_type(type,env) do { Expr initial = type; \
while (is_unknown(type)) { \
type = assoc(type,env); \
if (type == key_not_found)\
{ type = initial; break; } } } while(0)
#define is_small_implem(implem) (consp(implem) && car(implem) == small_type)
#define is_mixed_implem(implem) (consp(implem) && car(implem) == mixed_type)
#define is_large_implem(implem) (consp(implem) && car(implem) == large_type)
#define is_struct_ptr_type(type) (consp(type) && car(type) == type_struct_ptr)
#define struct_ptr_id_from_name(n) (consp(n) ? car(n): (n))
extern int is_global_address_type(Expr type); /* assumed to be already dereferenced */
extern char adm_encryption_key[];
extern Expr offline_pseudo_code(int implem_id);
struct Compiled_string_struct {
Expr string;
};
extern struct Compiled_string_struct *compiled_strings;
extern int next_compiled_string;
extern int max_compiled_string;
/* Compiler functions ********************************************************/
extern void print_symbolic_code(FILE *fp, FILE *profile_info, Expr code, U32 *offa,
Expr init_addr_val, Expr var_del_addr_val);
extern Expr op_comment(int opid);
extern void describe_serialization(Expr lc, Expr types);
extern void new_type_scheme (Expr line, /* <lc> */
int C_dump,
Expr name, /* <type name> */
Expr parms, /* <user type variables> */
Expr alts, /* <alternatives 1> */
int more,
int lpublic);
extern void make_C_constr (Expr line, Expr file_name, Expr name, Expr type);
extern void print_expr_to_C(FILE *,Expr);
extern void binary_print_expr(FILE *,Expr);
extern void binary_print_def(FILE *fp, int opid, Expr def);
extern void new_type_alias (Expr lc,
int C_dump,
Expr name,
Expr parms,
Expr def, /* <type> */
int lpublic);
extern int has_recursive_equality(Expr implem);
extern char * normalize_filepath(Expr lc,
char * path); /* The path is assumed absolute */
extern void dump_strong_operation(FILE * fp,
int opid,
Expr ctxt,
Expr def);
extern Expr drop_RW_WO(Expr type);
extern void new_op_scheme (Expr line, /* <lc> */
int global,
Expr ttype, /* <type> */
Expr name, /* <operation name> */
Expr args, /* <operation arguments> */
Expr body); /* <term> */
extern void check_operation(int opid);
extern void new_variable (Expr line,
int global,
Expr type,
Expr name,
Expr init);
extern Expr get_micro_ctxt(Expr lc,
Expr term,
Expr fname,
Expr bound,
Expr ctxt);
extern void make_destructors(Expr, int global, int tid);
extern Expr refresh (Expr expr,
Expr *already_refreshed);
extern void collect_type_variables(Expr *result,
Expr expr);
extern int check_explicit_type (Expr line, /* <lc> */
Expr expr, /* <type> */
Expr tvs); /* <user type variables> */
extern void check_incomplete_types(void);
extern struct Type_struct *get_type_description(Expr name_of_type, Expr lc);
extern int has_unknowns (Expr expr,
Expr env); /* <environment> */
extern void must_be_non_ambiguous (Expr interps); /* <term interpretations> */
extern Expr merge_envs(Expr, Expr);
extern Expr join_envs(Expr, Expr);
extern Expr term_interpretations(Expr target,
Expr term,
Expr ctxt,
Expr env,
Expr tvs,
int allow_mvar_access);
extern Expr name_of_type(Expr type);
extern Expr get_alts(Expr type, Expr env, Expr lc);
#ifdef _DEBUG
#define type_from_interpretation(i,e) _type_from_interpretation(i,e,__FILE__,__LINE__)
extern Expr _type_from_interpretation(Expr interp, Expr env, char *, int);
#else
#define type_from_interpretation(i,e) _type_from_interpretation(i,e)
extern Expr _type_from_interpretation(Expr interp, Expr env);
#endif
#define unify(x,ex,y,ey) (_unify(x,ex,y,ey))
extern Expr _unify (Expr x,
Expr ex, /* <environment> */
Expr y,
Expr ey); /* <environment> */
extern void _internal_error(const char *msg, Expr expr, const char *, int);
#define internal_error(msg, expr) _internal_error(msg, expr, __FILE__, __LINE__)
extern void find_determinism(void);
extern int typeid_by_name(Expr type_name);
#define is_functional_type(t) (consp(t) && (car(t) == functype))
extern int is_sum_type(Expr type, Expr env);
extern Expr _symbols_in_interp(Expr);
//#define symbols_in_interp(x) (fprintf(errfile,"\n\n%s:%d: ",__FILE__,__LINE__),debug(x),_symbols_in_interp(x))
#define symbols_in_interp(x) _symbols_in_interp(x)
#define check_clos do { debug(closure_codes[0].offline_code); } while(0)
#define debug(expr) _debug(#expr,expr,__FILE__,__LINE__)
#define debug_nl() _debug_nl(__FILE__,__LINE__)
#define debug_msg(m) _debug_msg(m)
#define debug_implem(id) do { debug(new_integer(id));\
debug(implems[id].type);\
debug(implems[id].env);\
debug(implems[id].implem);\
debug(implems[id].addr);\
debug(implems[id].offline_code); } while(0)
extern Expr _debug(char *,Expr, char *filename, int line);
extern void _debug_nl(char *file, int line);
extern void _debug_msg(char *msg);
extern Expr constructor_code_1(Expr alt_implem, int alt_index);
#define show_type(fp,t,e) (_show_type(__FILE__,__LINE__,fp,t,e))
Expr component_del_code(int iplem_id);
extern void show_names(FILE *, Expr names);
extern void show_interpretations(FILE *fp, Expr interps);
#ifdef _DEBUG
#define show_interpretations_types(f,i) _show_interpretations_types(f,i,__FILE__,__LINE__)
extern void _show_interpretations_types(FILE *fp, Expr interps,char *,int);
#else
#define show_interpretations_types(f,i) _show_interpretations_types(f,i)
extern void _show_interpretations_types(FILE *fp, Expr interps);
#endif
extern void show_interpretation(FILE *, Expr head, Expr env);
extern int _show_type(const char *filename, int line, FILE *, Expr type, Expr env);
extern void show_types(FILE *fp, Expr types, Expr env);
extern void show_alts(FILE *fp, Expr alts, Expr env);
extern void show_op_complete_interpretations(FILE *,Expr);
extern void show_tuple_interpretations(FILE *, Expr);
extern void show_tuple_interpretations_types(FILE *, Expr);
extern void show_alternatives(FILE *,Expr);
extern void show_simple_ambiguity (FILE *, Expr interps);
extern void show_parametric_ambiguity (FILE *, Expr head, Expr env);
extern void show_context(FILE *fp, Expr ctxt, Expr env);
extern void show_args(FILE *fp, Expr args, Expr env);
extern void show_alt(FILE *fp, int i, Expr alt, Expr env);
extern void show_typed_resurgent_symbols(FILE *fp, Expr alt, Expr env);
extern U32 resurgent_symbols_counter;
extern Expr get_type_name_id(Expr name);
extern int type_width(Expr type, Expr env);
extern int real_type_width(Expr type, Expr env);
extern int logar2(int);
extern int alt_width(Expr alt, Expr env, Expr type);
extern int byte_type_width(Expr type, Expr env);
//extern int small_implem_byte_width(Expr implem);
extern void find_infinite_types(void);
extern void test_type_width(void);
extern int _type_implementation_id(Expr type, Expr env);
#define type_implementation_id(t,e) _type_implementation_id(t,e)
/*
#define type_implementation_id(t,e) (printf("Calling '_type_implementation_id' file '%s' line %d\n",\
__FILE__,__LINE__),_type_implementation_id(t,e))
*/
extern Expr mixed_copy_mask(Expr implem);
extern int get_op_instance_id(Expr lc, int opid, Expr parms, Expr env);
extern int instruction_size(Expr instr, int offset);
extern void translate_instruction(U8* code, U8 **ptr, U32 *module_flags, int*offsets, Expr instr,
Expr init_addr_val, Expr var_del_addr_val);
extern Expr complete_dynamic_code(Expr code, Expr *already_appended,
Expr initialization_address_value, Expr variables_deletion_address_value);
extern void dump_op_def(FILE *fp, int opid);
extern void dump_predef(void);
extern void dump_code(FILE *, Expr code);
extern void make_naive_C(void);
extern void dump_symbolic_code(void);
extern void dump_dynamic_module(int);
extern void dump_dynamic_modules(void);
extern void dump_C_types(void);
extern Expr compile_term(Expr head,
Expr ctxt,
Expr env,
Expr end_code);
/* The index (hash-table) for symbols (operation names and type names). */
typedef enum {
syms_type,
syms_operation,
syms_variable
} SymbolSort;
typedef struct symbol_index_entry_struct {
Expr symbol;
SymbolSort sort;
int index;
} SymbolIndexEntry;
typedef struct symbol_index_array_struct {
U32 max;
U32 next;
SymbolIndexEntry *array;
} SymbolIndexArray;
extern SymbolIndexArray symbol_index[];
extern void init_symbol_index(void);
extern U8 u8_symbol_hash(Expr x);
extern void _add_symbol_index_entry(Expr symbol, SymbolSort sort, int index);
#if 0
#define add_symbol_index_entry(s,k,i) do { printf("adding symbol %s\n",string_content(s));\
fflush(stdout);\
_add_symbol_index_entry(s,k,i); } while(0)
#endif
#define add_symbol_index_entry(s,k,i) _add_symbol_index_entry(s,k,i)
/* The index (hash-table) for labels */
/* Sorts of labels (refering to some autonomous piece of code) in symbolic code */
typedef enum {
labs_closure,
labs_compiled_op,
labs_del_code,
labs_mctxt_del_code,
labs_implem,
labs_none
} LabelSort;
typedef struct label_index_entry_struct {
Expr label;
LabelSort sort;
int index;
} LabelIndexEntry;
typedef struct label_index_array_struct {
U32 max;
U32 next;
LabelIndexEntry *array;
} LabelIndexArray;
extern LabelIndexArray label_index[];
extern void init_label_index(void);
/*
#define new_addr_name(s,i) (printf("file '%s' line %d label %d\n",__FILE__,__LINE__,new_addr_count),\
_new_addr_name(s,i))
*/
#define new_addr_name(s,i) _new_addr_name(s,i)
extern Expr _new_addr_name(LabelSort sort, int index);
extern int new_addr_count;
extern Expr make_sha1_digest(Expr names,
Expr target_type,
Expr signature,
Expr parms,
Expr parms_values,
Expr env,
U8 *destination);
extern int is_address_type(Expr type, Expr env);
extern int is_far_address_type(Expr);
extern int is_far_RW_address_type(Expr);
int is_readable_address_type(Expr type, Expr env);
extern int is_writable_address_type(Expr type, Expr env);
extern int is_exchangeable_address_type(Expr);
extern int is_primitive_type(Expr);
extern Expr get_del_instr(Expr type, Expr env);
extern Expr get_copy_instr(Expr type, Expr env);
extern Expr adm_type_description(Expr type, Expr env);
/* messages */
extern int board_option;
extern U32 board_option_threshold;
extern FILE *errfile;
extern void err_line_col (Expr lc, const char *error_name, const char *error_text);
extern void warn_line_col (Expr lc, const char *error_name, const char *error_text);
extern const char* str_format(const char *format, ...);
extern const char *msgtext_line_col[];
extern const char *msgtext_warn_line_col[];
extern const char *msgtext_parse_error[];
extern const char *msgtext_syntax_error_type_expected[];
extern const char *msgtext_parse_error_config_file[];
extern const char *msgtext_ambiguous_term[];
extern const char *msgtext_term_with_unknowns[];
extern const char *msgtext_unknown_symbol[];
extern const char *msgtext_type_not_found[];
extern const char *msgtext_type_scheme_bad_arity[];
extern const char *msgtext_incompatible_explicit_type[];
extern const char *msgtext_incompatible_explicit_type_2[];
extern const char *msgtext_incompatible_args[];
extern const char *msgtext_args_interpretations[];
extern const char *msgtext_test_has_several_interpretations[];
extern const char *msgtext_test_type_unknown[];
extern const char *msgtext_test_type_is_parameter[];
extern const char *msgtext_test_type_not_complete[];
extern const char *msgtext_test_is_not_a_sum[];
extern const char *msgtext_wrong_number_of_cases[];
extern const char *msgtext_bad_case_name[];
extern const char *msgtext_wrong_number_of_resurgent_variables[];
extern const char *msgtext_definition_body_not_type_compatible[];
extern const char *msgtext_ambiguous_definition_body[];
extern const char *msgtext_type_already_completed[];
extern const char *msgtext_unknown_type_variable[];
extern const char *msgtext_definition_body_has_unknowns[];
extern const char *msgtext_operation_redefinition[];
extern const char *msgtext_out_of_memory[];
extern const char *msgtext_include_too_deeply[];
extern const char *msgtext_cannot_find_src_file[];
extern const char *msgtext_cannot_create_file[];
extern const char *msgtext_incompatible_types_in_assignment[];
extern const char *msgtext_interpretations_of_variable[];
extern const char *msgtext_interpretations_of_value[];
extern const char *msgtext_given_type[];
extern const char *msgtext_body_interpretations_types[];
extern const char *msgtext_symbol_bad_arity[];
extern const char *msgtext_not_a_function_of_arity[];
extern const char *msgtext_lambda_bad_arity[];
extern const char *msgtext_equality_has_no_interpretation[];
extern const char *msgtext_interpretations_of_members[];
extern const char *msgtext_no_interpretation[];
extern const char *msgtext_too_many_alternatives[];
extern const char *msgtext_ambiguous_local_def[];
extern const char *msgtext_ambiguous_local_init[];
extern const char *msgtext_welcome[];
extern const char *msgtext_syntax[];
extern const char *msgtext_syntax_standard[];
extern const char *msgtext_syntax_perso[];
extern const char *msgtext_build_date[];
extern const char *msgtext_compiling_file[];
extern const char *msgtext_returning_to_file[];
extern const char *msgtext_checking_type[];
extern const char *msgtext_checking_type_alias[];
extern const char *msgtext_checking_operation[];
extern const char *msgtext_finding_recursive_types[];
extern const char *msgtext_recursive[];
extern const char *msgtext_non_recursive[];
extern const char *msgtext_find_determinism[];
extern const char *msgtext_deterministic[];
extern const char *msgtext_non_deterministic[];
extern const char *msgtext_made_destructor[];
extern const char *msgtext_no_paragraph[];
extern const char *msgtext_repeated_alt_operand_name[];
extern const char *msgtext_unknown_packet_name[];
extern const char *msgtext_bad_packet_arity[];
extern const char *msgtext_packet_not_instanciated[];
extern const char *msgtext_packet_is_functional[];
extern const char *msgtext_string_too_long[];
extern const char *msgtext_global_with_parms[];
extern const char *msgtext_too_many_files[];
extern const char *msgtext_operation_not_defined[];
extern const char *msgtext_incomplete_type[];
extern const char *msgtext_no_C_dump_with_parms[];
extern const char *msgtext_cannot_interpret_as_readable_connection[];
extern const char *msgtext_cannot_interpret_as_writable_connection[];
extern const char *msgtext_cannot_interpret_as_exchangeable_connection[];
extern const char *msgtext_incompatible_write_type[];
extern const char *msgtext_incompatible_write_type2[];
extern const char *msgtext_connection_name_not_a_string[];
extern const char *msgtext_connection_addr_port_not_ints[];
extern const char *msgtext_ambiguous_connection_name[];
extern const char *msgtext_ambiguous_connection_addr_port[];
extern const char *msgtext_invalid_connect_return_type[];
extern const char *msgtext_invalid_IP_connect_return_type[];
extern const char *msgtext_cannot_interpret_cond_bodies[];
extern const char *msgtext_integer_not_acceptable_here[];
extern const char *msgtext_float_not_acceptable_here[];
extern const char *msgtext_string_not_acceptable_here[];
extern const char *msgtext_local_symbol_has_wrong_type[];
extern const char *msgtext_proposed_type_not_acceptable[];
extern const char *msgtext_proposed_type_not_acceptable2[];
extern const char *msgtext_unexpected_else_case[];
extern const char *msgtext_missing_else_case[];
extern const char *msgtext_duplicate_cases[];
extern const char *msgtext_no_alt_match[];
extern const char *msgtext_several_alt_matches[];
extern const char *msgtext_several_alt_matches_2[];
extern const char *msgtext_argument[];
extern const char *msgtext_wait_condition_not_boolean[];
extern const char *msgtext_wait_condition_ambiguous[];
extern const char *msgtext_wait_milliseconds_not_integer[];
extern const char *msgtext_wait_milliseconds_ambiguous[];
extern const char *msgtext_delegated_not_one[];
extern const char *msgtext_delegated_ambiguous[];
extern const char *msgtext_select_cond_incompatible_types[];
extern const char *msgtext_number[];
extern const char *msgtext_select_cond_with_one_alternative[];
extern const char *msgtext_non_recursive_equality[];
extern const char *msgtext_float_equality[];
extern const char *msgtext_error_banner[];
extern const char *msgtext_call_not_terminal[];
extern const char *msgtext_lexical_error[];
extern const char *msgtext_lexical_kwread_error[];
extern const char *msgtext_no_omega_interpretation[];
extern const char *msgtext_several_omega_interpretations[];
extern const char *msgtext_bad_global_signature[];
extern const char *msgtext_max_pair_limit[];
extern const char *msgtext_case_term[];
extern const char *msgtext_else_term[];
extern const char *msgtext_argument_number[];
extern const char *msgtext_case[];
extern const char *msgtext_checking_variable[];
extern const char *msgtext_variable_with_parms[];
extern const char *msgtext_variable_redeclaration[];
extern const char *msgtext_no_serializable_interpretation[];
extern const char *msgtext_serialize_ambiguous[];
extern const char *msgtext_no_ByteArray_interpretation[];
extern const char *msgtext_several_ByteArray_interpretations[];
extern const char *msgtext_no_TempByteArray_interpretation[];
extern const char *msgtext_several_TempByteArray_interpretations[];
extern const char *msgtext_duplicated_file_to_read[];
extern const char *msgtext_vcopy_num_not_an_int32[];
extern const char *msgtext_cannot_access_current_dir[];
extern const char *msgtext_used_header[];
extern const char *msgtext_used_type[];
extern const char *msgtext_used_operation[];
extern const char *msgtext_used_variable[];
extern const char *msgtext_alt_number[];
extern const char *msgtext_lock_no_string_interpretation[];
extern const char *msgtext_lock_several_string_interpretations[];
extern const char *msgtext_nested_locks[];
extern const char *msgtext_type_not_serializable[];
extern const char *msgtext_var_defined_at[];
extern const char *msgtext_bad_Ankh[];
extern const char *msgtext_bad_Djed[];
extern const char *msgtext_anubis_shell_variable_not_set[];
extern const char *msgtext_my_anubis_shell_variable_not_set[];
extern const char *msgtext_compiler_key_bad_version[];
extern const char *msgtext_predef_dat_bad_version[];
extern const char *msgtext_Djed_not_found[];
extern const char *msgtext_Ankh_not_found[];
extern const char *msgtext_syntax_error_in_conf_file[];
extern const char *msgtext_configuration_board[];
extern const char *msgtext_not_defined[];
extern const char *msgtext_yes[];
extern const char *msgtext_no[];
extern const char *msgtext_set_stop_after[];
extern const char *msgtext_set_verbose[];
extern const char *msgtext_set_djed[];
extern const char *msgtext_Y[];
extern const char *msgtext_N[];
extern const char *msgtext_config_file_header[];
extern const char *msgtext_no_config_file_found[];
extern const char *msgtext_configure_welcome[];
extern const char *msgtext_set_language[];
extern const char *msgtext_show_reads_file_header[];
extern const char *msgtext_show_reads_file_text[];
extern const char *msgtext_file_line[];
extern const char *msgtext_local_symbol[];
extern const char *msgtext_remove_alert[];
extern const char *msgtext_no_interp_of_type[];
extern const char *msgtext_no_interp_of_type2[];
extern const char *msgtext_several_interps_of_type[];
extern const char *msgtext_hidden_parms[];
extern const char *msgtext_mvar_incompatible_arg[];
extern const char *msgtext_mvar_args[];
extern const char *msgtext_type_already_seen[];
extern const char *msgtext_alternatives_seen[];
extern const char *msgtext_repeted_name_in_lambda[];
extern const char *msgtext_hidden_variables[];
extern const char *msgtext_incompatible_lambda_type[];
extern const char *msgtext_read_bad_path[];
extern const char *msgtext_fake_top_level_function[];
//extern const char *msgtext_load_adm_not_string[];
//extern const char *msgtext_load_adm_ambiguous[];
extern const char *msgtext_file_path_too_long[];
extern const char *msgtext_wrong_resurgent_symbol_type_declaration1[];
extern const char *msgtext_wrong_resurgent_symbol_type_declaration2[];
extern const char *msgtext_relay_file[];
extern const char *msgtext_unexpected_subcase[];
extern const char *msgtext_unexpected_subcase2[];
extern const char *msgtext_duplicate_alt_name[];
extern const char *msgtext_too_many_cases_subcases[];
extern const char *msgtext_invalid_subcase[];
extern const char *msgtext_not_enough_cases_subcases[];
extern const char *msgtext_non_equal_resurgents[];
extern const char *msgtext_not_enough_subcases[];
extern const char *msgtext_too_many_subcases[];
extern const char *msgtext_nested_head_doesnt_match_next_alt[];
extern const char *msgtext_circular_read[];
extern const char *msgtext_if_then[];
extern const char *msgtext_pardefs_for_this_type[];
extern const char *msgtext_type_pardef_info[];
extern const char *msgtext_premature_eof_in_paragraph[];
extern const char *msgtext_premature_eof_in_string[];
extern const char *msgtext_premature_eof_in_comment[];
extern const char *msgtext_premature_eof_in_linecomment[];
extern const char *msgtext_tab_forbidden[];
extern const char *msgtext_incompatible_case_bodies_types[];
extern const char *msgtext_variable_no_init[];
extern const char *msgtext_type_name_already_in_use[];
extern const char *msgtext_Int32_eliminated[];
extern const char *msgtext_symbol___not_usable[];
extern const char *msgtext_mvar_access[];
extern const char *msgtext_cannot_describe_schema[];
extern const char *msgtext_Opaque_not_serializable[];
extern const char *msgtext_alert_obsolete[];
extern const char *msgtext_func_args_table[];
extern const char *msgtext_incorrect_module_type[];
extern const char *msgtext_load_adm_type_with_parms[];
#ifdef __cplusplus
}
#endif