@samitouri / QOS-React-2 / commits / 894eadfa67

[valueblocks] For.update is a proper value block

Joe Savona committed Jan 31, 2023 at 13:39 UTC 894eadfa67752666a2d75ea39b6cf477fa9dfbfc
6 files changed +10 -13
compiler/forget/src/HIR/HIR.ts
+1 -1
@@ -173,7 +173,7 @@ export type ReactiveForTerminal = {
173 kind: "for";
174 init: ReactiveValueBlock;
175 test: ReactiveValue;
176 - update: ReactiveValueBlock;
176 + update: ReactiveValue;
177 loop: ReactiveBlock;
178 id: InstructionId;
179 };
compiler/forget/src/ReactiveScopes/BuildReactiveFunction.ts
+4 -7
@@ -320,13 +320,10 @@ class Driver {
320 terminal.loc
321 ).value;
322
323 - const updateBlock = this.cx.ir.blocks.get(terminal.update)!;
324 - const updateTerminal = updateBlock.terminal;
325 - invariant(
326 - updateTerminal.kind === "goto",
327 - "Expected for loop update block to end in a goto"
328 - );
329 - const updateValue = this.visitValueBlock(blockValue, updateBlock);
323 + const updateValue = this.visitValueBlockNew(
324 + terminal.update,
325 + terminal.loc
326 + ).value;
327
328 let loopBody: ReactiveBlock;
329 if (loopId) {
compiler/forget/src/ReactiveScopes/CodegenReactiveFunction.ts
+1 -1
@@ -266,7 +266,7 @@ function codegenTerminal(
266 return t.forStatement(
267 codegenForInit(cx, terminal.init),
268 codegenInstructionValue(cx, terminal.test),
269 - codegenValueBlock(cx, terminal.update),
269 + codegenInstructionValue(cx, terminal.update),
270 codegenBlock(cx, terminal.loop)
271 );
272 }
compiler/forget/src/ReactiveScopes/PrintReactiveFunction.ts
+1 -1
@@ -235,7 +235,7 @@ function printTerminal(writer: Writer, terminal: ReactiveTerminal): void {
235 writer.writeLine(";");
236 printReactiveValue(writer, terminal.test);
237 writer.writeLine(";");
238 - printValueBlock(writer, terminal.update);
238 + printReactiveValue(writer, terminal.update);
239 writer.writeLine(") {");
240 printReactiveInstructions(writer, terminal.loop);
241 writer.writeLine("}");
compiler/forget/src/ReactiveScopes/PropagateScopeDependencies.ts
+1 -1
@@ -232,7 +232,7 @@ function visit(context: Context, block: ReactiveBlock): void {
232 case "for": {
233 visitValueBlock(context, terminal.init);
234 visitReactiveValue(context, terminal.test);
235 - visitValueBlock(context, terminal.update);
235 + visitReactiveValue(context, terminal.update);
236 visit(context, terminal.loop);
237 break;
238 }
compiler/forget/src/ReactiveScopes/visitors.ts
+2 -2
@@ -104,7 +104,7 @@ export class ReactiveFunctionVisitor<TState = void> {
104 case "for": {
105 this.visitValueBlock(terminal.init, state);
106 this.visitValue(terminal.id, terminal.test, state);
107 - this.visitValueBlock(terminal.update, state);
107 + this.visitValue(terminal.id, terminal.update, state);
108 this.visitBlock(terminal.loop, state);
109 break;
110 }
@@ -336,7 +336,7 @@ export function eachTerminalBlock(
336 visitValueBlock(terminal.init);
337 // TODO
338 // visitValueBlock(terminal.test);
339 - visitValueBlock(terminal.update);
339 + // visitValueBlock(terminal.update);
340 visitBlock(terminal.loop);
341 break;
342 }