mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 01:21:07 +00:00
Flow analysis: remove the State.exit method.
It was redundant with State.setReachable(false), and it did not have the necessary logic to avoid creating State objects when unnecessary. Change-Id: If9e0b8b586dab0e681f4ee0bc7b792d49e1e5f4b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/109897 Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
parent
0a2993687b
commit
24c0507d73
|
@ -327,7 +327,7 @@ class FlowAnalysis<Statement, Expression, Variable, Type> {
|
|||
if (breakIndex != null) {
|
||||
_stack[breakIndex] = _join(_stack[breakIndex], _current);
|
||||
}
|
||||
_current = _current.exit();
|
||||
_current = _current.setReachable(false);
|
||||
}
|
||||
|
||||
void handleContinue(Statement target) {
|
||||
|
@ -336,13 +336,13 @@ class FlowAnalysis<Statement, Expression, Variable, Type> {
|
|||
var continueIndex = breakIndex + 1;
|
||||
_stack[continueIndex] = _join(_stack[continueIndex], _current);
|
||||
}
|
||||
_current = _current.exit();
|
||||
_current = _current.setReachable(false);
|
||||
}
|
||||
|
||||
/// Register the fact that the current state definitely exists, e.g. returns
|
||||
/// from the body, throws an exception, etc.
|
||||
void handleExit() {
|
||||
_current = _current.exit();
|
||||
_current = _current.setReachable(false);
|
||||
}
|
||||
|
||||
void ifNullExpression_end() {
|
||||
|
@ -756,15 +756,6 @@ class State<Variable, Type> {
|
|||
);
|
||||
}
|
||||
|
||||
/// Updates the state to indicate that the control flow path is unreachable.
|
||||
State<Variable, Type> exit() {
|
||||
return State<Variable, Type>._(
|
||||
false,
|
||||
notAssigned,
|
||||
promoted,
|
||||
);
|
||||
}
|
||||
|
||||
/// Updates the state to indicate that the given [variable] has been
|
||||
/// determined to contain a non-null value.
|
||||
///
|
||||
|
|
|
@ -143,14 +143,6 @@ main() {
|
|||
});
|
||||
});
|
||||
|
||||
test('exit', () {
|
||||
var s1 = State<_Var, _Type>(true);
|
||||
var s2 = s1.exit();
|
||||
expect(s2.reachable, false);
|
||||
expect(s2.notAssigned, same(s1.notAssigned));
|
||||
expect(s2.promoted, same(s1.promoted));
|
||||
});
|
||||
|
||||
group('promote', () {
|
||||
test('unpromoted -> unchanged (same)', () {
|
||||
var h = _Harness();
|
||||
|
@ -327,7 +319,7 @@ main() {
|
|||
test('reachability', () {
|
||||
var h = _Harness();
|
||||
var reachable = State<_Var, _Type>(true);
|
||||
var unreachable = reachable.exit();
|
||||
var unreachable = reachable.setReachable(false);
|
||||
expect(reachable.restrict(h, emptySet, reachable, {}), same(reachable));
|
||||
expect(reachable.restrict(h, emptySet, unreachable, {}),
|
||||
same(unreachable));
|
||||
|
|
Loading…
Reference in a new issue