import type { AwaitAnalysisResult, CapturedVariable } from "../../evaluator/async/await-analysis";
import type { Expr } from "../../expr";
import type { FunctionValue, FuncValueId } from "../../function-value";
import type { DynType, FunctionType, FutureTraitType, SomeType, StructType, Type, TypeId } from "../../types/definitions";
import type { CodeGenContext } from "../utils";
import type { EvidenceParameter } from "./declarations";
export interface FunctionGenerationContext extends CodeGenContext {
    functions: Record<FuncValueId, {
        value: FunctionValue;
        cName: string;
        effectStateMachineInfo?: unknown;
    }>;
    externFunctions: Record<TypeId, {
        type: FunctionType;
        cName: string;
        cInclude?: string;
    }>;
    currentFunctionName: string;
    unwindValueCTypes?: Set<string>;
    currentFunctionType?: FunctionType;
    currentClosureCaptures?: string[];
    currentClosureCaptureFrameLevel?: number;
    currentClosureType?: FunctionType;
    currentClosureCaptureTypeCName?: string;
    inAsyncStateMachine?: {
        futureType: SomeType | DynType;
    };
    stateMachineVariables?: Map<string, CapturedVariable>;
    stateMachineFieldAliases?: Map<string, string>;
    inEffectStateMachine?: unknown;
    isEffectRecordMemberFunction?: boolean;
    currentEvidenceParams?: Map<string, EvidenceParameter>;
    continuationVariables?: Map<string, {
        directReturnVar: string;
        directExitLabel?: string;
        isUnitReturn?: boolean;
    }>;
    variableIdRemapping?: Map<string, string>;
    pendingDeferredDrops?: Expr[];
    consumedVarPendingDrops?: Expr[];
    deferredAsyncBlocks?: Array<{
        bodyExpr: Expr;
        asyncBlockId: string;
        structName: string;
        resumeFunctionName: string;
        constructorName: string;
        disposeFunctionName: string;
        setEffectFunctionName: string;
        futureType: SomeType | DynType;
        futureTraitType: FutureTraitType;
        resultType: Type;
        resultTypeCName: string;
        captureType: StructType | undefined;
        analysis: AwaitAnalysisResult;
        closureParamSlots?: {
            fieldName: string;
            cType: string;
            paramName: string;
            paramType: Type;
        }[];
    }>;
    asyncCondBranchInfo?: Map<number, {
        branches: Array<{
            index: number;
            value: Expr;
            hasAwait: boolean;
            remainingExprs?: Expr[];
            deferredDropExpressions?: Expr[];
        }>;
        targetVariableId?: string;
        targetAssignmentCode?: string;
        condBranchFieldIndex?: number;
        chainedBranches?: Array<{
            branches: Array<{
                index: number;
                value: Expr;
                hasAwait: boolean;
                remainingExprs?: Expr[];
                deferredDropExpressions?: Expr[];
            }>;
            condBranchFieldIndex: number;
        }>;
    }>;
    asyncWhileLoopInfo?: Map<number, {
        conditionExpr: Expr;
        stepExpr?: Expr;
        bodyExpr: Expr;
        bodyExprsAfterAwait?: Expr[];
        whileLoopOriginIndex?: number;
        isChainedAwait?: boolean;
        condBranchPostWhileExprs?: {
            branchIndex: number;
            condBranchFieldIndex: number;
            exprs: Expr[];
            deferredDropExpressions?: Expr[];
            skipCondBranchCheck?: boolean;
        };
        outerWhileLoop?: {
            whileLoopIndex: number;
            conditionExpr: Expr;
            stepExpr?: Expr;
            bodyExpr: Expr;
            bodyExprsAfterAwait: Expr[];
        };
    }>;
    asyncNextWhileLoopIndex?: number;
    asyncBodyReturnExpr?: Expr;
    localShadowedVariables?: Set<string>;
    smWhileBreakInfo?: {
        label: string;
        activeIndex?: number;
    };
    smWhileContinueInfo?: {
        label: string;
        emitDropsBeforeGoto?: boolean;
        stepExpr?: Expr;
    };
    smWhileBodyDrops?: Expr[];
    shortCircuitHandledDropVarNames?: Set<string>;
    declaredTempVars?: Set<string>;
    effectHandlerParamDrops?: string[];
    effectSmConsumedArgCNames?: Set<string>;
    loopBodyDropsBaselineCount?: number;
    overrideReturnTypeStr?: string;
    usesAsync?: boolean;
    usesParallelism?: boolean;
}
