Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion compiler/packages/babel-plugin-react-compiler/src/HIR/HIR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1492,6 +1492,7 @@ export type ReactiveScopeDeclaration = {
scope: ReactiveScope; // the scope in which the variable was originally declared
};

export type DependencyPath = Array<{property: string; optional: boolean}>;
export type ReactiveScopeDependency = {
identifier: Identifier;
path: DependencyPath;
Expand All @@ -1506,7 +1507,21 @@ export function areEqualPaths(a: DependencyPath, b: DependencyPath): boolean {
)
);
}
export type DependencyPath = Array<{property: string; optional: boolean}>;

export function getPlaceScope(
id: InstructionId,
place: Place,
): ReactiveScope | null {
const scope = place.identifier.scope;
if (scope !== null && isScopeActive(scope, id)) {
return scope;
}
return null;
}

function isScopeActive(scope: ReactiveScope, id: InstructionId): boolean {
return id >= scope.range.start && id < scope.range.end;
}

/*
* Simulated opaque type for BlockIds to prevent using normal numbers as block ids
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
ReactiveScope,
makeInstructionId,
} from '.';
import {getPlaceScope} from '../ReactiveScopes/BuildReactiveBlocks';
import {getPlaceScope} from '../HIR/HIR';
import {isMutable} from '../ReactiveScopes/InferReactiveScopeVariables';
import DisjointSet from '../Utils/DisjointSet';
import {getOrInsertDefault} from '../Utils/utils';
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
MutableRange,
Place,
ReactiveScope,
getPlaceScope,
makeInstructionId,
} from '../HIR/HIR';
import {
Expand All @@ -23,7 +24,6 @@ import {
terminalFallthrough,
} from '../HIR/visitors';
import {retainWhere_Set} from '../Utils/utils';
import {getPlaceScope} from './BuildReactiveBlocks';

type InstructionRange = MutableRange;
/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
ReactiveScopeBlock,
ScopeId,
} from '../HIR';
import {getPlaceScope} from './BuildReactiveBlocks';
import {getPlaceScope} from '../HIR/HIR';
import {ReactiveFunctionVisitor} from './visitors';

/*
Expand Down
Loading