/** * Branch context manipulation helpers for if-statement emission. * Builds narrowed bindings, union complement bindings, cast declarations, * and condition AST nodes. */ import { IrExpression, IrStatement, IrType } from "@tsonic/frontend"; import { EmitterContext, NarrowedBinding } from "../../../types.js"; import type { CSharpExpressionAst, CSharpStatementAst, CSharpBlockStatementAst, CSharpTypeAst } from "../../../core/format/backend-ast/types.js"; import { buildUnionNarrowAst } from "../../../core/semantic/narrowing-builders.js"; export type EmitExprAstFn = (e: IrExpression, ctx: EmitterContext) => [CSharpExpressionAst, EmitterContext]; export { buildUnionNarrowAst }; /** Standard emitExpressionAst adapter for emitBooleanConditionAst callback. */ export declare const emitExprAstCb: EmitExprAstFn; export declare const mergeBranchContextMeta: (preferred: EmitterContext, alternate: EmitterContext) => EmitterContext; export declare const mergeBranchFlowState: (base: EmitterContext, preferred: EmitterContext, alternate: EmitterContext, context: EmitterContext) => [ReadonlyMap | undefined, EmitterContext]; export declare const mergeBranchExitContext: (base: EmitterContext, preferred: EmitterContext, alternate: EmitterContext) => EmitterContext; export declare const resetBranchFlowState: (base: EmitterContext, branchContext: EmitterContext) => EmitterContext; export declare const toReceiverAst: (receiver: string | CSharpExpressionAst) => CSharpExpressionAst; export declare const buildExprBinding: (exprAst: CSharpExpressionAst, type: IrType | undefined, sourceType: IrType | undefined, storageExprAst?: CSharpExpressionAst, storageType?: IrType, carrierExprAst?: CSharpExpressionAst, carrierType?: IrType) => Extract; export declare const buildProjectedExprBinding: (exprAst: CSharpExpressionAst, type: IrType | undefined, sourceType: IrType | undefined, carrierExprAst: CSharpExpressionAst, storageType?: IrType, carrierType?: IrType) => Extract; export declare const buildSubsetUnionType: (members: readonly IrType[]) => IrType | undefined; export declare const buildComplementNarrowedBinding: (receiver: string | CSharpExpressionAst, runtimeUnionArity: number, candidateMemberNs: readonly number[], candidateMembers: readonly IrType[], selectedMemberN: number, sourceType?: IrType, sourceMembers?: readonly IrType[], sourceCandidateMemberNs?: readonly number[]) => NarrowedBinding | undefined; export declare const buildComplementNarrowedBindingForMembers: (receiver: string | CSharpExpressionAst, runtimeUnionArity: number, candidateMemberNs: readonly number[], candidateMembers: readonly IrType[], selectedMemberNs: readonly number[], sourceType?: IrType, sourceMembers?: readonly IrType[], sourceCandidateMemberNs?: readonly number[]) => NarrowedBinding | undefined; export declare const applyExprFallthroughNarrowing: (originalName: string, exprAst: CSharpExpressionAst, narrowedType: IrType, baseContext: EmitterContext, finalContext: EmitterContext, storageType?: IrType) => EmitterContext; export declare const withoutNarrowedBinding: (context: EmitterContext, bindingKey: string) => EmitterContext; export declare const withComplementNarrowing: (originalName: string, receiver: string | CSharpExpressionAst, runtimeUnionArity: number, candidateMemberNs: readonly number[], candidateMembers: readonly IrType[], selectedMemberN: number, baseContext: EmitterContext) => EmitterContext; export declare const withComplementNarrowingForMembers: (originalName: string, receiver: string | CSharpExpressionAst, runtimeUnionArity: number, candidateMemberNs: readonly number[], candidateMembers: readonly IrType[], selectedMemberNs: readonly number[], baseContext: EmitterContext) => EmitterContext; export declare const withRuntimeUnionMemberNarrowing: (originalName: string, receiver: string | CSharpExpressionAst, memberN: number, memberType: IrType, sourceType: IrType | undefined, baseContext: EmitterContext, storageType?: IrType) => EmitterContext; /** Wrap an array of statements in a single statement (block if >1). */ export declare const wrapInBlock: (stmts: readonly CSharpStatementAst[]) => CSharpStatementAst; export declare const emitBranchScopedStatementAst: (bodyStmt: IrStatement, bodyCtx: EmitterContext) => [readonly CSharpStatementAst[], EmitterContext]; /** * Emit a forced block with a preamble line as AST. * Builds a blockStatement with preamble statements + body statements. * * If bodyStmt is already a block, its statements are inlined to avoid nesting. */ export declare const emitForcedBlockWithPreambleAst: (preambleStmts: readonly CSharpStatementAst[], bodyStmt: IrStatement, bodyCtx: EmitterContext) => [CSharpBlockStatementAst, EmitterContext]; /** * Build a `var name = expr.AsN();` statement as AST. */ export declare const buildCastLocalDecl: (varName: string, receiver: string | CSharpExpressionAst, memberN: number, narrowedTypeAst?: CSharpTypeAst) => CSharpStatementAst; /** * Build the condition expression `orig.IsN()` or `!orig.IsN()`. */ export declare const buildIsNCondition: (receiver: string | CSharpExpressionAst, memberN: number, negate: boolean, guardNullish?: boolean) => CSharpExpressionAst; export declare const buildAnyIsNCondition: (receiver: string | CSharpExpressionAst, memberNs: readonly number[], negate: boolean, guardNullish?: boolean) => CSharpExpressionAst; /** * Build the condition expression `orig is TypeName varName`. */ export declare const buildIsPatternCondition: (receiver: string | CSharpExpressionAst, rhsTypeAst: CSharpTypeAst, escapedNarrow: string) => CSharpExpressionAst; //# sourceMappingURL=branch-context.d.ts.map