diff --git a/compiler/forget/src/Babel/BabelPlugin.ts b/compiler/forget/src/Babel/BabelPlugin.ts index e2d0da658d..3588a84058 100644 --- a/compiler/forget/src/Babel/BabelPlugin.ts +++ b/compiler/forget/src/Babel/BabelPlugin.ts @@ -9,8 +9,7 @@ import jsx from "@babel/plugin-syntax-jsx"; import type * as BabelCore from "@babel/core"; -import { compileProgram } from "../CompilerEntrypoint"; -import { parsePluginOptions } from "../CompilerOptions"; +import { compileProgram, parsePluginOptions } from "../Entrypoint"; /** * The React Forget Babel Plugin diff --git a/compiler/forget/src/Babel/RunReactForgetBabelPlugin.ts b/compiler/forget/src/Babel/RunReactForgetBabelPlugin.ts index 9feb00a767..ddd955f304 100644 --- a/compiler/forget/src/Babel/RunReactForgetBabelPlugin.ts +++ b/compiler/forget/src/Babel/RunReactForgetBabelPlugin.ts @@ -11,7 +11,7 @@ import * as parser from "@babel/parser"; import invariant from "invariant"; import prettier from "prettier"; import ReactForgetBabelPlugin from "./BabelPlugin"; -import type { PluginOptions } from "../CompilerOptions"; +import type { PluginOptions } from "../Entrypoint"; type ReactForgetBabelPluginResult = { ast: BabelCore.BabelFileResult["ast"]; diff --git a/compiler/forget/src/CompilerInstrumentation.ts b/compiler/forget/src/Entrypoint/Instrumentation.ts similarity index 100% rename from compiler/forget/src/CompilerInstrumentation.ts rename to compiler/forget/src/Entrypoint/Instrumentation.ts diff --git a/compiler/forget/src/CompilerOptions.ts b/compiler/forget/src/Entrypoint/Options.ts similarity index 98% rename from compiler/forget/src/CompilerOptions.ts rename to compiler/forget/src/Entrypoint/Options.ts index 8db4c4f789..37145c2019 100644 --- a/compiler/forget/src/CompilerOptions.ts +++ b/compiler/forget/src/Entrypoint/Options.ts @@ -5,7 +5,7 @@ * LICENSE file in the root directory of this source tree. */ -import { EnvironmentConfig } from "./HIR/Environment"; +import { EnvironmentConfig } from "../HIR/Environment"; export type ExternalFunction = { /** diff --git a/compiler/forget/src/CompilerPipeline.ts b/compiler/forget/src/Entrypoint/Pipeline.ts similarity index 93% rename from compiler/forget/src/CompilerPipeline.ts rename to compiler/forget/src/Entrypoint/Pipeline.ts index d90fb6078e..7f6cf0b7ea 100644 --- a/compiler/forget/src/CompilerPipeline.ts +++ b/compiler/forget/src/Entrypoint/Pipeline.ts @@ -18,17 +18,17 @@ import { validateNoRefAccessInRender, validateTerminalSuccessors, validateUnconditionalHooks, -} from "./HIR"; -import { Environment, EnvironmentConfig } from "./HIR/Environment"; -import { findContextIdentifiers } from "./HIR/FindContextIdentifiers"; +} from "../HIR"; +import { Environment, EnvironmentConfig } from "../HIR/Environment"; +import { findContextIdentifiers } from "../HIR/FindContextIdentifiers"; import { analyseFunctions, dropMemoCalls, inferMutableRanges, inferReferenceEffects, inlineUseMemo, -} from "./Inference"; -import { constantPropagation, deadCodeElimination } from "./Optimization"; +} from "../Inference"; +import { constantPropagation, deadCodeElimination } from "../Optimization"; import { alignReactiveScopesToBlockScopes, buildReactiveBlocks, @@ -49,11 +49,11 @@ import { pruneUnusedLValues, pruneUnusedScopes, renameVariables, -} from "./ReactiveScopes"; -import { eliminateRedundantPhi, enterSSA, leaveSSA } from "./SSA"; -import { inferTypes } from "./TypeInference"; -import { logHIRFunction, logReactiveFunction } from "./Utils/logger"; -import { assertExhaustive } from "./Utils/utils"; +} from "../ReactiveScopes"; +import { eliminateRedundantPhi, enterSSA, leaveSSA } from "../SSA"; +import { inferTypes } from "../TypeInference"; +import { logHIRFunction, logReactiveFunction } from "../Utils/logger"; +import { assertExhaustive } from "../Utils/utils"; export type CompilerPipelineValue = | { kind: "ast"; name: string; value: t.FunctionDeclaration } @@ -263,7 +263,7 @@ export function* run( return ast; } -export function compile( +export function compileFn( func: NodePath, options?: Partial | null ): t.FunctionDeclaration { diff --git a/compiler/forget/src/CompilerEntrypoint.ts b/compiler/forget/src/Entrypoint/Program.ts similarity index 97% rename from compiler/forget/src/CompilerEntrypoint.ts rename to compiler/forget/src/Entrypoint/Program.ts index 07d7441126..1de6886ce3 100644 --- a/compiler/forget/src/CompilerEntrypoint.ts +++ b/compiler/forget/src/Entrypoint/Program.ts @@ -11,15 +11,11 @@ import { CompilerError, CompilerErrorDetail, ErrorSeverity, -} from "./CompilerError"; -import { compile } from "./CompilerPipeline"; -import { GeneratedSource } from "./HIR"; -import { addInstrumentForget } from "./CompilerInstrumentation"; -import { - ExternalFunction, - PluginOptions, - parsePluginOptions, -} from "./CompilerOptions"; +} from "../CompilerError"; +import { compileFn } from "./Pipeline"; +import { GeneratedSource } from "../HIR"; +import { addInstrumentForget } from "./Instrumentation"; +import { ExternalFunction, PluginOptions, parsePluginOptions } from "./Options"; export type CompilerPass = { opts: PluginOptions; @@ -51,7 +47,7 @@ export function compileProgram( pass: CompilerPass ): void { try { - const compiled = compile(fn, pass.opts.environment); + const compiled = compileFn(fn, pass.opts.environment); if (fn.node.id == null) { CompilerError.invariant( "FunctionDeclaration must have a name", diff --git a/compiler/forget/src/Entrypoint/index.ts b/compiler/forget/src/Entrypoint/index.ts new file mode 100644 index 0000000000..17a45c3159 --- /dev/null +++ b/compiler/forget/src/Entrypoint/index.ts @@ -0,0 +1,4 @@ +export * from "./Program"; +export * from "./Instrumentation"; +export * from "./Options"; +export * from "./Pipeline"; diff --git a/compiler/forget/src/index.ts b/compiler/forget/src/index.ts index deb0786942..6b939bdcfe 100644 --- a/compiler/forget/src/index.ts +++ b/compiler/forget/src/index.ts @@ -11,7 +11,7 @@ export { CompilerErrorDetail, ErrorSeverity, } from "./CompilerError"; -export { CompilerPipelineValue, compile, run } from "./CompilerPipeline"; +export { CompilerPipelineValue, compileFn as compile, run } from "./Entrypoint"; export { Effect, Hook, ValueKind, printHIR } from "./HIR"; export { printReactiveFunction } from "./ReactiveScopes";