From 7cf36c65fa3d8515b93177201520d0dfed48596b Mon Sep 17 00:00:00 2001 From: Sathya Gunsasekaran Date: Fri, 2 Aug 2024 19:26:43 +0100 Subject: [PATCH] [compiler] Refactor createTemporaryPlace Update createTemporaryPlace to use makeTemporary and also rename makeTemporary to makeTemporaryIdentifier to make it less ambiguous. [ghstack-poisoned] --- .../babel-plugin-react-compiler/src/HIR/HIR.ts | 2 +- .../src/HIR/HIRBuilder.ts | 13 +++---------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/compiler/packages/babel-plugin-react-compiler/src/HIR/HIR.ts b/compiler/packages/babel-plugin-react-compiler/src/HIR/HIR.ts index f0ada2d3708..fa7b4622633 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/HIR/HIR.ts +++ b/compiler/packages/babel-plugin-react-compiler/src/HIR/HIR.ts @@ -1205,7 +1205,7 @@ export type ValidIdentifierName = string & { [opaqueValidIdentifierName]: 'ValidIdentifierName'; }; -export function makeTemporary( +export function makeTemporaryIdentifier( id: IdentifierId, loc: SourceLocation, ): Identifier { diff --git a/compiler/packages/babel-plugin-react-compiler/src/HIR/HIRBuilder.ts b/compiler/packages/babel-plugin-react-compiler/src/HIR/HIRBuilder.ts index 890a27f4d4c..6badff5b297 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/HIR/HIRBuilder.ts +++ b/compiler/packages/babel-plugin-react-compiler/src/HIR/HIRBuilder.ts @@ -27,7 +27,7 @@ import { makeBlockId, makeIdentifierName, makeInstructionId, - makeTemporary, + makeTemporaryIdentifier, makeType, } from './HIR'; import {printInstruction} from './PrintHIR'; @@ -183,7 +183,7 @@ export default class HIRBuilder { makeTemporary(loc: SourceLocation): Identifier { const id = this.nextIdentifierId; - return makeTemporary(id, loc); + return makeTemporaryIdentifier(id, loc); } #resolveBabelBinding( @@ -891,14 +891,7 @@ export function createTemporaryPlace( ): Place { return { kind: 'Identifier', - identifier: { - id: env.nextIdentifierId, - mutableRange: {start: makeInstructionId(0), end: makeInstructionId(0)}, - name: null, - scope: null, - type: makeType(), - loc, - }, + identifier: makeTemporaryIdentifier(env.nextIdentifierId, loc), reactive: false, effect: Effect.Unknown, loc: GeneratedSource,