@samitouri / QOS-React-2 / commits / 29bb3f55a3

Rename IndexLoad/Store to ComputedLoad/Store

Hopefully a more clear name, these values correspond to computed properties.

Joe Savona committed Jan 3, 2023 at 17:03 UTC 29bb3f55a35ec906b3cdf37b7420a19eeaa375c1
8 files changed +21 -21
compiler/forget/src/HIR/BuildHIR.ts
+3 -3
@@ -1077,7 +1077,7 @@ function lowerExpression(
1077 );
1078 const propertyPlace = lowerExpressionToPlace(builder, property);
1079 value = {
1080 - kind: "IndexLoad",
1080 + kind: "ComputedLoad",
1081 object,
1082 property: propertyPlace,
1083 loc: exprLoc,
@@ -1423,7 +1423,7 @@ function lowerAssignment(
1423 );
1424 const propertyPlace = lowerExpressionToPlace(builder, property);
1425 return {
1426 - kind: "IndexStore",
1426 + kind: "ComputedStore",
1427 object,
1428 property: propertyPlace,
1429 value: valuePlace,
@@ -1465,7 +1465,7 @@ function lowerAssignment(
1465 loc: element.node.loc ?? GeneratedSource,
1466 });
1467 const value: InstructionValue = {
1468 - kind: "IndexLoad",
1468 + kind: "ComputedLoad",
1469 loc,
1470 object: { ...arrayPlace },
1471 property,
compiler/forget/src/HIR/Codegen.ts
+2 -2
@@ -473,7 +473,7 @@ export function codegenInstructionValue(
473 );
474 break;
475 }
476 - case "IndexStore": {
476 + case "ComputedStore": {
477 value = t.assignmentExpression(
478 "=",
479 t.memberExpression(
@@ -485,7 +485,7 @@ export function codegenInstructionValue(
485 );
486 break;
487 }
488 - case "IndexLoad": {
488 + case "ComputedLoad": {
489 value = t.memberExpression(
490 codegenPlace(temp, instrValue.object),
491 codegenPlace(temp, instrValue.property),
compiler/forget/src/HIR/HIR.ts
+2 -2
@@ -299,9 +299,9 @@ export type InstructionData =
299 | { kind: "PropertyLoad"; object: Place; property: string }
300
301 // store `object[index] = value` - like PropertyStore but with a dynamic property
302 - | { kind: "IndexStore"; object: Place; property: Place; value: Place }
302 + | { kind: "ComputedStore"; object: Place; property: Place; value: Place }
303 // load `object[index]` - like PropertyLoad but with a dynamic property
304 - | { kind: "IndexLoad"; object: Place; property: Place }
304 + | { kind: "ComputedLoad"; object: Place; property: Place }
305
306 /**
307 * Catch-all for statements such as type imports, nested class declarations, etc
compiler/forget/src/HIR/InferReferenceEffects.ts
+2 -2
@@ -607,7 +607,7 @@ function inferBlock(env: Environment, block: BasicBlock) {
607 }
608 continue;
609 }
610 - case "IndexStore": {
610 + case "ComputedStore": {
611 const effect = isObjectType(instrValue.object.identifier)
612 ? Effect.Store
613 : Effect.Mutate;
@@ -622,7 +622,7 @@ function inferBlock(env: Environment, block: BasicBlock) {
622 }
623 continue;
624 }
625 - case "IndexLoad": {
625 + case "ComputedLoad": {
626 if (!env.isDefined(instrValue.object)) {
627 // TODO @josephsavona: improve handling of globals
628 const value: InstructionValue = {
compiler/forget/src/HIR/PrintHIR.ts
+4 -4
@@ -277,14 +277,14 @@ export function printInstructionValue(instrValue: InstructionValue): string {
277 } = ${printPlace(instrValue.value)}`;
278 break;
279 }
280 - case "IndexLoad": {
281 - value = `IndexLoad ${printPlace(instrValue.object)}[${printPlace(
280 + case "ComputedLoad": {
281 + value = `ComputedLoad ${printPlace(instrValue.object)}[${printPlace(
282 instrValue.property
283 )}]`;
284 break;
285 }
286 - case "IndexStore": {
287 - value = `IndexStore ${printPlace(instrValue.object)}[${printPlace(
286 + case "ComputedStore": {
287 + value = `ComputedStore ${printPlace(instrValue.object)}[${printPlace(
288 instrValue.property
289 )}] = ${printPlace(instrValue.value)}`;
290 break;
compiler/forget/src/HIR/visitors.ts
+4 -4
@@ -50,12 +50,12 @@ export function* eachInstructionValueOperand(
50 yield instrValue.value;
51 break;
52 }
53 - case "IndexLoad": {
53 + case "ComputedLoad": {
54 yield instrValue.object;
55 yield instrValue.property;
56 break;
57 }
58 - case "IndexStore": {
58 + case "ComputedStore": {
59 yield instrValue.object;
60 yield instrValue.property;
61 yield instrValue.value;
@@ -121,12 +121,12 @@ export function mapInstructionOperands(
121 instrValue.value = fn(instrValue.value);
122 break;
123 }
124 - case "IndexLoad": {
124 + case "ComputedLoad": {
125 instrValue.object = fn(instrValue.object);
126 instrValue.property = fn(instrValue.property);
127 break;
128 }
129 - case "IndexStore": {
129 + case "ComputedStore": {
130 instrValue.object = fn(instrValue.object);
131 instrValue.property = fn(instrValue.property);
132 instrValue.value = fn(instrValue.value);
compiler/forget/src/ReactiveScopes/InferReactiveScopeVariables.ts
+2 -2
@@ -161,13 +161,13 @@ function mayAllocate(value: InstructionValue): boolean {
161 case "BinaryExpression":
162 case "Identifier":
163 case "PropertyLoad":
164 - case "IndexLoad":
164 + case "ComputedLoad":
165 case "JSXText":
166 case "Primitive": {
167 return false;
168 }
169 case "PropertyStore":
170 - case "IndexStore":
170 + case "ComputedStore":
171 case "ArrayExpression":
172 case "CallExpression":
173 case "JsxExpression":
compiler/forget/src/ReactiveScopes/PropagateScopeDependencies.ts
+2 -2
@@ -302,8 +302,8 @@ function valueKind(value: InstructionValue): DeclKind {
302 case "Primitive": {
303 return DeclKind.Const;
304 }
305 - case "IndexLoad":
306 - case "IndexStore":
305 + case "ComputedLoad":
306 + case "ComputedStore":
307 case "PropertyStore":
308 case "PropertyLoad":
309 case "Identifier":