mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
[valueblocks] For.update is a proper value block
This commit is contained in:
@@ -173,7 +173,7 @@ export type ReactiveForTerminal = {
|
||||
kind: "for";
|
||||
init: ReactiveValueBlock;
|
||||
test: ReactiveValue;
|
||||
update: ReactiveValueBlock;
|
||||
update: ReactiveValue;
|
||||
loop: ReactiveBlock;
|
||||
id: InstructionId;
|
||||
};
|
||||
|
||||
@@ -320,13 +320,10 @@ class Driver {
|
||||
terminal.loc
|
||||
).value;
|
||||
|
||||
const updateBlock = this.cx.ir.blocks.get(terminal.update)!;
|
||||
const updateTerminal = updateBlock.terminal;
|
||||
invariant(
|
||||
updateTerminal.kind === "goto",
|
||||
"Expected for loop update block to end in a goto"
|
||||
);
|
||||
const updateValue = this.visitValueBlock(blockValue, updateBlock);
|
||||
const updateValue = this.visitValueBlockNew(
|
||||
terminal.update,
|
||||
terminal.loc
|
||||
).value;
|
||||
|
||||
let loopBody: ReactiveBlock;
|
||||
if (loopId) {
|
||||
|
||||
@@ -266,7 +266,7 @@ function codegenTerminal(
|
||||
return t.forStatement(
|
||||
codegenForInit(cx, terminal.init),
|
||||
codegenInstructionValue(cx, terminal.test),
|
||||
codegenValueBlock(cx, terminal.update),
|
||||
codegenInstructionValue(cx, terminal.update),
|
||||
codegenBlock(cx, terminal.loop)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -235,7 +235,7 @@ function printTerminal(writer: Writer, terminal: ReactiveTerminal): void {
|
||||
writer.writeLine(";");
|
||||
printReactiveValue(writer, terminal.test);
|
||||
writer.writeLine(";");
|
||||
printValueBlock(writer, terminal.update);
|
||||
printReactiveValue(writer, terminal.update);
|
||||
writer.writeLine(") {");
|
||||
printReactiveInstructions(writer, terminal.loop);
|
||||
writer.writeLine("}");
|
||||
|
||||
@@ -232,7 +232,7 @@ function visit(context: Context, block: ReactiveBlock): void {
|
||||
case "for": {
|
||||
visitValueBlock(context, terminal.init);
|
||||
visitReactiveValue(context, terminal.test);
|
||||
visitValueBlock(context, terminal.update);
|
||||
visitReactiveValue(context, terminal.update);
|
||||
visit(context, terminal.loop);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ export class ReactiveFunctionVisitor<TState = void> {
|
||||
case "for": {
|
||||
this.visitValueBlock(terminal.init, state);
|
||||
this.visitValue(terminal.id, terminal.test, state);
|
||||
this.visitValueBlock(terminal.update, state);
|
||||
this.visitValue(terminal.id, terminal.update, state);
|
||||
this.visitBlock(terminal.loop, state);
|
||||
break;
|
||||
}
|
||||
@@ -336,7 +336,7 @@ export function eachTerminalBlock(
|
||||
visitValueBlock(terminal.init);
|
||||
// TODO
|
||||
// visitValueBlock(terminal.test);
|
||||
visitValueBlock(terminal.update);
|
||||
// visitValueBlock(terminal.update);
|
||||
visitBlock(terminal.loop);
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user