/** * Statement emission: every `Statement` kind's JavaScript, the `using` scope * that releases its bindings on the way out, module imports and the extern and * embedded JavaScript that arrive beside them. * * D114 R1c: `emitStatement` is still declared on `JavaScriptEmitter` — it is * one of the 32 `protected` members Web and Node override — and forwards here. */ import type { ClassDeclaration, BindingPattern, EmbeddedJavaScriptDeclaration, EnumDeclaration, Expression, ImportDeclaration, MatchPattern, Program, Statement, TypeAliasDeclaration, TypeDeclaration, UsingDeclaration } from "../ast.ts"; import { type BinaryStorageKind } from "../types.ts"; import { type LoweringHints } from "../contracts.ts"; import { type Span } from "../source.ts"; import { type PreparedEmbeddedJavaScriptModule } from "./javascript.ts"; export interface StatementEmitterHost { readonly moduleAccess: import("./module-access.ts").ModuleAccessEmitter; binaryIndexHelper(kind: BinaryStorageKind): string; binarySetIndexHelper(kind: Exclude): string; blockAlwaysReturns(statements: readonly Statement[]): boolean; collectionIteratorHelper(kind: "list" | "map" | "set" | "record" | "string" | "binary", pair: boolean): string; readonly embeddedJavaScript: Map; emitBindingPatternStatements(pattern: BindingPattern, value: string, binding: "const" | "let", exported: boolean, depth: number, label: string): readonly string[]; emitClass(statement: ClassDeclaration, depth: number): string; emitCondition(expression: Expression): string; emitEnumDeclaration(statement: EnumDeclaration, depth: number): string; emitMappedAssignmentTarget(expression: Extract): string; emitMappedExpression(expression: Expression, normalizeNull?: boolean): string; emitMappedJavaScript(sourceSpan: Span, render: () => string): string; emitMappedStatement(statement: Statement, depth: number): string; emitMatchPatternAttempt(pattern: MatchPattern, valueName: string, indentation: string): { readonly lines: readonly string[]; readonly bindings: readonly { readonly name: string; readonly value: string; }[]; }; emitParameter(name: string, defaultValue: Expression | null, rest?: boolean): string; emitStatementLines(statements: readonly Statement[], depth: number): readonly string[]; emitTypeAliasDeclaration(statement: TypeAliasDeclaration, depth: number): string; emitTypeDeclaration(statement: TypeDeclaration, depth: number): string; readonly executeMain: boolean; readonly externModuleExports: Map>; readonly forcedFunctionExports: ReadonlySet; readonly hints: LoweringHints; needsAssertionErrorClass: boolean; needsBinaryHelpers: boolean; needsBitwiseHelpers: boolean; needsCollectionHelpers: boolean; needsDisposalHelper: boolean; needsExternExportHelper: boolean; needsIndexHelpers: boolean; needsThrownValueHelper: boolean; readonly runtimeTypes: Set; readonly sourcePath: string; } export declare class StatementEmitter { private readonly host; constructor(host: StatementEmitterHost); emitStatement(statement: Statement, depth: number): string; /** * Declarations: the module boundary an import or re-export becomes, the two * embedded-JavaScript forms, the runtime `Type` a type or enum declaration * compiles to, a class, a binding, `@main`, a test, and a function. */ private emitDeclarationStatement; /** * The statements that leave or branch: `return`, `throw`, `assert`, `if` and * `match`. */ private emitBranchStatement; /** * The statements that repeat or unwind: `for` in both its forms, `while`, * `break`, `continue`, `pass` and `try`. */ private emitLoopStatement; /** * An assignment. The target decides the shape: an index assignment lowers * through the collection or binary helper for its receiver, a compound * assignment to a guarded field reads through the same guard it writes, and * everything else is the plain JavaScript assignment. */ private emitAssignmentStatement; emitUsingScope(statement: UsingDeclaration, rest: readonly Statement[], depth: number): readonly string[]; emitImport(statement: ImportDeclaration, indentation: string): string; prepareEmbeddedJavaScript(program: Program): void; private emitEmbeddedJavaScript; private emitCompoundOperation; private bitwiseAssignmentOperator; } //# sourceMappingURL=statements.d.ts.map