Skip to content

Commit

Permalink
[compiler] Stop reusing ScopeDep type in AnalyzeFunctions
Browse files Browse the repository at this point in the history
AnalyzeFunctions was reusing the `ReactiveScopeDependency` type since it happened to have a convenient shape, but we need to change this type to represent optionality. We now use a locally defined type instead.

ghstack-source-id: e305c6ede4bcbdffce606336c572cdc6dc1556c3
Pull Request resolved: #30811
  • Loading branch information
josephsavona committed Aug 28, 2024
1 parent 7771d3a commit 5e51d76
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
IdentifierName,
LoweredFunction,
Place,
ReactiveScopeDependency,
isRefOrRefValue,
makeInstructionId,
} from '../HIR';
Expand All @@ -25,9 +24,14 @@ import {inferMutableContextVariables} from './InferMutableContextVariables';
import {inferMutableRanges} from './InferMutableRanges';
import inferReferenceEffects from './InferReferenceEffects';

type Dependency = {
identifier: Identifier;
path: Array<string>;
};

// Helper class to track indirections such as LoadLocal and PropertyLoad.
export class IdentifierState {
properties: Map<Identifier, ReactiveScopeDependency> = new Map();
properties: Map<Identifier, Dependency> = new Map();

resolve(identifier: Identifier): Identifier {
const resolved = this.properties.get(identifier);
Expand All @@ -39,7 +43,7 @@ export class IdentifierState {

declareProperty(lvalue: Place, object: Place, property: string): void {
const objectDependency = this.properties.get(object.identifier);
let nextDependency: ReactiveScopeDependency;
let nextDependency: Dependency;
if (objectDependency === undefined) {
nextDependency = {identifier: object.identifier, path: [property]};
} else {
Expand All @@ -52,9 +56,7 @@ export class IdentifierState {
}

declareTemporary(lvalue: Place, value: Place): void {
const resolved: ReactiveScopeDependency = this.properties.get(
value.identifier,
) ?? {
const resolved: Dependency = this.properties.get(value.identifier) ?? {
identifier: value.identifier,
path: [],
};
Expand Down

0 comments on commit 5e51d76

Please sign in to comment.