irx.analysis.bindings

irx.analysis.bindings

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

title: Module-visible binding tables.
summary: >-
  Own the per-module namespace that imports and top-level declarations expose,
  keeping visible-name lookup separate from lexical scope resolution.

Classes

VisibleBindings

title: Module-visible binding manager.
summary: >-
  Track top-level and imported names that are visible within each module
  namespace and enforce conflicts independently from lexical scopes.
attributes:
  context:
    type: SemanticContext
  factory:
    type: SemanticEntityFactory
  _bindings:
    type: dict[ModuleKey, dict[str, SemanticBinding]]

Methods

tables(self) -> dict[ModuleKey, dict[str, SemanticBinding]]
title: Return the backing binding tables.
returns:
  type: dict[ModuleKey, dict[str, SemanticBinding]]
bindings_for(self, module_key: ModuleKey | None=None) -> dict[str, SemanticBinding]
title: Return one module's visible binding table.
parameters:
  module_key:
    type: ModuleKey | None
returns:
  type: dict[str, SemanticBinding]
binding_conflicts(self, existing: SemanticBinding, new_binding: SemanticBinding) -> bool
title: Return True when two bindings disagree.
parameters:
  existing:
    type: SemanticBinding
  new_binding:
    type: SemanticBinding
returns:
  type: bool
bind(self, local_name: str, binding: SemanticBinding, *, node: astx.AST, module_key: ModuleKey | None=None) -> SemanticBinding
title: Bind one visible name in a module namespace.
parameters:
  local_name:
    type: str
  binding:
    type: SemanticBinding
  node:
    type: astx.AST
  module_key:
    type: ModuleKey | None
returns:
  type: SemanticBinding
bind_function(self, local_name: str, function: SemanticFunction, *, node: astx.AST, module_key: ModuleKey | None=None) -> SemanticBinding
title: Bind a function in a module namespace.
parameters:
  local_name:
    type: str
  function:
    type: SemanticFunction
  node:
    type: astx.AST
  module_key:
    type: ModuleKey | None
returns:
  type: SemanticBinding
bind_struct(self, local_name: str, struct: SemanticStruct, *, node: astx.AST, module_key: ModuleKey | None=None) -> SemanticBinding
title: Bind a struct in a module namespace.
parameters:
  local_name:
    type: str
  struct:
    type: SemanticStruct
  node:
    type: astx.AST
  module_key:
    type: ModuleKey | None
returns:
  type: SemanticBinding
bind_class(self, local_name: str, class_: SemanticClass, *, node: astx.AST, module_key: ModuleKey | None=None) -> SemanticBinding
title: Bind a class in a module namespace.
parameters:
  local_name:
    type: str
  class_:
    type: SemanticClass
  node:
    type: astx.AST
  module_key:
    type: ModuleKey | None
returns:
  type: SemanticBinding
bind_module(self, local_name: str, module: SemanticModule, *, node: astx.AST, module_key: ModuleKey | None=None) -> SemanticBinding
title: Bind an imported module in a module namespace.
parameters:
  local_name:
    type: str
  module:
    type: SemanticModule
  node:
    type: astx.AST
  module_key:
    type: ModuleKey | None
returns:
  type: SemanticBinding
resolve(self, name: str, *, module_key: ModuleKey | None=None) -> SemanticBinding | None
title: Resolve one visible binding by name.
parameters:
  name:
    type: str
  module_key:
    type: ModuleKey | None
returns:
  type: SemanticBinding | None