X-Git-Url: https://jxself.org/git/?p=inform.git;a=blobdiff_plain;f=src%2Ftables.c;fp=src%2Ftables.c;h=389eb4bca1506a9d4aa99fe161d461717442ea30;hp=4158253d8e5af79a89fc1bf38db8e6d8d301a627;hb=8e63120c630c94c598d4e2d6ba823dac59bce8fa;hpb=d11f2f726ed7feea617476d99cf7505ddd9a27ce diff --git a/src/tables.c b/src/tables.c index 4158253..389eb4b 100644 --- a/src/tables.c +++ b/src/tables.c @@ -3,8 +3,8 @@ /* end of dynamic memory, gluing together all the required */ /* tables. */ /* */ -/* Part of Inform 6.35 */ -/* copyright (c) Graham Nelson 1993 - 2021 */ +/* Part of Inform 6.40 */ +/* copyright (c) Graham Nelson 1993 - 2022 */ /* */ /* Inform is free software: you can redistribute it and/or modify */ /* it under the terms of the GNU General Public License as published by */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with Inform. If not, see https://gnu.org/licenses/ * +/* along with Inform. If not, see https://gnu.org/licenses/ */ /* */ /* ------------------------------------------------------------------------- */ @@ -122,8 +122,20 @@ extern void write_serial_number(char *buffer) #endif } -static void percentage(char *name, int32 x, int32 total) -{ printf(" %-20s %2d.%d%%\n",name,x*100/total,(x*1000/total)%10); +static char percentage_buffer[32]; + +static char *show_percentage(int32 x, int32 total) +{ + if (memory_map_setting < 2) { + percentage_buffer[0] = '\0'; + } + else if (x == 0) { + sprintf(percentage_buffer, " ( --- )"); + } + else { + sprintf(percentage_buffer, " (%.1f %%)", (float)x * 100.0 / (float)total); + } + return percentage_buffer; } static char *version_name(int v) @@ -154,7 +166,7 @@ static int32 rough_size_of_paged_memory_z(void) ASSERT_ZCODE(); total = 64 /* header */ - + 2 + subtract_pointers(low_strings_top, low_strings) + + 2 + low_strings_top /* low strings pool */ + 6*32; /* abbreviations table */ @@ -188,7 +200,7 @@ static int32 rough_size_of_paged_memory_z(void) + 2*no_actions /* action routines */ + 2*no_grammar_token_routines; /* general parsing routines */ - total += (subtract_pointers(dictionary_top, dictionary)) /* dictionary */ + total += (dictionary_top) /* dictionary size */ + ((module_switch)?30:0); /* module map */ total += static_array_area_size; /* static arrays */ @@ -212,7 +224,8 @@ static int32 rough_size_of_paged_memory_g(void) /* No header for us! */ total = 1000; /* bit of a fudge factor */ - total += dynamic_array_area_size; /* arrays and global variables */ + total += no_globals * 4; /* global variables */ + total += dynamic_array_area_size; /* arrays */ total += no_objects * OBJECT_BYTE_LENGTH; /* object tables */ total += properties_table_size; /* property tables */ @@ -233,7 +246,7 @@ static int32 rough_size_of_paged_memory_g(void) total += 4 + no_actions * 4; /* actions functions table */ total += 4; - total += subtract_pointers(dictionary_top, dictionary); + total += dictionary_top; while (total % GPAGESIZE) total++; @@ -291,7 +304,7 @@ static void construct_storyfile_z(void) p[mark]=0x80; p[mark+1]=0; mark+=2; /* Start the low strings pool with a useful default string, " " */ - for (i=0; i+low_strings= 512) { k_long++; k_str=""; } - else if ((Out_Size-1024*k_long) > 0) { k_str=".5"; } - if (total_bytes_trans == 0) rate = 0; - else rate=total_bytes_trans*1000/total_chars_trans; - - { printf("In:\ -%3d source code files %6d syntactic lines\n\ -%6d textual lines %8ld characters ", - total_input_files, no_syntax_lines, - total_source_line_count, (long int) total_chars_read); - if (character_set_unicode) printf("(UTF-8)\n"); - else if (character_set_setting == 0) printf("(plain ASCII)\n"); - else - { printf("(ISO 8859-%d %s)\n", character_set_setting, - name_of_iso_set(character_set_setting)); - } - - printf("Allocated:\n\ -%6d symbols (maximum %4d) %8ld bytes of memory\n\ -Out: Version %d \"%s\" %s %d.%c%c%c%c%c%c (%ld%sK long):\n", - no_symbols, MAX_SYMBOLS, - (long int) malloced_bytes, - version_number, - version_name(version_number), - output_called, - release_number, p[18], p[19], p[20], p[21], p[22], p[23], - (long int) k_long, k_str); - - printf("\ -%6d classes (maximum %3d) %6d objects (maximum %3d)\n\ -%6d global vars (maximum 233) %6d variable/array space (maximum %d)\n", - no_classes, MAX_CLASSES, - no_objects, ((version_number==3)?255:(MAX_OBJECTS-1)), - no_globals, - dynamic_array_area_size, MAX_STATIC_DATA); - - printf( -"%6d verbs (maximum %3d) %6d dictionary entries (maximum %d)\n\ -%6d grammar lines (version %d) %6d grammar tokens (unlimited)\n\ -%6d actions (maximum %3d) %6d attributes (maximum %2d)\n\ -%6d common props (maximum %2d) %6d individual props (unlimited)\n", - no_Inform_verbs, MAX_VERBS, - dict_entries, MAX_DICT_ENTRIES, - no_grammar_lines, grammar_version_number, - no_grammar_tokens, - no_actions, MAX_ACTIONS, - no_attributes, ((version_number==3)?32:48), - no_properties-2, ((version_number==3)?30:62), - no_individual_properties - 64); - - if (track_unused_routines) - { - uint32 diff = df_total_size_before_stripping - df_total_size_after_stripping; - printf( -"%6ld bytes of Z-code %6ld unused bytes %s (%.1f%%)\n", - (long int) df_total_size_before_stripping, (long int) diff, - (OMIT_UNUSED_ROUTINES ? "stripped out" : "detected"), - 100 * (float)diff / (float)df_total_size_before_stripping); - } - - printf( -"%6ld characters used in text %6ld bytes compressed (rate %d.%3ld)\n\ -%6d abbreviations (maximum %d) %6d routines (unlimited)\n\ -%6ld instructions of Z-code %6d sequence points\n\ -%6ld bytes readable memory used (maximum 65536)\n\ -%6ld bytes used in Z-machine %6ld bytes free in Z-machine\n", - (long int) total_chars_trans, - (long int) total_bytes_trans, - (total_chars_trans>total_bytes_trans)?0:1, - (long int) rate, - no_abbreviations, MAX_ABBREVS, - no_routines, - (long int) no_instructions, no_sequence_points, - (long int) Write_Code_At, - (long int) Out_Size, - (long int) - (((long int) (limit*1024L)) - ((long int) Out_Size))); - - } - } - - if (offsets_switch) - { - { printf( -"\nOffsets in %s:\n\ -%05lx Synonyms %05lx Defaults %05lx Objects %05lx Properties\n\ -%05lx Variables %05lx Parse table %05lx Actions %05lx Preactions\n\ -%05lx Adjectives %05lx Dictionary %05lx Code %05lx Strings\n", - output_called, - (long int) abbrevs_at, - (long int) prop_defaults_at, - (long int) object_tree_at, - (long int) object_props_at, - (long int) globals_at, - (long int) grammar_table_at, - (long int) actions_at, - (long int) preactions_at, - (long int) adjectives_offset, - (long int) dictionary_at, - (long int) Write_Code_At, - (long int) Write_Strings_At); - if (module_switch) - printf("%05lx Linking data\n",(long int) link_table_at); - } - } - if (debugfile_switch) { begin_writing_debug_sections(); write_debug_section("abbreviations", 64); @@ -1100,130 +1003,125 @@ Out: Version %d \"%s\" %s %d.%c%c%c%c%c%c (%ld%sK long):\n", end_writing_debug_sections(Out_Size); } - if (memory_map_switch) + if (memory_map_setting) { + int32 addr; { printf("Dynamic +---------------------+ 00000\n"); -printf("memory | header |\n"); +printf("memory | header | %s\n", + show_percentage(0x40, Out_Size)); printf(" +---------------------+ 00040\n"); -printf(" | abbreviations |\n"); +printf(" | abbreviations | %s\n", + show_percentage(abbrevs_at-0x40, Out_Size)); printf(" + - - - - - - - - - - + %05lx\n", (long int) abbrevs_at); -printf(" | abbreviations table |\n"); +printf(" | abbreviations table | %s\n", + show_percentage(headerext_at-abbrevs_at, Out_Size)); printf(" +---------------------+ %05lx\n", (long int) headerext_at); -printf(" | header extension |\n"); +addr = (alphabet_modified ? charset_at : (zscii_defn_modified ? unicode_at : prop_defaults_at)); +printf(" | header extension | %s\n", + show_percentage(addr-headerext_at, Out_Size)); if (alphabet_modified) { printf(" + - - - - - - - - - - + %05lx\n", (long int) charset_at); -printf(" | alphabets table |\n"); +addr = (zscii_defn_modified ? unicode_at : prop_defaults_at); +printf(" | alphabets table | %s\n", + show_percentage(addr-charset_at, Out_Size)); } if (zscii_defn_modified) { printf(" + - - - - - - - - - - + %05lx\n", (long int) unicode_at); -printf(" | Unicode table |\n"); +printf(" | Unicode table | %s\n", + show_percentage(prop_defaults_at-unicode_at, Out_Size)); } printf(" +---------------------+ %05lx\n", (long int) prop_defaults_at); -printf(" | property defaults |\n"); +printf(" | property defaults | %s\n", + show_percentage(object_tree_at-prop_defaults_at, Out_Size)); printf(" + - - - - - - - - - - + %05lx\n", (long int) object_tree_at); -printf(" | objects |\n"); +printf(" | objects | %s\n", + show_percentage(object_props_at-object_tree_at, Out_Size)); printf(" + - - - - - - - - - - + %05lx\n", (long int) object_props_at); printf(" | object short names, |\n"); -printf(" | common prop values |\n"); +printf(" | common prop values | %s\n", + show_percentage(class_numbers_offset-object_props_at, Out_Size)); printf(" + - - - - - - - - - - + %05lx\n", (long int) class_numbers_offset); -printf(" | class numbers table |\n"); +printf(" | class numbers table | %s\n", + show_percentage(identifier_names_offset-class_numbers_offset, Out_Size)); printf(" + - - - - - - - - - - + %05lx\n", (long int) identifier_names_offset); -printf(" | symbol names table |\n"); +printf(" | symbol names table | %s\n", + show_percentage(individuals_offset-identifier_names_offset, Out_Size)); printf(" + - - - - - - - - - - + %05lx\n", (long int) individuals_offset); -printf(" | indiv prop values |\n"); +printf(" | indiv prop values | %s\n", + show_percentage(globals_at-individuals_offset, Out_Size)); printf(" +---------------------+ %05lx\n", (long int) globals_at); -printf(" | global variables |\n"); +printf(" | global variables | %s\n", + show_percentage(480, Out_Size)); printf(" + - - - - - - - - - - + %05lx\n", ((long int) globals_at)+480L); -printf(" | arrays |\n"); +printf(" | arrays | %s\n", + show_percentage(grammar_table_at-(globals_at+480), Out_Size)); printf(" +=====================+ %05lx\n", (long int) grammar_table_at); -printf("Readable| grammar table |\n"); +printf("Readable| grammar table | %s\n", + show_percentage(actions_at-grammar_table_at, Out_Size)); printf("memory + - - - - - - - - - - + %05lx\n", (long int) actions_at); -printf(" | actions |\n"); +printf(" | actions | %s\n", + show_percentage(preactions_at-actions_at, Out_Size)); printf(" + - - - - - - - - - - + %05lx\n", (long int) preactions_at); -printf(" | parsing routines |\n"); +printf(" | parsing routines | %s\n", + show_percentage(adjectives_offset-preactions_at, Out_Size)); printf(" + - - - - - - - - - - + %05lx\n", (long int) adjectives_offset); -printf(" | adjectives |\n"); +printf(" | adjectives | %s\n", + show_percentage(dictionary_at-adjectives_offset, Out_Size)); printf(" +---------------------+ %05lx\n", (long int) dictionary_at); -printf(" | dictionary |\n"); +addr = (module_switch ? map_of_module : (static_array_area_size ? static_arrays_at : Write_Code_At)); +printf(" | dictionary | %s\n", + show_percentage(addr-dictionary_at, Out_Size)); if (module_switch) { printf(" + - - - - - - - - - - + %05lx\n", (long int) map_of_module); -printf(" | map of module addrs |\n"); +addr = (static_array_area_size ? static_arrays_at : Write_Code_At); +printf(" | map of module addrs | %s\n", + show_percentage(addr-map_of_module, Out_Size)); } if (static_array_area_size) { printf(" +---------------------+ %05lx\n", (long int) static_arrays_at); -printf(" | static arrays |\n"); +printf(" | static arrays | %s\n", + show_percentage(Write_Code_At-static_arrays_at, Out_Size)); } printf(" +=====================+ %05lx\n", (long int) Write_Code_At); -printf("Above | Z-code |\n"); +printf("Above | Z-code | %s\n", + show_percentage(Write_Strings_At-Write_Code_At, Out_Size)); printf("readable+---------------------+ %05lx\n", (long int) Write_Strings_At); -printf("memory | strings |\n"); +addr = (module_switch ? link_table_at : Out_Size); +printf("memory | strings | %s\n", + show_percentage(addr-Write_Strings_At, Out_Size)); if (module_switch) { printf(" +=====================+ %05lx\n", (long int) link_table_at); -printf(" | module linking data |\n"); +printf(" | module linking data | %s\n", + show_percentage(Out_Size-link_table_at, Out_Size)); } printf(" +---------------------+ %05lx\n", (long int) Out_Size); } } - if (percentages_switch) - { printf("Approximate percentage breakdown of %s:\n", - output_called); - percentage("Z-code", code_length,Out_Size); - if (module_switch) - percentage("Linking data", link_data_size,Out_Size); - percentage("Static strings", strings_length,Out_Size); - percentage("Dictionary", Write_Code_At-dictionary_at,Out_Size); - percentage("Objects", globals_at-prop_defaults_at,Out_Size); - percentage("Globals", grammar_table_at-globals_at,Out_Size); - percentage("Parsing tables", dictionary_at-grammar_table_at,Out_Size); - percentage("Header and synonyms", prop_defaults_at,Out_Size); - percentage("Total of save area", grammar_table_at,Out_Size); - percentage("Total of text", total_bytes_trans,Out_Size); - } - if (frequencies_switch) - { - { printf("How frequently abbreviations were used, and roughly\n"); - printf("how many bytes they saved: ('_' denotes spaces)\n"); - for (i=0; i= 512) { k_long++; k_str=""; } - else if ((Out_Size-1024*k_long) > 0) { k_str=".5"; } - if (strings_length == 0) rate = 0; - else rate=strings_length*1000/total_chars_trans; - - { printf("In:\ -%3d source code files %6d syntactic lines\n\ -%6d textual lines %8ld characters ", - total_input_files, no_syntax_lines, - total_source_line_count, (long int) total_chars_read); - if (character_set_unicode) printf("(UTF-8)\n"); - else if (character_set_setting == 0) printf("(plain ASCII)\n"); - else - { printf("(ISO 8859-%d %s)\n", character_set_setting, - name_of_iso_set(character_set_setting)); - } - - {char serialnum[8]; - write_serial_number(serialnum); - printf("Allocated:\n\ -%6d symbols (maximum %4d) %8ld bytes of memory\n\ -Out: %s %s %d.%c%c%c%c%c%c (%ld%sK long):\n", - no_symbols, MAX_SYMBOLS, - (long int) malloced_bytes, - version_name(version_number), - output_called, - release_number, - serialnum[0], serialnum[1], serialnum[2], - serialnum[3], serialnum[4], serialnum[5], - (long int) k_long, k_str); - } - - printf("\ -%6d classes (maximum %3d) %6d objects (maximum %3d)\n\ -%6d global vars (maximum %3d) %6d variable/array space (maximum %d)\n", - no_classes, MAX_CLASSES, - no_objects, MAX_OBJECTS, - no_globals, MAX_GLOBAL_VARIABLES, - dynamic_array_area_size, MAX_STATIC_DATA); - - printf( -"%6d verbs (maximum %3d) %6d dictionary entries (maximum %d)\n\ -%6d grammar lines (version %d) %6d grammar tokens (unlimited)\n\ -%6d actions (maximum %3d) %6d attributes (maximum %2d)\n\ -%6d common props (maximum %3d) %6d individual props (unlimited)\n", - no_Inform_verbs, MAX_VERBS, - dict_entries, MAX_DICT_ENTRIES, - no_grammar_lines, grammar_version_number, - no_grammar_tokens, - no_actions, MAX_ACTIONS, - no_attributes, NUM_ATTR_BYTES*8, - no_properties, INDIV_PROP_START, - no_individual_properties - INDIV_PROP_START); - - if (track_unused_routines) - { - uint32 diff = df_total_size_before_stripping - df_total_size_after_stripping; - printf( -"%6ld bytes of code %6ld unused bytes %s (%.1f%%)\n", - (long int) df_total_size_before_stripping, (long int) diff, - (OMIT_UNUSED_ROUTINES ? "stripped out" : "detected"), - 100 * (float)diff / (float)df_total_size_before_stripping); - } - - printf( -"%6ld characters used in text %6ld bytes compressed (rate %d.%3ld)\n\ -%6d abbreviations (maximum %d) %6d routines (unlimited)\n\ -%6ld instructions of code %6d sequence points\n\ -%6ld bytes writable memory used %6ld bytes read-only memory used\n\ -%6ld bytes used in machine %10ld bytes free in machine\n", - (long int) total_chars_trans, - (long int) strings_length, - (total_chars_trans>strings_length)?0:1, - (long int) rate, - no_abbreviations, MAX_ABBREVS, - no_routines, - (long int) no_instructions, no_sequence_points, - (long int) (Out_Size - Write_RAM_At), - (long int) Write_RAM_At, - (long int) Out_Size, - (long int) - (((long int) (limit*1024L)) - ((long int) Out_Size))); - - } - } - - if (offsets_switch) - { - { printf( -"\nOffsets in %s:\n\ -%05lx Synonyms %05lx Defaults %05lx Objects %05lx Properties\n\ -%05lx Variables %05lx Parse table %05lx Actions %05lx Preactions\n\ -%05lx Adjectives %05lx Dictionary %05lx Code %05lx Strings\n", - output_called, - (long int) abbrevs_at, - (long int) prop_defaults_at, - (long int) object_tree_at, - (long int) object_props_at, - (long int) globals_at, - (long int) grammar_table_at, - (long int) actions_at, - (long int) preactions_at, - (long int) adjectives_offset, - (long int) dictionary_at, - (long int) Write_Code_At, - (long int) Write_Strings_At); - } - } - if (debugfile_switch) { begin_writing_debug_sections(); write_debug_section("memory layout id", GLULX_HEADER_SIZE); @@ -1797,73 +1572,79 @@ Out: %s %s %d.%c%c%c%c%c%c (%ld%sK long):\n", end_writing_debug_sections(Out_Size + MEMORY_MAP_EXTENSION); } - if (memory_map_switch) + if (memory_map_setting) { - + int32 addr; { printf(" +---------------------+ 000000\n"); -printf("Read- | header |\n"); +printf("Read- | header | %s\n", + show_percentage(GLULX_HEADER_SIZE, Out_Size)); printf(" only +=====================+ %06lx\n", (long int) GLULX_HEADER_SIZE); -printf("memory | memory layout id |\n"); +printf("memory | memory layout id | %s\n", + show_percentage(Write_Code_At-GLULX_HEADER_SIZE, Out_Size)); printf(" +---------------------+ %06lx\n", (long int) Write_Code_At); -printf(" | code |\n"); +printf(" | code | %s\n", + show_percentage(Write_Strings_At-Write_Code_At, Out_Size)); printf(" +---------------------+ %06lx\n", (long int) Write_Strings_At); -printf(" | string decode table |\n"); +printf(" | string decode table | %s\n", + show_percentage(compression_table_size, Out_Size)); printf(" + - - - - - - - - - - + %06lx\n", (long int) Write_Strings_At + compression_table_size); -printf(" | strings |\n"); +addr = (static_array_area_size ? static_arrays_at : Write_RAM_At+globals_at); +printf(" | strings | %s\n", + show_percentage(addr-(Write_Strings_At + compression_table_size), Out_Size)); if (static_array_area_size) { printf(" +---------------------+ %06lx\n", (long int) (static_arrays_at)); -printf(" | static arrays |\n"); +printf(" | static arrays | %s\n", + show_percentage(Write_RAM_At+globals_at-static_arrays_at, Out_Size)); } printf(" +=====================+ %06lx\n", (long int) (Write_RAM_At+globals_at)); -printf("Dynamic | global variables |\n"); +printf("Dynamic | global variables | %s\n", + show_percentage(arrays_at-globals_at, Out_Size)); printf("memory + - - - - - - - - - - + %06lx\n", (long int) (Write_RAM_At+arrays_at)); -printf(" | arrays |\n"); +printf(" | arrays | %s\n", + show_percentage(abbrevs_at-arrays_at, Out_Size)); printf(" +---------------------+ %06lx\n", (long int) (Write_RAM_At+abbrevs_at)); -printf(" | printing variables |\n"); - if (alphabet_modified) - { -printf(" + - - - - - - - - - - + %06lx\n", - (long int) (Write_RAM_At+charset_at)); -printf(" | alphabets table |\n"); - } - if (zscii_defn_modified) - { -printf(" + - - - - - - - - - - + %06lx\n", - (long int) (Write_RAM_At+unicode_at)); -printf(" | Unicode table |\n"); - } +printf(" | printing variables | %s\n", + show_percentage(object_tree_at-abbrevs_at, Out_Size)); printf(" +---------------------+ %06lx\n", (long int) (Write_RAM_At+object_tree_at)); -printf(" | objects |\n"); +printf(" | objects | %s\n", + show_percentage(object_props_at-object_tree_at, Out_Size)); printf(" + - - - - - - - - - - + %06lx\n", (long int) (Write_RAM_At+object_props_at)); -printf(" | property values |\n"); +printf(" | property values | %s\n", + show_percentage(prop_defaults_at-object_props_at, Out_Size)); printf(" + - - - - - - - - - - + %06lx\n", (long int) (Write_RAM_At+prop_defaults_at)); -printf(" | property defaults |\n"); +printf(" | property defaults | %s\n", + show_percentage(class_numbers_offset-prop_defaults_at, Out_Size)); printf(" + - - - - - - - - - - + %06lx\n", (long int) (Write_RAM_At+class_numbers_offset)); -printf(" | class numbers table |\n"); +printf(" | class numbers table | %s\n", + show_percentage(identifier_names_offset-class_numbers_offset, Out_Size)); printf(" + - - - - - - - - - - + %06lx\n", (long int) (Write_RAM_At+identifier_names_offset)); -printf(" | id names table |\n"); +printf(" | id names table | %s\n", + show_percentage(grammar_table_at-identifier_names_offset, Out_Size)); printf(" +---------------------+ %06lx\n", (long int) (Write_RAM_At+grammar_table_at)); -printf(" | grammar table |\n"); +printf(" | grammar table | %s\n", + show_percentage(actions_at-grammar_table_at, Out_Size)); printf(" + - - - - - - - - - - + %06lx\n", (long int) (Write_RAM_At+actions_at)); -printf(" | actions |\n"); +printf(" | actions | %s\n", + show_percentage(dictionary_offset-(Write_RAM_At+actions_at), Out_Size)); printf(" +---------------------+ %06lx\n", (long int) dictionary_offset); -printf(" | dictionary |\n"); +printf(" | dictionary | %s\n", + show_percentage(Out_Size-dictionary_offset, Out_Size)); if (MEMORY_MAP_EXTENSION == 0) { printf(" +---------------------+ %06lx\n", (long int) Out_Size); @@ -1871,56 +1652,276 @@ printf(" +---------------------+ %06lx\n", (long int) Out_Size); else { printf(" +=====================+ %06lx\n", (long int) Out_Size); -printf("Runtime | (empty) |\n"); +printf("Runtime | (empty) |\n"); /* no percentage */ printf(" extn +---------------------+ %06lx\n", (long int) Out_Size+MEMORY_MAP_EXTENSION); } } } +} +static void display_frequencies() +{ + int i, j; + + printf("How frequently abbreviations were used, and roughly\n"); + printf("how many bytes they saved: ('_' denotes spaces)\n"); + + for (i=0; i= 512) { k_long++; k_str=""; } + else if ((Out_Size-1024*k_long) > 0) { k_str=".5"; } + if (total_bytes_trans == 0) rate = 0; + else rate=total_bytes_trans*1000/total_chars_trans; + + { printf("In:\ +%3d source code files %6d syntactic lines\n\ +%6d textual lines %8ld characters ", + total_input_files, no_syntax_lines, + total_source_line_count, (long int) total_chars_read); + if (character_set_unicode) printf("(UTF-8)\n"); + else if (character_set_setting == 0) printf("(plain ASCII)\n"); + else + { printf("(ISO 8859-%d %s)\n", character_set_setting, + name_of_iso_set(character_set_setting)); } - if ((i%3)!=0) printf("\n"); - if (no_abbreviations==0) printf("None were declared.\n"); - } + + printf("Allocated:\n\ +%6d symbols %8ld bytes of memory\n\ +Out: Version %d \"%s\" %s %d.%c%c%c%c%c%c (%ld%sK long):\n", + no_symbols, + (long int) malloced_bytes, + version_number, + version_name(version_number), + output_called, + release_number, p[18], p[19], p[20], p[21], p[22], p[23], + (long int) k_long, k_str); + + printf("\ +%6d classes %6d objects\n\ +%6d global vars (maximum 233) %6d variable/array space\n", + no_classes, + no_objects, + no_globals, + dynamic_array_area_size); + + printf( + "%6d verbs %6d dictionary entries\n\ +%6d grammar lines (version %d) %6d grammar tokens (unlimited)\n\ +%6d actions %6d attributes (maximum %2d)\n\ +%6d common props (maximum %2d) %6d individual props (unlimited)\n", + no_Inform_verbs, + dict_entries, + no_grammar_lines, grammar_version_number, + no_grammar_tokens, + no_actions, + no_attributes, ((version_number==3)?32:48), + no_properties-3, ((version_number==3)?29:61), + no_individual_properties - 64); + + if (track_unused_routines) + { + uint32 diff = df_total_size_before_stripping - df_total_size_after_stripping; + printf( + "%6ld bytes of Z-code %6ld unused bytes %s (%.1f%%)\n", + (long int) df_total_size_before_stripping, (long int) diff, + (OMIT_UNUSED_ROUTINES ? "stripped out" : "detected"), + 100 * (float)diff / (float)df_total_size_before_stripping); + } + + printf( + "%6ld characters used in text %6ld bytes compressed (rate %d.%3ld)\n\ +%6d abbreviations (maximum %d) %6d routines (unlimited)\n\ +%6ld instructions of Z-code %6d sequence points\n\ +%6ld bytes readable memory used (maximum 65536)\n\ +%6ld bytes used in Z-machine %6ld bytes free in Z-machine\n", + (long int) total_chars_trans, + (long int) total_bytes_trans, + (total_chars_trans>total_bytes_trans)?0:1, + (long int) rate, + no_abbreviations, MAX_ABBREVS, + no_routines, + (long int) no_instructions, no_sequence_points, + (long int) Write_Code_At, + (long int) Out_Size, + (long int) + (((long int) (limit*1024L)) - ((long int) Out_Size))); + + } +} + +static void display_statistics_g() +{ + int32 k_long, rate; + char *k_str = ""; + int32 limit = 1024*1024; + int32 strings_length = compression_table_size + compression_string_size; + char *output_called = (module_switch)?"module":"story file"; + + k_long=(Out_Size/1024); + if ((Out_Size-1024*k_long) >= 512) { k_long++; k_str=""; } + else if ((Out_Size-1024*k_long) > 0) { k_str=".5"; } + + if (strings_length == 0) rate = 0; + else rate=strings_length*1000/total_chars_trans; + + { printf("In:\ +%3d source code files %6d syntactic lines\n\ +%6d textual lines %8ld characters ", + total_input_files, no_syntax_lines, + total_source_line_count, (long int) total_chars_read); + if (character_set_unicode) printf("(UTF-8)\n"); + else if (character_set_setting == 0) printf("(plain ASCII)\n"); + else + { printf("(ISO 8859-%d %s)\n", character_set_setting, + name_of_iso_set(character_set_setting)); + } + + {char serialnum[8]; + write_serial_number(serialnum); + printf("Allocated:\n\ +%6d symbols %8ld bytes of memory\n\ +Out: %s %s %d.%c%c%c%c%c%c (%ld%sK long):\n", + no_symbols, + (long int) malloced_bytes, + version_name(version_number), + output_called, + release_number, + serialnum[0], serialnum[1], serialnum[2], + serialnum[3], serialnum[4], serialnum[5], + (long int) k_long, k_str); + } + + printf("\ +%6d classes %6d objects\n\ +%6d global vars %6d variable/array space\n", + no_classes, + no_objects, + no_globals, + dynamic_array_area_size); + + printf( + "%6d verbs %6d dictionary entries\n\ +%6d grammar lines (version %d) %6d grammar tokens (unlimited)\n\ +%6d actions %6d attributes (maximum %2d)\n\ +%6d common props (maximum %3d) %6d individual props (unlimited)\n", + no_Inform_verbs, + dict_entries, + no_grammar_lines, grammar_version_number, + no_grammar_tokens, + no_actions, + no_attributes, NUM_ATTR_BYTES*8, + no_properties-3, INDIV_PROP_START-3, + no_individual_properties - INDIV_PROP_START); + + if (track_unused_routines) + { + uint32 diff = df_total_size_before_stripping - df_total_size_after_stripping; + printf( + "%6ld bytes of code %6ld unused bytes %s (%.1f%%)\n", + (long int) df_total_size_before_stripping, (long int) diff, + (OMIT_UNUSED_ROUTINES ? "stripped out" : "detected"), + 100 * (float)diff / (float)df_total_size_before_stripping); + } + + printf( + "%6ld characters used in text %6ld bytes compressed (rate %d.%3ld)\n\ +%6d abbreviations (maximum %d) %6d routines (unlimited)\n\ +%6ld instructions of code %6d sequence points\n\ +%6ld bytes writable memory used %6ld bytes read-only memory used\n\ +%6ld bytes used in machine %10ld bytes free in machine\n", + (long int) total_chars_trans, + (long int) strings_length, + (total_chars_trans>strings_length)?0:1, + (long int) rate, + no_abbreviations, MAX_ABBREVS, + no_routines, + (long int) no_instructions, no_sequence_points, + (long int) (Out_Size - Write_RAM_At), + (long int) Write_RAM_At, + (long int) Out_Size, + (long int) + (((long int) (limit*1024L)) - ((long int) Out_Size))); + } } + extern void construct_storyfile(void) { - if (!glulx_mode) - construct_storyfile_z(); - else - construct_storyfile_g(); + if (!glulx_mode) + construct_storyfile_z(); + else + construct_storyfile_g(); + + /* Display all the trace/stats info that came out of compilation. + + (Except for the memory map, which uses a bunch of local variables + from construct_storyfile_z/g(), so it's easier to do that inside + that function.) + */ + + if (frequencies_setting) + display_frequencies(); + + if (list_symbols_setting) + list_symbols(list_symbols_setting); + + if (list_dict_setting) + show_dictionary(list_dict_setting); + + if (list_verbs_setting) + list_verb_table(); + + if (list_objects_setting) + list_object_tree(); + + if (statistics_switch) { + if (!glulx_mode) + display_statistics_z(); + else + display_statistics_g(); + } } /* ========================================================================= */