irx.analysis.session

irx.analysis.session

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

title: Multi-module compilation session management.
summary: >-
  Track the reachable parsed-module graph, import edges, diagnostics, and
  visible bindings for one multi-module analysis run.

Classes

CompilationSession

title: Shared state for multi-module analysis and lowering.
summary: >-
  Own the loaded module graph and cross-module binding state that analysis
  and lowering share for one compilation.
attributes:
  root:
    type: ParsedModule
  resolver:
    type: ImportResolver
  modules:
    type: dict[ModuleKey, ParsedModule]
  graph:
    type: dict[ModuleKey, set[ModuleKey]]
  load_order:
    type: list[ModuleKey]
  diagnostics:
    type: DiagnosticBag
  visible_bindings:
    type: dict[ModuleKey, dict[str, SemanticBinding]]
  _resolution_cache:
    type: dict[tuple[ModuleKey, str], ParsedModule | None]
  _probe_cache:
    type: dict[tuple[ModuleKey, str], ParsedModule | None]

Methods

register_module(self, parsed_module: ParsedModule) -> ParsedModule
title: Register one parsed module in the session cache.
summary: >-
  Cache a parsed module once and initialize its graph and visible
  binding slots.
parameters:
  parsed_module:
    type: ParsedModule
returns:
  type: ParsedModule
module(self, module_key: ModuleKey) -> ParsedModule
title: Return a parsed module by key.
summary: >-
  Look up a previously-registered parsed module by its canonical host
  key.
parameters:
  module_key:
    type: ModuleKey
returns:
  type: ParsedModule
ordered_modules(self) -> list[ParsedModule]
title: Return parsed modules in stable dependency order.
summary: >-
  Materialize the dependency-ordered module list used by later semantic
  and lowering passes.
returns:
  type: list[ParsedModule]
resolve_import_specifier(self, requesting_module_key: ModuleKey, import_node: astx.ImportStmt | astx.ImportFromStmt, requested_specifier: str) -> ParsedModule | None
title: Resolve one import request through the host resolver.
summary: >-
  Call the host resolver once per import request, memoizing both
  successes and failures.
parameters:
  requesting_module_key:
    type: ModuleKey
  import_node:
    type: astx.ImportStmt | astx.ImportFromStmt
  requested_specifier:
    type: str
returns:
  type: ParsedModule | None
probe_import_specifier(self, requesting_module_key: ModuleKey, import_node: astx.ImportStmt | astx.ImportFromStmt, requested_specifier: str) -> ParsedModule | None
title: Probe one import request without emitting diagnostics.
summary: >-
  Try the host resolver for speculative import edges such as child-
  module fallbacks while keeping expected missing-module probes silent
  but still surfacing unexpected resolver failures.
parameters:
  requesting_module_key:
    type: ModuleKey
  import_node:
    type: astx.ImportStmt | astx.ImportFromStmt
  requested_specifier:
    type: str
returns:
  type: ParsedModule | None
resolve_import_from_name(self, requesting_module_key: ModuleKey, import_node: astx.ImportFromStmt, parent_module_key: ModuleKey, imported_name: str) -> tuple[SemanticBinding | None, ParsedModule | None]
title: >-
  Resolve one import-from name to a direct binding or child module.
summary: >-
  Apply symbol-first, child-module-second import-from semantics using
  the parent module's visible bindings before attempting module
  namespace fallback.
parameters:
  requesting_module_key:
    type: ModuleKey
  import_node:
    type: astx.ImportFromStmt
  parent_module_key:
    type: ModuleKey
  imported_name:
    type: str
returns:
  type: tuple[SemanticBinding | None, ParsedModule | None]
expand_graph(self) -> None
title: Expand the reachable import graph from the root module.
summary: >-
  Walk top-level imports from the root module, load every reachable
  dependency, and reject cycles.