|
7 | 7 |
|
8 | 8 | import { |
9 | 9 | IdentifierId, |
| 10 | + PrunedReactiveScopeBlock, |
10 | 11 | ReactiveFunction, |
11 | 12 | ReactiveInstruction, |
| 13 | + ReactiveScope, |
12 | 14 | ReactiveScopeBlock, |
13 | 15 | isSetStateType, |
14 | 16 | } from "../HIR"; |
@@ -95,23 +97,34 @@ class Visitor extends ReactiveFunctionVisitor<ReactiveIdentifiers> { |
95 | 97 | state: ReactiveIdentifiers |
96 | 98 | ): void { |
97 | 99 | this.traverseScope(scopeBlock, state); |
98 | | - for (const dep of scopeBlock.scope.dependencies) { |
| 100 | + this.visitScopeImpl(scopeBlock.scope, state); |
| 101 | + } |
| 102 | + |
| 103 | + override visitPrunedScope( |
| 104 | + scopeBlock: PrunedReactiveScopeBlock, |
| 105 | + state: ReactiveIdentifiers |
| 106 | + ): void { |
| 107 | + this.traversePrunedScope(scopeBlock, state); |
| 108 | + } |
| 109 | + |
| 110 | + visitScopeImpl(scope: ReactiveScope, state: ReactiveIdentifiers): void { |
| 111 | + for (const dep of scope.dependencies) { |
99 | 112 | const isReactive = state.has(dep.identifier.id); |
100 | 113 | if (!isReactive) { |
101 | | - scopeBlock.scope.dependencies.delete(dep); |
| 114 | + scope.dependencies.delete(dep); |
102 | 115 | } |
103 | 116 | } |
104 | | - if (scopeBlock.scope.dependencies.size !== 0) { |
| 117 | + if (scope.dependencies.size !== 0) { |
105 | 118 | /** |
106 | 119 | * If any of a scope's dependencies are reactive, then all of its |
107 | 120 | * outputs will re-evaluate whenever those dependencies change. |
108 | 121 | * Mark all of the outputs as reactive to reflect the fact that |
109 | 122 | * they may change in practice based on a reactive input. |
110 | 123 | */ |
111 | | - for (const [, declaration] of scopeBlock.scope.declarations) { |
| 124 | + for (const [, declaration] of scope.declarations) { |
112 | 125 | state.add(declaration.identifier.id); |
113 | 126 | } |
114 | | - for (const reassignment of scopeBlock.scope.reassignments) { |
| 127 | + for (const reassignment of scope.reassignments) { |
115 | 128 | state.add(reassignment.id); |
116 | 129 | } |
117 | 130 | } |
|
0 commit comments