mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
[be] Extract Environment to a separate file
Precursor to making the environment configurable
This commit is contained in:
@@ -11,6 +11,7 @@ import invariant from "invariant";
|
||||
import { CompilerError, ErrorSeverity } from "../CompilerError";
|
||||
import { Err, Ok, Result } from "../Utils/Result";
|
||||
import { assertExhaustive } from "../Utils/utils";
|
||||
import { Environment } from "./Environment";
|
||||
import {
|
||||
BlockId,
|
||||
BranchTerminal,
|
||||
@@ -29,7 +30,7 @@ import {
|
||||
SourceLocation,
|
||||
ThrowTerminal,
|
||||
} from "./HIR";
|
||||
import HIRBuilder, { Environment } from "./HIRBuilder";
|
||||
import HIRBuilder from "./HIRBuilder";
|
||||
|
||||
// *******************************************************************************************
|
||||
// *******************************************************************************************
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
import { IdentifierId, makeIdentifierId } from "./HIR";
|
||||
|
||||
export class Environment {
|
||||
#nextIdentifer: number = 0;
|
||||
|
||||
get nextIdentifierId(): IdentifierId {
|
||||
return makeIdentifierId(this.#nextIdentifer++);
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
import * as t from "@babel/types";
|
||||
import invariant from "invariant";
|
||||
import { Environment } from "./HIRBuilder";
|
||||
import { Environment } from "./Environment";
|
||||
|
||||
// *******************************************************************************************
|
||||
// *******************************************************************************************
|
||||
|
||||
@@ -11,6 +11,7 @@ import invariant from "invariant";
|
||||
import { CompilerError } from "../CompilerError";
|
||||
import { logHIR } from "../Utils/logger";
|
||||
import { assertExhaustive } from "../Utils/utils";
|
||||
import { Environment } from "./Environment";
|
||||
import { getOrAddGlobal } from "./Globals";
|
||||
import {
|
||||
BasicBlock,
|
||||
@@ -20,10 +21,8 @@ import {
|
||||
GotoVariant,
|
||||
HIR,
|
||||
Identifier,
|
||||
IdentifierId,
|
||||
Instruction,
|
||||
makeBlockId,
|
||||
makeIdentifierId,
|
||||
makeInstructionId,
|
||||
makeType,
|
||||
Terminal,
|
||||
@@ -71,14 +70,6 @@ function newBlock(id: BlockId, kind: BlockKind): WipBlock {
|
||||
return { id, kind, instructions: [] };
|
||||
}
|
||||
|
||||
export class Environment {
|
||||
#nextIdentifer: number = 0;
|
||||
|
||||
get nextIdentifierId(): IdentifierId {
|
||||
return makeIdentifierId(this.#nextIdentifer++);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper class for constructing a CFG
|
||||
*/
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
*/
|
||||
|
||||
export { lower } from "./BuildHIR";
|
||||
export { Environment } from "./Environment";
|
||||
export * from "./HIR";
|
||||
export {
|
||||
Environment,
|
||||
markInstructionIds,
|
||||
markPredecessors,
|
||||
removeUnreachableFallthroughs,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import invariant from "invariant";
|
||||
import { CompilerError } from "../CompilerError";
|
||||
import { Environment } from "../HIR/Environment";
|
||||
import {
|
||||
BasicBlock,
|
||||
BlockId,
|
||||
@@ -12,14 +13,12 @@ import {
|
||||
Phi,
|
||||
Place,
|
||||
} from "../HIR/HIR";
|
||||
import { Environment } from "../HIR/HIRBuilder";
|
||||
import { printIdentifier } from "../HIR/PrintHIR";
|
||||
import {
|
||||
eachTerminalSuccessor,
|
||||
mapInstructionOperands,
|
||||
mapTerminalOperands,
|
||||
} from "../HIR/visitors";
|
||||
import { todoInvariant } from "../Utils/todo";
|
||||
|
||||
type IncompletePhi = {
|
||||
oldId: Identifier;
|
||||
|
||||
Reference in New Issue
Block a user