File: smart_eiffel.e

package info (click to toggle)
smarteiffel 1.1-11
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 12,288 kB
  • ctags: 40,785
  • sloc: ansic: 35,791; lisp: 4,036; sh: 1,783; java: 895; ruby: 613; python: 209; makefile: 115; csh: 78; cpp: 50
file content (1595 lines) | stat: -rw-r--r-- 45,479 bytes parent folder | download | duplicates (2)
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
-- This file is part of SmartEiffel The GNU Eiffel Compiler Tools and Libraries
--
-- SmartEiffel is  free software;  you can redistribute it and/or  modify it
-- under  the terms of the  GNU General Public License, as published by  the
-- Free Software Foundation; either version 2, or (at your option) any later
-- version.
-- SmartEiffel is distributed in the hope that it will be useful but WITHOUT 
-- ANY WARRANTY;  without  even the implied warranty  of MERCHANTABILITY  or
-- FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
-- more details.  You should have received a copy of  the GNU General Public
-- License along with SmartEiffel;  see the file COPYING.  If not,  write to
-- the Free Software Foundation,  Inc., 59 Temple Place - Suite 330,  Boston, 
-- MA 02111-1307, USA.
--
-- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P.
--			   - University of Nancy 1 - FRANCE
-- Copyright(C) 2003:      INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne
--			   - University of Nancy 2 - FRANCE
--
--		 Dominique COLNET, Suzanne COLLIN, Olivier ZENDRA,
--			   Philippe RIBET, Cyril ADRIAN
--
-- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr
--
class SMART_EIFFEL
   --
   -- Singleton object to handle general purpose information about the 
   -- SmartEiffel global compilation process. (This singleton is shared via 
   -- the GLOBALS.`smart_eiffel' once function.)
   --

inherit
   GLOBALS
   VISITABLE

feature

   copyright: STRING is "[
      SmartEiffel The GNU Eiffel Compiler, Eiffel tools and libraries
      Release 1.1 Release (Monday June 16th 2003) [Charlemagne]
      Copyright (C), 1994-2003 - INRIA - LORIA - UHP - Nancy 2 - FRANCE
      D.COLNET, S.COLLIN, O.ZENDRA, P.RIBET, C.ADRIAN - SmartEiffel@loria.fr
      http://SmartEiffel.loria.fr

      ]"

   status: INTEGER
	 -- The compilation process reach different `status' which are
	 -- described below. Note: at time being, `status' are simply
	 -- numbered because I don't have yet a precise idea for
	 -- appropriate names.
	 --
	 -- 0 `status': live code gathering has just started but is not yet
	 --   finished. At this time we are not aware of all types which may
	 --   be created at run-time.
	 -- 1 `status': falling-down process has just started. During this
	 --   process, all call sites are considered again in order to know
	 --   more about effective definitions of deferred features or
	 --   redefinitions. At this time, because new code may be
	 --   considered, we are not aware of all types which may be created
	 --   at run-time.
	 -- 2 `status': after-falling-down process has just started. The goal
	 --   of this step is to finish the complete computation of the
	 --   actual set of live types. At the end of this process, all live
	 --   types are known and all source files should be loaded.
	 -- 3 `status': whole system analysis for the final safety check has 
	 --   just  started but is not yet finished.
	 -- 4 `status': the system is _not_ type safe (i.e. some dangerous
	 --   covariant redefinitions are used and the user has got 
	 --   warnings).
	 -- 5 `status': the safety check test has not been performed 
	 --   (because of the compilation mode for example), so, we do not 
	 --   know if the system is safe or not.
	 -- 6 `status': whole system analysis is finished and the system is
	 --   type safe! Great!

   is_ready: BOOLEAN is
	 -- Is all the live code alerady gathered (`status' in 4 .. 6)? 
      do
	 Result := status.in_range(4, 6)
      end

   short_flag: BOOLEAN
         -- True when command `short' is running.

   pretty_flag: BOOLEAN
         -- True when command `pretty' is running.

   no_id: BOOLEAN
         -- True when the ids file has not to be read.

   base_class(class_name: CLASS_NAME): BASE_CLASS is
	 -- Retrieve the good one into the `base_class_dictionary' or launch 
	 -- the `eiffel_parser' if this class is not yet loaded. 
	 -- (See also `loaded_base_class'.)
      require
         class_name /= Void
      do
	 Result := base_class_dictionary.reference_at(class_name)
         if Result = Void then
	    if no_file_for(class_name.to_string) then
	       create Result.face_class(class_name.to_string)
               echo.put_integer(base_class_count)
               echo.put_character('%T')
               echo.put_character('(')
               echo.put_string(class_name.to_string)
               echo.put_character(')')
               echo.put_character('%N')
	    elseif eiffel_parser.is_running then
	       error_handler.append("Internal Error #1 in SMART_EIFFEL.")
	       error_handler.print_as_fatal_error
	    else
	       if ace.parser_buffer_for(class_name.to_string) then
		  Result := eiffel_parser.analyse_class(class_name)
		  check
		     Result /= Void
                     implies
		     base_class_dictionary.has(class_name)
		  end
	       end
	       if Result = Void then
		  error_handler.add_position(class_name.start_position)
		  error_handler.append("Unable to load class %"")
		  error_handler.append(class_name.to_string)
		  error_handler.append("%".")
		  error_handler.print_as_fatal_error
	       end
	    end
	 end
	 check Result /= Void end
	 Result.obsolete_warning(class_name)
      end

   loaded_base_class(cn: CLASS_NAME): BASE_CLASS is
	 -- Retrieve the good one into the `base_class_dictionary'. When the 
	 -- corresponding class `cn' is not yet loaded, the `eiffel_parser' 
	 -- is _not_ launched and the Result is Void. 
	 -- (See also `loaded_base_class'.)
      do
         Result := base_class_dictionary.reference_at(cn)
      end

   same_base_feature(up_rf: RUN_FEATURE; run_time_set: RUN_TIME_SET)
      : BOOLEAN is
         -- True when all `dynamic' features of the `run_time_set' have 
         -- excately the same final name and refer exactely to the same 
         -- `base_feature'.
      require
	 up_rf /= Void
         is_ready and run_time_set.count > 1
      local
         i: INTEGER; f: E_FEATURE; dyn_rf: RUN_FEATURE; rc: RUN_CLASS
      do
         from
            Result := True
            i := run_time_set.count
            f := up_rf.base_feature
         until
            not Result or else i = 0
         loop
            rc := run_time_set.item(i)
            dyn_rf := rc.dynamic(up_rf)
            if f = dyn_rf.base_feature then
               if dyn_rf.name.to_string /= up_rf.name.to_string then
                  Result := False
               end
            else
               Result := False
            end
            i := i - 1
         end
      end

   no_file_for(class_name: STRING): BOOLEAN is
      require
	 class_name = string_aliaser.item(class_name)
      do
	 if as_none = class_name then
	    Result := True
	 elseif as_tuple = class_name then
	    Result := True
	 elseif as_routine = class_name then
	    Result := True
	 elseif as_procedure = class_name then
	    Result := True
	 elseif as_function = class_name then
	    Result := True
	 elseif as_predicate = class_name then
	    Result := True
	 end
      end

   stupid_switch(t: E_TYPE; run_time_set: RUN_TIME_SET): BOOLEAN is
         -- True when `t' drives exactely to the same `t.run_type' for all 
         -- element of the `run_time_set'.
      require
         is_ready
      do
	 if run_time_set.count <= 1 then
            Result := True
         else
            Result := t.stupid_switch(run_time_set)
         end
      end

   generating_type_used: BOOLEAN
         -- When GENERAL `generating_type' is used.

   generator_used: BOOLEAN
         -- When GENERAL `generator' is used.

   deep_twin_used: BOOLEAN
	 -- When `deep_twin' support is necessary.

   scoop: BOOLEAN
         -- When some SCOOP functions are used. See scoop.html for details.

feature {RUN_CLASS, CREATE_TOOLS}

   set_scoop is
      do
         scoop := True
      end

feature {GC_HANDLER,C_PRETTY_PRINTER}

   root_procedure: RUN_FEATURE_3
	 -- The root procedure of the system to compile.

feature {PRETTY}

   re_load_class(bc: BASE_CLASS): BOOLEAN is
	 -- Try to re-parse the `bc' class to check that this newly created
	 -- class is syntactically correct.
      require
         bc /= Void
      local
	 name: CLASS_NAME; new_class: like bc
      do
         name := bc.name
         check
            base_class_dictionary.has(name)
         end
         base_class_dictionary.remove(name)
         if ace.parser_buffer_for(name.to_string) then
            new_class := eiffel_parser.analyse_class(name)
         end
         Result := new_class /= Void
      end

feature {BASE_CLASS}

   add_base_class(bc: BASE_CLASS) is
      require
         bc /= Void
      local
	 name: CLASS_NAME
      do
         name := bc.name
         check
            not base_class_dictionary.has(name)
         end
         base_class_dictionary.put(bc,name)
         magic_count_increment
      ensure
         base_class_dictionary.has(bc.name)
      end

feature {FINDER, SMART_EIFFEL_VISITOR}

   find_path_for(arg: STRING): STRING is
      do
         if ace.parser_buffer_for(arg) then
            Result := parser_buffer.path
	    parser_buffer.release
         end
      end

feature {CLASS_CHECKER, SMART_EIFFEL_VISITOR}

   set_short_flag is
      do
         short_flag := True
         set_no_id
      end

feature {PRETTY, SMART_EIFFEL_VISITOR}

   set_pretty_flag is
      do
         pretty_flag := True
         set_no_id
      end

feature {SMART_EIFFEL_VISITOR}

   set_no_id is
      do
         no_id := True
      end

feature

   bit_n_ref_is_nyi_error(p: POSITION) is
      do
	 error_handler.add_position(p)
	 error_handler.append(
             "Type %"reference BIT_N%" is not yet implemented.")
	 error_handler.print_as_error
      end

   run_class(simple_type: E_TYPE): RUN_CLASS is
      require
         simple_type.run_type = simple_type
      local
         rtm: STRING
      do
         rtm := simple_type.run_time_mark
	 Result := run_class_dictionary.reference_at(rtm)
         if Result = Void then
            create Result.make(simple_type, rtm)
            check
               run_class_dictionary.has(rtm)
            end
         end
      ensure
         Result /= Void
      end

   base_class_count: INTEGER is
         -- Total number of base class actually loaded.
      do
         Result := base_class_dictionary.count
      end

   compile_to_c is
         -- Produce C code for `root_class'/`procedure'.
      local
         root_class, procedure: STRING; rc: RUN_CLASS
	 run_count, i: INTEGER; gc_flag: BOOLEAN
      do
         root_class := ace.root_class_name
         procedure := ace.root_procedure_name
         get_started(root_class, procedure)
         if nb_errors = 0 then
            check
               root_procedure /= Void
            end
            cpp.get_started
            cpp.swap_on_h
            gc_flag := not gc_handler.is_off
            -- ---------------------------------------------------------
	    if ace.boost then
	       cpp.put_string_on_h(once "#define SE_BOOST 1%N")
            end
	    if ace.sedb then
	       cpp.put_string_on_h(once "#define SE_SEDB 1%N")
            end
	    if gc_flag then
	       cpp.put_string_on_h(once "#define SE_GC_LIB 1%N")
            end
	    if exceptions_handler.used then
	       cpp.put_string_on_h(once "#define SE_EXCEPTIONS 1%N")
	    end
	    if scoop then
	       cpp.put_string_on_h(once "#define SE_SCOOP 1%N")
	    end
	    -- ---------------------------------------------------------
            if scoop then
               cpp.sys_runtime_h_and_c(once "scoop")
               cpp.sys_runtime_h_and_c(once "scoop_thread")
               system_tools.add_lib_scoop
            end
            -- ---------------------------------------------------------
            from
               cpp.put_comment_line(once "C Header Pass 1 :")
	       agent_pool.c_header_pass1
	       update_run_class_map
               i := run_class_map.upper
            until
               i < 0
            loop
               rc := run_class_map.item(i)
               if rc.at_run_time then
                  run_count := run_count + 1
               end
               rc.c_header_pass1
               i := i - 1
            end
            -- ---------------------------------------------------------
            from
               cpp.put_comment_line(once "C Header Pass 2 :")
	       update_run_class_map
               i := run_class_map.upper
            until
               i < 0
            loop
               rc := run_class_map.item(i)
               rc.c_header_pass2
               i := i - 1
            end
            -- ---------------------------------------------------------
            from
               cpp.put_comment_line(once "C Header Pass 3 :")
	       update_run_class_map
               i := run_class_map.upper
            until
               i < 0
            loop
               rc := run_class_map.item(i)
               rc.c_header_pass3
               i := i - 1
            end
            -- ---------------------------------------------------------
            from
               cpp.put_comment_line(once "C Header Pass 4 :")
	       update_run_class_map
               i := run_class_map.upper
	    until
               i < 0
            loop
               rc := run_class_map.item(i)
               rc.c_header_pass4
               i := i - 1
            end
            -- Force definition of T9 and T7 :
            if not run_class_dictionary.has(as_native_array_character) then
               cpp.put_string(once "typedef T3* T9;%N")
               if ace.no_check then
                  cpp.put_c_function(once "void se_prinT9(FILE* file, T9*o)",
                      once "fprintf(file, %"NATIVE_ARRAY[STRING]#%%p\n%",(void*)*o);")
               end
            end
            manifest_string_pool.c_define1(string_at_run_time)
            cpp.customize_runtime(sys_runtime_basic)
            -- ---------------------------------------------------------
            if gc_flag then
               gc_handler.define1
            end
            -- ---------------------------------------------------------
            compile_routines
            cpp.cecil_define
            -- ---------------------------------------------------------
	    if ace.sedb then
               prepare_introspection
            end
            -- ---------------------------------------------------------
            cpp.define_main(root_procedure)
            manifest_string_pool.c_define2(string_at_run_time)
            compile_registered_for_c_define
            address_of_pool.c_define
            if gc_flag then
               gc_handler.define2
            end
            manifest_array_pool.c_define
            switch_collection.c_define
	    agent_pool.c_define_missing_agent_launcher
            cpp.define_used_basics
	    if scoop then
	       separate_tools.generate_scoop_functions(run_class_map)
	    end
            debug
               echo.put_string(once "Very Final magic_count : ")
               echo.put_integer(magic_count)
               echo.put_character('%N')
            end
            cpp.write_make_file
	    very_last_information
         else
            error_handler.append("Cannot produce C code.")
            error_handler.print_as_error
         end
      end

   compile_to_jvm is
         -- Produce Java Byte Code for `root_class'/`procedure'.
      local
         root_class, procedure: STRING
         rc: RUN_CLASS
         run_count, i: INTEGER
      do
         root_class := ace.root_class_name
         procedure := ace.root_procedure_name
         get_started(root_class, procedure)
         if scoop then
            not_yet_implemented
         end
         if nb_errors = 0 then
            jvm.prepare_output_directory
            from
	       update_run_class_map
               i := run_class_map.upper
            until
               i < 0
            loop
               rc := run_class_map.item(i)
               if rc.at_run_time then
                  run_count := run_count + 1
                  rc.compile_to_jvm
               end
               i := i - 1
            end
            echo.print_count(once "Used Type",run_count)
	    agent_pool.customize_jvm_runtime
            jvm.write_jvm_root_class
            jvm.write_main_class(root_procedure)
	    very_last_information
         else
            error_handler.append(once "Cannot produce Java Byte Code.")
            error_handler.print_as_error
         end
      end

feature {NONE}

   base_class_dictionary: DICTIONARY[BASE_CLASS,CLASS_NAME] is
         -- When looking for a BASE_CLASS using the name of the base class
         -- (ie. FOO[BAR] is stored at key "FOO").
      once
         create Result.with_capacity(1024)
      end

feature

   magic_count: INTEGER
         -- Grow each time a new run class is added, each time a new class is 
         -- loaded, each time a new feature is checked, each time another 
         -- expression is optimized, etc. ...
         -- Thus when `magic_count' stops growing, we are really ready :-).

   magic_count_increment is
      do
         magic_count := magic_count + 1
      end

feature {GC_HANDLER}

   get_run_class_map: FIXED_ARRAY[RUN_CLASS] is
      do
	 check
	    run_class_map.count = run_class_dictionary.count
	 end
	 Result := run_class_map
      end

feature {RUN_CLASS}

   run_class_dictionary: DICTIONARY[RUN_CLASS,STRING] is
      once
         !!Result.with_capacity(2048)
      end

feature {BASE_CLASS,TYPE_BASIC_EIFFEL_EXPANDED}

   run_class_for(cn: CLASS_NAME): RUN_CLASS is
	 -- Assume `cn' is a simple non generic class.
      require
	 cn /= Void
      local
	 bc: BASE_CLASS; type_class: TYPE_CLASS
      do
         Result := run_class_dictionary.reference_at(cn.to_string)
         if Result = Void then
	    bc := base_class_dictionary.reference_at(cn)
	    if bc /= Void then
	       create type_class.make(bc.name)
	       Result := type_class.run_class
	    else
	       error_handler.append("SMART_EIFFEL Internal error for: ")
	       error_handler.append(cn.to_string)
	       error_handler.print_as_fatal_error
	    end
	 end
      ensure
	 Result /= Void
      end

feature {RUN_CLASS}

   is_tagged(rc: RUN_CLASS): BOOLEAN is
      require
         status >= 4
         rc.at_run_time
         rc.current_type.is_reference
         ace.boost
      local
         i: INTEGER; run_time_set: RUN_TIME_SET
      do
         from
	    update_run_class_map
            i := run_class_map.upper
	 until
            Result or else i < 0
         loop
            run_time_set := run_class_map.item(i).run_time_set
            if run_time_set.count = 0 then
            elseif run_time_set.has(rc) then
               Result := run_time_set.count > 1
            end
            i := i - 1
         end
      end
   
   memory_class_used: BASE_CLASS is
         -- The MEMORY class when used or Void when this class is not
         -- in the live code.
      local
	 cn: CLASS_NAME
      do
	 create cn.unknown_position(as_memory)
	 Result := base_class_dictionary.reference_at(cn)
      end

feature -- To add more Context for some `to_runnable' :

   top_rf: RUN_FEATURE is
      do
	 if not run_feature_stack.is_empty then
	    Result := run_feature_stack.last
	 end
      end

   push(rf: RUN_FEATURE) is
      do
         run_feature_stack.add_last(rf)
      ensure
         run_feature_stack.count = 1 + old (run_feature_stack.count)
      end

   pop is
      do
	 run_feature_stack.remove_last
      ensure
         run_feature_stack.count = old (run_feature_stack.count) - 1
      end

feature {NONE}

   run_feature_stack: FIXED_ARRAY[RUN_FEATURE] is
	 -- The top-most one gives the current analysis context.
      once
         !!Result.with_capacity(50)
      end

   run_class_map: FIXED_ARRAY[RUN_CLASS] is
      once
	 create Result.with_capacity(2048)
      end

   update_run_class_map is
      do
	 if run_class_map.count /= run_class_dictionary.count then
	    run_class_map.clear
	    run_class_dictionary.item_map_in(run_class_map)
	 end
      end

   falling_down is
      local
         rc: RUN_CLASS; i: INTEGER; n: STRING; root_type: E_TYPE
	 sp: POSITION; type_reference: TYPE_REFERENCE
      do
         if generator_used then
            type_string.set_at_run_time
         end
         address_of_pool.falling_down
	 agent_pool.falling_down
         from
	    update_run_class_map
            i := run_class_map.upper
         until
            i < 0
         loop
            rc := run_class_map.item(i)
	    n := rc.base_class_name.to_string
	    if no_file_for(n) or else n = as_bit_n then
	       -- No `falling_down' for NONE, TUPLE, ROUTINE, ...
	    else
	       type_reference ?= rc.current_type
	       if type_reference = Void then
		  rc.falling_down
	       elseif type_reference.expanded_type.is_integer then
		  rc.falling_down
		  if reference_integer_set = Void then
		     create reference_integer_set.make
		  end
		  reference_integer_set.add(rc)
	       end
	    end
            i := i - 1
         end
	 if reference_integer_set /= Void then
	    assignment_handler.force_compatibility(reference_integer_set)
	 end
	 if smart_eiffel.scoop then
	    root_type := root_procedure.current_type
	    if  not root_type.is_separate then
	       -- SCOOP needs the root object to be separate.
	       sp := root_type.start_position
	       root_type := separate_tools.create_type_separate(sp,
								root_type)
	       root_type := root_type.to_runnable(type_any)
	       root_procedure ?=
	                 root_type.run_class.get_feature(root_procedure.name)
	       check
		  root_procedure /= Void
	       end
	    end
         end
      end

   afd_check is
      local
         rc: RUN_CLASS; i: INTEGER
      do
         from
	    update_run_class_map
            i := run_class_map.upper
         until
            i < 0
         loop
            rc := run_class_map.item(i)
            rc.afd_check
            i := i - 1
         end
	 cecil_pool.afd_check
      end

   very_last_information is
      do
	 assignment_handler.echo_information
	 inspect
	    status
	 when 4 then
	    error_handler.append(
		"The system is not type safe (read previous %
		%warnings carefully.)")
	    error_handler.print_as_warning
	 when 5 then
	    echo.put_string(
		"Type-system safety check not performed in %
		%this mode (use flag -safety_check).%N")
	 when 6 then
	    echo.put_string("The system is type safe.%N")
	 end
	 eiffel_parser.show_nb_warnings
	 eiffel_parser.show_nb_errors
	 echo.put_string(fz_02)
      end

feature {RUN_FEATURE_9}

   afd_check_deferred(rf9: RUN_FEATURE_9) is
      do
         if not rf9_memory.fast_has(rf9) then
            rf9_memory.add_last(rf9)
         end
      end

feature {NONE}

   rf9_memory: FIXED_ARRAY[RUN_FEATURE_9] is
      once
         !!Result.with_capacity(1024)
      end

   check_for_deferred is
      local
         i: INTEGER
         rf9: RUN_FEATURE
         rc: RUN_CLASS
      do
         from
            i := rf9_memory.upper
            echo.print_count(once "Deferred Routine",i+1)
         until
            i < 0
         loop
            rf9 := rf9_memory.item(i)
            rc := rf9.current_type.run_class
            if rc.at_run_time then
               error_handler.append(rf9.name.to_string)
               error_handler.append(once " is a deferred feature in ")
               error_handler.append(rf9.current_type.written_mark)
               warning(rf9.start_position,fz_dot_blank)
            end
            i := i - 1
         end
      end

   check_generic_formal_arguments is
      local
         i: INTEGER
      do
         from
            i := 1
         until
            i > base_class_dictionary.count
         loop
            base_class_dictionary.item(i).check_generic_formal_arguments
            i := i + 1
         end
      end

feature {ID_PROVIDER}

   id_extra_information(tfw: TEXT_FILE_WRITE; name: STRING) is
      local
         bc: BASE_CLASS; rc: RUN_CLASS; path: STRING; cn: CLASS_NAME
     do
	if name = as_none then
	else
	   rc := run_class_dictionary.reference_at(name)
	   if rc /= Void then
	      bc := rc.base_class
	   else
	      create cn.unknown_position(name)
	      bc := base_class_dictionary.reference_at(cn)
	   end
        end
	tfw.put_character('%N')
        if bc /= Void then
           tfw.put_string(once "class-path: %"")
           path := bc.path
           tfw.put_string(path)
           tfw.put_character('%"')
           tfw.put_character('%N')
           bc.id_extra_information(tfw)
        end
        if rc /= Void then
           rc.id_extra_information(tfw)
        end
     end

feature {CALL_PROC_CALL}

   covariance_check(call_site: POSITION; up_rf: RUN_FEATURE
		    run_time_set: RUN_TIME_SET) is
      require
	 not call_site.is_unknown
	 up_rf.arguments.count >= 1
	 not run_time_set.is_empty
      local
	 dyn_rf: RUN_FEATURE; up_args, dyn_args: FORMAL_ARG_LIST; 
	 r, a: INTEGER; t1, t2: E_TYPE
      do
	 from
	    r := 1
	    up_args := up_rf.arguments
	 until
	    r > run_time_set.count
	 loop
	    dyn_rf := run_time_set.item(r).dynamic(up_rf)
	    from 
	       a := 1
	       dyn_args := dyn_rf.arguments
	    until 
	       a > up_args.count
	    loop
	       t1 := up_args.type(a)
	       t2 := dyn_args.type(a)
	       if t1.run_time_mark /= t2.run_time_mark then
		  error_handler.add_position(call_site)
		  error_handler.append(
                      "Unsafe covariant redefinition (type %"")
		  error_handler.append(t1.run_time_mark)
		  error_handler.append("%" redefined as %"")
		  error_handler.append(t2.run_time_mark)
		  error_handler.append("%").")
		  error_handler.add_position(t1.start_position)
		  error_handler.add_position(t2.start_position)
		  error_handler.print_as_warning
		  status := 4
	       end
	       a := a + 1
	    end
	    r := r + 1
	 end
      end

feature {CALL_PROC_CALL,PRECURSOR_CALL,CREATE_TOOLS,E_AGENT}

   argument_passing_check(call_site: POSITION
			  arguments: EFFECTIVE_ARG_LIST
			  rf: RUN_FEATURE) is
	 --  Check if argument passing at `call_site' position is valid or 
	 --  not. This verification is here (i.e. not in class 
	 --  EFFECTIVE_ARG_LIST or in class FORMAL_ARG_LIST) because 
	 --  `arguments' or/and `formal_arg_list' may be both Void.
      require
	 not call_site.is_unknown
	 rf /= Void
      local
	 i: INTEGER; formal_arg_list: FORMAL_ARG_LIST
      do
	 formal_arg_list := rf.arguments
         if arguments = Void then
	    if formal_arg_list /= Void then
	       error_handler.add_position(call_site)
	       error_handler.add_position(formal_arg_list.start_position)
	       error_handler.append("The feature called has ")
	       i := formal_arg_list.count
	       error_handler.append_integer(i)
	       error_handler.append(" argument")
	       if i > 1 then
		  error_handler.extend('s')
	       end
	       error_handler.append(". (The actual argument list is empty.)")
	       error_handler.print_as_fatal_error
	    end
	 elseif formal_arg_list = Void then
	    error_handler.add_position(rf.start_position)
	    error_handler.add_position(arguments.start_position)
	    error_handler.append("There ")
	    i := arguments.count
	    if i > 1 then
	       error_handler.append("are ")
	    else
	       error_handler.append("is ")
	    end
	    error_handler.append_integer(i)
	    error_handler.append(" actual argument")
	    if i > 1 then error_handler.extend('s') end
	    error_handler.append(". (The feature found has no argument.)")
	    error_handler.print_as_fatal_error
	 else
	    arguments.match_with(rf)
         end
      end

feature {C_PRETTY_PRINTER}

   define_extern_tables is
      require
         cpp.on_c
      local
         size: INTEGER
      do
         size := id_provider.max_id + 1
         cpp.macro_def(once "SE_MAXID",size)
         if generator_used then
            cpp.put_extern4(once "T7*g", size)
         end
         if generating_type_used then
            cpp.put_extern4(once "T7*t",size)
         end
         if ace.no_check then
            cpp.put_extern4(once "char*p",size)
            c_code.copy(once "void(*se_prinT[")
            size.append_in(c_code)
            c_code.append(once "])(FILE*,void**)")
            cpp.put_extern1(c_code)
            c_code.copy(once "int se_strucT[")
            size.append_in(c_code)
            c_code.extend(']')
            cpp.put_extern1(c_code)
            if ace.sedb then
               c_code.copy(once "void*(*se_introspecT[")
               size.append_in(c_code)
               c_code.append(once "])(void*,char*,int*,int*)")
               cpp.put_extern1(c_code)
               c_code.copy(once "char* se_atT[")
               size.append_in(c_code)
               c_code.append(once "]")
               cpp.put_extern1(c_code)
            end
         end
      end

   initialize_path_table is
      require
         ace.no_check
         cpp.on_c
      local
         i, id: INTEGER; bc: BASE_CLASS; rc: RUN_CLASS
      do
         from
            cpp.put_string(once "p[0]=%"???%";%N")
            i := 1
         until
            i > base_class_dictionary.count
         loop
            bc := base_class_dictionary.item(i)
	    id := bc.id
	    if id > 0 then
	       cpp.put_string(once "p[")
	       cpp.put_integer(id)
	       cpp.put_string(once "]=")
	       cpp.put_string_c(bc.path)
	       cpp.put_string(fz_00)
	    end
            i := i + 1
         end
         from
	    update_run_class_map
            i := run_class_map.upper
         until
            i < 0
         loop
            rc := run_class_map.item(i)
            if rc.at_run_time then
               cpp.put_string(once "se_prinT[")
               cpp.put_integer(rc.id)
               cpp.put_string(once "]=((void(*)(FILE*,void**))se_prinT")
               cpp.put_integer(rc.id)
               cpp.put_string(once ");%N")
               if rc.current_type.is_generic then
                  cpp.put_string(once "p[")
                  cpp.put_integer(rc.id)
                  cpp.put_string(once "]=p[")
                  cpp.put_integer(rc.base_class.id)
                  cpp.put_string(once "];%N")
               end
               cpp.put_string(once "se_strucT[")
               cpp.put_integer(rc.id)
               cpp.put_string(once "]=sizeof(T")
               cpp.put_integer(rc.id)
               cpp.put_string(fz_14)
	       if ace.sedb then
		  cpp.put_string(once "se_introspecT[")
		  cpp.put_integer(rc.id)
		  cpp.put_string(once "]=((void*(*)(void*,char*,int*,int*))se_introspecT")
		  cpp.put_integer(rc.id)
		  cpp.put_string(once ");%N")
                  rc.prepare_introspection2
	       end
            end
            i := i - 1
         end
      ensure
         cpp.on_c
      end

   initialize_generator is
      require
         cpp.on_c
      local
         i, id: INTEGER; bc: BASE_CLASS; rc: RUN_CLASS
      do
         from
            i := 1
         until
            i > base_class_dictionary.count
         loop
            bc := base_class_dictionary.item(i)
	    id := bc.id
	    if id >= 0 then
	       cpp.put_array1('g',id)
	       cpp.put_character('=')
	       cpp.put_se_string(bc.name.to_string)
	       cpp.put_string(fz_00)
	    end
            i := i + 1
         end
         from
	    update_run_class_map
            i := run_class_map.upper
         until
            i < 0
         loop
            rc := run_class_map.item(i)
            if rc.at_run_time then
               bc := rc.base_class
               if bc.name.to_string /= rc.current_type.run_time_mark then
                  cpp.put_array1('g',rc.id)
                  cpp.put_character('=')
                  cpp.put_array1('g',bc.id)
                  cpp.put_string(fz_00)
               end
            end
            i := i - 1
         end
      ensure
         cpp.on_c
      end

   initialize_generating_type is
      require
         cpp.on_c
      local
         i: INTEGER; rc: RUN_CLASS; bc: BASE_CLASS; rtm: STRING
      do
         from
	    update_run_class_map
            i := run_class_map.upper
         until
            i < 0
         loop
            rc := run_class_map.item(i)
            if rc.at_run_time then
               cpp.put_array1('t',rc.id)
               cpp.put_character('=')
               bc := rc.base_class
               rtm := rc.current_type.run_time_mark
               if bc.name.to_string /= rtm then
                  cpp.put_se_string(rtm)
               else
                  cpp.put_array1('g',rc.id)
               end
               cpp.put_string(fz_00)
            end
            i := i - 1
         end
      ensure
         cpp.on_c
      end

feature {RUN_FEATURE_3}

   register_for_c_define(rf: RUN_FEATURE_3) is
      require
         rf /= Void
      do
         registered_for_c_define.add_last(rf)
      end

feature {RUN_FEATURE_7, RUN_FEATURE_8, AGENT_POOL}

   register_sys_runtime_basic_of(name: STRING) is
         -- Add some SmartEiffel/sys/runtime/basic_* package as
         -- an already used one in order to customize the runtime.
      require
         name.has_prefix("basic_")
      local
         package: STRING
      do
         from
            package := once "basic_...................."
            package.copy(name)
         until
            package.occurrences('_') = 1
         loop
            package.remove_last(1)
         end
         if not sys_runtime_basic.has(package) then
            package := package.twin
            sys_runtime_basic.add(package)
         end
      end

feature {RUN_CLASS}

   set_deep_twin_used is
      do
         deep_twin_used := True
      end

   reference_to_separate(source_type: E_TYPE) is
      require
         source_type.is_reference
      local
         i: INTEGER
         rc: RUN_CLASS
         type: E_TYPE
      do
         from
	    update_run_class_map
            i := run_class_map.upper
         until
            i < 0
         loop
            rc := run_class_map.item(i)
            type := rc.current_type
            if type.is_separate then
               if type.is_a(source_type) then
                  type := type.actual_separate(source_type)
                  rc := type.run_class
                  if not rc.at_run_time then
                     rc.set_at_run_time
                     source_type.run_class.falling_down
                  end
               else
                  error_handler.cancel
               end
            end
            i := i - 1
         end
      end

feature {RUN_FEATURE_8}

   set_generating_type_used is
      do
         generating_type_used := True
      end

   set_generator_used is
      do
         generator_used := True
      end

feature {CLUSTER}

   parse_include(include_name: STRING) is
      require
	 include_name /= Void
      local
	 bc: BASE_CLASS
      do
	 check parser_buffer.is_ready end
	 echo.put_string(once "Handling include of %"")
	 echo.put_string(include_name)
	 echo.put_string(once "%" from ACE file. (Parsing %"")
	 echo.put_string(parser_buffer.path)
	 echo.put_string(once "%".)%N")
	 bc := eiffel_parser.analyse_buffer
	 check
	    bc /= Void
	    implies
	    base_class_dictionary.has(bc.name)
	 end
      end

feature {SMART_EIFFEL_VISITOR}

   accept(visitor: SMART_EIFFEL_VISITOR) is
      do
         visitor.visit_smart_eiffel(Current)
      end

feature {NONE}

   sys_runtime_basic: SET[STRING] is
         -- Actually used packages of SmartEiffel/sys/runtime.
         -- For example: basic_directory, basic_time, basic_*, etc.
      once
         !!Result.make
      end

   string_at_run_time: BOOLEAN is
      require
         is_ready
      local
         rc: RUN_CLASS
      do
         if run_class_dictionary.has(as_string) then
            rc := run_class_dictionary.at(as_string)
            Result := rc.at_run_time
         end
      end

   get_started(root_class_name, root_procedure_name: STRING) is
         -- Get started to compile using creation procedure `root_procedure_name'
         -- of base class `root_class_name'.
      require
         not root_class_name.is_empty
         not root_procedure_name.is_empty
      local
         sfn: FEATURE_NAME; root: BASE_CLASS; root_proc: E_PROCEDURE
         root_type: E_TYPE; magic: INTEGER; root_name: CLASS_NAME
      do
         if ace.no_check then
            set_generator_used
            set_generating_type_used
         end
	 ace.parse_include
	 create root_name.unknown_position(root_class_name)
         root := base_class(root_name)
         if root = Void then
            error_handler.append("Cannot load root class ")
            error_handler.append(root_class_name)
            error_handler.append(fz_dot_blank)
            error_handler.print_as_error
         elseif root.is_expanded then
	    error_handler.add_position(root.name.start_position)
	    error_handler.append("The root class must not be expanded (sorry,%
		      % but this is a limitation of the compiler).")
	    error_handler.print_as_fatal_error
	 else
	    sfn := root.root_creation_search(root_procedure_name)
            root_proc := root.root_procedure_check(sfn)
         end
         if nb_errors = 0 then
            if root_proc.arguments /= Void then
               error_handler.add_position(root_proc.start_position)
               error_handler.append("Creation procedure must not have arguments.")
               error_handler.print_as_fatal_error
            end
         end
         if nb_errors = 0 then
	    root_type := run_class_for(root.name).current_type
         end
         if nb_errors = 0 then
            root_procedure := root_proc.to_run_feature(root_type,sfn)
         end
         if nb_errors = 0 then
	    cecil_pool.fill_up
	    check status = 0 end
	    status := 1
            echo_magic_count(once "Starting Falling Down")
            if scoop then
               echo.put_string(once "(SCOOP target verification activated)%N")
            end
            from
               falling_down
            until
               magic = magic_count or else nb_errors > 0
            loop
               magic := magic_count
               falling_down
            end
            echo_magic_count(once "End of Falling Down")
         end
         if nb_errors = 0 then
	    check status = 1 end
	    status := 2
            echo_magic_count(once "Starting AFD Check")
            from
               afd_check
            until
               magic = magic_count or else nb_errors > 0
            loop
               magic := magic_count
               afd_check
            end
            check_for_deferred
            check_generic_formal_arguments
            echo_magic_count(once "Before conversion handling")
            assignment_handler.finish_falling_down
            echo_magic_count(once "After conversion handling")
            from
            until
               magic = magic_count or else nb_errors > 0
            loop
	       echo_magic_count(once "Extra falling-down")
               magic := magic_count
               falling_down
	       afd_check
            end
            echo_magic_count(once "End of AFD Check")
         end
         if not error_handler.is_empty then
            error_handler.append(
	       "Internal Warning #1 (Error Handler Not Empty): ")
            error_handler.print_as_warning
         end
         if nb_errors = 0 then
 	    safety_check
            echo.print_count(once "Loaded Classe",
			     base_class_dictionary.count)
         end
	 if nb_errors = 0 and then
	    not pretty_flag and then
	    not short_flag
	  then
	    simplify_2
	 end
      ensure
         nb_errors = 0 implies root_procedure /= Void
      end

   compile_routines is
         -- Try to give the best order to the C output.
      require
         root_procedure.set_is_root
      local
         rc, rc_string: RUN_CLASS; ct: E_TYPE; deep, i: INTEGER
         stop: BOOLEAN; bcn: STRING
      do
         echo.put_string(once "Compiling/Sorting routines for ")
         echo.put_integer(run_class_dictionary.count)
         echo.put_string(once " run classes :%N")
         cpp.swap_on_c
         from
	    update_run_class_map
            i := run_class_map.upper
         until
            i < 0
         loop
            rc := run_class_map.item(i)
            ct := rc.current_type
            if ct.is_basic_eiffel_expanded then
               rc.compile_to_c(0)
            elseif ct.is_string then
               rc_string := rc
            end
            i := i - 1
         end
         from
	    update_run_class_map
            i := run_class_map.upper
         until
            i < 0
         loop
            rc := run_class_map.item(i)
            ct := rc.current_type
            if ct.is_bit then
               rc.compile_to_c(0)
            end
            i := i - 1
         end
         from
	    update_run_class_map
            i := run_class_map.upper
         until
            i < 0
         loop
            rc := run_class_map.item(i)
            bcn := rc.base_class_name.to_string
            if as_native_array = bcn then
               rc.compile_to_c(0)
            end
            i := i - 1
         end
         if rc_string /= Void then
            rc_string.compile_to_c(0)
         end
         from
	    update_run_class_map
            i := run_class_map.upper
         until
            i < 0
         loop
            rc := run_class_map.item(i)
            ct := rc.current_type
            bcn := ct.base_class_name.to_string
            if as_array = bcn or else as_fixed_array = bcn then
               rc.compile_to_c(0)
            end
            i := i - 1
         end
         from
	    update_run_class_map
            i := run_class_map.upper
         until
            i < 0
         loop
            rc := run_class_map.item(i)
            ct := rc.current_type
            if ct.is_generic then
               rc.compile_to_c(0)
            end
            i := i - 1
         end
         from -- General sorting:
            deep := 6
         until
            stop
         loop
            from
               stop := True
	       update_run_class_map
	       i := run_class_map.upper
            until
               i < 0
            loop
               rc := run_class_map.item(i)
               if not rc.compile_to_c_done then
                  stop := False
                  rc.compile_to_c(deep)
               end
               i := i - 1
            end
            deep := deep - 1
         end
      end

   prepare_introspection is
         -- Creates the introspection features
      require
         ace.no_check
      local
         i: INTEGER
      do
         cpp.swap_on_c
         from
            i := run_class_map.upper
         until
            i < 0
         loop
            run_class_map.item(i).prepare_introspection
            i := i - 1
         end
      end

   c_code: STRING is
      once
         !!Result.make(128)
      end

   registered_for_c_define: FIXED_ARRAY[RUN_FEATURE_3] is
      once
         !!Result.with_capacity(512)
      end

   compile_registered_for_c_define is
      local
         i: INTEGER
      do
         from
            i := registered_for_c_define.upper
         until
            i < 0
         loop
            registered_for_c_define.item(i).c_define_or_scoop_define
            i := i - 1
         end
      end

   safety_check is
	 -- Start final whole system analysis to decide whether this 
	 -- system is safe or not.
      require
	 status = 2
      local
	 old_magic_count, i: INTEGER; do_it: BOOLEAN; rc: RUN_CLASS
      do
	 debug
	    old_magic_count := magic_count
	 end
	 do_it := ace.safety_check
	 if do_it then
	    status := 6
	    echo_magic_count(once "Starting type safety check")
	    from
	       update_run_class_map
	       i := run_class_map.upper
	    until
	       i < run_class_map.lower
	    loop
	       rc := run_class_map.item(i)
	       if rc.at_run_time then
		  rc.safety_check
	       end
	       i := i - 1
	    end
	 else
	    status := 5
	 end
	 debug
	    check
	       old_magic_count = magic_count
	    end
	 end
      ensure
	 status.in_range(4,6)
      end

   echo_magic_count(msg: STRING) is
      require
	 msg /= Void
      do
	 echo.put_string(msg)
	 echo.put_string(once " (magic_count = ")
	 echo.put_integer(magic_count)
	 echo.put_string(once ").%N")
      end

   simplify_2 is
      require
	 not smart_eiffel.pretty_flag
	 not smart_eiffel.short_flag
	 smart_eiffel.status >= 4
      local
         rc: RUN_CLASS; i: INTEGER; prev_magic_count: INTEGER 
      do
	 echo.put_string(once "[Starting simplify_2 (")
	 echo.put_integer(magic_count)
	 echo.put_string(once "): ")
	 from
	 until
	    prev_magic_count = magic_count
	 loop
	    prev_magic_count := magic_count
	    echo.put_character('.')
	    from
	       update_run_class_map
	       i := run_class_map.upper
	    until
	       i < 0
	    loop
	       rc := run_class_map.item(i)
	       rc.simplify_2
	       i := i - 1
	    end
	 end
	 echo.put_string(once " finished simplify_2 (")
	 echo.put_integer(magic_count)
	 echo.put_string(once ")]%N")
      end

   reference_integer_set: SET[RUN_CLASS]

   singleton_memory: SMART_EIFFEL is
      once
         Result := Current
      end

invariant

   status.in_range(0,6)

   is_real_singleton: Current = singleton_memory

end -- SMART_EIFFEL