import type { AgencyProgram, FunctionDefinition, FunctionParameter, GraphNodeDefinition, Scope, Tag, TypeAliasEntry, TypeParam, ValueParam, VariableType } from "./types.js"; import type { ImportNodeStatement, ImportStatement } from "./types/importStatement.js"; import type { SymbolTable, InterruptEffect } from "./symbolTable.js"; export declare const GLOBAL_SCOPE_KEY = "global"; /** * Type aliases keyed by the scope they were declared in. Lookups via * `visibleIn(scopeKey)` see the requested scope plus the global scope * (scope-local overrides global). */ export declare class ScopedTypeAliases { private readonly byScope; constructor(initial?: Record>); add(scopeKey: string, name: string, body: VariableType, typeParams?: TypeParam[], tags?: Tag[], valueParams?: ValueParam[], isEffectSet?: boolean): void; get(scopeKey: string): Record | undefined; /** Flat map of every alias visible in `scopeKey`; scope-local wins. */ visibleIn(scopeKey: string): Record; /** Iterate over every (scopeKey, aliases-in-that-scope) pair. */ scopes(): [string, Record][]; clone(): ScopedTypeAliases; } /** * Signature info collected from a SymbolTable for a name brought in via * `import { ... }`. Both fields may be populated lazily — `parameters` is * filled by the stitch loop in `buildCompilationUnit`, and `returnType` * comes from the imported function/node's declaration. */ export type ImportedFunctionSignature = { parameters: FunctionParameter[]; returnType: VariableType | null; /** Absolute path of the file the symbol was imported from. Used to * resolve type aliases referenced by the signature in the right module * (so a type-name collision across files picks the right one). */ originFile?: string; /** Name of the symbol as declared in its origin file, before any * `import { foo as bar }` aliasing rewrote it locally. Used by the * interrupt call-graph analysis to build a stable cross-file identity * (`${originFile}:${originalName}`) for resolved call edges. */ originalName?: string; }; /** * Per-compilation aggregate. Holds the rich AST nodes for the entry file's * local declarations plus a typechecker-shaped scoped type-alias map. For * any cross-file question — what does this name resolve to in another * file? — call methods on the SymbolTable directly. */ export type CompilationUnit = { functionDefinitions: Record; typeAliases: ScopedTypeAliases; graphNodes: GraphNodeDefinition[]; importedNodes: ImportNodeStatement[]; importStatements: ImportStatement[]; /** Local names (defs + imports + re-exports) marked `destructive`. Read * by codegen's containsDestructiveCall to track destructive execution. */ destructiveFunctions: Record; /** Local names marked `idempotent`. Populated for symmetry with * `destructiveFunctions`, but idempotent has NO codegen role today: the * tool-loop tier reads `handler.markers?.idempotent` off the registered * AgencyFunction (fed from the def's own `markers`), not this registry. * Kept for a future call-site consumer; nothing reads it yet. */ idempotentFunctions: Record; importedFunctions: Record; /** * Local names brought in by non-Agency `import { … } from "some.js"` * statements. We don't have signatures for these (they're JS), so they * live in their own bag and the typechecker treats them as untyped * known-callable bindings — enough to keep undefined-function / * variable diagnostics quiet without pretending we know their types. */ jsImportedNames: Record; /** Original source text. Used by the typechecker to locate * `// @tc-nocheck` / `// @tc-ignore` directives. Optional because * many callers (including most tests) construct the AST directly. */ sourceText?: string; /** Transitive interrupt effects per function/node, populated from the symbol table. */ interruptEffectsByFunction?: Record; /** Symbol table used to build this unit. Forwarded so downstream * consumers (e.g. the typechecker) can use it for cross-file lookups * like resolving the file a function/node lives in. Optional because * in-process callers that build a unit from a raw program (no entry * file) don't have one. */ symbolTable?: SymbolTable; /** Absolute path of the file this compilation unit was built from. * Forwarded so downstream consumers (e.g. the typechecker) can tag * scopes with the file they came from without re-running a name * lookup against the symbol table. Undefined when callers build a * unit from a raw program with no entry file. */ fromFile?: string; }; export declare function scopeKey(scope: Scope): string; export declare function buildCompilationUnit(program: AgencyProgram, symbolTable?: SymbolTable, fromFile?: string, sourceText?: string): CompilationUnit;