@@ -148,23 +148,25 @@ class FormalEvaluationContext {
148
148
void dump (SILGenFunction &SGF);
149
149
};
150
150
151
- // / A scope associated with the beginning of the formal evaluation of an lvalue.
151
+ // / A scope associated with the beginning of the evaluation of an lvalue.
152
152
// /
153
- // / A formal evaluation of an lvalue occurs when emitting:
153
+ // / The evaluation of an l-value is split into two stages: its formal
154
+ // / evaluation, which evaluates any independent r-values embedded in the l-value
155
+ // / expression (e.g. class references and subscript indices), and its formal
156
+ // / access duration, which delimits the span of time for which the referenced
157
+ // / storage is actually accessed.
154
158
// /
155
- // / 1. accessors.
156
- // / 2. getters.
157
- // / 3. materializeForSets.
159
+ // / Note that other evaluations can be interleaved between the formal evaluation
160
+ // / and the beginning of the formal access. For example, in a simple assignment
161
+ // / statement, the left-hand side of the assignment is first formally evaluated
162
+ // / as an l-value, then the right-hand side is evaluated as an r-value, and only
163
+ // / then does the write access begin to the l-value.
158
164
// /
159
- // / for lvalues. The general form of such an evaluation is:
160
- // /
161
- // / formally evaluate the lvalue "x" into memory
162
- // / begin formal access to "x"
163
- // / end formal access to "x"
164
- // / ... *more formal access*
165
- // / begin formal access to "x"
166
- // / end formal access to "x"
167
- // / end formal evaluation of lvalue into memory
165
+ // / Note also that the formal evaluation of an l-value will sometimes require
166
+ // / its component l-values to be formally accessed. For example, the formal
167
+ // / access of the l-value `x?.prop` will initiate an access to `x` immediately
168
+ // / because the downstream evaluation must be skipped if `x` has no value, which
169
+ // / cannot be determined without beginning the access.
168
170
// /
169
171
// / *NOTE* All formal access contain a pointer to a cleanup in the normal
170
172
// / cleanup stack. This is to ensure that when SILGen calls
0 commit comments