Skip to content

Commit ad41acf

Browse files
committed
Update on "[compiler] Implement support for hoisted and recursive functions"
Summary: Introduces a new binding kind for functions that allows them to be hoisted. Also has the result of causing all nested function declarations to be outputted as function declarations, not as let bindings. [ghstack-poisoned]
2 parents b308f2f + 067fbca commit ad41acf

File tree

283 files changed

+11225
-2718
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

283 files changed

+11225
-2718
lines changed

compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Pipeline.ts

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ import {propagatePhiTypes} from '../TypeInference/PropagatePhiTypes';
101101
import {lowerContextAccess} from '../Optimization/LowerContextAccess';
102102
import {validateNoSetStateInPassiveEffects} from '../Validation/ValidateNoSetStateInPassiveEffects';
103103
import {validateNoJSXInTryStatement} from '../Validation/ValidateNoJSXInTryStatement';
104+
import {propagateScopeDependenciesHIR} from '../HIR/PropagateScopeDependenciesHIR';
104105

105106
export type CompilerPipelineValue =
106107
| {kind: 'ast'; name: string; value: CodegenFunction}
@@ -341,6 +342,14 @@ function* runWithEnvironment(
341342
});
342343
assertTerminalSuccessorsExist(hir);
343344
assertTerminalPredsExist(hir);
345+
if (env.config.enablePropagateDepsInHIR) {
346+
propagateScopeDependenciesHIR(hir);
347+
yield log({
348+
kind: 'hir',
349+
name: 'PropagateScopeDependenciesHIR',
350+
value: hir,
351+
});
352+
}
344353

345354
const reactiveFunction = buildReactiveFunction(hir);
346355
yield log({
@@ -359,12 +368,14 @@ function* runWithEnvironment(
359368
});
360369
assertScopeInstructionsWithinScopes(reactiveFunction);
361370

362-
propagateScopeDependencies(reactiveFunction);
363-
yield log({
364-
kind: 'reactive',
365-
name: 'PropagateScopeDependencies',
366-
value: reactiveFunction,
367-
});
371+
if (!env.config.enablePropagateDepsInHIR) {
372+
propagateScopeDependencies(reactiveFunction);
373+
yield log({
374+
kind: 'reactive',
375+
name: 'PropagateScopeDependencies',
376+
value: reactiveFunction,
377+
});
378+
}
368379

369380
pruneNonEscapingScopes(reactiveFunction);
370381
yield log({

0 commit comments

Comments
 (0)