From 29bb3f55a35ec906b3cdf37b7420a19eeaa375c1 Mon Sep 17 00:00:00 2001 From: Joe Savona Date: Tue, 3 Jan 2023 17:03:45 -0800 Subject: [PATCH] Rename IndexLoad/Store to ComputedLoad/Store Hopefully a more clear name, these values correspond to computed properties. --- compiler/forget/src/HIR/BuildHIR.ts | 6 +++--- compiler/forget/src/HIR/Codegen.ts | 4 ++-- compiler/forget/src/HIR/HIR.ts | 4 ++-- compiler/forget/src/HIR/InferReferenceEffects.ts | 4 ++-- compiler/forget/src/HIR/PrintHIR.ts | 8 ++++---- compiler/forget/src/HIR/visitors.ts | 8 ++++---- .../src/ReactiveScopes/InferReactiveScopeVariables.ts | 4 ++-- .../src/ReactiveScopes/PropagateScopeDependencies.ts | 4 ++-- 8 files changed, 21 insertions(+), 21 deletions(-) diff --git a/compiler/forget/src/HIR/BuildHIR.ts b/compiler/forget/src/HIR/BuildHIR.ts index 7ccabcac1d..7a76dc2213 100644 --- a/compiler/forget/src/HIR/BuildHIR.ts +++ b/compiler/forget/src/HIR/BuildHIR.ts @@ -1077,7 +1077,7 @@ function lowerExpression( ); const propertyPlace = lowerExpressionToPlace(builder, property); value = { - kind: "IndexLoad", + kind: "ComputedLoad", object, property: propertyPlace, loc: exprLoc, @@ -1423,7 +1423,7 @@ function lowerAssignment( ); const propertyPlace = lowerExpressionToPlace(builder, property); return { - kind: "IndexStore", + kind: "ComputedStore", object, property: propertyPlace, value: valuePlace, @@ -1465,7 +1465,7 @@ function lowerAssignment( loc: element.node.loc ?? GeneratedSource, }); const value: InstructionValue = { - kind: "IndexLoad", + kind: "ComputedLoad", loc, object: { ...arrayPlace }, property, diff --git a/compiler/forget/src/HIR/Codegen.ts b/compiler/forget/src/HIR/Codegen.ts index d843b649a1..c792461792 100644 --- a/compiler/forget/src/HIR/Codegen.ts +++ b/compiler/forget/src/HIR/Codegen.ts @@ -473,7 +473,7 @@ export function codegenInstructionValue( ); break; } - case "IndexStore": { + case "ComputedStore": { value = t.assignmentExpression( "=", t.memberExpression( @@ -485,7 +485,7 @@ export function codegenInstructionValue( ); break; } - case "IndexLoad": { + case "ComputedLoad": { value = t.memberExpression( codegenPlace(temp, instrValue.object), codegenPlace(temp, instrValue.property), diff --git a/compiler/forget/src/HIR/HIR.ts b/compiler/forget/src/HIR/HIR.ts index b671f056ec..6d26f5a61a 100644 --- a/compiler/forget/src/HIR/HIR.ts +++ b/compiler/forget/src/HIR/HIR.ts @@ -299,9 +299,9 @@ export type InstructionData = | { kind: "PropertyLoad"; object: Place; property: string } // store `object[index] = value` - like PropertyStore but with a dynamic property - | { kind: "IndexStore"; object: Place; property: Place; value: Place } + | { kind: "ComputedStore"; object: Place; property: Place; value: Place } // load `object[index]` - like PropertyLoad but with a dynamic property - | { kind: "IndexLoad"; object: Place; property: Place } + | { kind: "ComputedLoad"; object: Place; property: Place } /** * Catch-all for statements such as type imports, nested class declarations, etc diff --git a/compiler/forget/src/HIR/InferReferenceEffects.ts b/compiler/forget/src/HIR/InferReferenceEffects.ts index a929eb1599..685265fc3a 100644 --- a/compiler/forget/src/HIR/InferReferenceEffects.ts +++ b/compiler/forget/src/HIR/InferReferenceEffects.ts @@ -607,7 +607,7 @@ function inferBlock(env: Environment, block: BasicBlock) { } continue; } - case "IndexStore": { + case "ComputedStore": { const effect = isObjectType(instrValue.object.identifier) ? Effect.Store : Effect.Mutate; @@ -622,7 +622,7 @@ function inferBlock(env: Environment, block: BasicBlock) { } continue; } - case "IndexLoad": { + case "ComputedLoad": { if (!env.isDefined(instrValue.object)) { // TODO @josephsavona: improve handling of globals const value: InstructionValue = { diff --git a/compiler/forget/src/HIR/PrintHIR.ts b/compiler/forget/src/HIR/PrintHIR.ts index 46e0b04870..040482543a 100644 --- a/compiler/forget/src/HIR/PrintHIR.ts +++ b/compiler/forget/src/HIR/PrintHIR.ts @@ -277,14 +277,14 @@ export function printInstructionValue(instrValue: InstructionValue): string { } = ${printPlace(instrValue.value)}`; break; } - case "IndexLoad": { - value = `IndexLoad ${printPlace(instrValue.object)}[${printPlace( + case "ComputedLoad": { + value = `ComputedLoad ${printPlace(instrValue.object)}[${printPlace( instrValue.property )}]`; break; } - case "IndexStore": { - value = `IndexStore ${printPlace(instrValue.object)}[${printPlace( + case "ComputedStore": { + value = `ComputedStore ${printPlace(instrValue.object)}[${printPlace( instrValue.property )}] = ${printPlace(instrValue.value)}`; break; diff --git a/compiler/forget/src/HIR/visitors.ts b/compiler/forget/src/HIR/visitors.ts index 8bf81c821c..97711d4b59 100644 --- a/compiler/forget/src/HIR/visitors.ts +++ b/compiler/forget/src/HIR/visitors.ts @@ -50,12 +50,12 @@ export function* eachInstructionValueOperand( yield instrValue.value; break; } - case "IndexLoad": { + case "ComputedLoad": { yield instrValue.object; yield instrValue.property; break; } - case "IndexStore": { + case "ComputedStore": { yield instrValue.object; yield instrValue.property; yield instrValue.value; @@ -121,12 +121,12 @@ export function mapInstructionOperands( instrValue.value = fn(instrValue.value); break; } - case "IndexLoad": { + case "ComputedLoad": { instrValue.object = fn(instrValue.object); instrValue.property = fn(instrValue.property); break; } - case "IndexStore": { + case "ComputedStore": { instrValue.object = fn(instrValue.object); instrValue.property = fn(instrValue.property); instrValue.value = fn(instrValue.value); diff --git a/compiler/forget/src/ReactiveScopes/InferReactiveScopeVariables.ts b/compiler/forget/src/ReactiveScopes/InferReactiveScopeVariables.ts index a8435b261e..3f674ae152 100644 --- a/compiler/forget/src/ReactiveScopes/InferReactiveScopeVariables.ts +++ b/compiler/forget/src/ReactiveScopes/InferReactiveScopeVariables.ts @@ -161,13 +161,13 @@ function mayAllocate(value: InstructionValue): boolean { case "BinaryExpression": case "Identifier": case "PropertyLoad": - case "IndexLoad": + case "ComputedLoad": case "JSXText": case "Primitive": { return false; } case "PropertyStore": - case "IndexStore": + case "ComputedStore": case "ArrayExpression": case "CallExpression": case "JsxExpression": diff --git a/compiler/forget/src/ReactiveScopes/PropagateScopeDependencies.ts b/compiler/forget/src/ReactiveScopes/PropagateScopeDependencies.ts index 172ab29dba..5f3a4440c3 100644 --- a/compiler/forget/src/ReactiveScopes/PropagateScopeDependencies.ts +++ b/compiler/forget/src/ReactiveScopes/PropagateScopeDependencies.ts @@ -302,8 +302,8 @@ function valueKind(value: InstructionValue): DeclKind { case "Primitive": { return DeclKind.Const; } - case "IndexLoad": - case "IndexStore": + case "ComputedLoad": + case "ComputedStore": case "PropertyStore": case "PropertyLoad": case "Identifier":