TNO / Rewriters-Ada

Advanced manipulation of Ada code
BSD 3-Clause "New" or "Revised" License
5 stars 1 forks source link

Use membership for "or" expressions #7

Closed pjljvandelaar closed 1 year ago

pjljvandelaar commented 1 year ago

Our membership rewriter current is: https://github.com/TNO/Rewriters-Ada/blob/47ca5f092d736ce7ab86a0214008023dd59b2f4f/src/predefined_rewriters_membership_test.ads#L46-L51

It checks for "or else" expressions.

Also add a pattern to check for "or" expressions. Of course, also assert no side effects in $S_Val2 since it might no longer be executed!

pjljvandelaar commented 1 year ago

Alternatively, first use prefer short circuit patch and then use prefer membership test

See e.g. https://github.com/zertovitch/hac/pull/11

pjljvandelaar commented 1 year ago

Won't add the patterns, since a clear and nice path already exists (prefer short circuit + prefer membership tests). Of course, users can add this pattern if they consider it important to do in a single step.