Skip to content
Merged
Changes from 1 commit
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
Next Next commit
[compiler] Stop reusing ScopeDep type in AnalyzeFunctions
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-poisoned]
  • Loading branch information
josephsavona committed Aug 26, 2024
commit cf27fa19ae053cffcb358e45cc276c25cacbe68f
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