mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Build -> Codegen for LabelTerminal
NOTE: See background in #1476. Updates BuildHIR to use the new LabelTerminal for LabeledStatements, and adds support for HIR->ReactiveFunction transformation and codegen. Note that we sometimes produce an extraneous block wrapper if it turns out the label wasn't necessary, that seems...fine?
This commit is contained in:
1 parent
b087635e5d
commit
d243e748d0
18 files changed
+167
-55
No files matched your search
@@ -29,7 +29,6 @@ import {
|
||||
ReactiveValue,
|
||||
Terminal,
|
||||
} from "../HIR/HIR";
|
||||
import todo from "../Utils/todo";
|
||||
import { assertExhaustive } from "../Utils/utils";
|
||||
|
||||
/**
|
||||
@@ -531,7 +530,35 @@ class Driver {
|
||||
break;
|
||||
}
|
||||
case "label": {
|
||||
todo("Support label terminals");
|
||||
const fallthroughId =
|
||||
terminal.fallthrough !== null &&
|
||||
!this.cx.isScheduled(terminal.fallthrough)
|
||||
? terminal.fallthrough
|
||||
: null;
|
||||
if (fallthroughId !== null) {
|
||||
const scheduleId = this.cx.schedule(fallthroughId, "if");
|
||||
scheduleIds.push(scheduleId);
|
||||
}
|
||||
|
||||
const block = this.traverseBlock(
|
||||
this.cx.ir.blocks.get(terminal.block)!
|
||||
);
|
||||
|
||||
this.cx.unscheduleAll(scheduleIds);
|
||||
blockValue.push({
|
||||
kind: "terminal",
|
||||
terminal: {
|
||||
kind: "label",
|
||||
block,
|
||||
id: terminal.id,
|
||||
},
|
||||
label: fallthroughId,
|
||||
});
|
||||
if (fallthroughId !== null) {
|
||||
this.visitBlock(this.cx.ir.blocks.get(fallthroughId)!, blockValue);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case "optional-call":
|
||||
case "ternary":
|
||||
|
||||
Reference in new issue
Block a user