irx.analysis.types

irx.analysis.types

Source: packages/irx/src/irx/analysis/types.py

title: Type helpers for semantic analysis.
summary: >-
  Provide the small AST-type predicates and promotion helpers that the semantic
  analyzer reuses across many node visitors.

Functions

requires_size_check(target_size: int | None, value_size: int | None) -> bool

title: Return whether assignment requires a runtime size check.
parameters:
  target_size:
    type: int | None
  value_size:
    type: int | None
returns:
  type: bool

requires_shape_check(target_shape: tuple[int, ...] | None, value_shape: tuple[int, ...] | None) -> bool

title: Return whether assignment requires a runtime shape check.
parameters:
  target_shape:
    type: tuple[int, Ellipsis] | None
  value_shape:
    type: tuple[int, Ellipsis] | None
returns:
  type: bool

clone_type(type_: astx.DataType) -> astx.DataType

title: Clone an AST type by class.
parameters:
  type_:
    type: astx.DataType
returns:
  type: astx.DataType

display_type_name(type_: astx.DataType | None) -> str

title: Return one stable human-facing type name.
parameters:
  type_:
    type: astx.DataType | None
returns:
  type: str

same_type(lhs: astx.DataType | None, rhs: astx.DataType | None) -> bool

title: Return whether two AST types share the same class.
parameters:
  lhs:
    type: astx.DataType | None
  rhs:
    type: astx.DataType | None
returns:
  type: bool

is_integer_type(type_: astx.DataType | None) -> bool

title: Is integer type.
parameters:
  type_:
    type: astx.DataType | None
returns:
  type: bool

is_signed_integer_type(type_: astx.DataType | None) -> bool

title: Is signed integer type.
parameters:
  type_:
    type: astx.DataType | None
returns:
  type: bool

is_unsigned_type(type_: astx.DataType | None) -> bool

title: Is unsigned type.
parameters:
  type_:
    type: astx.DataType | None
returns:
  type: bool

is_float_type(type_: astx.DataType | None) -> bool

title: Is float type.
parameters:
  type_:
    type: astx.DataType | None
returns:
  type: bool

is_numeric_type(type_: astx.DataType | None) -> bool

title: Is numeric type.
parameters:
  type_:
    type: astx.DataType | None
returns:
  type: bool

is_boolean_type(type_: astx.DataType | None) -> bool

title: Is boolean type.
parameters:
  type_:
    type: astx.DataType | None
returns:
  type: bool

is_string_type(type_: astx.DataType | None) -> bool

title: Is string type.
parameters:
  type_:
    type: astx.DataType | None
returns:
  type: bool

is_temporal_type(type_: astx.DataType | None) -> bool

title: Is temporal type.
parameters:
  type_:
    type: astx.DataType | None
returns:
  type: bool

is_none_type(type_: astx.DataType | None) -> bool

title: Is none type.
parameters:
  type_:
    type: astx.DataType | None
returns:
  type: bool

is_type_member(target: astx.DataType | None, value: astx.DataType | None) -> bool

title: Return whether a value type is a member of a target type.
parameters:
  target:
    type: astx.DataType | None
  value:
    type: astx.DataType | None
returns:
  type: bool

bit_width(type_: astx.DataType | None) -> int

title: Return the nominal bit width for numeric types.
parameters:
  type_:
    type: astx.DataType | None
returns:
  type: int

float_promotion_width_for_integer_width(width: int) -> int

title: Return the float width floor used when integers promote with floats.
parameters:
  width:
    type: int
returns:
  type: int

common_numeric_type(lhs: astx.DataType | None, rhs: astx.DataType | None) -> astx.DataType | None

title: Return a widened numeric type shared by both operands.
parameters:
  lhs:
    type: astx.DataType | None
  rhs:
    type: astx.DataType | None
returns:
  type: astx.DataType | None

is_explicitly_castable(source: astx.DataType | None, target: astx.DataType | None) -> bool

title: Return whether an explicit Cast expression is allowed.
parameters:
  source:
    type: astx.DataType | None
  target:
    type: astx.DataType | None
returns:
  type: bool

is_assignable(target: astx.DataType | None, value: astx.DataType | None) -> bool

title: Return whether a value type can be assigned to a target type.
parameters:
  target:
    type: astx.DataType | None
  value:
    type: astx.DataType | None
returns:
  type: bool