From 25d68a7541bf76dd9f18ef37b15f376f972f8aff Mon Sep 17 00:00:00 2001 From: Novus Nota <68142933+novusnota@users.noreply.github.com> Date: Thu, 24 Oct 2024 11:21:04 +0200 Subject: [PATCH] feat(api): export `precompile()` and allow passing `AstModule[]` in --- src/index.ts | 1 + src/pipeline/precompile.ts | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 7469a0101..da47c4368 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,5 @@ export { enableFeatures, build } from "./pipeline/build"; +export { precompile } from "./pipeline/precompile"; export { TactError, TactParseError, diff --git a/src/pipeline/precompile.ts b/src/pipeline/precompile.ts index eca8f3533..8ada419da 100644 --- a/src/pipeline/precompile.ts +++ b/src/pipeline/precompile.ts @@ -7,18 +7,20 @@ import { resolveErrors } from "../types/resolveErrors"; import { resolveSignatures } from "../types/resolveSignatures"; import { resolveImports } from "../imports/resolveImports"; import { VirtualFileSystem } from "../vfs/VirtualFileSystem"; +import { AstModule } from "../grammar/ast"; export function precompile( ctx: CompilerContext, project: VirtualFileSystem, stdlib: VirtualFileSystem, entrypoint: string, + parsedModules?: AstModule[], ) { // Load all sources const imported = resolveImports({ entrypoint, project, stdlib }); // Add information about all the source code entries to the context - ctx = openContext(ctx, imported.tact, imported.func); + ctx = openContext(ctx, imported.tact, imported.func, parsedModules); // First load type descriptors and check that // they all have valid signatures