[RFC] Stabilize naming of promoted temporaries

When the compiler promotes temporary values to named variables, we currently 
eagerly assign a name using the temporary's IdentifierId. This means that we're 
sort of stuck with this name later in compilation, and RenameVariables can't be 
100% sure whether a 't0' variable is a temporary or not. As a result, the names 
of these promoted temporaries is influenced by how many temporaries we happened 
to create during compilation (and what the next available identifier id was), 
making them fluctuate more as we iterate on the compiler. 

This is an RFC for showing how we can stabilize these names. The key elements: 

* Distinguish promoted temporaries from other named identifiers. Here we use a 
hack, naming them starting with '#t' or '#T', since '#' isn't a valid identifier 
starting point. This lets us keep all of our logic that looks for non-null 
identifiers names to distinguish named/unnamed, while also distinguishing real 
names from generated names (if this was Rust, we'd use an Enum and have a 
"isNamed()" method on it that was true for real/temporary names and false 
otherwise) 

* In RenameVariables, detect generated names and fall back to generating the 
next available `tN`-style name (or `TN` for JSX tags). 

* To reduce thrash overall, RenameVariables no longer keeps a global "next id" 
value that uses to distinguish all conflicting identifiers, instead we restart 
at 0 whenever we find a conflict, and keep bumping until we find a free name. 
Thus if both `foo` and `bar` had conflicts, we previously would end up with 
`foo$0` and `bar$1` as the deduped names, but now will end up with `foo$0` and 
`bar$0`. 

## RFC 

I'm open to feedback on the approach. Two main questions: 

* How to annotate promoted temporaries. The most type-safe option is to change 
`Identifier.name` to be a union of `{kind: 'named', value: string} | `{kind: 
'promoted', value: string} | `{kind: 'temporary'}` though TS then wouldn't allow 
`identifier.name.value` (even as nullable) since it doesn't exist on one of the 
variants. Maybe we could type the temporary one as `{kind: 'temporary', value?: 
null}` so the value has to be null but you can always access that property? 

* ?? Other concerns about the approach? We could keep the global 
auto-incrementing id rather than attempting to reset to 0 for each conflict.
This commit is contained in:
Joe Savona
2024-03-06 11:07:08 -08:00
parent d1d6310f25
commit 329bb555a0
76 changed files with 820 additions and 787 deletions
@@ -295,5 +295,5 @@ function declareTemporary(
}
function promoteTemporary(temp: Identifier): void {
temp.name = `t${temp.id}`;
temp.name = `#t${temp.id}`;
}
@@ -152,7 +152,7 @@ function transformDestructuring(
const tempId = state.env.nextIdentifierId;
const temporary = {
...place,
identifier: { ...place.identifier, id: tempId, name: `t${tempId}` },
identifier: { ...place.identifier, id: tempId, name: `#t${tempId}` },
};
renamed.set(place, temporary);
return temporary;
@@ -85,8 +85,8 @@ function promoteTemporary(identifier: Identifier, state: VisitorState): void {
suggestions: null,
});
if (state.tags.has(identifier.id)) {
identifier.name = `T${state.nextId++}`;
identifier.name = `#T${state.nextId++}`;
} else {
identifier.name = `t${state.nextId++}`;
identifier.name = `#t${state.nextId++}`;
}
}
@@ -274,7 +274,7 @@ class Transform extends ReactiveFunctionTransform<State> {
earlyReturnValue = state.earlyReturnValue;
} else {
const identifier = createTemporaryPlace(this.env).identifier;
identifier.name = `t${identifier.id}`;
identifier.name = `#t${identifier.id}`;
earlyReturnValue = {
label: this.env.nextBlockId,
loc,
@@ -13,26 +13,38 @@ import {
Place,
ReactiveBlock,
ReactiveFunction,
ReactiveInstruction,
ReactiveScopeBlock,
} from "../HIR/HIR";
import { eachInstructionLValue } from "../HIR/visitors";
import {
ReactiveFunctionVisitor,
eachReactiveValueOperand,
visitReactiveFunction,
} from "./visitors";
import { ReactiveFunctionVisitor, visitReactiveFunction } from "./visitors";
/*
/**
* Ensures that each named variable in the given function has a unique name
* that does not conflict with any other variables in the same block scope.
* Note that the scoping is based on the final inferred blocks, not the
* block scopes that were present in the original source. Thus variables
* that shadowed in the original source may end up with unique names in the
* output, if Forget would merge those two blocks into a single scope.
*
* Variables are renamed using their original name followed by a number,
* starting with 0 and incrementing until a unique name is found. Eg if the
* compiler collapses three scopes that each had their own `foo` declaration,
* they will be renamed to `foo`, `foo0`, and `foo1`, assuming that no conflicts'
* exist for `foo0` and `foo1`.
*
* For temporary values that are promoted to named variables, the starting name
* is "T0" for values that appear in JSX tag position and "t0" otherwise. If this
* name conflicts, the number portion increments until the name is unique (t1, t2, etc).
*/
export function renameVariables(fn: ReactiveFunction): void {
const scopes = new Scopes();
renameVariablesImpl(fn, new Visitor(), scopes);
}
function renameVariablesImpl(
fn: ReactiveFunction,
visitor: Visitor,
scopes: Scopes
): void {
scopes.enter(() => {
for (const param of fn.params) {
if (param.kind === "Identifier") {
@@ -41,11 +53,14 @@ export function renameVariables(fn: ReactiveFunction): void {
scopes.visit(param.place.identifier);
}
}
visitReactiveFunction(fn, new Visitor(), scopes);
visitReactiveFunction(fn, visitor, scopes);
});
}
class Visitor extends ReactiveFunctionVisitor<Scopes> {
override visitLValue(_id: InstructionId, lvalue: Place, state: Scopes): void {
state.visit(lvalue.identifier);
}
override visitPlace(id: InstructionId, place: Place, state: Scopes): void {
state.visit(place.identifier);
}
@@ -54,40 +69,58 @@ class Visitor extends ReactiveFunctionVisitor<Scopes> {
this.traverseBlock(block, state);
});
}
override visitInstruction(instr: ReactiveInstruction, state: Scopes): void {
for (const operand of eachReactiveValueOperand(instr.value)) {
state.visit(operand.identifier);
}
for (const operand of eachInstructionLValue(instr)) {
this.visitPlace(instr.id, operand, state);
}
}
override visitScope(scope: ReactiveScopeBlock, state: Scopes): void {
/*
* Intentionally bypass visitBlock() since scopes do not introduce a new
* block scope
*/
this.traverseBlock(scope.instructions, state);
for (const [_, declaration] of scope.scope.declarations) {
state.visit(declaration.identifier);
}
this.traverseScope(scope, state);
}
override visitReactiveFunctionValue(
_id: InstructionId,
_dependencies: Place[],
_fn: ReactiveFunction,
_state: Scopes
): void {
renameVariablesImpl(_fn, this, _state);
}
}
class Scopes {
#nextId: number = 0;
#seen: Set<IdentifierId> = new Set();
#seen: Map<IdentifierId, string> = new Map();
#stack: Array<Map<string, IdentifierId>> = [new Map()];
visit(identifier: Identifier): void {
if (identifier.name === null || this.#seen.has(identifier.id)) {
const originalName = identifier.name;
if (originalName === null) {
return;
}
this.#seen.add(identifier.id);
let name = identifier.name;
const mappedName = this.#seen.get(identifier.id);
if (mappedName !== undefined) {
identifier.name = mappedName;
return;
}
let name = originalName;
let id = 0;
if (name.startsWith("#t")) {
name = `t${id++}`;
} else if (name.startsWith("#T")) {
name = `T${id++}`;
}
let previous = this.#lookup(name);
while (previous !== null) {
name = `${identifier.name}$${this.#nextId++}`;
if (originalName.startsWith("#t")) {
name = `t${id++}`;
} else if (originalName.startsWith("#T")) {
name = `T${id++}`;
} else {
name = `${identifier.name}$${id++}`;
}
previous = this.#lookup(name);
}
identifier.name = name;
this.#seen.set(identifier.id, name);
this.#stack.at(-1)!.set(name, identifier.id);
}
@@ -49,16 +49,16 @@ function AllocatingPrimitiveAsDepNested(props) {
x = $[2];
y = $[3];
}
let t2;
let t0;
if ($[6] !== x || $[7] !== y) {
t2 = [x, y];
t0 = [x, y];
$[6] = x;
$[7] = y;
$[8] = t2;
$[8] = t0;
} else {
t2 = $[8];
t0 = $[8];
}
return t2;
return t0;
}
```
@@ -50,16 +50,16 @@ function foo(a, b, c) {
x = $[3];
z = $[4];
}
let t1;
let t0;
if ($[7] !== x || $[8] !== z) {
t1 = [x, z];
t0 = [x, z];
$[7] = x;
$[8] = z;
$[9] = t1;
$[9] = t0;
} else {
t1 = $[9];
t0 = $[9];
}
return t1;
return t0;
}
export const FIXTURE_ENTRYPOINT = {
@@ -40,24 +40,24 @@ function ArrayAtTest(props) {
t1 = $[3];
}
const arr = t1;
let t3;
let t2;
if ($[4] !== props.y || $[5] !== arr) {
let t2;
let t3;
if ($[7] !== props.y) {
t2 = bar(props.y);
t3 = bar(props.y);
$[7] = props.y;
$[8] = t2;
$[8] = t3;
} else {
t2 = $[8];
t3 = $[8];
}
t3 = arr.at(t2);
t2 = arr.at(t3);
$[4] = props.y;
$[5] = arr;
$[6] = t3;
$[6] = t2;
} else {
t3 = $[6];
t2 = $[6];
}
const result = t3;
const result = t2;
return result;
}
@@ -32,51 +32,51 @@ import {
function Component(props) {
const $ = useMemoCache(4);
const [x] = useState(0);
let t15;
let t0;
if ($[0] !== x) {
t0 = calculateExpensiveNumber(x);
$[0] = x;
$[1] = t0;
} else {
t0 = $[1];
}
t15 = t0;
const expensiveNumber = t15;
let t1;
if ($[2] !== expensiveNumber) {
t1 = <div>{expensiveNumber}</div>;
$[2] = expensiveNumber;
$[3] = t1;
if ($[0] !== x) {
t1 = calculateExpensiveNumber(x);
$[0] = x;
$[1] = t1;
} else {
t1 = $[3];
t1 = $[1];
}
return t1;
t0 = t1;
const expensiveNumber = t0;
let t2;
if ($[2] !== expensiveNumber) {
t2 = <div>{expensiveNumber}</div>;
$[2] = expensiveNumber;
$[3] = t2;
} else {
t2 = $[3];
}
return t2;
}
function Component2(props) {
const $ = useMemoCache(4);
const [x] = useState(0);
let t15;
let t0;
if ($[0] !== x) {
t0 = calculateExpensiveNumber(x);
$[0] = x;
$[1] = t0;
} else {
t0 = $[1];
}
t15 = t0;
const expensiveNumber = t15;
let t1;
if ($[2] !== expensiveNumber) {
t1 = <div>{expensiveNumber}</div>;
$[2] = expensiveNumber;
$[3] = t1;
if ($[0] !== x) {
t1 = calculateExpensiveNumber(x);
$[0] = x;
$[1] = t1;
} else {
t1 = $[3];
t1 = $[1];
}
return t1;
t0 = t1;
const expensiveNumber = t0;
let t2;
if ($[2] !== expensiveNumber) {
t2 = <div>{expensiveNumber}</div>;
$[2] = expensiveNumber;
$[3] = t2;
} else {
t2 = $[3];
}
return t2;
}
```
@@ -34,51 +34,51 @@ import {
function Component(props) {
const $ = useMemoCache(4);
const [x] = useState(0);
let t15;
let t0;
if ($[0] !== x) {
t0 = calculateExpensiveNumber(x);
$[0] = x;
$[1] = t0;
} else {
t0 = $[1];
}
t15 = t0;
const expensiveNumber = t15;
let t1;
if ($[2] !== expensiveNumber) {
t1 = <div>{expensiveNumber}</div>;
$[2] = expensiveNumber;
$[3] = t1;
if ($[0] !== x) {
t1 = calculateExpensiveNumber(x);
$[0] = x;
$[1] = t1;
} else {
t1 = $[3];
t1 = $[1];
}
return t1;
t0 = t1;
const expensiveNumber = t0;
let t2;
if ($[2] !== expensiveNumber) {
t2 = <div>{expensiveNumber}</div>;
$[2] = expensiveNumber;
$[3] = t2;
} else {
t2 = $[3];
}
return t2;
}
function Component2(props) {
const $ = useMemoCache(4);
const [x] = useState(0);
let t15;
let t0;
if ($[0] !== x) {
t0 = calculateExpensiveNumber(x);
$[0] = x;
$[1] = t0;
} else {
t0 = $[1];
}
t15 = t0;
const expensiveNumber = t15;
let t1;
if ($[2] !== expensiveNumber) {
t1 = <div>{expensiveNumber}</div>;
$[2] = expensiveNumber;
$[3] = t1;
if ($[0] !== x) {
t1 = calculateExpensiveNumber(x);
$[0] = x;
$[1] = t1;
} else {
t1 = $[3];
t1 = $[1];
}
return t1;
t0 = t1;
const expensiveNumber = t0;
let t2;
if ($[2] !== expensiveNumber) {
t2 = <div>{expensiveNumber}</div>;
$[2] = expensiveNumber;
$[3] = t2;
} else {
t2 = $[3];
}
return t2;
}
```
@@ -29,26 +29,26 @@ import { calculateExpensiveNumber } from "shared-runtime";
function Component(props) {
const $ = useMemoCache(4);
const [x] = React.useState(0);
let t17;
let t0;
if ($[0] !== x) {
t0 = calculateExpensiveNumber(x);
$[0] = x;
$[1] = t0;
} else {
t0 = $[1];
}
t17 = t0;
const expensiveNumber = t17;
let t1;
if ($[2] !== expensiveNumber) {
t1 = <div>{expensiveNumber}</div>;
$[2] = expensiveNumber;
$[3] = t1;
if ($[0] !== x) {
t1 = calculateExpensiveNumber(x);
$[0] = x;
$[1] = t1;
} else {
t1 = $[3];
t1 = $[1];
}
return t1;
t0 = t1;
const expensiveNumber = t0;
let t2;
if ($[2] !== expensiveNumber) {
t2 = <div>{expensiveNumber}</div>;
$[2] = expensiveNumber;
$[3] = t2;
} else {
t2 = $[3];
}
return t2;
}
export const FIXTURE_ENTRYPOINT = {
@@ -34,16 +34,16 @@ import { useMemo, unstable_useMemoCache as useMemoCache } from "react";
function Component(props) {
const $ = useMemoCache(2);
let t22;
let t0;
let t1;
if ($[0] !== props.value) {
t0 = { value: props.value };
t1 = { value: props.value };
$[0] = props.value;
$[1] = t0;
$[1] = t1;
} else {
t0 = $[1];
t1 = $[1];
}
const handlers = t0;
const handlers = t1;
bb2: switch (props.test) {
case true: {
console.log(handlers.value);
@@ -53,8 +53,8 @@ function Component(props) {
}
}
t22 = handlers;
const outerHandlers = t22;
t0 = handlers;
const outerHandlers = t0;
return outerHandlers;
}
@@ -29,17 +29,17 @@ function App(t25) {
const { text, hasDeps } = t25;
hasDeps ? null : [text];
let t18;
let t0;
let t1;
if ($[0] !== text) {
t0 = text.toUpperCase();
t1 = text.toUpperCase();
$[0] = text;
$[1] = t0;
$[1] = t1;
} else {
t0 = $[1];
t1 = $[1];
}
t18 = t0;
const resolvedText = t18;
t0 = t1;
const resolvedText = t0;
return resolvedText;
}
@@ -20,28 +20,28 @@ function Component(props) {
import { unstable_useMemoCache as useMemoCache } from "react";
function Component(props) {
const $ = useMemoCache(4);
let t1;
let t0;
if ($[0] !== props) {
const x = makeFunction(props);
let t0;
let t1;
if ($[2] !== props.text) {
t0 = (
t1 = (
<div>
<span>{props.text}</span>
</div>
);
$[2] = props.text;
$[3] = t0;
$[3] = t1;
} else {
t0 = $[3];
t1 = $[3];
}
t1 = x(t0);
t0 = x(t1);
$[0] = props;
$[1] = t1;
$[1] = t0;
} else {
t1 = $[1];
t0 = $[1];
}
const y = t1;
const y = t0;
return y;
}
@@ -73,14 +73,14 @@ import { unstable_useMemoCache as useMemoCache } from "react";
function ComponentA(props) {
const $ = useMemoCache(5);
let a_DEBUG;
let t37;
let t0;
if ($[0] !== props.a || $[1] !== props.b || $[2] !== props.d) {
t37 = Symbol.for("react.early_return_sentinel");
t0 = Symbol.for("react.early_return_sentinel");
bb7: {
a_DEBUG = [];
a_DEBUG.push(props.a);
if (props.b) {
t37 = null;
t0 = null;
break bb7;
}
@@ -90,13 +90,13 @@ function ComponentA(props) {
$[1] = props.b;
$[2] = props.d;
$[3] = a_DEBUG;
$[4] = t37;
$[4] = t0;
} else {
a_DEBUG = $[3];
t37 = $[4];
t0 = $[4];
}
if (t37 !== Symbol.for("react.early_return_sentinel")) {
return t37;
if (t0 !== Symbol.for("react.early_return_sentinel")) {
return t0;
}
return a_DEBUG;
}
@@ -129,15 +129,15 @@ function ComponentB(props) {
function ComponentC(props) {
const $ = useMemoCache(3);
let a;
let t47;
let t0;
if ($[0] !== props) {
t47 = Symbol.for("react.early_return_sentinel");
t0 = Symbol.for("react.early_return_sentinel");
bb7: {
a = [];
a.push(props.a);
if (props.b) {
a.push(props.c);
t47 = null;
t0 = null;
break bb7;
}
@@ -145,13 +145,13 @@ function ComponentC(props) {
}
$[0] = props;
$[1] = a;
$[2] = t47;
$[2] = t0;
} else {
a = $[1];
t47 = $[2];
t0 = $[2];
}
if (t47 !== Symbol.for("react.early_return_sentinel")) {
return t47;
if (t0 !== Symbol.for("react.early_return_sentinel")) {
return t0;
}
return a;
}
@@ -162,15 +162,15 @@ function ComponentC(props) {
function ComponentD(props) {
const $ = useMemoCache(3);
let a;
let t47;
let t0;
if ($[0] !== props) {
t47 = Symbol.for("react.early_return_sentinel");
t0 = Symbol.for("react.early_return_sentinel");
bb7: {
a = [];
a.push(props.a);
if (props.b) {
a.push(props.c);
t47 = a;
t0 = a;
break bb7;
}
@@ -178,13 +178,13 @@ function ComponentD(props) {
}
$[0] = props;
$[1] = a;
$[2] = t47;
$[2] = t0;
} else {
a = $[1];
t47 = $[2];
t0 = $[2];
}
if (t47 !== Symbol.for("react.early_return_sentinel")) {
return t47;
if (t0 !== Symbol.for("react.early_return_sentinel")) {
return t0;
}
return a;
}
@@ -37,22 +37,22 @@ function Component(props) {
t0 = $[1];
}
const childProps = t0;
let t2;
let t1;
if ($[2] !== childProps) {
let t1;
let t2;
if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
t1 = ["hello world"];
$[4] = t1;
t2 = ["hello world"];
$[4] = t2;
} else {
t1 = $[4];
t2 = $[4];
}
t2 = React.createElement("div", childProps, t1);
t1 = React.createElement("div", childProps, t2);
$[2] = childProps;
$[3] = t2;
$[3] = t1;
} else {
t2 = $[3];
t1 = $[3];
}
const element = t2;
const element = t1;
shallowCopy(childProps);
return element;
}
@@ -64,29 +64,29 @@ function Component(props) {
if ($[0] !== post) {
allUrls = [];
const { media: t0, comments: t2, urls: t4 } = post;
let t1;
if ($[4] !== t0) {
t1 = t0 === undefined ? null : t0;
$[4] = t0;
$[5] = t1;
} else {
t1 = $[5];
}
media = t1;
const { media: t0, comments: t1, urls: t2 } = post;
let t3;
if ($[6] !== t2) {
t3 = t2 === undefined ? [] : t2;
$[6] = t2;
$[7] = t3;
if ($[4] !== t0) {
t3 = t0 === undefined ? null : t0;
$[4] = t0;
$[5] = t3;
} else {
t3 = $[7];
t3 = $[5];
}
const comments = t3;
media = t3;
let t4;
if ($[6] !== t1) {
t4 = t1 === undefined ? [] : t1;
$[6] = t1;
$[7] = t4;
} else {
t4 = $[7];
}
const comments = t4;
let t5;
if ($[8] !== t4) {
t5 = t4 === undefined ? [] : t4;
$[8] = t4;
if ($[8] !== t2) {
t5 = t2 === undefined ? [] : t2;
$[8] = t2;
$[9] = t5;
} else {
t5 = $[9];
@@ -118,17 +118,17 @@ function Component(props) {
allUrls = $[2];
onClick = $[3];
}
let t7;
let t0;
if ($[12] !== media || $[13] !== allUrls || $[14] !== onClick) {
t7 = <Stringify media={media} allUrls={allUrls} onClick={onClick} />;
t0 = <Stringify media={media} allUrls={allUrls} onClick={onClick} />;
$[12] = media;
$[13] = allUrls;
$[14] = onClick;
$[15] = t7;
$[15] = t0;
} else {
t7 = $[15];
t0 = $[15];
}
return t7;
return t0;
}
export const FIXTURE_ENTRYPOINT = {
@@ -37,11 +37,11 @@ function Component(props) {
if ($[0] !== post) {
const allUrls = [];
const { media: t83, comments, urls } = post;
media = t83;
let t0;
const { media: t0, comments, urls } = post;
media = t0;
let t1;
if ($[3] !== comments.length) {
t0 = (e) => {
t1 = (e) => {
if (!comments.length) {
return;
}
@@ -49,11 +49,11 @@ function Component(props) {
console.log(comments.length);
};
$[3] = comments.length;
$[4] = t0;
$[4] = t1;
} else {
t0 = $[4];
t1 = $[4];
}
onClick = t0;
onClick = t1;
allUrls.push(...urls);
$[0] = post;
@@ -63,16 +63,16 @@ function Component(props) {
media = $[1];
onClick = $[2];
}
let t1;
let t0;
if ($[5] !== media || $[6] !== onClick) {
t1 = <Media media={media} onClick={onClick} />;
t0 = <Media media={media} onClick={onClick} />;
$[5] = media;
$[6] = onClick;
$[7] = t1;
$[7] = t0;
} else {
t1 = $[7];
t0 = $[7];
}
return t1;
return t0;
}
```
@@ -28,7 +28,7 @@ import * as React from "react";
function Component(props) {
const $ = useMemoCache(2);
let t19;
let t0;
let x;
if ($[0] !== props.value) {
x = [];
@@ -38,8 +38,8 @@ function Component(props) {
} else {
x = $[1];
}
t19 = x;
const x_0 = t19;
t0 = x;
const x_0 = t0;
return x_0;
}
@@ -32,29 +32,29 @@ export const FIXTURE_ENTRYPOINT = {
import { unstable_useMemoCache as useMemoCache } from "react";
function Component(props) {
const $ = useMemoCache(5);
let t53;
let t0;
if ($[0] !== props) {
t53 = Symbol.for("react.early_return_sentinel");
t0 = Symbol.for("react.early_return_sentinel");
bb11: {
const x = [];
if (props.cond) {
x.push(props.a);
if (props.b) {
let t0;
let t1;
if ($[2] !== props.b) {
t0 = [props.b];
t1 = [props.b];
$[2] = props.b;
$[3] = t0;
$[3] = t1;
} else {
t0 = $[3];
t1 = $[3];
}
const y = t0;
const y = t1;
x.push(y);
t53 = x;
t0 = x;
break bb11;
}
t53 = x;
t0 = x;
break bb11;
} else {
let t1;
@@ -64,17 +64,17 @@ function Component(props) {
} else {
t1 = $[4];
}
t53 = t1;
t0 = t1;
break bb11;
}
}
$[0] = props;
$[1] = t53;
$[1] = t0;
} else {
t53 = $[1];
t0 = $[1];
}
if (t53 !== Symbol.for("react.early_return_sentinel")) {
return t53;
if (t0 !== Symbol.for("react.early_return_sentinel")) {
return t0;
}
}
@@ -70,35 +70,35 @@ let ENABLE_FEATURE = false;
function Component(props) {
const $ = useMemoCache(3);
let t37;
let t0;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
t37 = Symbol.for("react.early_return_sentinel");
t0 = Symbol.for("react.early_return_sentinel");
bb8: {
const x = [];
if (ENABLE_FEATURE) {
x.push(42);
t37 = x;
t0 = x;
break bb8;
} else {
console.log("fallthrough");
}
}
$[0] = t37;
$[0] = t0;
} else {
t37 = $[0];
t0 = $[0];
}
if (t37 !== Symbol.for("react.early_return_sentinel")) {
return t37;
if (t0 !== Symbol.for("react.early_return_sentinel")) {
return t0;
}
let t0;
let t1;
if ($[1] !== props.a) {
t0 = makeArray(props.a);
t1 = makeArray(props.a);
$[1] = props.a;
$[2] = t0;
$[2] = t1;
} else {
t0 = $[2];
t1 = $[2];
}
return t0;
return t1;
}
export const FIXTURE_ENTRYPOINT = {
@@ -46,35 +46,35 @@ import { makeArray } from "shared-runtime";
function Component(props) {
const $ = useMemoCache(4);
let t33;
let t0;
if ($[0] !== props) {
t33 = Symbol.for("react.early_return_sentinel");
t0 = Symbol.for("react.early_return_sentinel");
bb8: {
const x = [];
if (props.cond) {
x.push(props.a);
t33 = x;
t0 = x;
break bb8;
} else {
let t0;
let t1;
if ($[2] !== props.b) {
t0 = makeArray(props.b);
t1 = makeArray(props.b);
$[2] = props.b;
$[3] = t0;
$[3] = t1;
} else {
t0 = $[3];
t1 = $[3];
}
t33 = t0;
t0 = t1;
break bb8;
}
}
$[0] = props;
$[1] = t33;
$[1] = t0;
} else {
t33 = $[1];
t0 = $[1];
}
if (t33 !== Symbol.for("react.early_return_sentinel")) {
return t33;
if (t0 !== Symbol.for("react.early_return_sentinel")) {
return t0;
}
}
@@ -26,8 +26,8 @@ function Component(props) {
const $ = useMemoCache(7);
let b;
if ($[0] !== props.a) {
const { a, ...t29 } = props.a;
b = t29;
const { a, ...t0 } = props.a;
b = t0;
$[0] = props.a;
$[1] = b;
} else {
@@ -35,8 +35,8 @@ function Component(props) {
}
let d;
if ($[2] !== props.c) {
const [c, ...t30] = props.c;
d = t30;
const [c, ...t0] = props.c;
d = t0;
$[2] = props.c;
$[3] = d;
} else {
@@ -50,35 +50,35 @@ function Component() {
const [state] = React$useState(0);
const object = Internal$Reassigned$useHook();
const json = JSON.stringify(object);
let t25;
let t0;
if ($[0] !== state) {
t25 = makeArray(state);
const doubledArray = t25;
t0 = doubledArray.join("");
$[0] = state;
$[1] = t0;
$[2] = t25;
} else {
t0 = $[1];
t25 = $[2];
}
let t1;
if ($[3] !== t0 || $[4] !== json) {
t1 = (
if ($[0] !== state) {
t0 = makeArray(state);
const doubledArray = t0;
t1 = doubledArray.join("");
$[0] = state;
$[1] = t1;
$[2] = t0;
} else {
t1 = $[1];
t0 = $[2];
}
let t2;
if ($[3] !== t1 || $[4] !== json) {
t2 = (
<div>
{t0}
{t1}
{json}
</div>
);
$[3] = t0;
$[3] = t1;
$[4] = json;
$[5] = t1;
$[5] = t2;
} else {
t1 = $[5];
t2 = $[5];
}
return t1;
return t2;
}
export const FIXTURE_ENTRYPOINT = {
@@ -27,19 +27,19 @@ import { getNull } from "shared-runtime";
function Component(props) {
const $ = useMemoCache(3);
let t10;
let t0;
let items;
if ($[0] !== props.a) {
t10 = getNull() ?? [];
items = t10;
t0 = getNull() ?? [];
items = t0;
items.push(props.a);
$[0] = props.a;
$[1] = items;
$[2] = t10;
$[2] = t0;
} else {
items = $[1];
t10 = $[2];
t0 = $[2];
}
return items;
}
@@ -29,13 +29,13 @@ function Component(props) {
const $ = useMemoCache(2);
let items;
if ($[0] !== props) {
let t9;
let t0;
if (props.cond) {
t9 = [];
t0 = [];
} else {
t9 = null;
t0 = null;
}
items = t9;
items = t0;
items?.push(props.a);
$[0] = props;
@@ -23,19 +23,19 @@ export const FIXTURE_ENTRYPOINT = {
import { unstable_useMemoCache as useMemoCache } from "react";
function Component(props) {
const $ = useMemoCache(3);
let t4;
let t0;
let items;
if ($[0] !== props.a) {
t4 = [];
items = t4;
t0 = [];
items = t0;
items.push(props.a);
$[0] = props.a;
$[1] = items;
$[2] = t4;
$[2] = t0;
} else {
items = $[1];
t4 = $[2];
t0 = $[2];
}
return items;
}
@@ -27,66 +27,66 @@ function Component(props) {
const $ = useMemoCache(15);
const item = useFragment(FRAGMENT, props.item);
useFreeze(item);
let t1;
let T2;
let t0;
let T3;
let T0;
let t1;
let T1;
if ($[0] !== item) {
const count = new MaybeMutable(item);
T3 = View;
T2 = View;
T1 = View;
T0 = View;
if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
t0 = <span>Text</span>;
$[5] = t0;
t1 = <span>Text</span>;
$[5] = t1;
} else {
t0 = $[5];
t1 = $[5];
}
t1 = maybeMutate(count);
t0 = maybeMutate(count);
$[0] = item;
$[1] = t1;
$[2] = T2;
$[3] = t0;
$[4] = T3;
$[1] = t0;
$[2] = T0;
$[3] = t1;
$[4] = T1;
} else {
t1 = $[1];
T2 = $[2];
t0 = $[3];
T3 = $[4];
t0 = $[1];
T0 = $[2];
t1 = $[3];
T1 = $[4];
}
let t2;
if ($[6] !== t0) {
t2 = <span>{t0}</span>;
$[6] = t0;
$[7] = t2;
} else {
t2 = $[7];
}
let t3;
if ($[8] !== T0 || $[9] !== t1 || $[10] !== t2) {
t3 = (
<T0>
{t1}
{t2}
</T0>
);
$[8] = T0;
$[9] = t1;
$[10] = t2;
$[11] = t3;
} else {
t3 = $[11];
}
let t4;
if ($[6] !== t1) {
t4 = <span>{t1}</span>;
$[6] = t1;
$[7] = t4;
if ($[12] !== T1 || $[13] !== t3) {
t4 = <T1>{t3}</T1>;
$[12] = T1;
$[13] = t3;
$[14] = t4;
} else {
t4 = $[7];
t4 = $[14];
}
let t5;
if ($[8] !== T2 || $[9] !== t0 || $[10] !== t4) {
t5 = (
<T2>
{t0}
{t4}
</T2>
);
$[8] = T2;
$[9] = t0;
$[10] = t4;
$[11] = t5;
} else {
t5 = $[11];
}
let t6;
if ($[12] !== T3 || $[13] !== t5) {
t6 = <T3>{t5}</T3>;
$[12] = T3;
$[13] = t5;
$[14] = t6;
} else {
t6 = $[14];
}
return t6;
return t4;
}
```
@@ -55,47 +55,47 @@ function Component(props) {
const $ = useMemoCache(11);
let Tag;
let T0;
let t1;
let t0;
if ($[0] !== props.component || $[1] !== props.alternateComponent) {
const maybeMutable = new MaybeMutable();
Tag = props.component;
T0 = Tag;
t1 = ((Tag = props.alternateComponent), maybeMutate(maybeMutable));
t0 = ((Tag = props.alternateComponent), maybeMutate(maybeMutable));
$[0] = props.component;
$[1] = props.alternateComponent;
$[2] = Tag;
$[3] = T0;
$[4] = t1;
$[4] = t0;
} else {
Tag = $[2];
T0 = $[3];
t1 = $[4];
t0 = $[4];
}
let t1;
if ($[5] !== Tag) {
t1 = <Tag />;
$[5] = Tag;
$[6] = t1;
} else {
t1 = $[6];
}
let t2;
if ($[5] !== Tag) {
t2 = <Tag />;
$[5] = Tag;
$[6] = t2;
} else {
t2 = $[6];
}
let t3;
if ($[7] !== T0 || $[8] !== t1 || $[9] !== t2) {
t3 = (
if ($[7] !== T0 || $[8] !== t0 || $[9] !== t1) {
t2 = (
<T0>
{t0}
{t1}
{t2}
</T0>
);
$[7] = T0;
$[8] = t1;
$[9] = t2;
$[10] = t3;
$[8] = t0;
$[9] = t1;
$[10] = t2;
} else {
t3 = $[10];
t2 = $[10];
}
return t3;
return t2;
}
export const FIXTURE_ENTRYPOINT = {
@@ -31,23 +31,23 @@ import { StaticText1, StaticText2 } from "shared-runtime";
function Component(props) {
const $ = useMemoCache(3);
const t1 = props.value;
let t0;
const t0 = props.value;
let t1;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
t0 = <StaticText2 />;
$[0] = t0;
t1 = <StaticText2 />;
$[0] = t1;
} else {
t0 = $[0];
t1 = $[0];
}
let t2;
if ($[1] !== t1) {
if ($[1] !== t0) {
t2 = (
<StaticText1>
{t1}
{t0}
{t1}
</StaticText1>
);
$[1] = t1;
$[1] = t0;
$[2] = t2;
} else {
t2 = $[2];
@@ -25,19 +25,19 @@ export const FIXTURE_ENTRYPOINT = {
import { unstable_useMemoCache as useMemoCache } from "react";
function Foo() {
const $ = useMemoCache(1);
let t18;
let t0;
let t1;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
t0 = function a(t28) {
t1 = function a(t28) {
const x_0 = t28 === undefined ? () => {} : t28;
return x_0;
};
$[0] = t0;
$[0] = t1;
} else {
t0 = $[0];
t1 = $[0];
}
t18 = t0;
return t18;
t0 = t1;
return t0;
}
export const FIXTURE_ENTRYPOINT = {
@@ -34,22 +34,22 @@ export const FIXTURE_ENTRYPOINT = {
import { unstable_useMemoCache as useMemoCache } from "react";
function Component(props) {
const $ = useMemoCache(3);
let t1;
let t0;
if ($[0] !== props.items) {
let t0;
let t1;
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
t0 = (item) => item != null;
$[2] = t0;
t1 = (item) => item != null;
$[2] = t1;
} else {
t0 = $[2];
t1 = $[2];
}
t1 = props.items.filter(t0);
t0 = props.items.filter(t1);
$[0] = props.items;
$[1] = t1;
$[1] = t0;
} else {
t1 = $[1];
t0 = $[1];
}
const filtered = t1;
const filtered = t0;
return filtered;
}
@@ -33,15 +33,15 @@ function foo(a, b, c, d) {
}
x = t0;
} else {
let t1;
let t0;
if ($[2] !== c) {
t1 = { c };
t0 = { c };
$[2] = c;
$[3] = t1;
$[3] = t0;
} else {
t1 = $[3];
t0 = $[3];
}
x = t1;
x = t0;
}
return x;
}
@@ -38,31 +38,31 @@ function useHook(t16) {
} else {
t0 = $[1];
}
let t2;
let t1;
if ($[2] !== b || $[3] !== c || $[4] !== t0) {
let t1;
let t2;
if ($[6] !== c) {
t1 = { c };
t2 = { c };
$[6] = c;
$[7] = t1;
$[7] = t2;
} else {
t1 = $[7];
t2 = $[7];
}
t2 = {
t1 = {
x: t0,
y() {
return [b];
},
z: t1,
z: t2,
};
$[2] = b;
$[3] = c;
$[4] = t0;
$[5] = t2;
$[5] = t1;
} else {
t2 = $[5];
t1 = $[5];
}
return t2;
return t1;
}
export const FIXTURE_ENTRYPOINT = {
@@ -32,39 +32,39 @@ import { unstable_useMemoCache as useMemoCache } from "react";
function Component(props) {
const $ = useMemoCache(4);
let y;
let t46;
let t0;
if ($[0] !== props) {
t46 = Symbol.for("react.early_return_sentinel");
t0 = Symbol.for("react.early_return_sentinel");
bb11: {
const x = [];
if (props.cond) {
x.push(props.a);
t46 = x;
t0 = x;
break bb11;
} else {
let t0;
let t1;
if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
t0 = foo();
$[3] = t0;
t1 = foo();
$[3] = t1;
} else {
t0 = $[3];
t1 = $[3];
}
y = t0;
y = t1;
if (props.b) {
t46 = undefined;
t0 = undefined;
break bb11;
}
}
}
$[0] = props;
$[1] = y;
$[2] = t46;
$[2] = t0;
} else {
y = $[1];
t46 = $[2];
t0 = $[2];
}
if (t46 !== Symbol.for("react.early_return_sentinel")) {
return t46;
if (t0 !== Symbol.for("react.early_return_sentinel")) {
return t0;
}
return y;
}
@@ -51,16 +51,16 @@ function PrimitiveAsDepNested(props) {
x = $[2];
y = $[3];
}
let t2;
let t0;
if ($[6] !== x || $[7] !== y) {
t2 = [x, y];
t0 = [x, y];
$[6] = x;
$[7] = y;
$[8] = t2;
$[8] = t0;
} else {
t2 = $[8];
t0 = $[8];
}
return t2;
return t0;
}
```
@@ -46,15 +46,15 @@ function Component(props) {
}
const count = posts.length;
foo(count);
let t1;
let t0;
if ($[3] !== posts) {
t1 = <>{posts}</>;
t0 = <>{posts}</>;
$[3] = posts;
$[4] = t1;
$[4] = t0;
} else {
t1 = $[4];
t0 = $[4];
}
return t1;
return t0;
}
```
@@ -51,16 +51,16 @@ function Component(props) {
x = $[3];
y = $[4];
}
let t1;
let t0;
if ($[6] !== x || $[7] !== y) {
t1 = <Component x={x} y={y} />;
t0 = <Component x={x} y={y} />;
$[6] = x;
$[7] = y;
$[8] = t1;
$[8] = t0;
} else {
t1 = $[8];
t0 = $[8];
}
return t1;
return t0;
}
```
@@ -47,16 +47,16 @@ function Component(props) {
x = $[2];
y = $[3];
}
let t1;
let t0;
if ($[5] !== x || $[6] !== y) {
t1 = <Component x={x} y={y} />;
t0 = <Component x={x} y={y} />;
$[5] = x;
$[6] = y;
$[7] = t1;
$[7] = t0;
} else {
t1 = $[7];
t0 = $[7];
}
return t1;
return t0;
}
```
@@ -44,14 +44,14 @@ function Component(props) {
}
return t1;
}
let t2;
let t1;
if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
t2 = <div>Default</div>;
$[3] = t2;
t1 = <div>Default</div>;
$[3] = t1;
} else {
t2 = $[3];
t1 = $[3];
}
return t2;
return t1;
}
```
@@ -28,11 +28,11 @@ function Component(props) {
};
const object = { x, onChange };
let t43;
let t0;
const { x: x_0, onChange: onChange_0 } = object;
t43 = <input value={x_0} onChange={onChange_0} />;
return t43;
t0 = <input value={x_0} onChange={onChange_0} />;
return t0;
}
```
@@ -62,27 +62,27 @@ function Component(props) {
let y;
const t3 = x.map((item) => {
const t2 = x.map((item) => {
item.flag = true;
return <span key={item.id}>{item.text}</span>;
});
let t2;
let t3;
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
t2 = mutate(y);
$[2] = t2;
t3 = mutate(y);
$[2] = t3;
} else {
t2 = $[2];
t3 = $[2];
}
let t4;
if ($[3] !== onClick || $[4] !== t3) {
if ($[3] !== onClick || $[4] !== t2) {
t4 = (
<div onClick={onClick}>
{t3}
{t2}
{t3}
</div>
);
$[3] = onClick;
$[4] = t3;
$[4] = t2;
$[5] = t4;
} else {
t4 = $[5];
@@ -21,31 +21,31 @@ export const FIXTURE_ENTRYPOINT = {
import { unstable_useMemoCache as useMemoCache } from "react";
function Component(props) {
const $ = useMemoCache(5);
let t1;
let t0;
if ($[0] !== props.items) {
let t0;
let t1;
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
t0 = (x) => x;
$[2] = t0;
t1 = (x) => x;
$[2] = t1;
} else {
t0 = $[2];
t1 = $[2];
}
t1 = props.items.map(t0);
t0 = props.items.map(t1);
$[0] = props.items;
$[1] = t1;
$[1] = t0;
} else {
t1 = $[1];
t0 = $[1];
}
const items = t1;
let t2;
const items = t0;
let t1;
if ($[3] !== items) {
t2 = [42, items];
t1 = [42, items];
$[3] = items;
$[4] = t2;
$[4] = t1;
} else {
t2 = $[4];
t1 = $[4];
}
return t2;
return t1;
}
export const FIXTURE_ENTRYPOINT = {
@@ -60,16 +60,16 @@ function Component(a, b) {
x = $[4];
y = $[5];
}
let t3;
let t2;
if ($[8] !== x || $[9] !== y) {
t3 = [x, y];
t2 = [x, y];
$[8] = x;
$[9] = y;
$[10] = t3;
$[10] = t2;
} else {
t3 = $[10];
t2 = $[10];
}
return t3;
return t2;
}
```
@@ -46,123 +46,123 @@ import { useMemo, unstable_useMemoCache as useMemoCache } from "react";
function Component(props) {
const $ = useMemoCache(29);
let t10;
let t0;
let t92;
let t1;
let t2;
if ($[0] !== props) {
t92 = Symbol.for("react.early_return_sentinel");
t2 = Symbol.for("react.early_return_sentinel");
bb10: {
t10 = toJSON(props);
const propsString = t10;
t0 = toJSON(props);
const propsString = t0;
if (propsString.length <= 2) {
t92 = null;
t2 = null;
break bb10;
}
t0 = identity(propsString);
t1 = identity(propsString);
}
$[0] = props;
$[1] = t0;
$[2] = t92;
$[3] = t10;
$[1] = t1;
$[2] = t2;
$[3] = t0;
} else {
t0 = $[1];
t92 = $[2];
t10 = $[3];
t1 = $[1];
t2 = $[2];
t0 = $[3];
}
if (t92 !== Symbol.for("react.early_return_sentinel")) {
return t92;
if (t2 !== Symbol.for("react.early_return_sentinel")) {
return t2;
}
let t1;
if ($[4] !== t0) {
t1 = { url: t0 };
$[4] = t0;
$[5] = t1;
} else {
t1 = $[5];
}
const linkProps = t1;
let T7;
let t8;
let t2;
let t3;
if ($[4] !== t1) {
t3 = { url: t1 };
$[4] = t1;
$[5] = t3;
} else {
t3 = $[5];
}
const linkProps = t3;
let T0;
let t4;
let t5;
let t6;
let t7;
let t8;
let t9;
let t10;
if ($[6] !== linkProps) {
const x = {};
T7 = Stringify;
t8 = linkProps;
T0 = Stringify;
t4 = linkProps;
if ($[15] === Symbol.for("react.memo_cache_sentinel")) {
t2 = [1];
t3 = [2];
t4 = [3];
t5 = [4];
t6 = [5];
$[15] = t2;
$[16] = t3;
$[17] = t4;
$[18] = t5;
$[19] = t6;
t5 = [1];
t6 = [2];
t7 = [3];
t8 = [4];
t9 = [5];
$[15] = t5;
$[16] = t6;
$[17] = t7;
$[18] = t8;
$[19] = t9;
} else {
t2 = $[15];
t3 = $[16];
t4 = $[17];
t5 = $[18];
t6 = $[19];
t5 = $[15];
t6 = $[16];
t7 = $[17];
t8 = $[18];
t9 = $[19];
}
t9 = makeArray(x, 2);
t10 = makeArray(x, 2);
$[6] = linkProps;
$[7] = T7;
$[8] = t8;
$[9] = t2;
$[10] = t3;
$[11] = t4;
$[12] = t5;
$[13] = t6;
$[14] = t9;
$[7] = T0;
$[8] = t4;
$[9] = t5;
$[10] = t6;
$[11] = t7;
$[12] = t8;
$[13] = t9;
$[14] = t10;
} else {
T7 = $[7];
t8 = $[8];
t2 = $[9];
t3 = $[10];
t4 = $[11];
t5 = $[12];
t6 = $[13];
t9 = $[14];
T0 = $[7];
t4 = $[8];
t5 = $[9];
t6 = $[10];
t7 = $[11];
t8 = $[12];
t9 = $[13];
t10 = $[14];
}
let t10$0;
let t11;
if (
$[20] !== T7 ||
$[21] !== t8 ||
$[22] !== t2 ||
$[23] !== t3 ||
$[24] !== t4 ||
$[25] !== t5 ||
$[26] !== t6 ||
$[27] !== t9
$[20] !== T0 ||
$[21] !== t4 ||
$[22] !== t5 ||
$[23] !== t6 ||
$[24] !== t7 ||
$[25] !== t8 ||
$[26] !== t9 ||
$[27] !== t10
) {
t10$0 = (
<T7 link={t8} val1={t2} val2={t3} val3={t4} val4={t5} val5={t6}>
{t9}
</T7>
t11 = (
<T0 link={t4} val1={t5} val2={t6} val3={t7} val4={t8} val5={t9}>
{t10}
</T0>
);
$[20] = T7;
$[21] = t8;
$[22] = t2;
$[23] = t3;
$[24] = t4;
$[25] = t5;
$[26] = t6;
$[27] = t9;
$[28] = t10$0;
$[20] = T0;
$[21] = t4;
$[22] = t5;
$[23] = t6;
$[24] = t7;
$[25] = t8;
$[26] = t9;
$[27] = t10;
$[28] = t11;
} else {
t10$0 = $[28];
t11 = $[28];
}
return t10$0;
return t11;
}
export const FIXTURE_ENTRYPOINT = {
@@ -52,18 +52,18 @@ function Component(props) {
const { buttons } = props;
let nonPrimaryButtons;
if ($[0] !== buttons) {
const [primaryButton, ...t79] = buttons;
nonPrimaryButtons = t79;
const [primaryButton, ...t0] = buttons;
nonPrimaryButtons = t0;
$[0] = buttons;
$[1] = nonPrimaryButtons;
} else {
nonPrimaryButtons = $[1];
}
let t1;
let t0;
if ($[2] !== nonPrimaryButtons) {
let t0;
let t1;
if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
t0 = (buttonProps, i) => (
t1 = (buttonProps, i) => (
<Stringify
{...buttonProps}
key={`button-${i}`}
@@ -74,26 +74,26 @@ function Component(props) {
}
/>
);
$[4] = t0;
$[4] = t1;
} else {
t0 = $[4];
t1 = $[4];
}
t1 = nonPrimaryButtons.map(t0);
t0 = nonPrimaryButtons.map(t1);
$[2] = nonPrimaryButtons;
$[3] = t1;
$[3] = t0;
} else {
t1 = $[3];
t0 = $[3];
}
const renderedNonPrimaryButtons = t1;
let t2;
const renderedNonPrimaryButtons = t0;
let t1;
if ($[5] !== renderedNonPrimaryButtons) {
t2 = <StaticText1>{renderedNonPrimaryButtons}</StaticText1>;
t1 = <StaticText1>{renderedNonPrimaryButtons}</StaticText1>;
$[5] = renderedNonPrimaryButtons;
$[6] = t2;
$[6] = t1;
} else {
t2 = $[6];
t1 = $[6];
}
return t2;
return t1;
}
const styles = {
@@ -51,20 +51,20 @@ function Component(props) {
const y = useFeature;
const z = useFeature.useProperty;
let t1;
let t0;
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
t1 = (
t0 = (
<Stringify val={useFeature}>
{x}
{y}
{z}
</Stringify>
);
$[1] = t1;
$[1] = t0;
} else {
t1 = $[1];
t0 = $[1];
}
return t1;
return t0;
}
export const FIXTURE_ENTRYPOINT = {
@@ -53,9 +53,9 @@ function Component(t29) {
const y = useFeature;
const z = useFeature.useProperty;
let t2;
let t0;
if ($[3] !== useFeature || $[4] !== x || $[5] !== y || $[6] !== z) {
t2 = (
t0 = (
<Stringify val={useFeature}>
{x}
{y}
@@ -66,11 +66,11 @@ function Component(t29) {
$[4] = x;
$[5] = y;
$[6] = z;
$[7] = t2;
$[7] = t0;
} else {
t2 = $[7];
t0 = $[7];
}
return t2;
return t0;
}
export const FIXTURE_ENTRYPOINT = {
@@ -47,8 +47,8 @@ function Component(statusName) {
let t0;
let t1;
if ($[0] !== statusName) {
const { status, text: t47 } = foo(statusName);
text = t47;
const { status, text: t2 } = foo(statusName);
text = t2;
const { bg, color } = getStyles(status);
t1 = identity(bg);
@@ -50,11 +50,11 @@ function Component(statusName) {
let text;
let font;
if ($[0] !== statusName) {
const { status, text: t49 } = foo(statusName);
text = t49;
const { status, text: t1 } = foo(statusName);
text = t1;
const { color, font: t50 } = getStyles(status);
font = t50;
const { color, font: t2 } = getStyles(status);
font = t2;
t0 = identity(color);
$[0] = statusName;
@@ -29,16 +29,16 @@ export default function foo(x, y) {
return t0;
}
const t1 = y * 10;
let t2;
if ($[2] !== t1) {
t2 = [t1];
$[2] = t1;
$[3] = t2;
const t0 = y * 10;
let t1;
if ($[2] !== t0) {
t1 = [t0];
$[2] = t0;
$[3] = t1;
} else {
t2 = $[3];
t1 = $[3];
}
return t2;
return t1;
}
```
@@ -42,14 +42,14 @@ function foo(a) {
const y = t0;
x.y = y;
} else {
let t1;
let t0;
if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
t1 = {};
$[3] = t1;
t0 = {};
$[3] = t0;
} else {
t1 = $[3];
t0 = $[3];
}
const z = t1;
const z = t0;
x.z = z;
}
$[0] = a;
@@ -67,26 +67,26 @@ function Component(props) {
x = $[1];
y = $[2];
}
let t1;
let t0;
if ($[4] !== x) {
t1 = <Component data={x} />;
t0 = <Component data={x} />;
$[4] = x;
$[5] = t1;
$[5] = t0;
} else {
t1 = $[5];
t0 = $[5];
}
const child = t1;
const child = t0;
y.push(props.p4);
let t2;
let t1;
if ($[6] !== y || $[7] !== child) {
t2 = <Component data={y}>{child}</Component>;
t1 = <Component data={y}>{child}</Component>;
$[6] = y;
$[7] = child;
$[8] = t2;
$[8] = t1;
} else {
t2 = $[8];
t1 = $[8];
}
return t2;
return t1;
}
```
@@ -26,31 +26,31 @@ import { unstable_useMemoCache as useMemoCache } from "react";
function Component(props) {
const $ = useMemoCache(5);
const data = useFreeze();
let t1;
let t0;
if ($[0] !== data.items) {
let t0;
let t1;
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
t0 = (item) => <Item item={item} />;
$[2] = t0;
t1 = (item) => <Item item={item} />;
$[2] = t1;
} else {
t0 = $[2];
t1 = $[2];
}
t1 = data.items.map(t0);
t0 = data.items.map(t1);
$[0] = data.items;
$[1] = t1;
$[1] = t0;
} else {
t1 = $[1];
t0 = $[1];
}
const items = t1;
let t2;
const items = t0;
let t1;
if ($[3] !== items) {
t2 = <div>{items}</div>;
t1 = <div>{items}</div>;
$[3] = items;
$[4] = t2;
$[4] = t1;
} else {
t2 = $[4];
t1 = $[4];
}
return t2;
return t1;
}
```
@@ -72,22 +72,22 @@ function Component(props) {
t2 = $[6];
}
useEffect(t1, t2);
let t4;
let t3;
if ($[7] !== data) {
let t3;
let t4;
if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
t3 = (x) => x;
$[9] = t3;
t4 = (x) => x;
$[9] = t4;
} else {
t3 = $[9];
t4 = $[9];
}
t4 = data.map(t3);
t3 = data.map(t4);
$[7] = data;
$[8] = t4;
$[8] = t3;
} else {
t4 = $[8];
t3 = $[8];
}
const items = t4;
const items = t3;
return items;
}
@@ -31,9 +31,9 @@ const { throwInput } = require("shared-runtime");
function Component(props) {
const $ = useMemoCache(3);
let t49;
let t0;
if ($[0] !== props.y || $[1] !== props.e) {
t49 = Symbol.for("react.early_return_sentinel");
t0 = Symbol.for("react.early_return_sentinel");
bb18: {
try {
const y = [];
@@ -42,21 +42,21 @@ function Component(props) {
} catch (t25) {
const e = t25;
e.push(props.e);
t49 = e;
t0 = e;
break bb18;
}
t49 = null;
t0 = null;
break bb18;
}
$[0] = props.y;
$[1] = props.e;
$[2] = t49;
$[2] = t0;
} else {
t49 = $[2];
t0 = $[2];
}
if (t49 !== Symbol.for("react.early_return_sentinel")) {
return t49;
if (t0 !== Symbol.for("react.early_return_sentinel")) {
return t0;
}
}
@@ -32,9 +32,9 @@ const { throwInput } = require("shared-runtime");
function Component(props) {
const $ = useMemoCache(1);
let t36;
let t0;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
t36 = Symbol.for("react.early_return_sentinel");
t0 = Symbol.for("react.early_return_sentinel");
bb11: {
const x = [];
try {
@@ -42,19 +42,19 @@ function Component(props) {
} catch (t22) {
const e = t22;
e.push(null);
t36 = e;
t0 = e;
break bb11;
}
t36 = x;
t0 = x;
break bb11;
}
$[0] = t36;
$[0] = t0;
} else {
t36 = $[0];
t0 = $[0];
}
if (t36 !== Symbol.for("react.early_return_sentinel")) {
return t36;
if (t0 !== Symbol.for("react.early_return_sentinel")) {
return t0;
}
}
@@ -34,32 +34,32 @@ const { shallowCopy, throwInput } = require("shared-runtime");
function Component(props) {
const $ = useMemoCache(2);
let x;
let t43;
let t0;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
t43 = Symbol.for("react.early_return_sentinel");
t0 = Symbol.for("react.early_return_sentinel");
bb25: {
x = [];
try {
const y = shallowCopy({});
if (y == null) {
t43 = undefined;
t0 = undefined;
break bb25;
}
x.push(throwInput(y));
} catch {
t43 = null;
t0 = null;
break bb25;
}
}
$[0] = x;
$[1] = t43;
$[1] = t0;
} else {
x = $[0];
t43 = $[1];
t0 = $[1];
}
if (t43 !== Symbol.for("react.early_return_sentinel")) {
return t43;
if (t0 !== Symbol.for("react.early_return_sentinel")) {
return t0;
}
return x;
}
@@ -43,14 +43,14 @@ function Component(props) {
}
x.push(t0);
} catch {
let t1;
let t0;
if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
t1 = shallowCopy({});
$[3] = t1;
t0 = shallowCopy({});
$[3] = t0;
} else {
t1 = $[3];
t0 = $[3];
}
x.push(t1);
x.push(t0);
}
x.push(props.value);
@@ -23,22 +23,22 @@ export const FIXTURE_ENTRYPOINT = {
import { unstable_useMemoCache as useMemoCache } from "react"; // @enableUseTypeAnnotations
function useArray(items) {
const $ = useMemoCache(3);
let t1;
let t0;
if ($[0] !== items) {
let t0;
let t1;
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
t0 = (x) => x !== 0;
$[2] = t0;
t1 = (x) => x !== 0;
$[2] = t1;
} else {
t0 = $[2];
t1 = $[2];
}
t1 = items.filter(t0);
t0 = items.filter(t1);
$[0] = items;
$[1] = t1;
$[1] = t0;
} else {
t1 = $[1];
t0 = $[1];
}
return t1;
return t0;
}
export const FIXTURE_ENTRYPOINT = {
@@ -24,8 +24,8 @@ function Foo(props) {
const $ = useMemoCache(2);
let rest;
if ($[0] !== props.a) {
const { unused, ...t15 } = props.a;
rest = t15;
const { unused, ...t0 } = props.a;
rest = t0;
$[0] = props.a;
$[1] = rest;
} else {
@@ -20,18 +20,18 @@ function Component(props) {
import { unstable_useMemoCache as useMemoCache } from "react";
function Component(props) {
const $ = useMemoCache(4);
let t20;
let t0;
bb7: {
if (props.cond) {
let t0;
let t1;
if ($[0] !== props.a) {
t0 = makeObject(props.a);
t1 = makeObject(props.a);
$[0] = props.a;
$[1] = t0;
$[1] = t1;
} else {
t0 = $[1];
t1 = $[1];
}
t20 = t0;
t0 = t1;
break bb7;
}
let t1;
@@ -42,9 +42,9 @@ function Component(props) {
} else {
t1 = $[3];
}
t20 = t1;
t0 = t1;
}
const x = t20;
const x = t0;
return x;
}
@@ -20,46 +20,46 @@ function Component(props) {
import { unstable_useMemoCache as useMemoCache } from "react";
function Component(props) {
const $ = useMemoCache(10);
let t26;
let t0;
if ($[0] !== props.a) {
t0 = makeObject(props.a);
$[0] = props.a;
$[1] = t0;
} else {
t0 = $[1];
}
const a = t0;
let t1;
if ($[2] !== props.b) {
t1 = makeObject(props.b);
$[2] = props.b;
$[3] = t1;
if ($[0] !== props.a) {
t1 = makeObject(props.a);
$[0] = props.a;
$[1] = t1;
} else {
t1 = $[3];
t1 = $[1];
}
const b = t1;
const a = t1;
let t2;
if ($[2] !== props.b) {
t2 = makeObject(props.b);
$[2] = props.b;
$[3] = t2;
} else {
t2 = $[3];
}
const b = t2;
let t3;
if ($[4] !== a || $[5] !== b) {
t2 = [a, b];
t3 = [a, b];
$[4] = a;
$[5] = b;
$[6] = t2;
$[6] = t3;
} else {
t2 = $[6];
t3 = $[6];
}
t26 = t2;
const [a_0, b_0] = t26;
let t3;
t0 = t3;
const [a_0, b_0] = t0;
let t4;
if ($[7] !== a_0 || $[8] !== b_0) {
t3 = [a_0, b_0];
t4 = [a_0, b_0];
$[7] = a_0;
$[8] = b_0;
$[9] = t3;
$[9] = t4;
} else {
t3 = $[9];
t4 = $[9];
}
return t3;
return t4;
}
```
@@ -25,23 +25,23 @@ export const FIXTURE_ENTRYPOINT = {
import { unstable_useMemoCache as useMemoCache } from "react";
function component(a, b) {
const $ = useMemoCache(2);
let t13;
let t0;
bb6: {
if (a) {
let t0;
let t1;
if ($[0] !== b) {
t0 = { b };
t1 = { b };
$[0] = b;
$[1] = t0;
$[1] = t1;
} else {
t0 = $[1];
t1 = $[1];
}
t13 = t0;
t0 = t1;
break bb6;
}
t13 = undefined;
t0 = undefined;
}
const x = t13;
const x = t0;
return x;
}
@@ -27,20 +27,20 @@ export const FIXTURE_ENTRYPOINT = {
```javascript
function Component(props) {
let t16;
let t0;
bb10: {
bb2: {
if (props.cond) {
break bb2;
}
t16 = props.a;
t0 = props.a;
break bb10;
}
t16 = props.b;
t0 = props.b;
}
const x = t16;
const x = t0;
return x;
}
@@ -23,10 +23,10 @@ export const FIXTURE_ENTRYPOINT = {
```javascript
function Component(props) {
let t8;
let t0;
t8 = props.value;
const x = t8;
t0 = props.value;
const x = t0;
return x;
}
@@ -19,9 +19,9 @@ export const FIXTURE_ENTRYPOINT = {
```javascript
function Component(props) {
let t16;
t16 = props.a && props.b;
const x = t16;
let t0;
t0 = props.a && props.b;
const x = t0;
return x;
}
@@ -56,13 +56,13 @@ function Component(props) {
const part = free2.part;
useHook();
let t39;
let t0;
const x = makeObject_Primitives();
x.value = props.value;
mutate(x, free, part);
t39 = x;
const object = t39;
t0 = x;
const object = t0;
identity(free);
identity(part);
@@ -76,7 +76,7 @@ function Component(props) {
const part = free2.part;
useHook();
let t39;
let t2;
let x;
if ($[2] !== props.value) {
x = makeObject_Primitives();
@@ -87,8 +87,8 @@ function Component(props) {
} else {
x = $[3];
}
t39 = x;
const object = t39;
t2 = x;
const object = t2;
identity(free);
identity(part);
@@ -28,17 +28,17 @@ import { identity, makeObject_Primitives, mutate } from "shared-runtime";
function Component(props) {
const $ = useMemoCache(2);
let t7;
let t0;
let object;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
t7 = makeObject_Primitives();
object = t7;
t0 = makeObject_Primitives();
object = t0;
identity(object);
$[0] = object;
$[1] = t7;
$[1] = t0;
} else {
object = $[0];
t7 = $[1];
t0 = $[1];
}
return object;
}
@@ -28,16 +28,16 @@ import { identity, makeObject_Primitives, mutate } from "shared-runtime";
function Component(props) {
const $ = useMemoCache(1);
let t7;
let t0;
let t1;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
t0 = makeObject_Primitives();
$[0] = t0;
t1 = makeObject_Primitives();
$[0] = t1;
} else {
t0 = $[0];
t1 = $[0];
}
t7 = t0;
const object = t7;
t0 = t1;
const object = t0;
identity(object);
return object;
}
@@ -33,7 +33,7 @@ import { useMemo, unstable_useMemoCache as useMemoCache } from "react";
function Component(props) {
const $ = useMemoCache(3);
let t31;
let t0;
bb9: {
let y;
if ($[0] !== props) {
@@ -42,21 +42,21 @@ function Component(props) {
y.push(props.a);
}
if (props.cond2) {
t31 = y;
t0 = y;
break bb9;
}
y.push(props.b);
$[0] = props;
$[1] = y;
$[2] = t31;
$[2] = t0;
} else {
y = $[1];
t31 = $[2];
t0 = $[2];
}
t31 = y;
t0 = y;
}
const x = t31;
const x = t0;
return x;
}
@@ -15,26 +15,26 @@ function component(a) {
import { unstable_useMemoCache as useMemoCache } from "react";
function component(a) {
const $ = useMemoCache(4);
let t9;
let t0;
if ($[0] !== a) {
t0 = [a];
$[0] = a;
$[1] = t0;
} else {
t0 = $[1];
}
t9 = t0;
const x = t9;
let t1;
if ($[2] !== x) {
t1 = <Foo x={x} />;
$[2] = x;
$[3] = t1;
if ($[0] !== a) {
t1 = [a];
$[0] = a;
$[1] = t1;
} else {
t1 = $[3];
t1 = $[1];
}
return t1;
t0 = t1;
const x = t0;
let t2;
if ($[2] !== x) {
t2 = <Foo x={x} />;
$[2] = x;
$[3] = t2;
} else {
t2 = $[3];
}
return t2;
}
```
@@ -28,17 +28,17 @@ export const FIXTURE_ENTRYPOINT = {
```javascript
function Component(props) {
let t17;
let t0;
bb8: switch (props.key) {
case "key": {
t17 = props.value;
t0 = props.value;
break bb8;
}
default: {
t17 = props.defaultValue;
t0 = props.defaultValue;
}
}
const x = t17;
const x = t0;
return x;
}
@@ -34,12 +34,12 @@ export const FIXTURE_ENTRYPOINT = {
```javascript
function Component(props) {
let t21;
let t0;
bb10: {
let y;
bb2: switch (props.switch) {
case "foo": {
t21 = "foo";
t0 = "foo";
break bb10;
}
case "bar": {
@@ -51,9 +51,9 @@ function Component(props) {
}
}
t21 = y;
t0 = y;
}
const x = t21;
const x = t0;
return x;
}
@@ -62,33 +62,33 @@ function Component(props) {
return t1;
}
case 1: {
let t2;
let t1;
if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
t2 = { foo: "joe" };
$[3] = t2;
t1 = { foo: "joe" };
$[3] = t1;
} else {
t2 = $[3];
t1 = $[3];
}
let t3;
let t2;
if ($[4] !== onSubmit) {
t3 = <OtherComponent data={t2} onSubmit={onSubmit} />;
t2 = <OtherComponent data={t1} onSubmit={onSubmit} />;
$[4] = onSubmit;
$[5] = t3;
$[5] = t2;
} else {
t3 = $[5];
t2 = $[5];
}
return t3;
return t2;
}
default: {
logEvent("Invalid step");
let t4;
let t1;
if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
t4 = <OtherComponent data={null} />;
$[6] = t4;
t1 = <OtherComponent data={null} />;
$[6] = t1;
} else {
t4 = $[6];
t1 = $[6];
}
return t4;
return t1;
}
}
}