MergeOverlappingScopes visits value block final values
Joe Savona committed
Jan 12, 2023 at 09:12 UTC
919f193934169af600b4bdd865b720d2e8345c98
1 file changed
+15
-2
compiler/forget/src/ReactiveScopes/MergeOverlappingReactiveScopes.ts
+15
-2
@@ -20,6 +20,7 @@ import { eachInstructionValueOperand } from "../HIR/visitors";
20
import { invariant } from "../Utils/CompilerError";
21
import DisjointSet from "../Utils/DisjointSet";
22
import { retainWhere } from "../Utils/utils";
23
+import { getPlaceScope } from "./BuildReactiveBlocks";
24
import { eachTerminalBlock, eachTerminalOperand } from "./visitors";
25
26
/**
@@ -127,7 +128,11 @@ function visitBlock(context: Context, block: ReactiveBlock): void {
128
visitBlock(context, block);
129
});
130
},
130
- (valueBlock) => visitValueBlock(context, valueBlock)
131
+ (valueBlock) => {
132
+ context.enter(() => {
133
+ visitValueBlock(context, valueBlock);
134
+ });
135
+ }
136
);
137
break;
138
}
@@ -140,7 +145,15 @@ function visitBlock(context: Context, block: ReactiveBlock): void {
145
146
function visitValueBlock(context: Context, block: ReactiveValueBlock): void {
147
visitBlock(context, block.instructions);
143
- // TODO: visit the value block value!
148
+ if (block.last !== null) {
149
+ context.visitId(block.last.id);
150
+ if (block.last.value.kind === "Identifier") {
151
+ const scope = getPlaceScope(block.last.id, block.last.value);
152
+ if (scope !== null) {
153
+ context.visitScope(scope);
154
+ }
155
+ }
156
+ }
157
}
158
159
function visitInstruction(