diff --git a/compiler/forget/src/HIR/BuildHIR.ts b/compiler/forget/src/HIR/BuildHIR.ts index 9d38badad5..b2827a535f 100644 --- a/compiler/forget/src/HIR/BuildHIR.ts +++ b/compiler/forget/src/HIR/BuildHIR.ts @@ -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"; // ******************************************************************************************* // ******************************************************************************************* diff --git a/compiler/forget/src/HIR/Environment.ts b/compiler/forget/src/HIR/Environment.ts new file mode 100644 index 0000000000..4b72b43037 --- /dev/null +++ b/compiler/forget/src/HIR/Environment.ts @@ -0,0 +1,9 @@ +import { IdentifierId, makeIdentifierId } from "./HIR"; + +export class Environment { + #nextIdentifer: number = 0; + + get nextIdentifierId(): IdentifierId { + return makeIdentifierId(this.#nextIdentifer++); + } +} diff --git a/compiler/forget/src/HIR/HIR.ts b/compiler/forget/src/HIR/HIR.ts index 6126f6c5cc..f320d2a5e5 100644 --- a/compiler/forget/src/HIR/HIR.ts +++ b/compiler/forget/src/HIR/HIR.ts @@ -7,7 +7,7 @@ import * as t from "@babel/types"; import invariant from "invariant"; -import { Environment } from "./HIRBuilder"; +import { Environment } from "./Environment"; // ******************************************************************************************* // ******************************************************************************************* diff --git a/compiler/forget/src/HIR/HIRBuilder.ts b/compiler/forget/src/HIR/HIRBuilder.ts index 4cff0c0b83..58c8372870 100644 --- a/compiler/forget/src/HIR/HIRBuilder.ts +++ b/compiler/forget/src/HIR/HIRBuilder.ts @@ -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 */ diff --git a/compiler/forget/src/HIR/index.ts b/compiler/forget/src/HIR/index.ts index 9c37e081cd..6918473071 100644 --- a/compiler/forget/src/HIR/index.ts +++ b/compiler/forget/src/HIR/index.ts @@ -6,9 +6,9 @@ */ export { lower } from "./BuildHIR"; +export { Environment } from "./Environment"; export * from "./HIR"; export { - Environment, markInstructionIds, markPredecessors, removeUnreachableFallthroughs, diff --git a/compiler/forget/src/SSA/EnterSSA.ts b/compiler/forget/src/SSA/EnterSSA.ts index 470f5454ae..f573134391 100644 --- a/compiler/forget/src/SSA/EnterSSA.ts +++ b/compiler/forget/src/SSA/EnterSSA.ts @@ -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;