@samitouri / QOS-React-1 / commits / 4571979e46

Add pass to lower useState

Sathya Gunasekaran committed Sep 5, 2023 at 11:13 UTC 4571979e4685aaf0e42f0f24200e52059af7a4fd
2 files changed +16
compiler/packages/babel-plugin-react-forget/src/Entrypoint/Pipeline.ts
+10
@@ -7,6 +7,7 @@
7
8 import { NodePath } from "@babel/traverse";
9 import * as t from "@babel/types";
10 +import { lowerUseState } from "../Forest";
11 import {
12 HIRFunction,
13 ReactiveFunction,
@@ -245,6 +246,15 @@ export function* run(
246 value: reactiveFunction,
247 });
248
249 + if (config?.enableForest) {
250 + lowerUseState(reactiveFunction);
251 + yield log({
252 + kind: "reactive",
253 + name: "LowerUseState",
254 + value: reactiveFunction,
255 + });
256 + }
257 +
258 promoteUsedTemporaries(reactiveFunction);
259 yield log({
260 kind: "reactive",
compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/index.ts
+6
@@ -28,3 +28,9 @@ export { pruneTemporaryLValues as pruneUnusedLValues } from "./PruneTemporaryLVa
28 export { pruneUnusedLabels } from "./PruneUnusedLabels";
29 export { pruneUnusedScopes } from "./PruneUnusedScopes";
30 export { renameVariables } from "./RenameVariables";
31 +export {
32 + ReactiveFunctionTransform,
33 + Transformed,
34 + eachReactiveValueOperand,
35 + visitReactiveFunction,
36 +} from "./visitors";