@samitouri / QOS-React-2 / commits / 11d4ff430f

ConstantPropagation traverses function expressions

Joe Savona committed Jun 8, 2023 at 14:02 UTC 11d4ff430f1fde20566417acc5499e3b4d02d877
2 files changed +5 -2
compiler/forget/packages/babel-plugin-react-forget/src/Inference/AnalyseFunctions.ts
-2
@@ -16,7 +16,6 @@ import {
16 Place,
17 ReactiveScopeDependency,
18 } from "../HIR";
19 -import { constantPropagation } from "../Optimization";
19 import { inferTypes } from "../TypeInference";
20 import { logHIRFunction } from "../Utils/logger";
21 import { inferMutableRanges } from "./InferMutableRanges";
@@ -88,7 +87,6 @@ export default function analyseFunctions(func: HIRFunction): void {
87 }
88
89 function lower(func: HIRFunction): void {
91 - constantPropagation(func);
90 inferTypes(func);
91 analyseFunctions(func);
92 inferReferenceEffects(func, { isFunctionExpression: true });
compiler/forget/packages/babel-plugin-react-forget/src/Optimization/ConstantPropagation.ts
+5
@@ -349,6 +349,11 @@ function evaluateInstruction(
349 }
350 return placeValue;
351 }
352 + case "FunctionExpression": {
353 + // TODO: propagate constants in the outer scope into the function when traversing
354 + constantPropagation(value.loweredFunc);
355 + return null;
356 + }
357 default: {
358 // TODO: handle more cases
359 return null;