@samitouri / QOS-React-1 / commits / 1debb59830

🌲 Remove reactive scope handling from codegen

The previous PR converts reactive scopes to normal instructions, so that Forest mode won't have any scopes left by the time we reach codegen. This PR removes the now-unused codegen logic for forest.

Joe Savona committed Dec 11, 2023 at 11:34 UTC 1debb59830c7873ac8455c54e43b2b534f4ab77a
1 file changed +1 -49
compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/CodegenReactiveFunction.ts
+1 -49
@@ -308,7 +308,7 @@ function wrapCacheDep(cx: Context, value: t.Expression): t.Expression {
308 }
309 }
310
311 -function codegenMemoBlockForReactiveScope(
311 +function codegenReactiveScope(
312 cx: Context,
313 statements: Array<t.Statement>,
314 scope: ReactiveScope,
@@ -507,54 +507,6 @@ function codegenMemoBlockForReactiveScope(
507 statements.push(memoStatement);
508 }
509
510 -function codegenSignalBlockForReactiveScope(
511 - cx: Context,
512 - statements: Array<t.Statement>,
513 - scope: ReactiveScope,
514 - block: ReactiveBlock
515 -): void {
516 - CompilerError.invariant(scope.reassignments.size === 0, {
517 - reason: "Add support for reassignments in a derived computation block",
518 - loc: null,
519 - suggestions: null,
520 - });
521 - CompilerError.invariant(scope.declarations.size === 1, {
522 - reason:
523 - "Add support for multiple declarations in a derived computation block",
524 - loc: null,
525 - suggestions: null,
526 - });
527 - const [_, { identifier }] = [...scope.declarations][0];
528 - const name = convertIdentifier(identifier);
529 -
530 - const derivedBlock = codegenBlock(cx, block);
531 - derivedBlock.body.push(t.returnStatement(name));
532 -
533 - const derivedLambda = t.functionExpression(null, [], derivedBlock, false);
534 - const derivedComputationCall = t.callExpression(t.identifier("derived"), [
535 - derivedLambda,
536 - ]);
537 -
538 - statements.push(
539 - t.variableDeclaration("const", [
540 - t.variableDeclarator(name, derivedComputationCall),
541 - ])
542 - );
543 -}
544 -
545 -function codegenReactiveScope(
546 - cx: Context,
547 - statements: Array<t.Statement>,
548 - scope: ReactiveScope,
549 - block: ReactiveBlock
550 -): void {
551 - if (cx.env.config.enableForest) {
552 - codegenSignalBlockForReactiveScope(cx, statements, scope, block);
553 - } else {
554 - codegenMemoBlockForReactiveScope(cx, statements, scope, block);
555 - }
556 -}
557 -
510 function codegenTerminal(
511 cx: Context,
512 terminal: ReactiveTerminal