Skip to content

Commit 7b98a16

Browse files
committed
[compiler][cleanup] Delete now-unused reactive scope fork
Followup to #30891 ghstack-source-id: 6b42055 Pull Request resolved: #30892
1 parent 43264a6 commit 7b98a16

11 files changed

+20
-929
lines changed

compiler/packages/babel-plugin-react-compiler/src/HIR/HIR.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1492,6 +1492,7 @@ export type ReactiveScopeDeclaration = {
14921492
scope: ReactiveScope; // the scope in which the variable was originally declared
14931493
};
14941494

1495+
export type DependencyPath = Array<{property: string; optional: boolean}>;
14951496
export type ReactiveScopeDependency = {
14961497
identifier: Identifier;
14971498
path: DependencyPath;
@@ -1506,7 +1507,21 @@ export function areEqualPaths(a: DependencyPath, b: DependencyPath): boolean {
15061507
)
15071508
);
15081509
}
1509-
export type DependencyPath = Array<{property: string; optional: boolean}>;
1510+
1511+
export function getPlaceScope(
1512+
id: InstructionId,
1513+
place: Place,
1514+
): ReactiveScope | null {
1515+
const scope = place.identifier.scope;
1516+
if (scope !== null && isScopeActive(scope, id)) {
1517+
return scope;
1518+
}
1519+
return null;
1520+
}
1521+
1522+
function isScopeActive(scope: ReactiveScope, id: InstructionId): boolean {
1523+
return id >= scope.range.start && id < scope.range.end;
1524+
}
15101525

15111526
/*
15121527
* Simulated opaque type for BlockIds to prevent using normal numbers as block ids

compiler/packages/babel-plugin-react-compiler/src/HIR/MergeOverlappingReactiveScopesHIR.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
ReactiveScope,
66
makeInstructionId,
77
} from '.';
8-
import {getPlaceScope} from '../ReactiveScopes/BuildReactiveBlocks';
8+
import {getPlaceScope} from '../HIR/HIR';
99
import {isMutable} from '../ReactiveScopes/InferReactiveScopeVariables';
1010
import DisjointSet from '../Utils/DisjointSet';
1111
import {getOrInsertDefault} from '../Utils/utils';

compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/AlignReactiveScopesToBlockScopes.ts

Lines changed: 0 additions & 187 deletions
This file was deleted.

compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/AlignReactiveScopesToBlockScopesHIR.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
MutableRange,
1414
Place,
1515
ReactiveScope,
16+
getPlaceScope,
1617
makeInstructionId,
1718
} from '../HIR/HIR';
1819
import {
@@ -23,7 +24,6 @@ import {
2324
terminalFallthrough,
2425
} from '../HIR/visitors';
2526
import {retainWhere_Set} from '../Utils/utils';
26-
import {getPlaceScope} from './BuildReactiveBlocks';
2727

2828
type InstructionRange = MutableRange;
2929
/*

compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/AssertScopeInstructionsWithinScope.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
ReactiveScopeBlock,
1515
ScopeId,
1616
} from '../HIR';
17-
import {getPlaceScope} from './BuildReactiveBlocks';
17+
import {getPlaceScope} from '../HIR/HIR';
1818
import {ReactiveFunctionVisitor} from './visitors';
1919

2020
/*

0 commit comments

Comments
 (0)