Commit 7dd0991a7ddfc4e37b25bb283aeb56be7c2e4654
1 parent
784da72f
Fixed several bugs in new visibility system. Made tests using the option -reads.…
… Hope it's now ok (AP). (-reads now produces a beautiful visibility table) Some 'replaced by' still to be changed into 'transmit' in the library.
Showing
8 changed files
with
49 additions
and
34 deletions
Show diff stats
anubis_dev/compiler/src/compil.h
| ... | ... | @@ -85,6 +85,8 @@ extern int show_to_do; |
| 85 | 85 | extern void finish_show_reads(void); |
| 86 | 86 | extern int is_visible(char *filename); // visibility from current file |
| 87 | 87 | extern void add_to_visible(U32 a, U32 b); |
| 88 | +extern void saturate_visi_table(void); | |
| 89 | +extern void show_visi_table(void); | |
| 88 | 90 | extern void add_transmit(U32 a, U32 b); // make all files visible from 'b' also visible from 'a' |
| 89 | 91 | extern int current_par_line; |
| 90 | 92 | extern void show_missing_reads(void); |
| ... | ... | @@ -1907,6 +1909,7 @@ extern const char *msgtext_unused_argument[]; |
| 1907 | 1909 | extern const char *msgtext_inline_macro[]; |
| 1908 | 1910 | extern const char *msgtext_unused_named_resurgent[]; |
| 1909 | 1911 | extern const char *msgtext_duplicate_type_name[]; |
| 1912 | +extern const char *msgtext_replaced_by[]; | |
| 1910 | 1913 | |
| 1911 | 1914 | |
| 1912 | 1915 | ... | ... |
anubis_dev/compiler/src/lexer.l
| ... | ... | @@ -518,28 +518,30 @@ void show_visible_files(U32 from, char *filename) |
| 518 | 518 | fprintf(show_reads_file," ---------------------\n"); |
| 519 | 519 | } |
| 520 | 520 | |
| 521 | -void register_read(char *filename,int file_id) | |
| 521 | +void register_read(char *filename, // name of file we begin to read read | |
| 522 | + int file_id, // id of file we begin to read | |
| 523 | + int already_read) // 1 if file already read, 0 otherwise | |
| 522 | 524 | { |
| 523 | 525 | assert(show_reads_file != NULL); |
| 524 | 526 | |
| 525 | - if (is_already_included(filename)) | |
| 527 | + if (already_read) | |
| 526 | 528 | { |
| 527 | 529 | print_push(); |
| 528 | - fprintf(show_reads_file,"%s (already read)\n",filename); | |
| 530 | + fprintf(show_reads_file,"[%d] %s (already read)\n",file_id,filename); | |
| 529 | 531 | } |
| 530 | 532 | else |
| 531 | 533 | { |
| 532 | 534 | print_push(); |
| 533 | - fprintf(show_reads_file,"%s\n",filename); | |
| 535 | + fprintf(show_reads_file,"[%d] %s\n",file_id,filename); | |
| 534 | 536 | } |
| 535 | 537 | show_visible_files((U16)file_id,filename); |
| 536 | 538 | } |
| 537 | 539 | |
| 538 | -void show_come_back(char *filename) | |
| 540 | +void show_come_back(char *filename, int file_id) | |
| 539 | 541 | { |
| 540 | 542 | assert(show_reads_file != NULL); |
| 541 | 543 | print_pop(); |
| 542 | - fprintf(show_reads_file,"%s\n",filename); | |
| 544 | + fprintf(show_reads_file,"[%d] %s\n",file_id,filename); | |
| 543 | 545 | show_visible_files((U16)get_file_id(filename),filename); |
| 544 | 546 | } |
| 545 | 547 | |
| ... | ... | @@ -552,6 +554,7 @@ void finish_show_reads(void) |
| 552 | 554 | fprintf(show_reads_file,"[%d] %s\n", |
| 553 | 555 | i,already_included[i]); |
| 554 | 556 | fprintf(show_reads_file,"\n"); |
| 557 | + show_visi_table(); | |
| 555 | 558 | fclose(show_reads_file); |
| 556 | 559 | } |
| 557 | 560 | |
| ... | ... | @@ -572,17 +575,8 @@ void come_back(void) |
| 572 | 575 | include_dir[include_stack_ptr]); |
| 573 | 576 | current_file_abs_path = abs_file_paths_stack[include_stack_ptr]; |
| 574 | 577 | current_file_id = get_file_id(current_file_abs_path); |
| 575 | -#if 0 | |
| 576 | - /* if we are leaving a relay file everything visible from it | |
| 577 | - should be visible from the previous one. */ | |
| 578 | - if (is_relay_file[previous_file_id]) | |
| 579 | - { | |
| 580 | - handle_replaced_by_visibility(get_file_id(previous_current_file_abs_path), | |
| 581 | - get_file_id(current_file_abs_path)); | |
| 582 | - } | |
| 583 | -#endif | |
| 584 | - //add_to_visible((U32)previous_file_id,(U32)current_file_id); | |
| 585 | - if (show_reads) show_come_back(current_file_abs_path); | |
| 578 | + saturate_visi_table(); | |
| 579 | + if (show_reads) show_come_back(current_file_abs_path,current_file_id); | |
| 586 | 580 | lineno = include_lines[include_stack_ptr]; |
| 587 | 581 | colno = 1; |
| 588 | 582 | if (verbose) printf(msgtext_returning_to_file[0],current_file_abs_path); |
| ... | ... | @@ -1078,7 +1072,8 @@ W [\ \t\r\n] |
| 1078 | 1072 | return yy__p_operation_inline; } |
| 1079 | 1073 | ^[Rr]ead{W}+ { transmit_just_read = 0; if (!gindex /* && !errors */) { BEGIN INCL; } } |
| 1080 | 1074 | ^[Tt]ransmit{W}+ { transmit_just_read = 1; if (!gindex /* && !errors */) { BEGIN INCL; } } |
| 1081 | -^[Dd]escribe{W}+ { BEGIN PAR; par_seen = 1; current_par_line = lineno; par_start_time = system_time(); | |
| 1075 | +^[Rr]eplaced{W}+by{W}+ { err_line_col(linecol(),"E122",msgtext_replaced_by[0]); } | |
| 1076 | +^[Dd]escribe{W}+ { BEGIN PAR; par_seen = 1; current_par_line = lineno; par_start_time = system_time(); | |
| 1082 | 1077 | yylval.expr = linecol(); return yy__p_describe; } |
| 1083 | 1078 | ^C[\ \t]+constructors[\ \t]+for { BEGIN PAR; par_seen = 1; current_par_line = lineno; |
| 1084 | 1079 | yylval.expr = linecol(); return yy__C_constr_for; } |
| ... | ... | @@ -1097,8 +1092,8 @@ W [\ \t\r\n] |
| 1097 | 1092 | |
| 1098 | 1093 | check_for_circularities(path); |
| 1099 | 1094 | if (verbose) printf("%s is already included.\n",path); |
| 1100 | - if (show_reads) register_read(fname,path_file_id); | |
| 1101 | - if (show_reads) show_come_back(current_file_abs_path); | |
| 1095 | + if (show_reads) register_read(fname,path_file_id,1); | |
| 1096 | + if (show_reads) show_come_back(current_file_abs_path,path_file_id); | |
| 1102 | 1097 | BEGIN INITIAL; |
| 1103 | 1098 | } |
| 1104 | 1099 | else |
| ... | ... | @@ -1130,7 +1125,7 @@ W [\ \t\r\n] |
| 1130 | 1125 | assert(is_absolute_path(fopensrc_cur_dir)); |
| 1131 | 1126 | if (verbose) printf("Push current directory: %s\n",fopensrc_cur_dir); |
| 1132 | 1127 | if (!reading_predef) assert(next_already_included >= 2); |
| 1133 | - if (show_reads) register_read(current_file_abs_path,next_already_included); | |
| 1128 | + if (show_reads) register_read(current_file_abs_path,next_already_included-1,0); | |
| 1134 | 1129 | current_file_id = get_file_id(current_file_abs_path); |
| 1135 | 1130 | if (verbose) printf(msgtext_compiling_file[0],current_file_abs_path); |
| 1136 | 1131 | if ((new_yy_buffer = yy_create_buffer(yyin,YY_BUF_SIZE)) == NULL) | ... | ... |
anubis_dev/compiler/src/main.cpp
| ... | ... | @@ -852,7 +852,10 @@ int main(int argc, const char **argv) |
| 852 | 852 | if (show_reads_file == NULL) |
| 853 | 853 | { |
| 854 | 854 | show_reads_file = fopenz("reads.txt","wt"); |
| 855 | - fprintf(show_reads_file,msgtext_show_reads_file_header[0],current_file_abs_path); | |
| 855 | + fprintf(show_reads_file,msgtext_show_reads_file_header[0], | |
| 856 | + current_file_abs_path, | |
| 857 | + current_file_id, | |
| 858 | + current_file_abs_path); | |
| 856 | 859 | } |
| 857 | 860 | //initialize_visibility(); |
| 858 | 861 | yyin = fopensrc(main_file_original_path); | ... | ... |
anubis_dev/compiler/src/msgtexts.c
| ... | ... | @@ -249,7 +249,7 @@ const char *msgtext_syntax[] = |
| 249 | 249 | " -profile add profiling code to ADMs. This will allow anbexec to output \n" |
| 250 | 250 | " statistics on execution times\n" |
| 251 | 251 | " -publics make a public declarations file ('_publics.anubis')\n" |
| 252 | - " -reads produces the file 'reads.txt' showing all usages of the initial keyword 'read'\n" | |
| 252 | + " -reads produces the file 'reads.txt' showing all usages of 'read' and 'transmit'\n" | |
| 253 | 253 | " -sc produces 'symbolic code files' (human readable .sc versions of .adm files)\n" |
| 254 | 254 | " -seo print the error messages on standard error output\n" |
| 255 | 255 | " -shell makes a 'shell' file (in 'my_anubis/shells')\n" |
| ... | ... | @@ -676,13 +676,16 @@ const char *msgtext_configure_welcome[] = |
| 676 | 676 | { "Welcome on this Anubis compiler configuration utility.\n\n" }; |
| 677 | 677 | |
| 678 | 678 | const char *msgtext_show_reads_file_header[] = |
| 679 | -{ "Trace of uses of the keyword 'read'.\n\n" | |
| 679 | +{ " Uses of the keywords 'read' and 'transmit'.\n" | |
| 680 | + " (this file was generated by the Anubis compiler)\n" | |
| 681 | + " (compiling '%s' with the option '-reads')\n\n" | |
| 680 | 682 | " > entering a file\n" |
| 681 | 683 | " < coming back to a file\n\n" |
| 682 | - "> %s\n" }; | |
| 684 | + " List of compiled files and visibility table at the end of this file.\n\n" | |
| 685 | + "> [%d] %s\n" }; | |
| 683 | 686 | |
| 684 | 687 | const char *msgtext_show_reads_file_text[] = |
| 685 | -{ "\nList of compiled files:\n\n" }; | |
| 688 | +{ "\n --- List of compiled files ----------\n\n" }; | |
| 686 | 689 | |
| 687 | 690 | const char *msgtext_local_symbol[] = |
| 688 | 691 | { "local symbol" }; |
| ... | ... | @@ -1027,7 +1030,11 @@ const char *msgtext_duplicate_type_name[] = |
| 1027 | 1030 | " You should chose another name for this type.)\n\n" |
| 1028 | 1031 | }; |
| 1029 | 1032 | |
| 1030 | - | |
| 1033 | +const char *msgtext_replaced_by[] = | |
| 1034 | + { | |
| 1035 | + " The initial key locution 'replaced by' is obsolete. Use\n" | |
| 1036 | + " 'transmit' instead.\n\n" | |
| 1037 | + }; | |
| 1031 | 1038 | |
| 1032 | 1039 | |
| 1033 | 1040 | ... | ... |
anubis_dev/compiler/src/opdef.c
| ... | ... | @@ -148,14 +148,16 @@ void new_op_scheme(Expr lc, /* <lc> */ |
| 148 | 148 | abs_file_path = new_string(current_file_abs_path); |
| 149 | 149 | current_name = string_content(car(names)); |
| 150 | 150 | |
| 151 | + //debug(abs_file_path); | |
| 152 | + | |
| 151 | 153 | /* if checking only types */ |
| 152 | 154 | if (types_only) return; |
| 153 | 155 | |
| 154 | - if (verbose && par_seen) | |
| 156 | + if (verbose && par_seen && strcmp(current_file_abs_path,"/predefined.anubis")) | |
| 155 | 157 | printf(msgtext_checking_operation[0], |
| 156 | - string_content(car(names)), | |
| 158 | + string_content(car(names)), | |
| 157 | 159 | file_in(lc), |
| 158 | - line_in(lc)); | |
| 160 | + line_in(lc)); | |
| 159 | 161 | |
| 160 | 162 | /* collect_type_variables into parms (without repetition) */ |
| 161 | 163 | parms = nil; | ... | ... |
anubis_dev/compiler/src/typedef.c
| ... | ... | @@ -15,6 +15,7 @@ |
| 15 | 15 | #include <assert.h> |
| 16 | 16 | #include <stdio.h> |
| 17 | 17 | #include <stdlib.h> |
| 18 | +#include <string.h> | |
| 18 | 19 | #include "compil.h" |
| 19 | 20 | |
| 20 | 21 | |
| ... | ... | @@ -205,7 +206,7 @@ void new_type_scheme(Expr lc, /* <lc> */ |
| 205 | 206 | abs_file_path = new_string(current_file_abs_path); |
| 206 | 207 | current_name = string_content(name); |
| 207 | 208 | |
| 208 | - if ((verbose && par_seen)) | |
| 209 | + if (verbose && par_seen && strcmp(current_file_abs_path,"/predefined.anubis")) | |
| 209 | 210 | printf(msgtext_checking_type[0], |
| 210 | 211 | string_content(name), |
| 211 | 212 | file_in(lc), |
| ... | ... | @@ -219,7 +220,7 @@ void new_type_scheme(Expr lc, /* <lc> */ |
| 219 | 220 | //&& is_visible(string_content(types[tid].abs_file_path)) |
| 220 | 221 | ) |
| 221 | 222 | { |
| 222 | - if (verbose && par_seen) | |
| 223 | + if (verbose && par_seen && strcmp(current_file_abs_path,"/predefined.anubis")) | |
| 223 | 224 | { |
| 224 | 225 | printf(msgtext_type_already_seen[0], |
| 225 | 226 | string_content(name)); | ... | ... |
anubis_dev/library/tools/findstring.anubis
anubis_dev/library/tools/latex.anubis