DavidKinder / Inform6

The latest version of the Inform 6 compiler, used for generating interactive fiction games.
http://inform-fiction.org/
Other
199 stars 32 forks source link

OMIT_SYMBOL_TABLE option #239

Closed erkyrath closed 11 months ago

erkyrath commented 11 months ago

From https://github.com/DavidKinder/Inform6/issues/204 :

The generated game file includes a "symbol names table" segment (see identifier_names_offset in tables.c). This refers to compiled strings containing the names of all properties, attributes, fake actions, and arrays.

This information is in general used only for debug library code and debug veneer error messages. It would be nice to have a (opt-in) compiler setting to strip it all out. (Both the table segment and the compiled strings.)

This now exists, as $OMIT_SYMBOL_TABLE=1. Works in both Glulx and Z-code, although anybody who needs this level of byte-scraping will be in Z-code.

When $OMIT_SYMBOL_TABLE=1 is set:

Also, with this option set, the following system constants are not available: (Trying to use one is a compile-time error.)

#identifiers_table, #attribute_names_array, #property_names_array, #action_names_array,
#fake_action_names_array, #array_names_offset, #global_names_array, #routine_names_array,
#constant_names_array

Note that the I6 library uses #identifiers_table for some debug verbs. The Infix library extension uses all the affected constants. It may or may not be worth updating the library to be compatible with this option. You would do this by putting the debug code under #IFNDEF OMIT_SYMBOL_TABLE; and just not trying to print symbol names.


Implementation notes:

We call check_system_constant_available() when parsing a #systemconstant value. If OMIT_SYMBOL_TABLE is set, this prints an error for the listed constants.

At game file generation time, if OMIT_SYMBOL_TABLE is set, we skip writing out that segment of the game file. We also skip write_the_identifier_names(), which compiles the name strings themselves.

The veneer code now has some sections with #IFDEF OMIT_SYMBOL_TABLE for the runtime error adjustments noted above.

Unrelated: I added a V7 case to the version_name() routine. V7 is obscure but it's not experimental any more. :)

I also added a crude overflow check to the use of the zmachine_paged_memory buffer. We allocate that based on rough_size_of_paged_memory(), which is supposed to be an overestimate. As far as I know it's safe, and furthermore my test suite would catch any overflow. But it doesn't hurt to check again.