import type { AgencyNode } from "../../types.js"; import type { CompilationUnit } from "../../compilationUnit.js"; /** * Plain JS functions that bypass the `__call` dispatcher and are invoked * directly. These are NOT AgencyFunction instances and do not participate in * the interrupt-checking machinery. */ export declare const DIRECT_CALL_FUNCTIONS: ReadonlySet; /** * Answers "what kind of name is this?" questions for the TypeScriptBuilder. * * The builder repeatedly needs to ask whether a given identifier names a * graph node, an imported function, an impure call, a top-level * declaration, etc. Previously each question was implemented as an ad-hoc * method on the builder, with its own lazily-built caches sprinkled * through the file. This class collects them in one place, builds the * caches eagerly in its constructor, and exposes a small predicate API. * * Pure — depends only on the `CompilationUnit` it is constructed with. */ export declare class NameClassifier { private readonly compilationUnit; private readonly plainTsImportNames; private readonly agencyImportNames; private readonly graphNodeNames; constructor(compilationUnit: CompilationUnit); /** True if `functionName` names a graph node defined in or imported into this module. */ isGraphNode(functionName: string): boolean; /** * True if `name` was brought in by an `import { … } from ".agency"` * statement (as opposed to a `.js`/`.ts` import). Used by the codegen to * decide whether a read of `name` in user code should be wrapped with * `__readStatic` — agency imports could be `static const` values which * hold the `__UNINIT_STATIC` sentinel before their initializer runs. * Non-static agency imports (functions, nodes) will never equal the * sentinel, so the wrap is a no-op for them. */ isAgencyImport(name: string): boolean; /** * True if `functionName` is one of the plain-JS helpers that bypass the * `__call` dispatcher (`approve`, `reject`, `success`, `failure`, …). */ isDirectCallFunction(functionName: string): boolean; /** * AST nodes that should be emitted at module top level (function * declarations, type aliases, classes, imports, comments, blank lines, * and static-scoped assignments). Anything else belongs inside the * per-execution `__initializeGlobals` body. */ isTopLevelDeclaration(node: AgencyNode): boolean; /** The function name a call-bearing node targets, if any. Handles a plain * `functionCall` and the `try f()` case (`walkNodes` yields the * tryExpression node but does not descend into its `.call`, so the common * `return try _extern(...)` stdlib pattern would otherwise be missed). */ private callTarget; /** Recursively walks `node` and returns true if any function call within * it targets a function marked `destructive`; reads the destructiveFunctions * registry. */ containsDestructiveCall(node: AgencyNode): boolean; /** * True if a call to `functionName` should be wrapped in the * interrupt-checking boilerplate. Everything gets it EXCEPT known * non-Agency direct-call helpers, compiler-internal `__` names, and * graph nodes (which handle their own interrupts). */ shouldHandleInterrupts(functionName: string): boolean; }