11
visitReactiveFunction,
12
} from ".";
13
import {
14
- IdentifierId,
14
+ Identifier,
15
ReactiveFunction,
16
ReactiveInstruction,
17
ReactiveScopeBlock,
33
}
34
35
class Transform extends ReactiveFunctionTransform<boolean> {
36
- alwaysInvalidatingValues: Set<IdentifierId> = new Set();
37
- unmemoizedValues: Set<IdentifierId> = new Set();
36
+ alwaysInvalidatingValues: Set<Identifier> = new Set();
37
+ unmemoizedValues: Set<Identifier> = new Set();
38
39
override transformInstruction(
40
instruction: ReactiveInstruction,
50
case "JsxFragment":
51
case "NewExpression": {
52
if (lvalue !== null) {
53
- this.alwaysInvalidatingValues.add(lvalue.identifier.id);
53
+ this.alwaysInvalidatingValues.add(lvalue.identifier);
54
if (!withinScope) {
55
- this.unmemoizedValues.add(lvalue.identifier.id);
55
+ this.unmemoizedValues.add(lvalue.identifier);
56
}
57
}
58
break;
59
}
60
case "StoreLocal": {
61
- if (this.alwaysInvalidatingValues.has(value.value.identifier.id)) {
62
- this.alwaysInvalidatingValues.add(value.lvalue.place.identifier.id);
61
+ if (this.alwaysInvalidatingValues.has(value.value.identifier)) {
62
+ this.alwaysInvalidatingValues.add(value.lvalue.place.identifier);
63
}
64
- if (this.unmemoizedValues.has(value.value.identifier.id)) {
65
- this.unmemoizedValues.add(value.lvalue.place.identifier.id);
64
+ if (this.unmemoizedValues.has(value.value.identifier)) {
65
+ this.unmemoizedValues.add(value.lvalue.place.identifier);
66
}
67
break;
68
}
69
case "LoadLocal": {
70
if (
71
lvalue !== null &&
72
- this.alwaysInvalidatingValues.has(value.place.identifier.id)
72
+ this.alwaysInvalidatingValues.has(value.place.identifier)
73
) {
74
- this.alwaysInvalidatingValues.add(lvalue.identifier.id);
74
+ this.alwaysInvalidatingValues.add(lvalue.identifier);
75
}
76
if (
77
lvalue !== null &&
78
- this.unmemoizedValues.has(value.place.identifier.id)
78
+ this.unmemoizedValues.has(value.place.identifier)
79
) {
80
- this.unmemoizedValues.add(lvalue.identifier.id);
80
+ this.unmemoizedValues.add(lvalue.identifier);
81
}
82
break;
83
}
92
this.visitScope(scopeBlock, true);
93
94
for (const dep of scopeBlock.scope.dependencies) {
95
- if (this.unmemoizedValues.has(dep.identifier.id)) {
95
+ if (this.unmemoizedValues.has(dep.identifier)) {
96
/*
97
* This scope depends on an always-invalidating value so the scope will always invalidate:
98
* prune it to avoid wasted comparisons
99
*/
100
- for (const [id, _decl] of scopeBlock.scope.declarations) {
101
- if (this.alwaysInvalidatingValues.has(id)) {
102
- this.unmemoizedValues.add(id);
100
+ for (const [_, decl] of scopeBlock.scope.declarations) {
101
+ if (this.alwaysInvalidatingValues.has(decl.identifier)) {
102
+ this.unmemoizedValues.add(decl.identifier);
103
}
104
}
105
for (const identifier of scopeBlock.scope.reassignments) {
106
- if (this.alwaysInvalidatingValues.has(identifier.id)) {
107
- this.unmemoizedValues.add(identifier.id);
106
+ if (this.alwaysInvalidatingValues.has(identifier)) {
107
+ this.unmemoizedValues.add(identifier);
108
}
109
}
110
return { kind: "replace-many", value: scopeBlock.instructions };