visitBlock() — react Function Reference
Architecture documentation for the visitBlock() function in BuildReactiveFunction.ts from the react codebase.
Entity Profile
Dependency Diagram
graph TD 59c4bc0e_ec5f_af0c_d67c_d518b3f117bc["visitBlock()"] e20dc57f_069b_7065_293d_92b4bae116ae["Driver"] 59c4bc0e_ec5f_af0c_d67c_d518b3f117bc -->|defined in| e20dc57f_069b_7065_293d_92b4bae116ae de2e8e2f_72ef_875e_8240_38a6fb22ff0b["traverseBlock()"] de2e8e2f_72ef_875e_8240_38a6fb22ff0b -->|calls| 59c4bc0e_ec5f_af0c_d67c_d518b3f117bc de2e8e2f_72ef_875e_8240_38a6fb22ff0b["traverseBlock()"] 59c4bc0e_ec5f_af0c_d67c_d518b3f117bc -->|calls| de2e8e2f_72ef_875e_8240_38a6fb22ff0b 14cac00b_2abe_f917_5c8f_e34a72cd5047["emptyBlock()"] 59c4bc0e_ec5f_af0c_d67c_d518b3f117bc -->|calls| 14cac00b_2abe_f917_5c8f_e34a72cd5047 21ce7ec8_0512_fc1a_b5e4_cc6bfd19ca66["visitValueBlock()"] 59c4bc0e_ec5f_af0c_d67c_d518b3f117bc -->|calls| 21ce7ec8_0512_fc1a_b5e4_cc6bfd19ca66 94607a28_ed02_b0d5_72b8_7b074efdebad["valueBlockResultToSequence()"] 59c4bc0e_ec5f_af0c_d67c_d518b3f117bc -->|calls| 94607a28_ed02_b0d5_72b8_7b074efdebad f1ad8882_f4aa_8bed_3eb6_757cd4990fab["visitBreak()"] 59c4bc0e_ec5f_af0c_d67c_d518b3f117bc -->|calls| f1ad8882_f4aa_8bed_3eb6_757cd4990fab 69119c39_6bb5_7c2b_0712_73f7e045a58d["visitValueBlockTerminal()"] 59c4bc0e_ec5f_af0c_d67c_d518b3f117bc -->|calls| 69119c39_6bb5_7c2b_0712_73f7e045a58d 2b0607db_4995_18d7_b551_6ff462406377["visitContinue()"] 59c4bc0e_ec5f_af0c_d67c_d518b3f117bc -->|calls| 2b0607db_4995_18d7_b551_6ff462406377 041ca752_10c1_3cda_1f5c_02f44a01310e["invariant()"] 59c4bc0e_ec5f_af0c_d67c_d518b3f117bc -->|calls| 041ca752_10c1_3cda_1f5c_02f44a01310e 073c81a5_c389_d108_5b8f_4d6dc6eece83["push()"] 59c4bc0e_ec5f_af0c_d67c_d518b3f117bc -->|calls| 073c81a5_c389_d108_5b8f_4d6dc6eece83 1f49a9d5_b964_3a45_69a0_1b11206d9167["reachable()"] 59c4bc0e_ec5f_af0c_d67c_d518b3f117bc -->|calls| 1f49a9d5_b964_3a45_69a0_1b11206d9167 3211b3cf_7008_8b9d_08fc_eac57eabd5b2["isScheduled()"] 59c4bc0e_ec5f_af0c_d67c_d518b3f117bc -->|calls| 3211b3cf_7008_8b9d_08fc_eac57eabd5b2 216a1a94_c1bc_9d34_ed30_b8a6c02b0687["schedule()"] 59c4bc0e_ec5f_af0c_d67c_d518b3f117bc -->|calls| 216a1a94_c1bc_9d34_ed30_b8a6c02b0687 f51ff363_bceb_1d79_f026_ed2ca9638f21["unscheduleAll()"] 59c4bc0e_ec5f_af0c_d67c_d518b3f117bc -->|calls| f51ff363_bceb_1d79_f026_ed2ca9638f21 style 59c4bc0e_ec5f_af0c_d67c_d518b3f117bc fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/BuildReactiveFunction.ts lines 205–892
visitBlock(block: BasicBlock, blockValue: ReactiveBlock): void {
CompilerError.invariant(!this.cx.emitted.has(block.id), {
reason: `Cannot emit the same block twice: bb${block.id}`,
loc: GeneratedSource,
});
this.cx.emitted.add(block.id);
for (const instruction of block.instructions) {
blockValue.push({
kind: 'instruction',
instruction,
});
}
const terminal = block.terminal;
const scheduleIds = [];
switch (terminal.kind) {
case 'return': {
blockValue.push({
kind: 'terminal',
terminal: {
kind: 'return',
loc: terminal.loc,
value: terminal.value,
id: terminal.id,
},
label: null,
});
break;
}
case 'throw': {
blockValue.push({
kind: 'terminal',
terminal: {
kind: 'throw',
loc: terminal.loc,
value: terminal.value,
id: terminal.id,
},
label: null,
});
break;
}
case 'if': {
const fallthroughId =
this.cx.reachable(terminal.fallthrough) &&
!this.cx.isScheduled(terminal.fallthrough)
? terminal.fallthrough
: null;
const alternateId =
terminal.alternate !== terminal.fallthrough
? terminal.alternate
: null;
if (fallthroughId !== null) {
const scheduleId = this.cx.schedule(fallthroughId, 'if');
scheduleIds.push(scheduleId);
}
let consequent: ReactiveBlock | null = null;
if (this.cx.isScheduled(terminal.consequent)) {
CompilerError.invariant(false, {
reason: `Unexpected 'if' where the consequent is already scheduled`,
loc: terminal.loc,
});
} else {
consequent = this.traverseBlock(
this.cx.ir.blocks.get(terminal.consequent)!,
);
}
let alternate: ReactiveBlock | null = null;
if (alternateId !== null) {
if (this.cx.isScheduled(alternateId)) {
CompilerError.invariant(false, {
reason: `Unexpected 'if' where the alternate is already scheduled`,
loc: terminal.loc,
});
} else {
alternate = this.traverseBlock(this.cx.ir.blocks.get(alternateId)!);
}
}
Domain
Subdomains
Defined In
Calls
Called By
Source
Frequently Asked Questions
What does visitBlock() do?
visitBlock() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/BuildReactiveFunction.ts.
Where is visitBlock() defined?
visitBlock() is defined in compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/BuildReactiveFunction.ts at line 205.
What does visitBlock() call?
visitBlock() calls 16 function(s): assertExhaustive, emptyBlock, invariant, isScheduled, push, reachable, schedule, scheduleCatchHandler, and 8 more.
What calls visitBlock()?
visitBlock() is called by 1 function(s): traverseBlock.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free