mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Scaffolding for LoadGlobal instruction
Adds a new `LoadGlobal` InstructionValue variant which will be used to represent identifiers that refer to globals. We don't construct this value type yet.
This commit is contained in:
@@ -442,6 +442,7 @@ export type InstructionData =
|
||||
| { kind: "ComputedStore"; object: Place; property: Place; value: Place }
|
||||
// load `object[index]` - like PropertyLoad but with a dynamic property
|
||||
| { kind: "ComputedLoad"; object: Place; property: Place }
|
||||
| { kind: "LoadGlobal"; name: string }
|
||||
| FunctionExpression
|
||||
| {
|
||||
kind: "TaggedTemplateExpression";
|
||||
|
||||
@@ -381,6 +381,10 @@ export function printInstructionValue(instrValue: ReactiveValue): string {
|
||||
value += instrValue.quasis.at(-1)!.raw + "`";
|
||||
break;
|
||||
}
|
||||
case "LoadGlobal": {
|
||||
value = `Global ${instrValue.name}`;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
assertExhaustive(
|
||||
instrValue,
|
||||
|
||||
@@ -131,6 +131,7 @@ export function* eachInstructionValueOperand(
|
||||
yield* instrValue.subexprs;
|
||||
break;
|
||||
}
|
||||
case "LoadGlobal":
|
||||
case "UnsupportedNode":
|
||||
case "Primitive":
|
||||
case "JSXText": {
|
||||
@@ -259,6 +260,7 @@ export function mapInstructionOperands(
|
||||
instrValue.subexprs = instrValue.subexprs.map(fn);
|
||||
break;
|
||||
}
|
||||
case "LoadGlobal":
|
||||
case "UnsupportedNode":
|
||||
case "Primitive":
|
||||
case "JSXText": {
|
||||
|
||||
@@ -640,6 +640,7 @@ function inferBlock(
|
||||
effectKind = Effect.Read;
|
||||
break;
|
||||
}
|
||||
case "LoadGlobal":
|
||||
case "JSXText":
|
||||
case "Primitive": {
|
||||
valueKind = ValueKind.Immutable;
|
||||
|
||||
@@ -94,6 +94,7 @@ function pruneableValue(value: InstructionValue): boolean {
|
||||
// Potentially safe to prune, since they should just be creating new values
|
||||
return false;
|
||||
}
|
||||
case "LoadGlobal":
|
||||
case "ArrayExpression":
|
||||
case "BinaryExpression":
|
||||
case "ComputedLoad":
|
||||
|
||||
@@ -788,6 +788,10 @@ function codegenInstructionValue(
|
||||
);
|
||||
break;
|
||||
}
|
||||
case "LoadGlobal": {
|
||||
value = t.identifier(instrValue.name);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
assertExhaustive(
|
||||
instrValue,
|
||||
|
||||
@@ -168,6 +168,7 @@ function isMutable({ id }: Instruction, place: Place): boolean {
|
||||
|
||||
function mayAllocate(value: InstructionValue): boolean {
|
||||
switch (value.kind) {
|
||||
case "LoadGlobal":
|
||||
case "TypeCastExpression":
|
||||
case "BinaryExpression":
|
||||
case "Identifier":
|
||||
|
||||
Reference in New Issue
Block a user