Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$ZCODE_LESS_DICT_DATA option to omit last byte in dictionary words #148

Merged
merged 10 commits into from
Dec 28, 2021

Conversation

erkyrath
Copy link
Contributor

Setting $ZCODE_LESS_DICT_DATA to a nonzero value tells the compiler to omit the last dict entry byte (the one referred to as #dict_par3). See #146 .

This turned out to be more of a pain than it looked. The Z-code dict computation of ((version_number==3)?7:9) was hardwired in quite a lot of places. I replaced them all with the DICT_ENTRY_BYTE_LENGTH compiler variable, which is set at startup time.

Complication: The Version directive can change the Z-code version in mid-compile, which means we must change DICT_ENTRY_BYTE_LENGTH at that point. And also the DICT_ENTRY_BYTES I6 constant. This is doable, it's just messy. See #147 about the idea of deprecating this directive.

Anyhow, with all that in place, we just have to reduce DICT_ENTRY_BYTE_LENGTH by one when $ZCODE_LESS_DICT_DATA is set.

We generate warnings and errors for three cases when $ZCODE_LESS_DICT_DATA is set:

  • Warning when using Dictionary 'word' x y. (The third value is ignored.)
  • Error when using #dict_par3.
  • Error if you define verbs without using Grammar__Version 2. (GV1 wants to store the preposition number in the #dict_par3 field.)

@erkyrath
Copy link
Contributor Author

https://github.com/erkyrath/Inform6-Testing/tree/small-dict (small-dict branch) has tests for this feature, including the errors and warnings.

Saves 728 bytes when compiling Advent.z5!

@DavidKinder DavidKinder merged commit b7e3f60 into DavidKinder:master Dec 28, 2021
DavidKinder pushed a commit that referenced this pull request Dec 28, 2021
@erkyrath erkyrath deleted the small-dict branch September 27, 2023 23:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants