[be] Rename NextIterableOf -> AdvanceIterator
ghstack-source-id: 024ec00511483cf342d851fde001c96348a2d3c6 Pull Request resolved: https://github.com/facebook/react-forget/pull/2898
Joe Savona committed
Apr 24, 2024 at 14:59 UTC
08b777d6dc0c1261d344e7807738ffc0a7794c7c
10 files changed
+18
-18
compiler/packages/babel-plugin-react-forget/src/HIR/BuildHIR.ts
+5
-5
@@ -1070,8 +1070,8 @@ function lowerStatement(
1070
suggestions: null,
1071
});
1072
const id = declarations[0].get("id");
1073
- const nextIterableOf = lowerValueToTemporary(builder, {
1074
- kind: "NextIterableOf",
1073
+ const advanceIterator = lowerValueToTemporary(builder, {
1074
+ kind: "IteratorNext",
1075
loc: leftLoc,
1076
iterator: { ...iterator },
1077
collection: { ...value },
@@ -1081,7 +1081,7 @@ function lowerStatement(
1081
leftLoc,
1082
InstructionKind.Let,
1083
id,
1084
- nextIterableOf,
1084
+ advanceIterator,
1085
"Assignment"
1086
);
1087
test = lowerValueToTemporary(builder, assign);
@@ -1157,7 +1157,7 @@ function lowerStatement(
1157
suggestions: null,
1158
});
1159
const id = declarations[0].get("id");
1160
- const nextIterableOf = lowerValueToTemporary(builder, {
1160
+ const nextPropertyTemp = lowerValueToTemporary(builder, {
1161
kind: "NextPropertyOf",
1162
loc: leftLoc,
1163
value,
@@ -1167,7 +1167,7 @@ function lowerStatement(
1167
leftLoc,
1168
InstructionKind.Let,
1169
id,
1170
- nextIterableOf,
1170
+ nextPropertyTemp,
1171
"Assignment"
1172
);
1173
test = lowerValueToTemporary(builder, assign);
compiler/packages/babel-plugin-react-forget/src/HIR/HIR.ts
+1
-1
@@ -964,7 +964,7 @@ export type InstructionValue =
964
loc: SourceLocation;
965
}
966
| {
967
- kind: "NextIterableOf";
967
+ kind: "IteratorNext";
968
iterator: Place; // the iterator created with GetIterator
969
collection: Place; // the collection being iterated over (which may be an iterable or iterator)
970
loc: SourceLocation;
compiler/packages/babel-plugin-react-forget/src/HIR/PrintHIR.ts
+2
-2
@@ -613,8 +613,8 @@ export function printInstructionValue(instrValue: ReactiveValue): string {
613
value = `GetIterator collection=${printPlace(instrValue.collection)}`;
614
break;
615
}
616
- case "NextIterableOf": {
617
- value = `NextIterableOf iterator=${printPlace(
616
+ case "IteratorNext": {
617
+ value = `IteratorNext iterator=${printPlace(
618
instrValue.iterator
619
)} collection=${printPlace(instrValue.collection)}`;
620
break;
compiler/packages/babel-plugin-react-forget/src/HIR/visitors.ts
+2
-2
@@ -212,7 +212,7 @@ export function* eachInstructionValueOperand(
212
yield instrValue.collection;
213
break;
214
}
215
- case "NextIterableOf": {
215
+ case "IteratorNext": {
216
yield instrValue.iterator;
217
yield instrValue.collection;
218
break;
@@ -536,7 +536,7 @@ export function mapInstructionValueOperands(
536
instrValue.collection = fn(instrValue.collection);
537
break;
538
}
539
- case "NextIterableOf": {
539
+ case "IteratorNext": {
540
instrValue.iterator = fn(instrValue.iterator);
541
instrValue.collection = fn(instrValue.collection);
542
break;
compiler/packages/babel-plugin-react-forget/src/Inference/InferReferenceEffects.ts
+2
-2
@@ -1824,7 +1824,7 @@ function inferBlock(
1824
* as props to a component and then for..of over that in the component body, but
1825
* this already violates React's rules so we assume you're not doing this.
1826
* 2. The collection could be an Iterator itself, such that advancing the iterator
1827
- * (modeled with NextIterableOf) mutates the collection itself.
1827
+ * (modeled with IteratorNext) mutates the collection itself.
1828
*/
1829
const kind = state.kind(instrValue.collection).kind;
1830
const isMutable =
@@ -1851,7 +1851,7 @@ function inferBlock(
1851
lvalueEffect = Effect.Store;
1852
break;
1853
}
1854
- case "NextIterableOf": {
1854
+ case "IteratorNext": {
1855
/**
1856
* This instruction represents advancing an iterator with .next(). We use a
1857
* conditional mutate to model the two cases for GetIterator:
compiler/packages/babel-plugin-react-forget/src/Optimization/DeadCodeElimination.ts
+2
-2
@@ -327,9 +327,9 @@ function pruneableValue(value: InstructionValue, state: State): boolean {
327
}
328
case "GetIterator":
329
case "NextPropertyOf":
330
- case "NextIterableOf": {
330
+ case "IteratorNext": {
331
/*
332
- * Technically a NextIterableOf/NextPropertyOf will never be unused because it's
332
+ * Technically a IteratorNext/NextPropertyOf will never be unused because it's
333
* always used later by another StoreLocal or Destructure instruction, but conceptually
334
* we can't prune
335
*/
compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/CodegenReactiveFunction.ts
+1
-1
@@ -1856,7 +1856,7 @@ function codegenInstructionValue(
1856
value = codegenPlaceToExpression(cx, instrValue.collection);
1857
break;
1858
}
1859
- case "NextIterableOf": {
1859
+ case "IteratorNext": {
1860
value = codegenPlaceToExpression(cx, instrValue.iterator);
1861
break;
1862
}
compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/InferReactiveScopeVariables.ts
+1
-1
@@ -189,7 +189,7 @@ function mayAllocate(env: Environment, instruction: Instruction): boolean {
189
case "TemplateLiteral":
190
case "Primitive":
191
case "GetIterator":
192
- case "NextIterableOf":
192
+ case "IteratorNext":
193
case "NextPropertyOf":
194
case "Debugger":
195
case "StartMemoize":
compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/PruneNonEscapingScopes.ts
+1
-1
@@ -484,7 +484,7 @@ function computeMemoizationInputs(
484
rvalues: [value.value],
485
};
486
}
487
- case "NextIterableOf": {
487
+ case "IteratorNext": {
488
return {
489
// Indirection for the inner value, memoized if the value is
490
lvalues:
compiler/packages/babel-plugin-react-forget/src/TypeInference/InferTypes.ts
+1
-1
@@ -338,7 +338,7 @@ function* generateInstructionTypes(
338
case "TaggedTemplateExpression":
339
case "Await":
340
case "GetIterator":
341
- case "NextIterableOf":
341
+ case "IteratorNext":
342
case "UnsupportedNode":
343
case "Debugger":
344
case "FinishMemoize":