Skip to content

Commit 98d8290

Browse files
committed
Update on "[compiler] Add Identifier.declarationId"
Adds `Identifier.declarationId` and the new `DeclarationId` (simulated) opaque type. DeclarationId allows uniquely identifying a variable in the original source, ie regardless of reassignments. This allows us to stay in SSA form throughout compilation (see next diff) while still being able to distinguish SSA versions (via IdentifierId) and non-SSA versions (DeclarationId). [ghstack-poisoned]
2 parents bce8097 + 280dc56 commit 98d8290

4 files changed

Lines changed: 6 additions & 15 deletions

File tree

compiler/packages/babel-plugin-react-compiler/src/HIR/HIR.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1213,7 +1213,7 @@ export type ValidIdentifierName = string & {
12131213
[opaqueValidIdentifierName]: 'ValidIdentifierName';
12141214
};
12151215

1216-
export function makeTemporary(
1216+
export function makeTemporaryIdentifier(
12171217
id: IdentifierId,
12181218
loc: SourceLocation,
12191219
): Identifier {

compiler/packages/babel-plugin-react-compiler/src/HIR/HIRBuilder.ts

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import {
2828
makeDeclarationId,
2929
makeIdentifierName,
3030
makeInstructionId,
31-
makeTemporary,
31+
makeTemporaryIdentifier,
3232
makeType,
3333
} from './HIR';
3434
import {printInstruction} from './PrintHIR';
@@ -184,7 +184,7 @@ export default class HIRBuilder {
184184

185185
makeTemporary(loc: SourceLocation): Identifier {
186186
const id = this.nextIdentifierId;
187-
return makeTemporary(id, loc);
187+
return makeTemporaryIdentifier(id, loc);
188188
}
189189

190190
#resolveBabelBinding(
@@ -891,18 +891,9 @@ export function createTemporaryPlace(
891891
env: Environment,
892892
loc: SourceLocation,
893893
): Place {
894-
const id = env.nextIdentifierId;
895894
return {
896895
kind: 'Identifier',
897-
identifier: {
898-
id,
899-
declarationId: makeDeclarationId(id),
900-
mutableRange: {start: makeInstructionId(0), end: makeInstructionId(0)},
901-
name: null,
902-
scope: null,
903-
type: makeType(),
904-
loc,
905-
},
896+
identifier: makeTemporaryIdentifier(env.nextIdentifierId, loc),
906897
reactive: false,
907898
effect: Effect.Unknown,
908899
loc: GeneratedSource,

fixtures/flight/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"version": "0.1.0",
55
"private": true,
66
"devEngines": {
7-
"node": "20.x || 21.x"
7+
"node": "20.x || 22.x"
88
},
99
"dependencies": {
1010
"@babel/core": "^7.16.0",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103
"yargs": "^15.3.1"
104104
},
105105
"devEngines": {
106-
"node": "16.x || 18.x || 20.x || 21.x"
106+
"node": "16.x || 18.x || 20.x || 22.x"
107107
},
108108
"jest": {
109109
"testRegex": "/scripts/jest/dont-run-jest-directly\\.js$"

0 commit comments

Comments
 (0)