From 95514b3e4267dbc2182ac69aeb310bb13a47c5cf Mon Sep 17 00:00:00 2001 From: Drew Youngwerth Date: Tue, 3 Sep 2024 21:53:33 -0700 Subject: [PATCH] Improve cli and config interface --- src/cli/exec.ts | 15 +++------------ src/lib/config/{cli.ts => arg-parser.ts} | 8 ++------ src/lib/config/index.ts | 2 +- src/lib/config/types.ts | 6 ++---- 4 files changed, 8 insertions(+), 23 deletions(-) rename src/lib/config/{cli.ts => arg-parser.ts} (87%) diff --git a/src/cli/exec.ts b/src/cli/exec.ts index a79cecad..ec7229b3 100644 --- a/src/cli/exec.ts +++ b/src/cli/exec.ts @@ -21,12 +21,8 @@ async function main() { return emit(await getCoreAst(config.index)); } - if (config.emitModuleAst) { - return emit(await getModuleAst(config.index)); - } - - if (config.emitMacroAst) { - return emit(await getMacroAst(config.index)); + if (config.emitIrAst) { + return emit(await getIrAST(config.index)); } if (config.emitWasmText) { @@ -60,12 +56,7 @@ async function getCoreAst(index: string) { return await getParserAst(index); } -async function getModuleAst(index: string) { - const module = await parseModuleFromSrc(index); - return processSemantics(module); -} - -async function getMacroAst(index: string) { +async function getIrAST(index: string) { const module = await parseModuleFromSrc(index); return processSemantics(module); } diff --git a/src/lib/config/cli.ts b/src/lib/config/arg-parser.ts similarity index 87% rename from src/lib/config/cli.ts rename to src/lib/config/arg-parser.ts index fdeda862..964fe9cb 100644 --- a/src/lib/config/cli.ts +++ b/src/lib/config/arg-parser.ts @@ -8,10 +8,7 @@ const options: ParseArgsConfig["options"] = { "emit-core-ast": { type: "boolean", }, - "emit-module-ast": { - type: "boolean", - }, - "emit-macro-ast": { + "emit-ir-ast": { type: "boolean", }, "emit-wasm": { @@ -53,8 +50,7 @@ export const getConfigFromCli = (): VoidConfig => { index, emitParserAst: values["emit-parser-ast"] as boolean, emitCoreAst: values["emit-core-ast"] as boolean, - emitModuleAst: values["emit-module-ast"] as boolean, - emitMacroAst: values["emit-macro-ast"] as boolean, + emitIrAst: values["emit-ir-ast"] as boolean, emitWasm: values["emit-wasm"] as boolean, emitWasmText: values["emit-wasm-text"] as boolean, runBinaryenOptimizationPass: values["opt"] as boolean, diff --git a/src/lib/config/index.ts b/src/lib/config/index.ts index 5582cdea..158aff71 100644 --- a/src/lib/config/index.ts +++ b/src/lib/config/index.ts @@ -1,4 +1,4 @@ -import { getConfigFromCli } from "./cli.js"; +import { getConfigFromCli } from "./arg-parser.js"; import { VoidConfig } from "./types.js"; let config: VoidConfig | undefined = undefined; diff --git a/src/lib/config/types.ts b/src/lib/config/types.ts index bff1711f..b520ace6 100644 --- a/src/lib/config/types.ts +++ b/src/lib/config/types.ts @@ -3,10 +3,8 @@ export type VoidConfig = { emitParserAst?: boolean; /** Write desurfaced AST to stdout */ emitCoreAst?: boolean; - /** Emit full AST with all resolved file modules */ - emitModuleAst?: boolean; - /** Emit ast with regular macros expanded */ - emitMacroAst?: boolean; + /** Emit ast ir expanded (post semantic phases) */ + emitIrAst?: boolean; /** Write wasm bytecode to stdout */ emitWasm?: boolean; /** Write wasm bytecode to stdout (binaryen flavor) */