/**
 * Core expression types for IR — base types, union, and primary expression nodes.
 */
import { IrType } from "./ir-types.js";
import type { IrParameter, IrPattern, IrBinaryOperator, IrAssignmentOperator } from "./helpers.js";
import type { IrClassMember } from "./statements.js";
import { IrBlockStatement } from "./statements.js";
import { NumericKind } from "./numeric-kind.js";
import { SourceLocation } from "../../types/diagnostic.js";
import type { DeclId, SignatureId, MemberId } from "../type-system/types.js";
import type { IrNumericNarrowingExpression, IrTypeAssertionExpression, IrAsInterfaceExpression, IrTryCastExpression, IrStackAllocExpression, IrDefaultOfExpression, IrNameOfExpression, IrSizeOfExpression } from "./expressions-extended.js";
/**
 * Base fields shared by all expression types.
 * - inferredType: The type TypeScript infers for this expression
 * - contextualType: The type expected from context (assignment target, return type, etc.)
 * - sourceSpan: Source location for error reporting
 */
export type IrExpressionBase = {
    readonly inferredType?: IrType;
    readonly contextualType?: IrType;
    readonly sourceSpan?: SourceLocation;
};
export type IrExpression = IrLiteralExpression | IrIdentifierExpression | IrArrayExpression | IrObjectExpression | IrFunctionExpression | IrArrowFunctionExpression | IrMemberExpression | IrCallExpression | IrNewExpression | IrThisExpression | IrUpdateExpression | IrUnaryExpression | IrBinaryExpression | IrLogicalExpression | IrConditionalExpression | IrAssignmentExpression | IrTemplateLiteralExpression | IrSpreadExpression | IrAwaitExpression | IrYieldExpression | IrNumericNarrowingExpression | IrTypeAssertionExpression | IrAsInterfaceExpression | IrTryCastExpression | IrStackAllocExpression | IrDefaultOfExpression | IrNameOfExpression | IrSizeOfExpression;
export type IrLiteralExpression = {
    readonly kind: "literal";
    readonly value: string | number | boolean | null | undefined;
    readonly raw?: string;
    readonly inferredType?: IrType;
    readonly sourceSpan?: SourceLocation;
    /**
     * For numeric literals, the inferred numeric kind based on lexeme form.
     * - Integer literals (42, 0xFF) → "Int32"
     * - Floating literals (42.0, 3.14, 1e3) → "Double"
     *
     * This is expression-level information, NOT type-level.
     * The type system still sees this as "number" (which means double).
     * This field enables the emitter to emit `42` vs `42.0` appropriately
     * and the coercion pass to detect int→double conversions.
     */
    readonly numericIntent?: NumericKind;
};
export type IrIdentifierExpression = {
    readonly kind: "identifier";
    readonly name: string;
    readonly inferredType?: IrType;
    readonly sourceSpan?: SourceLocation;
    readonly declId?: DeclId;
    readonly resolvedClrType?: string;
    readonly resolvedAssembly?: string;
    readonly csharpName?: string;
    readonly importedFrom?: {
        readonly containerName: string;
        readonly exportName: string;
        readonly namespace: string;
    };
    readonly originalName?: string;
};
export type IrArrayExpression = {
    readonly kind: "array";
    readonly elements: readonly (IrExpression | IrSpreadExpression | undefined)[];
    readonly inferredType?: IrType;
    readonly sourceSpan?: SourceLocation;
};
export type IrObjectExpression = {
    readonly kind: "object";
    readonly properties: readonly IrObjectProperty[];
    /** Synthesized behavioral members (currently accessors) for object literal lowering. */
    readonly behaviorMembers?: readonly IrClassMember[];
    readonly inferredType?: IrType;
    readonly sourceSpan?: SourceLocation;
    /** Contextual type for object literals in typed positions (return, assignment, etc.) */
    readonly contextualType?: IrType;
    /** True if this object literal contains spread expressions (for IIFE lowering) */
    readonly hasSpreads?: boolean;
};
export type IrObjectProperty = {
    readonly kind: "property";
    readonly key: string | IrExpression;
    readonly value: IrExpression;
    readonly shorthand: boolean;
} | {
    readonly kind: "spread";
    readonly expression: IrExpression;
};
export type IrFunctionExpression = {
    readonly kind: "functionExpression";
    readonly name?: string;
    readonly parameters: readonly IrParameter[];
    readonly returnType?: IrType;
    readonly body: IrBlockStatement;
    readonly isAsync: boolean;
    readonly isGenerator: boolean;
    /** True when object-literal method shorthand must bind `this` to the constructed object. */
    readonly capturesObjectLiteralThis?: boolean;
    readonly inferredType?: IrType;
    readonly sourceSpan?: SourceLocation;
};
export type IrArrowFunctionExpression = {
    readonly kind: "arrowFunction";
    readonly parameters: readonly IrParameter[];
    readonly returnType?: IrType;
    readonly body: IrBlockStatement | IrExpression;
    readonly isAsync: boolean;
    readonly inferredType?: IrType;
    /** Contextual type from call site (e.g., array.map callback signature) */
    readonly contextualType?: IrType;
    readonly sourceSpan?: SourceLocation;
};
/**
 * Classification for computed member access lowering.
 * Determines whether TSN5107 (Int32 proof) is required.
 *
 * - clrIndexer: CLR indexer (obj[int]) - requires Int32 proof
 * - dictionary: Dictionary<K,V>[key] - NO Int32 requirement (key is typed)
 * - stringChar: string[int] character access - requires Int32 proof
 * - unknown: Fallback for unclassified access - emit error
 */
export type ComputedAccessKind = "clrIndexer" | "dictionary" | "stringChar" | "unknown";
export type ComputedAccessProtocol = {
    readonly getterMember: string;
    readonly setterMember?: string;
};
export type IrMemberExpression = {
    readonly kind: "memberAccess";
    readonly object: IrExpression;
    readonly property: IrExpression | string;
    readonly isComputed: boolean;
    readonly isOptional: boolean;
    readonly inferredType?: IrType;
    /**
     * True when `unknown` is the declared/resulting type (for example `unknown[]`
     * element access) rather than an unrecovered/poisoned type.
     */
    readonly allowUnknownInferredType?: boolean;
    readonly sourceSpan?: SourceLocation;
    readonly memberId?: MemberId;
    readonly memberBinding?: {
        readonly kind: "method" | "property";
        readonly assembly: string;
        readonly type: string;
        readonly member: string;
        readonly parameterModifiers?: readonly {
            readonly index: number;
            readonly modifier: "ref" | "out" | "in";
        }[];
        readonly isExtensionMethod?: boolean;
        readonly receiverExpectedType?: IrType;
        readonly emitSemantics?: {
            readonly callStyle?: "receiver" | "static";
            readonly callableStaticAccessorKind?: "property" | "field";
        };
    };
    readonly accessKind?: ComputedAccessKind;
    /** Explicit source-surface protocol for computed index access. */
    readonly accessProtocol?: ComputedAccessProtocol;
};
export type IrCallExpression = {
    readonly kind: "call";
    readonly callee: IrExpression;
    readonly arguments: readonly (IrExpression | IrSpreadExpression)[];
    readonly isOptional: boolean;
    readonly intrinsicKind?: "globalSymbol";
    readonly inferredType?: IrType;
    /**
     * True when `unknown` is the declared return type (for example JSON.parse())
     * rather than a failed recovery from an unannotated signature.
     */
    readonly allowUnknownInferredType?: boolean;
    readonly sourceSpan?: SourceLocation;
    readonly signatureId?: SignatureId;
    /** Alternate overload candidates for post-proof re-resolution. */
    readonly candidateSignatureIds?: readonly SignatureId[];
    readonly typeArguments?: readonly IrType[];
    readonly requiresSpecialization?: boolean;
    /** Contextual expected return type used during original overload selection. */
    readonly resolutionExpectedReturnType?: IrType;
    readonly argumentPassing?: readonly ("value" | "ref" | "out" | "in")[];
    /** Parameter types from resolved signature (for expectedType threading to array literals etc.) */
    readonly parameterTypes?: readonly (IrType | undefined)[];
    /** Declared/public parameter surface types for emission; not narrowed per call-site argument. */
    readonly surfaceParameterTypes?: readonly (IrType | undefined)[];
    /** Explicit rest-parameter metadata from the resolved/public signature. */
    readonly restParameter?: {
        readonly index: number;
        readonly arrayType: IrType | undefined;
        readonly elementType: IrType | undefined;
    };
    /** Declared/public rest-parameter metadata for emission. */
    readonly surfaceRestParameter?: {
        readonly index: number;
        readonly arrayType: IrType | undefined;
        readonly elementType: IrType | undefined;
    };
    /** Exact source-declared parameter surface retained across refresh passes. */
    readonly sourceBackedParameterTypes?: readonly (IrType | undefined)[];
    /** Exact source-declared public parameter surface retained across refresh passes. */
    readonly sourceBackedSurfaceParameterTypes?: readonly (IrType | undefined)[];
    /** Exact source-declared rest metadata retained across refresh passes. */
    readonly sourceBackedRestParameter?: {
        readonly index: number;
        readonly arrayType: IrType | undefined;
        readonly elementType: IrType | undefined;
    };
    /** Exact source-declared return type retained across refresh passes. */
    readonly sourceBackedReturnType?: IrType;
    /** Type predicate narrowing metadata (for `x is T` predicates) */
    readonly narrowing?: {
        readonly kind: "typePredicate";
        readonly argIndex: number;
        readonly targetType: IrType;
    };
    /**
     * Closed-world local dynamic import namespace object for `import("./local.js")`.
     * When present, the emitter lowers the call to `Task<namespaceObject>`.
     */
    readonly dynamicImportNamespace?: IrObjectExpression;
};
export type IrNewExpression = {
    readonly kind: "new";
    readonly callee: IrExpression;
    readonly arguments: readonly (IrExpression | IrSpreadExpression)[];
    readonly inferredType?: IrType;
    readonly sourceSpan?: SourceLocation;
    readonly signatureId?: SignatureId;
    /** Contextual expected return type used during original constructor resolution. */
    readonly resolutionExpectedReturnType?: IrType;
    /** Passing mode for each constructor argument (ref/out/in/value). */
    readonly argumentPassing?: readonly ("value" | "ref" | "out" | "in")[];
    /** Parameter types from resolved constructor signature (for expectedType threading). */
    readonly parameterTypes?: readonly (IrType | undefined)[];
    /** Declared/public constructor parameter surface types for emission. */
    readonly surfaceParameterTypes?: readonly (IrType | undefined)[];
    /** Exact source-declared constructor parameter surface retained across refresh passes. */
    readonly sourceBackedParameterTypes?: readonly (IrType | undefined)[];
    /** Exact source-declared public constructor parameter surface retained across refresh passes. */
    readonly sourceBackedSurfaceParameterTypes?: readonly (IrType | undefined)[];
    /** Exact source-declared constructor rest metadata retained across refresh passes. */
    readonly sourceBackedRestParameter?: {
        readonly index: number;
        readonly arrayType: IrType | undefined;
        readonly elementType: IrType | undefined;
    };
    /** Exact source-declared constructor result type retained across refresh passes. */
    readonly sourceBackedReturnType?: IrType;
    readonly typeArguments?: readonly IrType[];
    readonly requiresSpecialization?: boolean;
    readonly surfaceRestParameter?: {
        readonly index: number;
        readonly arrayType: IrType | undefined;
        readonly elementType: IrType | undefined;
    };
};
export type IrThisExpression = {
    readonly kind: "this";
    readonly inferredType?: IrType;
    readonly sourceSpan?: SourceLocation;
};
export type IrUpdateExpression = {
    readonly kind: "update";
    readonly operator: "++" | "--";
    readonly prefix: boolean;
    readonly expression: IrExpression;
    readonly inferredType?: IrType;
    readonly sourceSpan?: SourceLocation;
};
export type IrUnaryExpression = {
    readonly kind: "unary";
    readonly operator: "+" | "-" | "!" | "~" | "typeof" | "void" | "delete";
    readonly expression: IrExpression;
    readonly inferredType?: IrType;
    readonly sourceSpan?: SourceLocation;
};
export type IrBinaryExpression = {
    readonly kind: "binary";
    readonly operator: IrBinaryOperator;
    readonly left: IrExpression;
    readonly right: IrExpression;
    readonly inferredType?: IrType;
    readonly sourceSpan?: SourceLocation;
};
export type IrLogicalExpression = {
    readonly kind: "logical";
    readonly operator: "&&" | "||" | "??";
    readonly left: IrExpression;
    readonly right: IrExpression;
    readonly inferredType?: IrType;
    readonly sourceSpan?: SourceLocation;
};
export type IrConditionalExpression = {
    readonly kind: "conditional";
    readonly condition: IrExpression;
    readonly whenTrue: IrExpression;
    readonly whenFalse: IrExpression;
    readonly inferredType?: IrType;
    readonly sourceSpan?: SourceLocation;
};
export type IrAssignmentExpression = {
    readonly kind: "assignment";
    readonly operator: IrAssignmentOperator;
    readonly left: IrExpression | IrPattern;
    readonly right: IrExpression;
    readonly inferredType?: IrType;
    readonly sourceSpan?: SourceLocation;
};
export type IrTemplateLiteralExpression = {
    readonly kind: "templateLiteral";
    readonly quasis: readonly string[];
    readonly expressions: readonly IrExpression[];
    readonly inferredType?: IrType;
    readonly sourceSpan?: SourceLocation;
};
export type IrSpreadExpression = {
    readonly kind: "spread";
    readonly expression: IrExpression;
    readonly inferredType?: IrType;
    readonly sourceSpan?: SourceLocation;
};
export type IrAwaitExpression = {
    readonly kind: "await";
    readonly expression: IrExpression;
    readonly inferredType?: IrType;
    readonly sourceSpan?: SourceLocation;
};
export type IrYieldExpression = {
    readonly kind: "yield";
    readonly expression?: IrExpression;
    readonly delegate: boolean;
    readonly inferredType?: IrType;
    readonly sourceSpan?: SourceLocation;
};
//# sourceMappingURL=expressions-core.d.ts.map