Skip to content

Refactor well-definedness of field acesses and permission division#451

Merged
gauravpartha merged 3 commits into
masterfrom
field_welldef_order
Feb 23, 2023
Merged

Refactor well-definedness of field acesses and permission division#451
gauravpartha merged 3 commits into
masterfrom
field_welldef_order

Conversation

@gauravpartha

@gauravpartha gauravpartha commented Feb 22, 2023

Copy link
Copy Markdown
Contributor

Now, the well-definedness of a field access first checks the well-definedness of a receiver and only afterwards checks whether there is enough permission (previously the order was reversed). Now, the well-definedness of a permission division first checks the well-definedness of the dividend and the divisor and only afterwards checks the whether the divisor is nonzero (before the order was reversed).

In the case of acc(e.f) and perm(e.f) (“PermAccess case”), the well-definedness check for e.f need not be checked. In all other cases (“NonPermAccess case”) such as “x := e.f”, the well-definedness check requires a permission check. In both cases, e.f is represented by the same AST subnode. Previously, Carbon differentiated the two cases in the well-definedness check with global state in a fragile way that relied on the fact that for the “NonPermAccess case” permission to e.f was checked before well-definedness of e was checke. Now, Carbon does not use global state for this differentiation (which then allowed me to also change the order of the checks). Instead, the expression module (responsible for orchestrating the definedness checks) makes sure that the components contributing to the definedness check never obtain field accesses as an input for which no definedness check is required.

Now, the well-definedness of a field access first checks the well-definedness of a receiver and only afterwards checks whether there is enough permission (before the order was reversed).
Now, the well-definedness of a permission division first checks the well-definedness of the dividend and the divisor and only afterwards checks the whether the divisor is nonzero (before the order was reversed).

Moreover, in order to avoid checking whether permission to field accesses at the top-level of an accessibility predicate or permission introspection, the current implementation uses global state in a somewhat fragile way. Now, a different approach is used that avoids global state.

@marcoeilers marcoeilers left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, I just left two comments with cosmetic suggestions.

Comment thread src/main/scala/viper/carbon/modules/impls/DefaultExpModule.scala Outdated
Comment thread src/main/scala/viper/carbon/modules/impls/DefaultExpModule.scala Outdated
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