generate() — react Function Reference
Architecture documentation for the generate() function in InferTypes.ts from the react codebase.
Entity Profile
Dependency Diagram
graph TD da9b080c_d617_2a0e_a938_61a002d496d9["generate()"] 35147ed6_ce97_e85f_570c_faf2d25f42f4["InferTypes.ts"] da9b080c_d617_2a0e_a938_61a002d496d9 -->|defined in| 35147ed6_ce97_e85f_570c_faf2d25f42f4 fafa4e35_d1bd_5163_9aea_72cb4d1742f3["inferTypes()"] fafa4e35_d1bd_5163_9aea_72cb4d1742f3 -->|calls| da9b080c_d617_2a0e_a938_61a002d496d9 b282c6e8_cb4e_aa17_9bb5_f36ea62991f4["generateInstructionTypes()"] b282c6e8_cb4e_aa17_9bb5_f36ea62991f4 -->|calls| da9b080c_d617_2a0e_a938_61a002d496d9 2e348290_df23_74fb_f3d0_6d6f275d86e1["equation()"] da9b080c_d617_2a0e_a938_61a002d496d9 -->|calls| 2e348290_df23_74fb_f3d0_6d6f275d86e1 b282c6e8_cb4e_aa17_9bb5_f36ea62991f4["generateInstructionTypes()"] da9b080c_d617_2a0e_a938_61a002d496d9 -->|calls| b282c6e8_cb4e_aa17_9bb5_f36ea62991f4 073c81a5_c389_d108_5b8f_4d6dc6eece83["push()"] da9b080c_d617_2a0e_a938_61a002d496d9 -->|calls| 073c81a5_c389_d108_5b8f_4d6dc6eece83 style da9b080c_d617_2a0e_a938_61a002d496d9 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
compiler/packages/babel-plugin-react-compiler/src/TypeInference/InferTypes.ts lines 113–158
function* generate(
func: HIRFunction,
): Generator<TypeEquation, void, undefined> {
if (func.fnType === 'Component') {
const [props, ref] = func.params;
if (props && props.kind === 'Identifier') {
yield equation(props.identifier.type, {
kind: 'Object',
shapeId: BuiltInPropsId,
});
}
if (ref && ref.kind === 'Identifier') {
yield equation(ref.identifier.type, {
kind: 'Object',
shapeId: BuiltInUseRefId,
});
}
}
const names = new Map();
const returnTypes: Array<Type> = [];
for (const [_, block] of func.body.blocks) {
for (const phi of block.phis) {
yield equation(phi.place.identifier.type, {
kind: 'Phi',
operands: [...phi.operands.values()].map(id => id.identifier.type),
});
}
for (const instr of block.instructions) {
yield* generateInstructionTypes(func.env, names, instr);
}
const terminal = block.terminal;
if (terminal.kind === 'return') {
returnTypes.push(terminal.value.identifier.type);
}
}
if (returnTypes.length > 1) {
yield equation(func.returns.identifier.type, {
kind: 'Phi',
operands: returnTypes,
});
} else if (returnTypes.length === 1) {
yield equation(func.returns.identifier.type, returnTypes[0]!);
}
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does generate() do?
generate() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/TypeInference/InferTypes.ts.
Where is generate() defined?
generate() is defined in compiler/packages/babel-plugin-react-compiler/src/TypeInference/InferTypes.ts at line 113.
What does generate() call?
generate() calls 3 function(s): equation, generateInstructionTypes, push.
What calls generate()?
generate() is called by 2 function(s): generateInstructionTypes, inferTypes.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free