From 7dd0991a7ddfc4e37b25bb283aeb56be7c2e4654 Mon Sep 17 00:00:00 2001 From: Alain Prouté Date: Wed, 30 Jul 2014 08:18:34 +0000 Subject: [PATCH] Fixed several bugs in new visibility system. Made tests using the option -reads. Hope it's now ok (AP). --- anubis_dev/compiler/src/compil.h | 3 +++ anubis_dev/compiler/src/lexer.l | 37 ++++++++++++++++--------------------- anubis_dev/compiler/src/main.cpp | 5 ++++- anubis_dev/compiler/src/msgtexts.c | 17 ++++++++++++----- anubis_dev/compiler/src/opdef.c | 8 +++++--- anubis_dev/compiler/src/typedef.c | 5 +++-- anubis_dev/library/tools/findstring.anubis | 4 +++- anubis_dev/library/tools/latex.anubis | 4 +++- 8 files changed, 49 insertions(+), 34 deletions(-) diff --git a/anubis_dev/compiler/src/compil.h b/anubis_dev/compiler/src/compil.h index 5bb79ae..78cdfab 100644 --- a/anubis_dev/compiler/src/compil.h +++ b/anubis_dev/compiler/src/compil.h @@ -85,6 +85,8 @@ extern int show_to_do; extern void finish_show_reads(void); extern int is_visible(char *filename); // visibility from current file extern void add_to_visible(U32 a, U32 b); +extern void saturate_visi_table(void); +extern void show_visi_table(void); extern void add_transmit(U32 a, U32 b); // make all files visible from 'b' also visible from 'a' extern int current_par_line; extern void show_missing_reads(void); @@ -1907,6 +1909,7 @@ extern const char *msgtext_unused_argument[]; extern const char *msgtext_inline_macro[]; extern const char *msgtext_unused_named_resurgent[]; extern const char *msgtext_duplicate_type_name[]; +extern const char *msgtext_replaced_by[]; diff --git a/anubis_dev/compiler/src/lexer.l b/anubis_dev/compiler/src/lexer.l index acf0104..034e1eb 100644 --- a/anubis_dev/compiler/src/lexer.l +++ b/anubis_dev/compiler/src/lexer.l @@ -518,28 +518,30 @@ void show_visible_files(U32 from, char *filename) fprintf(show_reads_file," ---------------------\n"); } -void register_read(char *filename,int file_id) +void register_read(char *filename, // name of file we begin to read read + int file_id, // id of file we begin to read + int already_read) // 1 if file already read, 0 otherwise { assert(show_reads_file != NULL); - if (is_already_included(filename)) + if (already_read) { print_push(); - fprintf(show_reads_file,"%s (already read)\n",filename); + fprintf(show_reads_file,"[%d] %s (already read)\n",file_id,filename); } else { print_push(); - fprintf(show_reads_file,"%s\n",filename); + fprintf(show_reads_file,"[%d] %s\n",file_id,filename); } show_visible_files((U16)file_id,filename); } -void show_come_back(char *filename) +void show_come_back(char *filename, int file_id) { assert(show_reads_file != NULL); print_pop(); - fprintf(show_reads_file,"%s\n",filename); + fprintf(show_reads_file,"[%d] %s\n",file_id,filename); show_visible_files((U16)get_file_id(filename),filename); } @@ -552,6 +554,7 @@ void finish_show_reads(void) fprintf(show_reads_file,"[%d] %s\n", i,already_included[i]); fprintf(show_reads_file,"\n"); + show_visi_table(); fclose(show_reads_file); } @@ -572,17 +575,8 @@ void come_back(void) include_dir[include_stack_ptr]); current_file_abs_path = abs_file_paths_stack[include_stack_ptr]; current_file_id = get_file_id(current_file_abs_path); -#if 0 - /* if we are leaving a relay file everything visible from it - should be visible from the previous one. */ - if (is_relay_file[previous_file_id]) - { - handle_replaced_by_visibility(get_file_id(previous_current_file_abs_path), - get_file_id(current_file_abs_path)); - } -#endif - //add_to_visible((U32)previous_file_id,(U32)current_file_id); - if (show_reads) show_come_back(current_file_abs_path); + saturate_visi_table(); + if (show_reads) show_come_back(current_file_abs_path,current_file_id); lineno = include_lines[include_stack_ptr]; colno = 1; if (verbose) printf(msgtext_returning_to_file[0],current_file_abs_path); @@ -1078,7 +1072,8 @@ W [\ \t\r\n] return yy__p_operation_inline; } ^[Rr]ead{W}+ { transmit_just_read = 0; if (!gindex /* && !errors */) { BEGIN INCL; } } ^[Tt]ransmit{W}+ { transmit_just_read = 1; if (!gindex /* && !errors */) { BEGIN INCL; } } -^[Dd]escribe{W}+ { BEGIN PAR; par_seen = 1; current_par_line = lineno; par_start_time = system_time(); +^[Rr]eplaced{W}+by{W}+ { err_line_col(linecol(),"E122",msgtext_replaced_by[0]); } +^[Dd]escribe{W}+ { BEGIN PAR; par_seen = 1; current_par_line = lineno; par_start_time = system_time(); yylval.expr = linecol(); return yy__p_describe; } ^C[\ \t]+constructors[\ \t]+for { BEGIN PAR; par_seen = 1; current_par_line = lineno; yylval.expr = linecol(); return yy__C_constr_for; } @@ -1097,8 +1092,8 @@ W [\ \t\r\n] check_for_circularities(path); if (verbose) printf("%s is already included.\n",path); - if (show_reads) register_read(fname,path_file_id); - if (show_reads) show_come_back(current_file_abs_path); + if (show_reads) register_read(fname,path_file_id,1); + if (show_reads) show_come_back(current_file_abs_path,path_file_id); BEGIN INITIAL; } else @@ -1130,7 +1125,7 @@ W [\ \t\r\n] assert(is_absolute_path(fopensrc_cur_dir)); if (verbose) printf("Push current directory: %s\n",fopensrc_cur_dir); if (!reading_predef) assert(next_already_included >= 2); - if (show_reads) register_read(current_file_abs_path,next_already_included); + if (show_reads) register_read(current_file_abs_path,next_already_included-1,0); current_file_id = get_file_id(current_file_abs_path); if (verbose) printf(msgtext_compiling_file[0],current_file_abs_path); if ((new_yy_buffer = yy_create_buffer(yyin,YY_BUF_SIZE)) == NULL) diff --git a/anubis_dev/compiler/src/main.cpp b/anubis_dev/compiler/src/main.cpp index 921105e..446d45b 100644 --- a/anubis_dev/compiler/src/main.cpp +++ b/anubis_dev/compiler/src/main.cpp @@ -852,7 +852,10 @@ int main(int argc, const char **argv) if (show_reads_file == NULL) { show_reads_file = fopenz("reads.txt","wt"); - fprintf(show_reads_file,msgtext_show_reads_file_header[0],current_file_abs_path); + fprintf(show_reads_file,msgtext_show_reads_file_header[0], + current_file_abs_path, + current_file_id, + current_file_abs_path); } //initialize_visibility(); yyin = fopensrc(main_file_original_path); diff --git a/anubis_dev/compiler/src/msgtexts.c b/anubis_dev/compiler/src/msgtexts.c index f20ae3f..57ed11c 100644 --- a/anubis_dev/compiler/src/msgtexts.c +++ b/anubis_dev/compiler/src/msgtexts.c @@ -249,7 +249,7 @@ const char *msgtext_syntax[] = " -profile add profiling code to ADMs. This will allow anbexec to output \n" " statistics on execution times\n" " -publics make a public declarations file ('_publics.anubis')\n" - " -reads produces the file 'reads.txt' showing all usages of the initial keyword 'read'\n" + " -reads produces the file 'reads.txt' showing all usages of 'read' and 'transmit'\n" " -sc produces 'symbolic code files' (human readable .sc versions of .adm files)\n" " -seo print the error messages on standard error output\n" " -shell makes a 'shell' file (in 'my_anubis/shells')\n" @@ -676,13 +676,16 @@ const char *msgtext_configure_welcome[] = { "Welcome on this Anubis compiler configuration utility.\n\n" }; const char *msgtext_show_reads_file_header[] = -{ "Trace of uses of the keyword 'read'.\n\n" +{ " Uses of the keywords 'read' and 'transmit'.\n" + " (this file was generated by the Anubis compiler)\n" + " (compiling '%s' with the option '-reads')\n\n" " > entering a file\n" " < coming back to a file\n\n" - "> %s\n" }; + " List of compiled files and visibility table at the end of this file.\n\n" + "> [%d] %s\n" }; const char *msgtext_show_reads_file_text[] = -{ "\nList of compiled files:\n\n" }; +{ "\n --- List of compiled files ----------\n\n" }; const char *msgtext_local_symbol[] = { "local symbol" }; @@ -1027,7 +1030,11 @@ const char *msgtext_duplicate_type_name[] = " You should chose another name for this type.)\n\n" }; - +const char *msgtext_replaced_by[] = + { + " The initial key locution 'replaced by' is obsolete. Use\n" + " 'transmit' instead.\n\n" + }; diff --git a/anubis_dev/compiler/src/opdef.c b/anubis_dev/compiler/src/opdef.c index 3ae57c1..6dd63d6 100644 --- a/anubis_dev/compiler/src/opdef.c +++ b/anubis_dev/compiler/src/opdef.c @@ -148,14 +148,16 @@ void new_op_scheme(Expr lc, /* */ abs_file_path = new_string(current_file_abs_path); current_name = string_content(car(names)); + //debug(abs_file_path); + /* if checking only types */ if (types_only) return; - if (verbose && par_seen) + if (verbose && par_seen && strcmp(current_file_abs_path,"/predefined.anubis")) printf(msgtext_checking_operation[0], - string_content(car(names)), + string_content(car(names)), file_in(lc), - line_in(lc)); + line_in(lc)); /* collect_type_variables into parms (without repetition) */ parms = nil; diff --git a/anubis_dev/compiler/src/typedef.c b/anubis_dev/compiler/src/typedef.c index 6e8bf99..252bb1e 100644 --- a/anubis_dev/compiler/src/typedef.c +++ b/anubis_dev/compiler/src/typedef.c @@ -15,6 +15,7 @@ #include #include #include +#include #include "compil.h" @@ -205,7 +206,7 @@ void new_type_scheme(Expr lc, /* */ abs_file_path = new_string(current_file_abs_path); current_name = string_content(name); - if ((verbose && par_seen)) + if (verbose && par_seen && strcmp(current_file_abs_path,"/predefined.anubis")) printf(msgtext_checking_type[0], string_content(name), file_in(lc), @@ -219,7 +220,7 @@ void new_type_scheme(Expr lc, /* */ //&& is_visible(string_content(types[tid].abs_file_path)) ) { - if (verbose && par_seen) + if (verbose && par_seen && strcmp(current_file_abs_path,"/predefined.anubis")) { printf(msgtext_type_already_seen[0], string_content(name)); diff --git a/anubis_dev/library/tools/findstring.anubis b/anubis_dev/library/tools/findstring.anubis index 6d6afe7..0266de2 100644 --- a/anubis_dev/library/tools/findstring.anubis +++ b/anubis_dev/library/tools/findstring.anubis @@ -1 +1,3 @@ -replaced by system/string.anubis + +transmit system/string.anubis + diff --git a/anubis_dev/library/tools/latex.anubis b/anubis_dev/library/tools/latex.anubis index c816e57..ea0e638 100644 --- a/anubis_dev/library/tools/latex.anubis +++ b/anubis_dev/library/tools/latex.anubis @@ -1,3 +1,5 @@ -replaced by doc_tools/latex.anubis (since version 1.6) +transmit doc_tools/latex.anubis (since version 1.6) + + -- libgit2 0.21.4