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

Encoding refactor #466

Merged
merged 7 commits into from
Jun 20, 2022
Merged

Encoding refactor #466

merged 7 commits into from
Jun 20, 2022

Conversation

Felalolf
Copy link
Contributor

The changeset looks worse than it is. This PR:

  • Merges interface/components and implementations/components into library/
  • Moves the translators from implementations/translators into the encodings folder. Furthermore, all translators now extend the TypeEncoding trait.
  • Extends the type-encoding interface with hooks for built-ins and encoding extensions. The goal of the encoding extensions is to simplify encodings that first need to collect information and then extend the encoding of another node based on that information, for instance add additional checks. I will need this for instance for defer. Because encoding extensions are extremely powerful, we have to be careful not to abuse them.
  • Extends the ViperWriter with the option to collect more general information.
  • Adds the encoding functions to the context, such that we do not have to give the context twice all the time. This also makes it easier if we change how encodings are invoked in the future.

@Felalolf Felalolf requested review from ArquintL, jcp19 and Dspil June 19, 2022 18:33
Copy link
Contributor

@jcp19 jcp19 left a comment

Choose a reason for hiding this comment

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

LGTM! I have some minor questions/points, but overall, these quality of life improvements can be useful already in my branch for globals

arg <- ctx.predicate.predicateAccess(ctx)(cp.acc.op, in.FullPerm(cp.info))
res = vpr.CurrentPerm(arg.loc)(pos, info, errT)
arg <- ctx.ass(in.Access(in.Accessible.Predicate(cp.acc.op), in.FullPerm(cp.info))(cp.info))
pap = arg.asInstanceOf[vpr.PredicateAccessPredicate]
Copy link
Member

Choose a reason for hiding this comment

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

why did you choose not to offer predicateAccess anymore?

@@ -296,7 +297,7 @@ class StringEncoding extends LeafTypeEncoding {
terminationMeasures = Vector(in.WildcardMeasure(None)(info)),
body = None
)(info)
val translatedFunc = ctx.pureMethod.pureFunction(func)(ctx)
val translatedFunc = ctx.function(func)
Copy link
Member

Choose a reason for hiding this comment

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

is this a mistake or just confusing that pureMethod.pureFunction becomes function?

case meth: in.Method => ctx.method.method(meth)(ctx).res
case meth: in.PureMethod => ctx.pureMethod.pureMethod(meth)(ctx).res
case meth: in.Method => ctx.method(meth).res
case meth: in.PureMethod => ctx.function(meth).res
Copy link
Member

Choose a reason for hiding this comment

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

same here: should we think about method and function in the Viper way?

@Felalolf Felalolf merged commit d9d91a4 into master Jun 20, 2022
@Felalolf Felalolf deleted the encoding-refactor branch June 20, 2022 17:37
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.

4 participants