Skip to content

Improvements in maps#676

Merged
jcp19 merged 10 commits intomasterfrom
joao-fix-map-triggers
Sep 22, 2023
Merged

Improvements in maps#676
jcp19 merged 10 commits intomasterfrom
joao-fix-map-triggers

Conversation

@jcp19
Copy link
Contributor

@jcp19 jcp19 commented Sep 21, 2023

This PR extends the TypeEncoding with a method triggerExpr that is now used to encode expressions that occur in triggers (instead of encoding them with expression). This allows us to select well-formed triggers whenever the expression encoding generates ill-formed triggers. With this, we solve a long-standing issue where triggers containing a a map (like m[i] or i in range(m)) are translated to invalid triggers at the Viper level.

Besides, this PR introduces two quality of life improvements

  • like in Viper, we now support the idiom key in m, where m is a map, whereas before we would have had to write key in domain(m). The previous idiom is still supported.
  • the assert method in ViperWriter has been simplified to not generate a call to assert whenever the condition is TrueLit. Instead, it simplifies to the expression. This makes the resulting Viper code look much cleaner.

In the future, we may re-organize the map encoding as done in #606.

TODO:

  • doc
  • use default encoding for the fallback case instead of having it in the type combiner
  • test with the slayers/path package in SCION

@jcp19 jcp19 linked an issue Sep 21, 2023 that may be closed by this pull request
@jcp19 jcp19 changed the title Improvements on maps Improvements in maps Sep 21, 2023
@jcp19 jcp19 marked this pull request as ready for review September 22, 2023 14:47
@jcp19 jcp19 requested a review from Felalolf September 22, 2023 14:47
Copy link
Contributor

@Felalolf Felalolf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do the changes, then you can merge

jcp19 and others added 2 commits September 22, 2023 18:46
Co-authored-by: Felix Wolf <60103963+Felalolf@users.noreply.github.com>
@jcp19 jcp19 merged commit 8895ec3 into master Sep 22, 2023
@jcp19 jcp19 deleted the joao-fix-map-triggers branch September 22, 2023 17:44
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.

Improve triggers generated for map accesses

2 participants