mirror of
https://github.com/facebook/react.git
synced 2026-11-18 20:15:56 +00:00
[hir] Store env in HIRFunction
The env is specific to the HIR function anwyays. It's not very useful outside the HIRFunction.
This commit is contained in:
1 parent
0a60bf2071
commit
da6d372c3a
4 files changed
+9
-8
No files matched your search
@@ -42,9 +42,7 @@ export type CompilerPipelineValue =
|
||||
export function* run(
|
||||
func: NodePath<t.FunctionDeclaration>
|
||||
): Generator<CompilerPipelineValue, t.Function> {
|
||||
const env = new Environment();
|
||||
|
||||
const lowering = lower(func, env).orElse((errors) => {
|
||||
const lowering = lower(func).orElse((errors) => {
|
||||
const msg = errors.map((error) => error.toString()).join("\n\n");
|
||||
throw new Error(msg);
|
||||
});
|
||||
@@ -55,7 +53,7 @@ export function* run(
|
||||
mergeConsecutiveBlocks(hir);
|
||||
yield log({ kind: "hir", name: "MergeConsecutiveBlocks", value: hir });
|
||||
|
||||
enterSSA(hir, env);
|
||||
enterSSA(hir);
|
||||
yield log({ kind: "hir", name: "SSA", value: hir });
|
||||
|
||||
eliminateRedundantPhi(hir);
|
||||
|
||||
@@ -48,9 +48,9 @@ import HIRBuilder, { Environment } from "./HIRBuilder";
|
||||
* grained reactivity.
|
||||
*/
|
||||
export function lower(
|
||||
func: NodePath<t.Function>,
|
||||
env: Environment
|
||||
func: NodePath<t.Function>
|
||||
): Result<HIRFunction, CompilerError[]> {
|
||||
const env = new Environment();
|
||||
const builder = new HIRBuilder(env);
|
||||
|
||||
const id =
|
||||
@@ -106,6 +106,7 @@ export function lower(
|
||||
generator: func.node.generator === true,
|
||||
async: func.node.async === true,
|
||||
loc: func.node.loc ?? GeneratedSource,
|
||||
env,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
import * as t from "@babel/types";
|
||||
import invariant from "invariant";
|
||||
import { Environment } from "./HIRBuilder";
|
||||
|
||||
// *******************************************************************************************
|
||||
// *******************************************************************************************
|
||||
@@ -161,6 +162,7 @@ export type ReactiveIfTerminal = {
|
||||
export type HIRFunction = {
|
||||
loc: SourceLocation;
|
||||
id: Identifier | null;
|
||||
env: Environment;
|
||||
params: Array<Place>;
|
||||
body: HIR;
|
||||
generator: boolean;
|
||||
|
||||
@@ -182,9 +182,9 @@ class SSABuilder {
|
||||
}
|
||||
}
|
||||
|
||||
export default function enterSSA(func: HIRFunction, env: Environment) {
|
||||
export default function enterSSA(func: HIRFunction) {
|
||||
const visitedBlocks: Set<BasicBlock> = new Set();
|
||||
const builder = new SSABuilder(env, func.body.blocks);
|
||||
const builder = new SSABuilder(func.env, func.body.blocks);
|
||||
for (const [blockId, block] of func.body.blocks) {
|
||||
invariant(
|
||||
!visitedBlocks.has(block),
|
||||
|
||||
Reference in new issue
Block a user