Skip to content

Commit

Permalink
clarify substitution comments
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-chew committed Jun 7, 2024
1 parent 8e44ac9 commit cc06580
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -823,11 +823,11 @@ private record ReadsCheckDelayer(ExpressionTranslator etran, Function selfCallsA
if (wfOptions.DoReadsChecks) {
// check that the callee reads only what the caller is already allowed to read

// substitute actual args for parameter is frames for the description expression...
// substitute actual args for parameters in description expression frames...
var requiredFrames = e.Function.Reads.Expressions.ConvertAll(directSub.SubstFrameExpr);
var desc = new PODesc.ReadFrameSubset("invoke function", requiredFrames, readFrames);

// ... but no need to do so for frames passed to CheckFrameSubset
// ... but that substitution isn't needed for frames passed to CheckFrameSubset
var readsSubst = new Substituter(null, new Dictionary<IVariable, Expression>(), e.GetTypeArgumentSubstitutions());
CheckFrameSubset(callExpr.tok,
e.Function.Reads.Expressions.ConvertAll(readsSubst.SubstFrameExpr),
Expand Down
8 changes: 4 additions & 4 deletions Source/DafnyCore/Verifier/BoogieGenerator.TrStatement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2044,25 +2044,25 @@ public partial class BoogieGenerator {
// Check that the reads clause of a subcall is a subset of the current reads frame,
// but support the optimization that we don't define a reads frame at all if it's `reads *`.
if (etran.readsFrame != null) {
// substitute actual args for parameter in frames for the description expression...
// substitute actual args for parameters in description expression frames...
var requiredFrames = callee.Reads.Expressions.ConvertAll(directSub.SubstFrameExpr);
var desc = new PODesc.ReadFrameSubset("call", requiredFrames, GetContextReadsFrames());

// ... but no need to do so for frames passed to CheckFrameSubset
// ... but that substitution isn't needed for frames passed to CheckFrameSubset
var readsSubst = new Substituter(null, new Dictionary<IVariable, Expression>(), tySubst);
CheckFrameSubset(tok, callee.Reads.Expressions.ConvertAll(readsSubst.SubstFrameExpr),
receiver, substMap, etran, etran.ReadsFrame(tok), builder, desc, null);
}
// Check that the modifies clause of a subcall is a subset of the current modifies frame,
// but only if we're in a context that defines a modifies frame.
if (codeContext is IMethodCodeContext methodCodeContext) {
// substitute actual args for parameters in frames for the description expression...
// substitute actual args for parameters in description expression frames...
var desc = new PODesc.ModifyFrameSubset(
"call",
callee.Mod.Expressions.ConvertAll(directSub.SubstFrameExpr),
methodCodeContext.Modifies.Expressions
);
// ... but no need to do so for frames passed to CheckFrameSubset
// ... but that substitution isn't needed for frames passed to CheckFrameSubset
var modifiesSubst = new Substituter(null, new(), tySubst);
CheckFrameSubset(
tok, callee.Mod.Expressions.ConvertAll(modifiesSubst.SubstFrameExpr),
Expand Down

0 comments on commit cc06580

Please sign in to comment.