You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the following example, the initialization assignment for 'i' never triggers a value change event.
int j = 7;
for (final int i = 17; j < i; ++j);
GhostWriter checks the 'step' part of the 'for' expression for mutations and adds value change event triggers to the body of the for loop. Thus we get an event at each iteration.
The problem with the 'initialization' part of the 'for' expression part is that there seems to be only one correct solution. The value change event triggering for the initialization needs to be put in the for loop body with as a conditional statement. Generating the conditional statement for the first iteration that covers all general use cases can be quite tricky.
int j = 7;
for (final int i = 17; j < i; ++j) {
if (isFirstIteration) {
GW.valueChange("i");
}
GW.valueChange("j");
}
One thing to keep in mind that it can happen that we execute the initialization part of the 'for' expression, but do not iterate, since the terminating condition is met at the start. In that case we still miss a value change event that happened.
In all cases, the solution to have the value change event triggered after the 'for' expression would work, however the down side is that the events come out of order, meaning the iteration step events come before the initialization event.
One possible "optimal" solution could be to extend GW API to support this use case, by having the valueChange API call return the traced value. So we would have something like this:
for (final int i = GW.valueChange(17); j < i; ++j);
Though this leads to a whole lot of things that need to be considered, supported (chaining, exceptions ... ).
The text was updated successfully, but these errors were encountered:
In the following example, the initialization assignment for 'i' never triggers a value change event.
GhostWriter checks the 'step' part of the 'for' expression for mutations and adds value change event triggers to the body of the for loop. Thus we get an event at each iteration.
The problem with the 'initialization' part of the 'for' expression part is that there seems to be only one correct solution. The value change event triggering for the initialization needs to be put in the for loop body with as a conditional statement. Generating the conditional statement for the first iteration that covers all general use cases can be quite tricky.
One thing to keep in mind that it can happen that we execute the initialization part of the 'for' expression, but do not iterate, since the terminating condition is met at the start. In that case we still miss a value change event that happened.
In all cases, the solution to have the value change event triggered after the 'for' expression would work, however the down side is that the events come out of order, meaning the iteration step events come before the initialization event.
One possible "optimal" solution could be to extend GW API to support this use case, by having the valueChange API call return the traced value. So we would have something like this:
Though this leads to a whole lot of things that need to be considered, supported (chaining, exceptions ... ).
The text was updated successfully, but these errors were encountered: