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
|
-- 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 ACE
--
-- Assembly of Classes in Eiffel.
--
-- Singleton object in charge of parsing the *.ace file if any.
-- This singleton is also in charge to memorize and to give access to the
-- corresponding information (keep in mind that we can still use only
-- command line arguments to launch the compiler).
-- This singleton is shared via the GLOBALS.`ace' once function.
--
inherit
PARSER
redefine
accept
end
ASSERTION_LEVEL_NUMBERING
feature
file_path: STRING
-- Non Void when a ACE file is in use (keep in mind that one can
-- stil launch a compilation without any ACE file, passing all the
-- information using command arguments only).
-- Usually, ACE files are suffixed with ".ace" or ".ACE".
executable_name: STRING
-- The name of the executable to build (after the "system" keyword
-- in the ACE file or after the -o flag in the command line).
-- In command line mode, a Void value means that "a.out" is to be
-- used for C mode while using gcc for example. For the Java
-- byte-code this name is used as the name of the main output class
-- file and as the name of the directory used to store auxilliary
-- class files.
root_class_name: STRING is
-- The name of the root class using only upper case letters. This
-- is actually the generating type of the very first live object at
-- runtime. This `root_class_name' is after the "root" keyword in
-- the ACE file or is given as a command line argument.
do
if root_class_names.count > 0 then
Result := root_class_names.last
end
end
root_procedure_name: STRING is
-- The name of the procedure which is actually the main program.
-- This procedure is supposed to be member of the creation clause
-- of `root_class_name'.
require
root_class_names.count = 1
local
bc: BASE_CLASS; cn: CLASS_NAME
do
if root_procedure_name_memory = Void then
create cn.unknown_position(root_class_name)
bc := smart_eiffel.base_class(cn)
root_procedure_name_memory := bc.default_root_procedure_name
end
Result := root_procedure_name_memory
end
root_class_names: FIXED_ARRAY[STRING] is
-- All the class names given on the command line
once
create Result.with_capacity(1)
end
boost: BOOLEAN is
do
Result := default_assertion_level = level_boost
end
no_check: BOOLEAN is
-- The system level value (see also {BASE_CLASS}.no_check).
do
Result := default_assertion_level >= level_no
end
require_check: BOOLEAN is
do
Result := default_assertion_level >= level_require
end
all_check: BOOLEAN is
do
Result := default_assertion_level >= level_all
end
no_main: BOOLEAN
-- Don't include a main() in the generated executable.
safety_check: BOOLEAN
manifest_string_trace: BOOLEAN
high_memory_compiler: BOOLEAN
sedb: BOOLEAN is
-- The -sedb flag is used or some class of the ACE file is
-- in trace mode. (When `sedb' is set, files sys/runtime/sedb.[ch]
-- are included.)
do
Result := no_check and then sedb_flag
end
feature {BASE_CLASS}
trace_of(base_class: BASE_CLASS): BOOLEAN is
-- Is the -sedb trace mode enabled for `base_class'.
local
cluster: CLUSTER
do
cluster := base_class.cluster
if cluster /= Void then
Result := cluster.trace(base_class.name)
else
Result := default_trace
end
if Result then
if default_assertion_level = level_boost then
default_assertion_level := level_no
end
end
end
feature {COMPOUND}
debug_check(e_debug: E_DEBUG): BOOLEAN is
-- Is this `e_debug' statement is active or not?
-- Note: during the execution of this routine, the
-- `default_assertion_level' may be switch from `level_boost' to
-- `level_no'.
require
e_debug /= Void
local
base_class: BASE_CLASS; cluster: CLUSTER
do
base_class := e_debug.start_position.base_class
cluster := base_class.cluster
if cluster /= Void then
Result := cluster.debug_check(base_class.name,e_debug)
else
Result := default_debug(e_debug)
end
if Result then
if default_assertion_level = level_boost then
default_assertion_level := level_no
end
end
end
feature {BASE_CLASS}
assertion_level_of(base_class: BASE_CLASS): INTEGER is
require
avoid_recomputation: base_class.assertion_level = level_unknown
local
cluster: CLUSTER
do
cluster := base_class.cluster
if cluster /= Void then
Result := cluster.assertion_level_of(base_class.name)
else
Result := default_assertion_level
end
ensure
Result.in_range(level_boost,level_debug)
end
feature {COMMAND_LINE_TOOLS}
analyse_ace_file(fp: like file_path) is
-- Parse `fp' which is supposed to be some file containing
-- an ACE description.
local
echo_set_verbose_delayed: BOOLEAN
do
if file_path /= Void then
echo.w_put_string("Multiple ACE files in the command%
% line: %"")
echo.w_put_string(file_path)
echo.w_put_string("%" and %"")
echo.w_put_string(fp)
echo.w_put_string("%".%N")
die_with_code(exit_failure_code)
end
file_path := fp
parser_buffer.load_file(fp)
if not parser_buffer.is_ready then
error_handler.append("Cannot open %"")
error_handler.append(fp)
error_handler.append("%" file.%NACE file not found.")
error_handler.print_as_fatal_error
end
echo.put_string("Parsing %"")
echo.put_string(file_path)
echo.put_string("%" ACE file.%N")
line := 1
column := 1
current_line := parser_buffer.item(line)
set_highest_level(level_boost)
if current_line.count = 0 then
cc := '%N'
else
cc := current_line.first
end
drop_comments := True
skip_comments
if not a_keyword(once "system") then
error_handler.add_position(current_position)
error_handler.append(
"Keyword %"system%" expected. Invalid ACE file.")
error_handler.print_as_fatal_error
end
executable_name := a_name
if not a_keyword(once "root") then
error_handler.add_position(current_position)
error_handler.append(
"Keyword %"root%" expected. Invalid ACE file.")
error_handler.print_as_fatal_error
end
set_root_class_name(a_name)
a_cluster_mark
if skip1(':') then
root_procedure_name_memory := a_name
end
if a_keyword(fz_default) then
echo_set_verbose_delayed := a_system_level_defaults
end
if a_clusters then end
if a_keyword(fz_external) then
a_external
end
if a_keyword(fz_generate) then
a_generate
end
if a_keyword(fz_end) then end
if cc /= end_of_text then
error_handler.add_position(current_position)
error_handler.append(
"End of text expected (invalid ACE file).")
error_handler.print_as_fatal_error
end
parser_buffer.release
get_started
if echo_set_verbose_delayed then
echo.set_verbose
end
ensure
file_path = fp
default_assertion_level /= level_unknown
end
feature {NONE}
set_default_c_mode is
local
c_mode: STRING
do
c_mode := once "................"
c_mode.copy(level_name(highest_level))
if not c_mode.is_equal(fz_boost) then
c_mode.append(once "_check")
end
system_tools.set_default_c_mode(c_mode)
end
feature {COMMAND_LINE_TOOLS,SYSTEM_TOOLS}
set_root_class_name_using(command_line_name: STRING) is
-- Compute the `root_class_name' name using the `command_line_name'
-- as a model.
-- Trailing Eiffel file suffix is removed if any.
-- Leading path is also removed if any.
-- Finally, the feature `to_upper' is applied.
require
not command_line_name.is_empty
local
rcn: STRING
do
compute_class_name_buffer_using(command_line_name)
rcn := class_name_buffer.twin
rcn := string_aliaser.item(rcn)
root_class_names.add_last(rcn)
ensure
root_class_names.count = old root_class_names.count + 1
root_class_names.last /= command_line_name
root_class_names.last = string_aliaser.item(root_class_names.last)
not root_class_names.last.has_suffix(eiffel_suffix)
end
feature {COMPILE}
clean: BOOLEAN
-- Should the clean command to be launched after compilation?
feature {COMPILE_TO_JVM,SYSTEM_TOOLS}
set_root_procedure_name(rp: STRING) is
do
root_procedure_name_memory := rp
ensure
root_procedure_name = rp
end
feature {COMMAND_LINE_TOOLS}
set_default_level is
do
if default_assertion_level = level_unknown then
default_assertion_level := level_all
end
set_highest_level(default_assertion_level)
set_default_c_mode
end
set_boost is
do
default_assertion_level := level_boost
end
set_no_check is
do
default_assertion_level := level_no
end
set_require_check is
do
default_assertion_level := level_require
end
set_ensure_check is
do
default_assertion_level := level_ensure
end
set_invariant_check is
do
default_assertion_level := level_invariant
end
set_loop_check is
do
default_assertion_level := level_loop
end
set_all_check is
do
default_assertion_level := level_all
end
set_debug_check is
do
default_assertion_level := level_debug
default_debug_key := fz_yes
end
command_line_parsed(command_name: STRING) is
-- Should be called the end of command line argument parsing
-- (i.e. only in command line mode) to check among other things
-- that the root class was actually given as argument.
require
file_path = Void
do
if root_class_name = Void then
echo.w_put_string(command_name)
echo.w_put_string(": error: No <Root-Class> in command line.%N")
die_with_code(exit_failure_code)
end
if sedb and then boost then
echo.w_put_string(command_name)
echo.w_put_string(": cannot use -sedb with -boost flag.%N")
die_with_code(exit_failure_code)
end
system_tools.read_loadpath_files
get_started
ensure
default_assertion_level /= level_unknown
end
set_default_trace is
do
default_trace := True
sedb_flag := True
ensure
default_trace = True
end
set_executable_name(name: STRING) is
do
executable_name := name
ensure
executable_name = name
end
set_clean(flag: BOOLEAN) is
do
clean := flag
end
set_safety_check is
do
safety_check := True
end
set_manifest_string_trace is
do
manifest_string_trace := True
end
set_high_memory_compiler is
do
high_memory_compiler := True
end
feature {SMART_EIFFEL}
parser_buffer_for(name: STRING): BOOLEAN is
-- The algorithm to search some class on the disk using the `name'
-- key which is usually some simple class name using the standard
-- notation, but which can also be any other kind of notation (even
-- file path notation). When the `Result' is True, the `parser_buffer' is
-- ready to be used. When no file can be found using `name' and the
-- `cluster_list' information, a viewable information about this `cluster_list'
-- is printed.
require
not parser_buffer.is_ready
local
i: INTEGER; cluster: CLUSTER; class_name: STRING
do
from
compute_class_name_buffer_using(name)
class_name := string_aliaser.item(class_name_buffer)
i := cluster_list.lower
until
i > cluster_list.upper or else Result
loop
cluster := cluster_list.item(i)
Result := cluster.parser_buffer_for(class_name)
i := i + 1
end
if not Result and then file_path = Void then
-- To handle old "rename.se" files.
handle_rename_se_files
from
i := cluster_list.lower
until
i > cluster_list.upper or else Result
loop
cluster := cluster_list.item(i)
Result := cluster.rename_se_parser_buffer_for(class_name)
i := i + 1
end
end
if not Result then
echo.w_put_string("Unable to find file for class %"")
echo.w_put_string(name)
echo.w_put_string("%". ")
buffer.clear
view_in(buffer)
echo.w_put_string(buffer)
end
end
parse_include is
-- Look for some class(es) to be loaded first because of
-- some "include" option.
local
i: INTEGER
do
if file_path /= Void then
from
i := cluster_list.lower
until
i > cluster_list.upper
loop
cluster_list.item(i).include_parsing
i := i + 1
end
end
end
feature {ACE_CHECK}
pretty_in(txt: STRING) is
-- Performs the `ace_check' and also prepare in `txt' a pretty version
-- of the Ace file as it is memorized (can be also used to pretty
-- one's ACE file).
require
file_path /= Void
local
i: INTEGER
do
txt.append("system ")
txt.append(executable_name)
txt.append("%Nroot ")
txt.append(root_class_name)
if root_procedure_name_memory /= Void then
txt.append(": %"")
txt.append(root_procedure_name_memory)
txt.extend('%"')
end
txt.append("%Ndefault%N assertion (")
txt.append(level_name(default_assertion_level))
txt.append(")%N debug (")
txt.append(default_debug_key)
txt.append(")%N")
if default_trace then
txt.append(" trace (yes)%N")
else
txt.append(" trace (no)%N")
end
if gc_handler.is_off then
txt.append(" collect (no)%N")
else
txt.append(" collect (yes)%N")
end
if eiffel_parser.case_insensitive then
txt.append(" case_insensitive (yes)%N")
else
txt.append(" case_insensitive (no)%N")
end
if eiffel_parser.no_style_warning then
txt.append(" no_style_warning (yes)%N")
else
txt.append(" no_style_warning (no)%N")
end
if error_handler.no_warning then
txt.append(" no_warning (yes)%N")
else
txt.append(" no_warning (no)%N")
end
if echo.verbose then
txt.append(" verbose (yes)%N")
else
txt.append(" verbose (no)%N")
end
if manifest_string_trace then
txt.append(" manifest_string_trace (yes)%N")
else
txt.append(" manifest_string_trace (no)%N")
end
if high_memory_compiler then
txt.append(" high_memory_compiler (yes)%N")
else
txt.append(" high_memory_compiler (no)%N")
end
if safety_check then
txt.append(" safety_check (yes)%N")
else
txt.append(" safety_check (no)%N")
end
txt.append("cluster%N")
from
i := cluster_list.lower
until
i > cluster_list.upper
loop
cluster_list.item(i).pretty_in(txt)
i := i + 1
end
txt.append("external%N")
if not system_tools.external_object_files.is_empty then
txt.append(" external_object_files: %"")
txt.append(system_tools.external_object_files)
txt.append("%"%N")
end
if not system_tools.external_c_files.is_empty then
txt.append(" external_c_files: %"")
txt.append(system_tools.external_c_files)
txt.append("%"%N")
end
if not system_tools.external_c_plus_plus_files.is_empty then
txt.append(" external_c_plus_plus_files: %"")
txt.append(system_tools.external_c_plus_plus_files)
txt.append("%"%N")
end
-- *** cecil_pool.pretty_ace_in(txt)
-- *** to continue...
txt.append("generate%N")
if system_tools.no_strip then
txt.append(" no_strip (yes)%N")
else
txt.append(" no_strip (no)%N")
end
if no_split then
txt.append(" no_split (yes)%N")
else
txt.append(" no_split (no)%N")
end
if clean then
txt.append(" clean (yes)%N")
else
txt.append(" clean (no)%N")
end
-- *** to continue...
txt.append("end%N")
end
feature {SYSTEM_TOOLS, ACE_VISITOR}
view_in(msg: STRING) is
-- Append in `msg' a viewable version of the `cluster_list' as well as
-- some other informations to help the user to fix the problem.
require
msg /= Void
local
i, no: INTEGER
sed: STRING
do
if smart_eiffel.pretty_flag then
elseif file_path = Void then
msg.append(
"%N%
%You are in command line mode (i.e. no ACE file is used).%N%
%The load path can be changed using a file called%N%
%loadpath.se in the current working directory.%N%
%Usually, this loadpath.se file is a simple list of directories.%N%
%It is also possible to use system variables or include files. See%N%
%the documentation for the finder command for more information.%N")
else
msg.append(
"%N%
%Eiffel class file searching is being done according to the ACE %
%file %"")
msg.append(file_path)
msg.append("%".%N")
end
if smart_eiffel.pretty_flag then
check cluster_list.count = 1 end
msg.append(
"(Command pretty only looks in the current working directory.)%N")
else
msg.append("Files are being searched for in the following %
%list of clusters (")
cluster_list.count.append_in(msg)
msg.append(" items):%N")
from
i := cluster_list.lower
until
i > cluster_list.upper
loop
no := no + 1
cluster_list.item(i).view_in(no,msg)
i := i + 1
end
system_tools.system_name_in(msg)
msg.append(
"The value of the environment variable %"SmartEiffel%" is:%N%"")
sed := echo.getenv(fz_smarteiffel,Void)
if sed /= Void then
msg.append(sed)
end
msg.append("%".%N")
if file_path /= Void then
msg.append(
"Please, also note that you can use the %"ace_check%" command%N%
%to view all informations stored into your ACE file.%N")
end
end
end
cluster_add_last(path, cluster_name: STRING; is_config_cluster: BOOLEAN) is
require
path /= Void
local
cluster: CLUSTER
do
cluster := new_cluster(path, is_config_cluster)
if cluster_name /= Void then
cluster.set_name(string_aliaser.item(cluster_name))
end
end
cluster_count: INTEGER is
do
Result := cluster_list.count
end
feature {ACE_VISITOR}
cluster_at(i: INTEGER): CLUSTER is
do
Result := cluster_list.item(i)
end
get_started is
-- Should be called to set some default values at the end of
-- command line parsing or at the end of the ACE file parsing.
local
i: INTEGER
do
set_default_level
system_tools.get_started
if default_debug_key = Void then
default_debug_key := fz_no
end
from
i := cluster_list.upper
until
i < cluster_list.lower
loop
cluster_list.item(i).get_started
i := i - 1
end
end
feature {CLUSTER}
highest_level: INTEGER
-- Used to compute the C mode to use. It is the "most-debug'wards"
-- assertion level.
default_trace: BOOLEAN
-- Code generated with the -sedb flag way is the default for all
-- classes of the ACE file (see also `sedb').
default_assertion_level: INTEGER
-- The default assertion level mangled using constants and tools
-- from class ASSERTION_LEVEL_NUMBERING.
-- This value memorize the command line flag such as (-boost,
-- -no_check, -require_check, ...). When the ACE file is used,
-- this value memorize the information after "assertion" tag
-- of the default section.
default_debug(e_debug: E_DEBUG): BOOLEAN is
require
e_debug /= Void
do
check default_debug_key /= Void end
if default_debug_key = fz_yes then
Result := True
elseif default_debug_key = fz_no then
else
Result := e_debug.match_debug_key(default_debug_key)
end
end
rename_se_clash(full_name: STRING): STRING is
-- To handle old "rename.se" files.
require
file_path = Void
local
i: INTEGER
do
from
i := cluster_list.lower
until
Result /= Void or else i > cluster_list.upper
loop
Result := cluster_list.item(i).rename_se_clash(full_name)
i := i + 1
end
end
feature {PRETTY}
start_pretty_mode is
-- Because the command `pretty' must have only the current
-- working directory in the loading path.
do
check
file_path = Void
root_class_name = Void
end
set_debug_check
check
cluster_list.is_empty
end
cluster_add_last("", Void, False)
end
feature {ACE_VISITOR}
set_root_class_name(rcn: STRING) is
do
root_class_names.add_last(rcn)
ensure
root_class_name = rcn
end
feature {C_PRETTY_PRINTER, COMPILE_TO_C, STRING_COMMAND_LINE}
no_split: BOOLEAN
-- True when the "-no_split" flag or equivalent is in use.
set_no_split(flag: BOOLEAN) is
do
no_split := flag
end
set_no_main is
do
no_main := True
ensure
no_main
end
wedit: BOOLEAN
-- When the code is generated for lcc/wedit (the -wedit flag).
set_wedit(value: BOOLEAN) is
do
wedit := value
end
feature {ACE_VISITOR}
accept(visitor: ACE_VISITOR) is
do
visitor.visit_ace(Current)
end
feature {NONE}
default_debug_key: STRING
-- To memorize some value after the "debug" keyword in the
-- default section of the ACE file (see also `a_debug_key').
a_name: STRING is
-- Analyse what's called a Name (i.e. an Eiffel identifier or some
-- manifest string). When the notation is like the one for manifest
-- strings, only the content of the manifest string is returned.
-- System environment variable are considered only inside
-- manifest_strings.
do
Result := string_aliaser.item(a_cluster_path)
check
Result /= buffer
end
ensure
Result = string_aliaser.item(Result)
end
a_cluster_path: STRING is
-- Do the work of `a_name', but avoid the `string_aliaser' filter.
local
stop: BOOLEAN; p: POSITION; envar, value, cl: STRING; c, l: INTEGER
do
Result := buffer
Result.clear
if skip1('%"') then
from -- Manifest string notation:
p := pos(start_line,start_column)
until
stop
loop
inspect
cc
when '%"' then
stop := True
when end_of_text then
error_handler.add_position(p)
error_handler.append("Closing %" not found.")
error_handler.print_as_fatal_error
when '$' then
from
l := line; c := column; cl := current_line
next_char
if cc = '{' then
next_char
!!envar.make(12)
else
Result.extend('$')
line := l; column := c; current_line := cl
end
until
envar = Void
loop
inspect
cc
when '}' then
value := echo.getenv(envar,file_path)
if value /= Void then
Result.append(value)
end
envar := Void
when end_of_text then
error_handler.add_position(p)
error_handler.append("Bad Environment variable.%N%
%(Closing %"}%" not found.)")
error_handler.print_as_fatal_error
else
envar.extend(cc)
next_char
end
end
else
Result.extend(cc)
end
next_char
end
else
from -- Eiffel identifier or keyword notation:
until
stop
loop
inspect
cc
when 'a'..'z', 'A'..'Z', '0'..'9', '_' then
Result.extend(cc)
next_char
else
stop := True
end
end
end
if Result.is_empty then
fcp("Non empty name expected here.")
end
skip_comments
ensure
Result = buffer
not Result.is_empty
end
a_cluster_mark is
do
-- At time beeing, this is just syntactic sugar because
-- clusters are not handled :-(
if skip1('(') then
if a_name /= Void then end
if skip1(')') then end
end
end
a_system_level_defaults: BOOLEAN is
-- The `Result' is used to delay the `echo.verbose' value setting
local
stop: BOOLEAN
do
from until stop
loop
if cc = end_of_text then
stop := True
elseif a_clusters then
stop := True
elseif a_keyword(fz_external) then
a_external
stop := True
elseif a_keyword(fz_generate) then
a_generate
stop := True
elseif skip1(';') then
elseif a_keyword(fz_assertion) then
default_assertion_level := a_assertion_level
elseif a_keyword(fz_debug) then
default_debug_key := a_debug_key
elseif a_keyword(once "collect") then
if not a_yes_no_all then
gc_handler.no_gc
end
elseif a_keyword(fz_case_insensitive) then
if a_yes_no_all then
eiffel_parser.set_case_insensitive
end
elseif a_keyword(fz_no_style_warning) then
if a_yes_no_all then
eiffel_parser.set_no_style_warning
end
elseif a_keyword(fz_no_warning) then
if a_yes_no_all then
error_handler.set_no_warning
end
elseif a_keyword(fz_trace) then
if a_yes_no_all then
set_default_trace
end
elseif a_keyword(fz_safety_check) then
if a_yes_no_all then
set_safety_check
end
elseif a_keyword(fz_verbose) then
Result := a_yes_no_all
elseif a_keyword(fz_manifest_string_trace) then
manifest_string_trace := a_yes_no_all
elseif a_keyword(fz_high_memory_compiler) then
high_memory_compiler := a_yes_no_all
else
stop := True
end
end
end
a_clusters: BOOLEAN is
--++ clusters --> "cluster" { cluster_clause ";" ...}
local
stop: BOOLEAN
do
if a_keyword(fz_cluster) then
Result := True
from until stop
loop
if a_cluster_clause then
if skip1(';') then end
if a_keyword(fz_end) then end
else
stop := True
end
end
end
end
a_cluster_clause: BOOLEAN is
--++ cluster_clause --> [cluster_tag]
--++ directory_name
--++ cluster_properties
local
cluster_name: STRING; cluster: CLUSTER
do
if cc = end_of_text then
elseif a_keyword(fz_external) then
a_external
elseif a_keyword(fz_generate) then
a_generate
elseif a_keyword(fz_end) then
elseif cc = '%"' then
Result := True
cluster := new_cluster(a_cluster_path, False)
a_cluster_properties(cluster)
elseif cc.is_letter then
Result := True
cluster_name := a_name
if skip1(':') then
if cc = '%"' then
cluster := new_cluster(a_cluster_path, False)
cluster.set_name(cluster_name)
else
error_handler.add_position(current_position)
error_handler.append(
"Cluster path expected after cluster name.")
error_handler.print_as_fatal_error
end
else
cluster := new_cluster(cluster_name, False)
end
a_cluster_properties(cluster)
else
fatal_error_in(fz_cluster)
end
end
a_cluster_properties(cluster: CLUSTER) is
--++ cluster_properties -->
--++ [use]
--++ [include]
--++ [exclude]
--++ [name_adaptation]
--++ [default]
--++ [options]
--++ [visible]
require
cluster /= Void
local
stop, yna: BOOLEAN
do
if a_keyword(fz_use) then
fcp("The %"use%" clause is not yet implemented.")
end
if a_keyword(fz_include) then
from until cc /= '%"'
loop
cluster.include_add_last(a_name)
if skip1(';') then end
end
end
if a_keyword(fz_exclude) then
from until cc /= '%"'
loop
cluster.exclude_add_last(a_name)
if skip1(';') then end
end
end
if a_keyword(fz_adapt) then
fcp("The %"adapt%" clause is not yet implemented.")
end
if a_keyword(fz_default) then
from until stop
loop
if a_keyword(fz_assertion) then
cluster.set_default_assertion_level(a_assertion_level)
elseif a_keyword(fz_trace) then
yna := a_yes_no_all
sedb_flag := sedb_flag or else yna
cluster.set_default_trace(yna)
elseif a_keyword(fz_debug) then
cluster.add_default_debug_key(a_debug_key)
else
stop := True
end
if skip1(';') then end
end
end
if a_keyword(fz_option) then
from until not a_option_in_cluster_properties(cluster)
loop
end
end
end
a_option_in_cluster_properties(cluster: CLUSTER): BOOLEAN is
-- Possible option after the keyword "option" in one
-- `cluster' description.
require
cluster /= Void
local
level: INTEGER; class_name: CLASS_NAME; debug_key: STRING
do
if a_keyword(fz_assertion) then
Result := True
level := a_assertion_level
if not skip1(':') then
wcp(em29)
end
from
until
not a_class_name
loop
class_name := tmp_name.to_class_name
cluster.set_option_assertion_level(class_name,level)
if skip1(',') then end
end
elseif a_keyword(fz_trace) then
sedb_flag := True
Result := True
if not skip1(':') then
wcp(em29)
end
from
until
not a_class_name
loop
class_name := tmp_name.to_class_name
cluster.add_option_trace(class_name)
if skip1(',') then end
end
elseif a_keyword(fz_debug) then
Result := True
debug_key := a_debug_key
if not skip1(':') then
wcp(em29)
end
from
until
not a_class_name
loop
class_name := tmp_name.to_class_name
cluster.add_option_debug_key(class_name,debug_key)
if skip1(',') then end
end
end
end
a_class_name: BOOLEAN is
-- A single class name strictly written using only uppercase letter
-- in order to avoid any possible ambiguities. When the `Result' is
-- True, the corresponding class name is stored as usual in the
-- `tmp_name' buffer.
do
if cc.is_upper then
from
tmp_name.reset(pos(line,column))
tmp_name.extend(cc)
until
Result
loop
next_char
inspect
cc
when 'A'..'Z','0'..'9','_' then
tmp_name.extend(cc)
else
Result := True
end
end
skip_comments
end
end
a_external is
local
stop: BOOLEAN
do
from until stop
loop
if cc = end_of_text then
stop := True
elseif a_keyword(fz_generate) then
a_generate
stop := True
elseif skip1(';') then
elseif a_keyword(once "external_c_files") then
if skip1(':') then end
system_tools.external_c_files.copy(a_name)
elseif a_keyword(once "external_header_path") then
if skip1(':') then end
system_tools.set_external_header_path(a_name)
elseif a_keyword(once "external_c_plus_plus_files") then
if skip1(':') then end
system_tools.external_c_plus_plus_files.copy(a_name)
elseif a_keyword(once "external_object_files") then
if skip1(':') then end
system_tools.external_object_files.copy(a_name)
elseif a_keyword(fz_cecil) then
cecil_pool.add_file(a_debug_key)
elseif a_keyword(once "external_lib_path") then
if skip1(':') then end
system_tools.set_ace_external_lib_path(a_name)
elseif a_keyword(once "external_lib") then
if skip1(':') then end
system_tools.set_ace_external_lib(a_name)
else
stop := True
end
end
end
a_generate is
local
stop, value: BOOLEAN
do
from until stop
loop
if cc = end_of_text then
stop := True
elseif skip1(';') then
elseif a_keyword(fz_cc) then
if skip1(':') then end
system_tools.set_c_compiler(a_name)
elseif a_keyword(fz_gc_info) then
if a_yes_no_all then
gc_handler.set_info_flag
end
elseif a_keyword(fz_no_strip) then
if a_yes_no_all then
system_tools.set_no_strip
end
elseif a_keyword(fz_no_main) then
if a_yes_no_all then
set_no_main
end
elseif a_keyword(fz_no_split) then
set_no_split(a_yes_no_all)
elseif a_keyword(fz_clean) then
value := a_yes_no_all
-- Priority to the command line -clean flag:
if not clean then
set_clean(value)
end
elseif a_keyword(fz_wedit) then
set_wedit(a_yes_no_all)
elseif a_keyword(once "c_compiler_options") then
if skip1(':') then end
system_tools.set_ace_compiler_options(a_name)
elseif a_keyword(once "linker_options") then
if skip1(':') then end
system_tools.set_ace_linker_options(a_name)
elseif a_keyword(once "c_mode") then
if skip1(':') then end
system_tools.set_alternate_c_mode(a_name)
elseif a_keyword(fz_compact) then
cpp.set_compact(a_yes_no_all)
else
stop := True
end
end
end
a_yes_no_all: BOOLEAN is
-- Return True for a notation like "(yes)" or for a notation
-- like "(all)". Return False for a notation like "(no").
do
if not skip1('(') then
wcp(em27)
end
if a_keyword(fz_no) then
elseif (a_keyword(fz_all)
or else
a_keyword(fz_yes))
then
Result := True
else
fcp("At this point in the ACE file, you are supposed to %
%say %"yes%", %"no%", or %"all%".")
end
if not skip1(')') then
wcp(em28)
end
end
a_assertion_level: INTEGER is
do
if not skip1('(') then
wcp(em27)
end
if a_keyword(fz_boost) then
Result := level_boost
elseif a_keyword(fz_no) then
Result := level_no
elseif a_keyword(fz_require) then
Result := level_require
elseif a_keyword(fz_ensure) then
Result := level_ensure
elseif a_keyword(fz_invariant) then
Result := level_invariant
elseif a_keyword(fz_loop) then
Result := level_loop
elseif a_keyword(fz_check)
or else a_keyword(fz_all)
or else a_keyword(fz_yes)
then
Result := level_all
elseif a_keyword(fz_debug) then
Result := level_debug
else
error_handler.add_position(current_position)
error_handler.append("Unknown assertion level tag.")
error_handler.print_as_error
error_handler.append(
"You have to fix the problem in your ACE file. Valid %
%assertion level tags are: %"no%", %"require%", %"ensure%",%
% %"invariant%", %"loop%", %"check%", %"all%", and %"debug%".")
error_handler.print_as_fatal_error
end
if not skip1(')') then
wcp(em28)
end
set_highest_level(Result)
ensure
Result.in_range(level_boost,level_debug)
end
a_debug_key: STRING is
-- Return some acceptable notation for a debug key: "yes",
-- "no" or some user defined key.
do
if not skip1('(') then
wcp(em27)
end
if a_keyword(fz_no) then
Result := fz_no
elseif a_keyword(fz_yes) or else a_keyword(fz_all) then
set_highest_level(level_debug)
Result := fz_yes
else
set_highest_level(level_debug)
Result := a_name
end
if not skip1(')') then
wcp(em28)
end
end
pos(l, c: INTEGER): POSITION is
do
Result.ace_file(l,c)
end
buffer: STRING is
once
!!Result.make(256)
end
cluster_list: FIXED_ARRAY[CLUSTER] is
once
!!Result.with_capacity(64)
end
root_procedure_name_memory: STRING
class_name_buffer: STRING is
-- Temporary buffer to store some class name like eg. "ARRAY".
once
!!Result.make(64)
end
compute_class_name_buffer_using(name: STRING) is
-- Compute some Eiffel class name in the `class_name_buffer' using
-- the `name' information which can be some complete file path
-- notation with some Eiffel file suffix. The result, stored in the
-- `class_name_buffer' is written using the standard Eiffel
-- notation for class names (upper case letters only).
require
not name.is_empty
local
i: INTEGER; c: CHARACTER
do
class_name_buffer.copy(name)
-- Removes the ".e" or the ".E" suffix if any:
i := class_name_buffer.count
if i > 2 then
if class_name_buffer.item(i - 1) = '.' then
if class_name_buffer.item(i).same_as('e') then
class_name_buffer.remove_last(2)
end
end
end
from
i := class_name_buffer.count
until
i = 0
loop
c := class_name_buffer.item(i)
if c.is_letter then
i := i - 1
elseif c = '_' then
i := i - 1
elseif c.is_digit then
i := i - 1
else
class_name_buffer.remove_first(i)
i := 0
end
end
class_name_buffer.to_upper
end
new_cluster(path: STRING; is_config_cluster: BOOLEAN): CLUSTER is
require
path /= Void
do
create Result.compute_directory_path_using(path, is_config_cluster)
cluster_list.add_last(Result)
end
fatal_error_in(section_name: STRING) is
do
error_handler.add_position(current_position)
error_handler.append("Error in the %"")
error_handler.append(section_name)
error_handler.append("%" section.")
error_handler.print_as_fatal_error
end
handle_rename_se_files is
-- To handle old "rename.se" files.
require
file_path = Void
local
i: INTEGER
do
if not handle_rename_se_files_flag then
handle_rename_se_files_flag := True
from
i := cluster_list.lower
until
i > cluster_list.upper
loop
cluster_list.item(i).rename_se_read
i := i + 1
end
end
end
set_highest_level(level: INTEGER) is
do
if level > highest_level then
highest_level := level
end
end
handle_rename_se_files_flag: BOOLEAN
-- To handle old "rename.se" files.
sedb_flag: BOOLEAN
singleton_memory: ACE is
once
Result := Current
end
invariant
is_real_singleton: Current = singleton_memory
end -- ACE
|